summaryrefslogtreecommitdiff
path: root/android/src
diff options
context:
space:
mode:
authorPaul Gardiner <paul@glidos.net>2012-02-24 18:24:27 +0000
committerPaul Gardiner <paul@glidos.net>2012-03-15 11:37:48 +0000
commitf6ec243a4a629913419a739a25199ec8a28bab65 (patch)
tree47c92d7a843ee8238406c5329a2168d8165c33ce /android/src
parent77eed8154c782a4d3b0e38a49986c18c240ab2f2 (diff)
downloadmupdf-f6ec243a4a629913419a739a25199ec8a28bab65.tar.xz
android app: support hardware acceleration
Diffstat (limited to 'android/src')
-rw-r--r--android/src/com/artifex/mupdf/PageView.java12
1 files changed, 12 insertions, 0 deletions
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);