mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
shareable: Refactoring
This commit is contained in:
parent
b1e4c3c8f0
commit
dec921809b
@ -94,17 +94,20 @@ type Image struct {
|
||||
|
||||
backend *backend
|
||||
|
||||
// If node is nil, the image is not shared.
|
||||
node *packing.Node
|
||||
}
|
||||
|
||||
func (i *Image) isShared() bool {
|
||||
return i.node != nil
|
||||
}
|
||||
|
||||
func (i *Image) ensureNotShared() {
|
||||
if i.backend == nil {
|
||||
i.allocate(false)
|
||||
return
|
||||
}
|
||||
|
||||
if i.node == nil {
|
||||
if !i.isShared() {
|
||||
return
|
||||
}
|
||||
|
||||
@ -124,7 +127,7 @@ func (i *Image) region() (x, y, width, height int) {
|
||||
if i.backend == nil {
|
||||
panic("not reached")
|
||||
}
|
||||
if i.node == nil {
|
||||
if !i.isShared() {
|
||||
w, h := i.backend.restorable.Size()
|
||||
return 0, 0, w, h
|
||||
}
|
||||
@ -223,7 +226,7 @@ func (i *Image) dispose(markDisposed bool) {
|
||||
return
|
||||
}
|
||||
|
||||
if i.node == nil {
|
||||
if !i.isShared() {
|
||||
i.backend.restorable.Dispose()
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user