mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
restorable: Unexport add
This commit is contained in:
parent
ed4cd67fb3
commit
aa5c278445
4
image.go
4
image.go
@ -221,7 +221,6 @@ func NewImage(width, height int, filter Filter) (*Image, error) {
|
|||||||
checkSize(width, height)
|
checkSize(width, height)
|
||||||
r := restorable.NewImage(width, height, glFilter(filter), false)
|
r := restorable.NewImage(width, height, glFilter(filter), false)
|
||||||
r.Fill(color.RGBA{})
|
r.Fill(color.RGBA{})
|
||||||
restorable.Images().Add(r)
|
|
||||||
i := &Image{r}
|
i := &Image{r}
|
||||||
runtime.SetFinalizer(i, (*Image).Dispose)
|
runtime.SetFinalizer(i, (*Image).Dispose)
|
||||||
return i, nil
|
return i, nil
|
||||||
@ -244,7 +243,6 @@ func newVolatileImage(width, height int, filter Filter) (*Image, error) {
|
|||||||
checkSize(width, height)
|
checkSize(width, height)
|
||||||
r := restorable.NewImage(width, height, glFilter(filter), true)
|
r := restorable.NewImage(width, height, glFilter(filter), true)
|
||||||
r.Fill(color.RGBA{})
|
r.Fill(color.RGBA{})
|
||||||
restorable.Images().Add(r)
|
|
||||||
i := &Image{r}
|
i := &Image{r}
|
||||||
runtime.SetFinalizer(i, (*Image).Dispose)
|
runtime.SetFinalizer(i, (*Image).Dispose)
|
||||||
return i, nil
|
return i, nil
|
||||||
@ -261,7 +259,6 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) {
|
|||||||
checkSize(w, h)
|
checkSize(w, h)
|
||||||
rgbaImg := graphics.CopyImage(source)
|
rgbaImg := graphics.CopyImage(source)
|
||||||
r := restorable.NewImageFromImage(rgbaImg, w, h, glFilter(filter))
|
r := restorable.NewImageFromImage(rgbaImg, w, h, glFilter(filter))
|
||||||
restorable.Images().Add(r)
|
|
||||||
i := &Image{r}
|
i := &Image{r}
|
||||||
runtime.SetFinalizer(i, (*Image).Dispose)
|
runtime.SetFinalizer(i, (*Image).Dispose)
|
||||||
return i, nil
|
return i, nil
|
||||||
@ -270,7 +267,6 @@ func NewImageFromImage(source image.Image, filter Filter) (*Image, error) {
|
|||||||
func newImageWithScreenFramebuffer(width, height int) (*Image, error) {
|
func newImageWithScreenFramebuffer(width, height int) (*Image, error) {
|
||||||
checkSize(width, height)
|
checkSize(width, height)
|
||||||
r := restorable.NewScreenFramebufferImage(width, height)
|
r := restorable.NewScreenFramebufferImage(width, height)
|
||||||
restorable.Images().Add(r)
|
|
||||||
i := &Image{r}
|
i := &Image{r}
|
||||||
runtime.SetFinalizer(i, (*Image).Dispose)
|
runtime.SetFinalizer(i, (*Image).Dispose)
|
||||||
return i, nil
|
return i, nil
|
||||||
|
@ -49,11 +49,13 @@ type Image struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewImage(width, height int, filter opengl.Filter, volatile bool) *Image {
|
func NewImage(width, height int, filter opengl.Filter, volatile bool) *Image {
|
||||||
return &Image{
|
i := &Image{
|
||||||
image: graphics.NewImage(width, height, filter),
|
image: graphics.NewImage(width, height, filter),
|
||||||
filter: filter,
|
filter: filter,
|
||||||
volatile: volatile,
|
volatile: volatile,
|
||||||
}
|
}
|
||||||
|
theImages.add(i)
|
||||||
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewImageFromImage(source *image.RGBA, width, height int, filter opengl.Filter) *Image {
|
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++ {
|
for j := 0; j < height; j++ {
|
||||||
copy(p[j*w2*4:(j+1)*w2*4], source.Pix[j*source.Stride:])
|
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),
|
image: graphics.NewImageFromImage(source, width, height, filter),
|
||||||
basePixels: p,
|
basePixels: p,
|
||||||
filter: filter,
|
filter: filter,
|
||||||
}
|
}
|
||||||
|
theImages.add(i)
|
||||||
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewScreenFramebufferImage(width, height int) *Image {
|
func NewScreenFramebufferImage(width, height int) *Image {
|
||||||
return &Image{
|
i := &Image{
|
||||||
image: graphics.NewScreenFramebufferImage(width, height),
|
image: graphics.NewScreenFramebufferImage(width, height),
|
||||||
volatile: true,
|
volatile: true,
|
||||||
screen: true,
|
screen: true,
|
||||||
}
|
}
|
||||||
|
theImages.add(i)
|
||||||
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Image) Size() (int, int) {
|
func (p *Image) Size() (int, int) {
|
||||||
|
@ -35,7 +35,7 @@ func Images() *images {
|
|||||||
return theImages
|
return theImages
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *images) Add(img *Image) {
|
func (i *images) add(img *Image) {
|
||||||
i.m.Lock()
|
i.m.Lock()
|
||||||
defer i.m.Unlock()
|
defer i.m.Unlock()
|
||||||
i.images[img] = struct{}{}
|
i.images[img] = struct{}{}
|
||||||
|
Loading…
Reference in New Issue
Block a user