restorable: Unexport add

This commit is contained in:
Hajime Hoshi 2017-05-03 23:15:18 +09:00
parent ed4cd67fb3
commit aa5c278445
3 changed files with 10 additions and 8 deletions

View File

@ -221,7 +221,6 @@ func NewImage(width, height int, filter Filter) (*Image, error) {
checkSize(width, height)
r := restorable.NewImage(width, height, glFilter(filter), false)
r.Fill(color.RGBA{})
restorable.Images().Add(r)
i := &Image{r}
runtime.SetFinalizer(i, (*Image).Dispose)
return i, nil
@ -244,7 +243,6 @@ func newVolatileImage(width, height int, filter Filter) (*Image, error) {
checkSize(width, height)
r := restorable.NewImage(width, height, glFilter(filter), true)
r.Fill(color.RGBA{})
restorable.Images().Add(r)
i := &Image{r}
runtime.SetFinalizer(i, (*Image).Dispose)
return i, nil
@ -261,7 +259,6 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) {
checkSize(w, h)
rgbaImg := graphics.CopyImage(source)
r := restorable.NewImageFromImage(rgbaImg, w, h, glFilter(filter))
restorable.Images().Add(r)
i := &Image{r}
runtime.SetFinalizer(i, (*Image).Dispose)
return i, nil
@ -270,7 +267,6 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) {
func newImageWithScreenFramebuffer(width, height int) (*Image, error) {
checkSize(width, height)
r := restorable.NewScreenFramebufferImage(width, height)
restorable.Images().Add(r)
i := &Image{r}
runtime.SetFinalizer(i, (*Image).Dispose)
return i, nil

View File

@ -49,11 +49,13 @@ type Image struct {
}
func NewImage(width, height int, filter opengl.Filter, volatile bool) *Image {
return &Image{
i := &Image{
image: graphics.NewImage(width, height, filter),
filter: filter,
volatile: volatile,
}
theImages.add(i)
return i
}
func NewImageFromImage(source *image.RGBA, width, height int, filter opengl.Filter) *Image {
@ -62,19 +64,23 @@ func NewImageFromImage(source *image.RGBA, width, height int, filter opengl.Filt
for j := 0; j < height; j++ {
copy(p[j*w2*4:(j+1)*w2*4], source.Pix[j*source.Stride:])
}
return &Image{
i := &Image{
image: graphics.NewImageFromImage(source, width, height, filter),
basePixels: p,
filter: filter,
}
theImages.add(i)
return i
}
func NewScreenFramebufferImage(width, height int) *Image {
return &Image{
i := &Image{
image: graphics.NewScreenFramebufferImage(width, height),
volatile: true,
screen: true,
}
theImages.add(i)
return i
}
func (p *Image) Size() (int, int) {

View File

@ -35,7 +35,7 @@ func Images() *images {
return theImages
}
func (i *images) Add(img *Image) {
func (i *images) add(img *Image) {
i.m.Lock()
defer i.m.Unlock()
i.images[img] = struct{}{}