internal/restorable: Remove needsDisposingWhenRestoring

Now restoring from context lost doesn't work on browsers. Then,
the constant needsDisposingWhenRestoring is actually always true.
This commit is contained in:
Hajime Hoshi 2021-10-23 23:46:26 +09:00
parent dddfe73604
commit 96dc80fd08
4 changed files with 2 additions and 16 deletions

View File

@ -17,6 +17,4 @@
package restorable package restorable
const needsDisposingWhenRestoring = true
const canDetectContextLostExplicitly = true const canDetectContextLostExplicitly = true

View File

@ -14,11 +14,5 @@
package restorable package restorable
// needsDisposingWhenRestoring reports whether disposing resources is necessary or not when restoring.
//
// On browsers, disposing resources is not required since the objects are already managed by JavaScript GC and they
// are already invalidated. Rather, disposing them when restoring causes warnings on the console.
const needsDisposingWhenRestoring = false
// canDetectContextLostExplicitly reports whether the context lost can be detected by handlers in an explicit way. // canDetectContextLostExplicitly reports whether the context lost can be detected by handlers in an explicit way.
const canDetectContextLostExplicitly = true const canDetectContextLostExplicitly = true

View File

@ -19,6 +19,4 @@
package restorable package restorable
const needsDisposingWhenRestoring = true
const canDetectContextLostExplicitly = false const canDetectContextLostExplicitly = false

View File

@ -201,9 +201,7 @@ func (i *images) restore() error {
// Dispose all the shaders ahead of restoring. A current shader ID and a new shader ID can be duplicated. // Dispose all the shaders ahead of restoring. A current shader ID and a new shader ID can be duplicated.
for s := range i.shaders { for s := range i.shaders {
if needsDisposingWhenRestoring {
s.shader.Dispose() s.shader.Dispose()
}
s.shader = nil s.shader = nil
} }
for s := range i.shaders { for s := range i.shaders {
@ -213,9 +211,7 @@ func (i *images) restore() error {
// Dispose all the images ahead of restoring. A current texture ID and a new texture ID can be duplicated. // Dispose all the images ahead of restoring. A current texture ID and a new texture ID can be duplicated.
// TODO: Write a test to confirm that ID duplication never happens. // TODO: Write a test to confirm that ID duplication never happens.
for i := range i.images { for i := range i.images {
if needsDisposingWhenRestoring {
i.image.Dispose() i.image.Dispose()
}
i.image = nil i.image = nil
} }