Add a function to protect textures

This commit is contained in:
Sasha Koshka 2023-08-20 18:33:20 -04:00
parent 5f5b928528
commit 3614979e35
1 changed files with 15 additions and 0 deletions

View File

@ -12,3 +12,18 @@ type Texture interface {
// the original texture as well.
Clip (image.Rectangle) Texture
}
type protectedTexture struct {
Texture
}
func (protectedTexture) Close () error {
return nil
}
// Protect makes the Close() method of a texture do nothing. This is useful if
// several of the same texture are given out to different objects, but only one
// has the responsibility of closing it.
func Protect (texture Texture) Texture {
return protectedTexture { Texture: texture }
}