mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +01:00
restorable: Remove Images()
This commit is contained in:
parent
8b48d010ed
commit
951e5bccef
@ -161,11 +161,11 @@ func (c *graphicsContext) UpdateAndDraw(context *opengl.Context, updateCount int
|
|||||||
if err := c.initializeIfNeeded(context); err != nil {
|
if err := c.initializeIfNeeded(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := restorable.Images().ResolveStalePixels(context); err != nil {
|
if err := restorable.ResolveStalePixels(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i := 0; i < updateCount; i++ {
|
for i := 0; i < updateCount; i++ {
|
||||||
restorable.Images().ClearVolatileImages()
|
restorable.ClearVolatileImages()
|
||||||
setRunningSlowly(i < updateCount-1)
|
setRunningSlowly(i < updateCount-1)
|
||||||
if err := c.f(c.offscreen); err != nil {
|
if err := c.f(c.offscreen); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -186,7 +186,7 @@ func (c *graphicsContext) restore(context *opengl.Context) error {
|
|||||||
if err := graphics.Reset(context); err != nil {
|
if err := graphics.Reset(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := restorable.Images().Restore(context); err != nil {
|
if err := restorable.Restore(context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
c.invalidated = false
|
c.invalidated = false
|
||||||
|
@ -30,8 +30,16 @@ var theImages = &images{
|
|||||||
images: map[*Image]struct{}{},
|
images: map[*Image]struct{}{},
|
||||||
}
|
}
|
||||||
|
|
||||||
func Images() *images {
|
func ResolveStalePixels(context *opengl.Context) error {
|
||||||
return theImages
|
return theImages.resolveStalePixels(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Restore(context *opengl.Context) error {
|
||||||
|
return theImages.restore(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ClearVolatileImages() {
|
||||||
|
theImages.clearVolatileImages()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *images) add(img *Image) {
|
func (i *images) add(img *Image) {
|
||||||
@ -46,7 +54,7 @@ func (i *images) remove(img *Image) {
|
|||||||
delete(i.images, img)
|
delete(i.images, img)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *images) ResolveStalePixels(context *opengl.Context) error {
|
func (i *images) resolveStalePixels(context *opengl.Context) error {
|
||||||
i.m.Lock()
|
i.m.Lock()
|
||||||
defer i.m.Unlock()
|
defer i.m.Unlock()
|
||||||
i.lastChecked = nil
|
i.lastChecked = nil
|
||||||
@ -74,7 +82,7 @@ func (i *images) resetPixelsIfDependingOn(target *Image) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *images) Restore(context *opengl.Context) error {
|
func (i *images) restore(context *opengl.Context) error {
|
||||||
i.m.Lock()
|
i.m.Lock()
|
||||||
defer i.m.Unlock()
|
defer i.m.Unlock()
|
||||||
// Framebuffers/textures cannot be disposed since framebuffers/textures that
|
// Framebuffers/textures cannot be disposed since framebuffers/textures that
|
||||||
@ -102,7 +110,7 @@ func (i *images) Restore(context *opengl.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *images) ClearVolatileImages() {
|
func (i *images) clearVolatileImages() {
|
||||||
i.m.Lock()
|
i.m.Lock()
|
||||||
defer i.m.Unlock()
|
defer i.m.Unlock()
|
||||||
for img := range i.images {
|
for img := range i.images {
|
||||||
|
Loading…
Reference in New Issue
Block a user