Chromium Code Reviews| Index: android_webview/java/src/org/chromium/android_webview/JavaBrowserViewRendererHelper.java |
| diff --git a/android_webview/java/src/org/chromium/android_webview/JavaBrowserViewRendererHelper.java b/android_webview/java/src/org/chromium/android_webview/JavaBrowserViewRendererHelper.java |
| index d4e79c82254e6fd7d9471c49156913afbf9f2f78..0e18bbd43c4f8ebea8c72c5171411c7e8b049353 100644 |
| --- a/android_webview/java/src/org/chromium/android_webview/JavaBrowserViewRendererHelper.java |
| +++ b/android_webview/java/src/org/chromium/android_webview/JavaBrowserViewRendererHelper.java |
| @@ -12,18 +12,30 @@ import android.graphics.Picture; |
| import org.chromium.base.CalledByNative; |
| import org.chromium.base.JNINamespace; |
| +import java.lang.ref.SoftReference; |
| + |
| /** |
| * Provides auxiliary methods related to Picture objects and native SkPictures. |
| */ |
| @JNINamespace("android_webview") |
| public class JavaBrowserViewRendererHelper { |
| + private static SoftReference<Bitmap> sCachedBitmap; |
| + |
| /** |
| * Provides a Bitmap object with a given width and height used for auxiliary rasterization. |
| */ |
| @CalledByNative |
| - private static Bitmap createBitmap(int width, int height) { |
| - return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
| + private static Bitmap createBitmap(int width, int height, boolean cacheResult) { |
| + if (cacheResult && sCachedBitmap != null) { |
| + Bitmap result = sCachedBitmap.get(); |
| + if (result != null && result.getWidth() == width && result.getHeight() == height) { |
| + return result; |
| + } |
| + } |
| + Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
| + if (cacheResult) sCachedBitmap = new SoftReference<Bitmap>(result); |
|
kaanb
2013/05/23 16:56:11
nit: it would be more readable if you break this s
joth
2013/05/23 20:23:14
Done.
|
| + return result; |
| } |
| /** |