Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1422)

Unified Diff: ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java

Issue 184453002: Android::Pass Bitmap.Config instead of bool to CreateJavaBitmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code changed as per review comments. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/android/java_bitmap.cc » ('j') | ui/gfx/android/java_bitmap.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a936fe77b58f27469be022bd46e1d0df9acceb06..4b6d689697161f4abfff73ee492d1662bfd0d175 100644
--- a/ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java
+++ b/ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java
@@ -19,11 +19,9 @@ public class BitmapHelper {
@CalledByNative
private static Bitmap createBitmap(int width,
int height,
- boolean is565Config) {
- if (is565Config) {
- return Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
- }
- return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ int bitmapFormatValue) {
+ Bitmap.Config bitmapConfig = getJavabitmapConfig(bitmapFormatValue);
+ return Bitmap.createBitmap(width, height, bitmapConfig);
}
/**
@@ -83,7 +81,7 @@ public class BitmapHelper {
* @return Matching integer constant for the Bitmap.Config value passed.
*/
@CalledByNative
- private static int bitmapConfig(Bitmap.Config bitmapConfig) {
+ private static int getConfigEnumValue(Bitmap.Config bitmapConfig) {
bulach 2014/03/04 13:05:13 nit: how about "getBitmapFormatForConfig" and the
sivag 2014/03/04 13:57:55 Done.
switch (bitmapConfig) {
case ALPHA_8:
return BitmapFormat.FORMAT_ALPHA_8;
@@ -97,4 +95,25 @@ public class BitmapHelper {
return BitmapFormat.FORMAT_NO_CONFIG;
}
}
+
+ /**
+ * Provides a matching Bitmap.Config for the enum config value passed.
+ *
+ * @param bitmapFormatValue The Bitmap Configuration enum value.
+ * @return Matching Bitmap.Config for the enum value passed.
+ */
+ private static Bitmap.Config getJavabitmapConfig(int bitmapFormatValue) {
bulach 2014/03/04 13:05:13 nit: I'd prefer my suggestion above, but if we dec
sivag 2014/03/04 13:57:55 Done.
+ switch (bitmapFormatValue) {
+ case BitmapFormat.FORMAT_ALPHA_8:
+ return Bitmap.Config.ALPHA_8;
+ case BitmapFormat.FORMAT_ARGB_4444:
+ return Bitmap.Config.ARGB_4444;
+ case BitmapFormat.FORMAT_RGB_565:
+ return Bitmap.Config.RGB_565;
+ case BitmapFormat.FORMAT_ARGB_8888:
+ default:
bulach 2014/03/04 13:05:13 nit: unindent "default" and keep at the same level
sivag 2014/03/04 13:57:55 Done.
+ return Bitmap.Config.ARGB_8888;
+ }
+ }
+
}
« no previous file with comments | « no previous file | ui/gfx/android/java_bitmap.cc » ('j') | ui/gfx/android/java_bitmap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698