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