From f6ec243a4a629913419a739a25199ec8a28bab65 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Fri, 24 Feb 2012 18:24:27 +0000 Subject: android app: support hardware acceleration --- android/AndroidManifest.xml | 5 +++-- android/project.properties | 2 +- android/src/com/artifex/mupdf/PageView.java | 12 ++++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) (limited to 'android') diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 9d4ef58c..e69aeaf5 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -7,10 +7,11 @@ android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" /> - + + android:debuggable="true" + android:hardwareAccelerated="true"> diff --git a/android/project.properties b/android/project.properties index ea89160e..d79abae1 100644 --- a/android/project.properties +++ b/android/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-8 +target=android-11 diff --git a/android/src/com/artifex/mupdf/PageView.java b/android/src/com/artifex/mupdf/PageView.java index 6fe6d43d..4dce6d23 100644 --- a/android/src/com/artifex/mupdf/PageView.java +++ b/android/src/com/artifex/mupdf/PageView.java @@ -9,6 +9,7 @@ import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; import android.os.AsyncTask; +import android.os.Build; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -59,6 +60,7 @@ public abstract class PageView extends ViewGroup { private RectF mSearchBoxes[]; private View mSearchView; private boolean mIsBlank; + private boolean mUsingHardwareAcceleration; private ProgressBar mBusyIndicator; @@ -67,6 +69,7 @@ public abstract class PageView extends ViewGroup { mContext = c; mParentSize = parentSize; setBackgroundColor(BACKGROUND_COLOR); + mUsingHardwareAcceleration = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; } protected abstract void drawPage(Bitmap bm, int sizeX, int sizeY, int patchX, int patchY, int patchWidth, int patchHeight); @@ -119,6 +122,15 @@ public abstract class PageView extends ViewGroup { mSourceScale = Math.min(mParentSize.x/size.x, mParentSize.y/size.y); Point newSize = new Point((int)(size.x*mSourceScale), (int)(size.y*mSourceScale)); mSize = newSize; + + if (mUsingHardwareAcceleration) { + // When hardware accelerated, updates to the bitmap seem to be + // ignored, so we recreate it. There may be another way around this + // that we are yet to find. + mEntire.setImageBitmap(null); + mEntireBm = null; + } + if (mEntireBm == null || mEntireBm.getWidth() != newSize.x || mEntireBm.getHeight() != newSize.y) { mEntireBm = Bitmap.createBitmap(mSize.x, mSize.y, Bitmap.Config.ARGB_8888); -- cgit v1.2.3