Add a function to protect textures
This commit is contained in:
parent
5f5b928528
commit
3614979e35
15
texture.go
15
texture.go
|
@ -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 }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue