diff options
author | Matt Holgate <matt@emobix.co.uk> | 2014-06-25 14:40:20 +0100 |
---|---|---|
committer | Matt Holgate <matt@emobix.co.uk> | 2014-06-25 14:40:20 +0100 |
commit | e8f0394761e24ad1cdb143aa40e5594e93a97f0b (patch) | |
tree | d738724d0b7ddd7b6a59200593deaa5c912ab07c /platform/android/src/com/artifex | |
parent | 38ae8629788b21ae653943f8ef4f02f9bbd74b96 (diff) | |
download | mupdf-e8f0394761e24ad1cdb143aa40e5594e93a97f0b.tar.xz |
Fix for pages being repeated when running on Android Honeycomb.
Fixes bug #695191 - Mupdf Build49/armv7a & Android 3.1: cycles
through subset of pages & page scrubber
The problem here was that in Honeycomb, various bitmap operations
(including drawing via JNI) do not update the bitmap generation count.
When hardware acceleration is enabled, this means that the underlying GL
layer is not aware that the bitmap has changed, and ends up reusing old
textures.
To workaround this, we erase the bitmap before drawing the page. Erase
appears to be the only operation I could find (after pouring through the
source), which actually increments the generation count. The other option
would have been to disable hardware acceleration, but that was far less ideal.
Diffstat (limited to 'platform/android/src/com/artifex')
-rw-r--r-- | platform/android/src/com/artifex/mupdfdemo/MuPDFPageView.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/platform/android/src/com/artifex/mupdfdemo/MuPDFPageView.java b/platform/android/src/com/artifex/mupdfdemo/MuPDFPageView.java index c18f44ab..ff6b6bbb 100644 --- a/platform/android/src/com/artifex/mupdfdemo/MuPDFPageView.java +++ b/platform/android/src/com/artifex/mupdfdemo/MuPDFPageView.java @@ -14,6 +14,7 @@ import android.graphics.Point; import android.graphics.PointF; import android.graphics.RectF; import android.net.Uri; +import android.os.Build; import android.text.method.PasswordTransformationMethod; import android.view.LayoutInflater; import android.view.WindowManager; @@ -559,6 +560,11 @@ public class MuPDFPageView extends PageView implements MuPDFView { return new MuPDFCancellableTaskDefinition<Void, Void>(mCore) { @Override public Void doInBackground(MuPDFCore.Cookie cookie, Void ... params) { + // Workaround bug in Android Honeycomb 3.x, where the bitmap generation count + // is not incremented when drawing. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && + Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) + bm.eraseColor(0); mCore.drawPage(bm, mPageNumber, sizeX, sizeY, patchX, patchY, patchWidth, patchHeight, cookie); return null; } @@ -573,6 +579,11 @@ public class MuPDFPageView extends PageView implements MuPDFView { @Override public Void doInBackground(MuPDFCore.Cookie cookie, Void ... params) { + // Workaround bug in Android Honeycomb 3.x, where the bitmap generation count + // is not incremented when drawing. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && + Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) + bm.eraseColor(0); mCore.updatePage(bm, mPageNumber, sizeX, sizeY, patchX, patchY, patchWidth, patchHeight, cookie); return null; } |