summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/browser')
-rw-r--r--src/com/android/browser/PhoneUi.java38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index ffcaaf8..a13eca3 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -529,12 +529,14 @@ public class PhoneUi extends BaseUi {
if (mTitleBarBitmap == null
|| mTitleBarBitmap.getWidth() != tbar.getWidth()
|| mTitleBarBitmap.getHeight() != tbar.getEmbeddedHeight()) {
- mTitleBarBitmap = Bitmap.createBitmap(tbar.getWidth(),
- tbar.getEmbeddedHeight(), Bitmap.Config.RGB_565);
+ mTitleBarBitmap = safeCreateBitmap(tbar.getWidth(),
+ tbar.getEmbeddedHeight());
+ }
+ if (mTitleBarBitmap != null) {
+ Canvas c = new Canvas(mTitleBarBitmap);
+ tbar.draw(c);
+ c.setBitmap(null);
}
- Canvas c = new Canvas(mTitleBarBitmap);
- tbar.draw(c);
- c.setBitmap(null);
} else {
mTitleBarBitmap = null;
}
@@ -544,18 +546,28 @@ public class PhoneUi extends BaseUi {
if (mContentBitmap == null
|| mContentBitmap.getWidth() != web.getWidth()
|| mContentBitmap.getHeight() != h) {
- mContentBitmap = Bitmap.createBitmap(web.getWidth(), h,
- Bitmap.Config.RGB_565);
+ mContentBitmap = safeCreateBitmap(web.getWidth(), h);
+ }
+ if (mContentBitmap != null) {
+ Canvas c = new Canvas(mContentBitmap);
+ int tx = web.getScrollX();
+ int ty = web.getScrollY();
+ c.translate(-tx, -ty - tbar.getEmbeddedHeight());
+ web.draw(c);
+ c.setBitmap(null);
}
- Canvas c = new Canvas(mContentBitmap);
- int tx = web.getScrollX();
- int ty = web.getScrollY();
- c.translate(-tx, -ty - tbar.getEmbeddedHeight());
- web.draw(c);
- c.setBitmap(null);
mContent.setImageBitmap(mContentBitmap);
}
+ private Bitmap safeCreateBitmap(int width, int height) {
+ if (width <= 0 || height <= 0) {
+ Log.w(LOGTAG, "safeCreateBitmap failed! width: " + width
+ + ", height: " + height);
+ return null;
+ }
+ return Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
+ }
+
public void set(Bitmap image) {
mTitle.setVisibility(View.GONE);
mContent.setImageBitmap(image);