mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
restorable: Do not dispose objects when restoring on browsers
This fix suppresses warnings on the Chrome console.
This commit is contained in:
parent
1042eb71e0
commit
117fd61d27
@ -183,7 +183,9 @@ func (i *images) restore() error {
|
||||
|
||||
// Dispose all the shaders ahead of restoring. A current shader ID and a new shader ID can be duplicated.
|
||||
for s := range i.shaders {
|
||||
s.shader.Dispose()
|
||||
if needsDisposingWhenRestoring {
|
||||
s.shader.Dispose()
|
||||
}
|
||||
s.shader = nil
|
||||
}
|
||||
for s := range i.shaders {
|
||||
@ -193,7 +195,9 @@ func (i *images) restore() error {
|
||||
// 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.
|
||||
for i := range i.images {
|
||||
i.image.Dispose()
|
||||
if needsDisposingWhenRestoring {
|
||||
i.image.Dispose()
|
||||
}
|
||||
i.image = nil
|
||||
}
|
||||
|
||||
|
22
internal/restorable/js.go
Normal file
22
internal/restorable/js.go
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2020 The Ebiten Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build js
|
||||
|
||||
package restorable
|
||||
|
||||
// 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
|
19
internal/restorable/notjs.go
Normal file
19
internal/restorable/notjs.go
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2020 The Ebiten Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build !js
|
||||
|
||||
package restorable
|
||||
|
||||
const needsDisposingWhenRestoring = true
|
Loading…
Reference in New Issue
Block a user