tdf#142153 android: Delete unused textures immediately
Don't delay the call to 'glDeleteTextures' but
always call it immediately via 'TextureReaper.get().reap()'
in 'Subtile#cleanTexture'.
Delaying it appears to sometimes cause it to be called
"at the wrong time", resulting in black areas being
shown instead of properly rendering/displaying the document
content in the corresponding tile.
This fixes the issue also mentioned in commit
1bc42472200c32c9a0a10dd1c3cd6c6a8a5d47d2
("tdf#95517 android: Rework app/doc lifecycle handling"),
which was present before, though:
> (Well, sometimes there is an issue with
> invalidation/repaint and single tiles remain black,
> but that happened previously - when the whole doc
> was loaded anew - just the same way).
Change-Id: I5f18dbe3133d9d00a76b129fd119c2e80441e531
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115241
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/SubTile.java b/android/source/src/java/org/mozilla/gecko/gfx/SubTile.java
index 42750df..bdad371 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/SubTile.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/SubTile.java
@@ -86,26 +86,24 @@ public class SubTile extends Layer {
protected void finalize() throws Throwable {
try {
destroyImage();
cleanTexture(false);
cleanTexture();
} finally {
super.finalize();
}
}
private void cleanTexture(boolean immediately) {
private void cleanTexture() {
if (mTextureIDs != null) {
TextureReaper.get().add(mTextureIDs);
mTextureIDs = null;
if (immediately) {
TextureReaper.get().reap();
}
TextureReaper.get().reap();
}
}
public void destroy() {
try {
destroyImage();
cleanTexture(false);
cleanTexture();
} catch (Exception ex) {
Log.e(LOGTAG, "Error clearing buffers: ", ex);
}
@@ -140,7 +138,7 @@ public class SubTile extends Layer {
if (!textureSize.equals(mSize)) {
mSize = textureSize;
cleanTexture(true);
cleanTexture();
}
}
@@ -253,4 +251,4 @@ public class SubTile extends Layer {
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
}
}
}
\ No newline at end of file
}