Index: ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java |
diff --git a/ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java b/ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java |
index 5c4549cd9d8f03ebd7154a012c2e2721edf0ca01..91ebecc5815db523a907789605e770d512c0aa91 100644 |
--- a/ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java |
+++ b/ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java |
@@ -25,6 +25,32 @@ public class BitmapHelper { |
} |
/** |
+ * Decode a bitmap resource. |
+ * |
+ * @param name The resource name of the bitmap to decode. |
+ * @return The corresponding bitmap. |
+ */ |
+ @CalledByNative |
+ private static Bitmap decodeDrawableResource(String name) { |
+ Resources res = Resources.getSystem(); |
+ return decodeDrawableResource(res.getIdentifier(name, null, null)); |
+ } |
+ |
+ /** |
+ * Decode a bitmap resource. |
+ * |
+ * @param resId The resource id of the bitmap to decode. |
+ * @return The corresponding bitmap. |
+ */ |
+ @CalledByNative |
+ private static Bitmap decodeDrawableResource(int resId) { |
+ final BitmapFactory.Options options = new BitmapFactory.Options(); |
+ options.inJustDecodeBounds = false; |
+ options.inPreferredConfig = Bitmap.Config.ARGB_8888; |
+ return BitmapFactory.decodeResource(Resources.getSystem(), resId, options); |
+ } |
+ |
+ /** |
* Decode and sample down a bitmap resource to the requested width and height. |
* |
* @param name The resource name of the bitmap to decode. |
@@ -34,9 +60,9 @@ public class BitmapHelper { |
* that are equal to or greater than the requested width and height. |
*/ |
@CalledByNative |
- private static Bitmap decodeDrawableResource(String name, |
- int reqWidth, |
- int reqHeight) { |
+ private static Bitmap decodeAndDownsampleDrawableResource(String name, |
+ int reqWidth, |
+ int reqHeight) { |
Resources res = Resources.getSystem(); |
int resId = res.getIdentifier(name, null, null); |
if (resId == 0) return null; |