From e8f0394761e24ad1cdb143aa40e5594e93a97f0b Mon Sep 17 00:00:00 2001 From: Matt Holgate Date: Wed, 25 Jun 2014 14:40:20 +0100 Subject: 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. --- platform/android/src/com/artifex/mupdfdemo/MuPDFPageView.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'platform/android/src/com') 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(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; } -- cgit v1.2.3