From 0c6bc40564d4e15f2801266115e7a7a137451907 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 22 May 2013 19:57:25 +0100 Subject: Bug 694092: Android: Redraw performance (overdraw) fixes Thanks to Goncalo Ferreira(*) (aka monxalo) for this patch. Firstly, we move our textured background off the layout and into a style applied to MuPDFActivity. By using "windowBackground", we avoid the default background being redrawn only to be overlaid with ours. This cuts out one level of overdrawing. Secondly, when drawing each PageView, the old code would render the background for the page, then would draw the bitmap over the top of that. While it's important to draw the background of the page before we have a bitmap for the page, we can avoid that stage once a page bitmap arrives. (* apologies for not being able to put the cedilla on the 'c' in your name, but git gives problems with top bit set chars.) --- android/AndroidManifest.xml | 2 +- android/res/values/styles.xml | 5 +++++ android/src/com/artifex/mupdfdemo/MuPDFActivity.java | 2 -- android/src/com/artifex/mupdfdemo/PageView.java | 6 +++++- 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 android/res/values/styles.xml diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 2bc2217f..f91ccd83 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -28,7 +28,7 @@ diff --git a/android/res/values/styles.xml b/android/res/values/styles.xml new file mode 100644 index 00000000..ade851dd --- /dev/null +++ b/android/res/values/styles.xml @@ -0,0 +1,5 @@ + + + diff --git a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java index 5fea13e3..3133fc17 100644 --- a/android/src/com/artifex/mupdfdemo/MuPDFActivity.java +++ b/android/src/com/artifex/mupdfdemo/MuPDFActivity.java @@ -578,8 +578,6 @@ public class MuPDFActivity extends Activity RelativeLayout layout = new RelativeLayout(this); layout.addView(mDocView); layout.addView(mButtonsView); - layout.setBackgroundResource(R.drawable.tiled_background); - //layout.setBackgroundResource(R.color.canvas); setContentView(layout); } diff --git a/android/src/com/artifex/mupdfdemo/PageView.java b/android/src/com/artifex/mupdfdemo/PageView.java index 756ee2f5..14d6b729 100644 --- a/android/src/com/artifex/mupdfdemo/PageView.java +++ b/android/src/com/artifex/mupdfdemo/PageView.java @@ -6,6 +6,7 @@ import java.util.Iterator; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Point; @@ -219,6 +220,8 @@ public abstract class PageView extends ViewGroup { mBusyIndicator.setBackgroundResource(R.drawable.busy); addView(mBusyIndicator); } + + setBackgroundColor(BACKGROUND_COLOR); } public void setPage(int page, PointF size) { @@ -270,6 +273,7 @@ public abstract class PageView extends ViewGroup { } protected void onPreExecute() { + setBackgroundColor(BACKGROUND_COLOR); mEntire.setImageBitmap(null); mEntireBmh.setBm(null); @@ -293,7 +297,7 @@ public abstract class PageView extends ViewGroup { mBusyIndicator = null; mEntire.setImageBitmap(bm); mEntireBmh.setBm(bm); - invalidate(); + setBackgroundColor(Color.TRANSPARENT); } }; -- cgit v1.2.3