diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-01-22 10:31:12 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-01-22 10:37:43 +0000 |
commit | b9b12fb56e0337fd068ad5bf810914ffdc5a7e7a (patch) | |
tree | 395bc35db15e1397c2fef9c8701f3872e28ca201 /android/src/com/artifex/mupdfdemo/PageView.java | |
parent | 5822ff1619fda7f0cc0b10f77d351eb459e3c67c (diff) | |
download | mupdf-b9b12fb56e0337fd068ad5bf810914ffdc5a7e7a.tar.xz |
More work on android bitmap recycling.
After much discussion and investigation, Paul and I have realised
that we do in fact (in the current scheme at least) need to hold
the existing bitmap in memory while drawing the next one (as the
existing bitmap is still in an ImageView and being used for any
foreground render requests). As such remove a 'setBm(null)' in
drawPage.
Also, in the onPostExecute for the patch redraw, we cannot recycle
the bitmap in a bitmap holder due to it still potentially being
in use. We therefore add a 'drop' method to the BitmapHolder class
that sets the reference to null without recycling. This is not
ideal, but is better than recycling too early and causing crashes.
Diffstat (limited to 'android/src/com/artifex/mupdfdemo/PageView.java')
-rw-r--r-- | android/src/com/artifex/mupdfdemo/PageView.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/android/src/com/artifex/mupdfdemo/PageView.java b/android/src/com/artifex/mupdfdemo/PageView.java index 064ce3f8..8e784b24 100644 --- a/android/src/com/artifex/mupdfdemo/PageView.java +++ b/android/src/com/artifex/mupdfdemo/PageView.java @@ -140,7 +140,7 @@ public abstract class PageView extends ViewGroup { mPatchBmh = new BitmapHolder(); } - protected abstract Bitmap drawPage(BitmapHolder h, int sizeX, int sizeY, int patchX, int patchY, int patchWidth, int patchHeight); + protected abstract Bitmap drawPage(int sizeX, int sizeY, int patchX, int patchY, int patchWidth, int patchHeight); protected abstract Bitmap updatePage(BitmapHolder h, int sizeX, int sizeY, int patchX, int patchY, int patchWidth, int patchHeight); protected abstract LinkInfo[] getLinkInfo(); protected abstract TextWord[][] getText(); @@ -255,7 +255,7 @@ public abstract class PageView extends ViewGroup { // Render the page in the background mDrawEntire = new AsyncTask<Void,Void,Bitmap>() { protected Bitmap doInBackground(Void... v) { - return drawPage(mEntireBmh, mSize.x, mSize.y, 0, 0, mSize.x, mSize.y); + return drawPage(mSize.x, mSize.y, 0, 0, mSize.x, mSize.y); } protected void onPreExecute() { @@ -529,7 +529,7 @@ public abstract class PageView extends ViewGroup { // previously invoked task, and possibly for a different // area, so we cannot risk the bitmap generated by this task // being passed to it - mPatchBmh.setBm(null); + mPatchBmh.drop(); mPatchBmh = new BitmapHolder(); } @@ -544,13 +544,13 @@ public abstract class PageView extends ViewGroup { mDrawPatch = new AsyncTask<PatchInfo,Void,PatchInfo>() { protected PatchInfo doInBackground(PatchInfo... v) { if (v[0].completeRedraw) { - v[0].bm = drawPage(v[0].bmh, v[0].patchViewSize.x, v[0].patchViewSize.y, - v[0].patchArea.left, v[0].patchArea.top, - v[0].patchArea.width(), v[0].patchArea.height()); + v[0].bm = drawPage(v[0].patchViewSize.x, v[0].patchViewSize.y, + v[0].patchArea.left, v[0].patchArea.top, + v[0].patchArea.width(), v[0].patchArea.height()); } else { - v[0].bm = updatePage(v[0].bmh, v[0].patchViewSize.x, v[0].patchViewSize.y, - v[0].patchArea.left, v[0].patchArea.top, - v[0].patchArea.width(), v[0].patchArea.height()); + v[0].bm = updatePage(v[0].bmh, v[0].patchViewSize.x, v[0].patchViewSize.y, + v[0].patchArea.left, v[0].patchArea.top, + v[0].patchArea.width(), v[0].patchArea.height()); } return v[0]; |