shareable: Refactoring

This commit is contained in:
Hajime Hoshi 2019-09-21 19:15:49 +09:00
parent 1c2c932c6c
commit 053f5a0ce7

View File

@ -488,11 +488,12 @@ func (i *Image) allocate(shareable bool) {
panic("shareable: the image is already allocated") panic("shareable: the image is already allocated")
} }
runtime.SetFinalizer(i, (*Image).disposeFromFinalizer)
if i.screen { if i.screen {
i.backend = &backend{ i.backend = &backend{
restorable: restorable.NewScreenFramebufferImage(i.width, i.height), restorable: restorable.NewScreenFramebufferImage(i.width, i.height),
} }
runtime.SetFinalizer(i, (*Image).disposeFromFinalizer)
return return
} }
@ -500,7 +501,6 @@ func (i *Image) allocate(shareable bool) {
i.backend = &backend{ i.backend = &backend{
restorable: restorable.NewImage(i.width, i.height, i.volatile), restorable: restorable.NewImage(i.width, i.height, i.volatile),
} }
runtime.SetFinalizer(i, (*Image).disposeFromFinalizer)
return return
} }
@ -508,7 +508,6 @@ func (i *Image) allocate(shareable bool) {
if n, ok := b.TryAlloc(i.width, i.height); ok { if n, ok := b.TryAlloc(i.width, i.height); ok {
i.backend = b i.backend = b
i.node = n i.node = n
runtime.SetFinalizer(i, (*Image).disposeFromFinalizer)
return return
} }
} }
@ -532,7 +531,6 @@ func (i *Image) allocate(shareable bool) {
} }
i.backend = b i.backend = b
i.node = n i.node = n
runtime.SetFinalizer(i, (*Image).disposeFromFinalizer)
} }
func (i *Image) Dump(path string) error { func (i *Image) Dump(path string) error {