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

Unified Diff: ui/gfx/android/java_bitmap.cc

Issue 184453002: Android::Pass Bitmap.Config instead of bool to CreateJavaBitmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NOTREACHED check. 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 | « ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/android/java_bitmap.cc
diff --git a/ui/gfx/android/java_bitmap.cc b/ui/gfx/android/java_bitmap.cc
index b7a0f5add151a0fdf52872b6bf6363bb191256f8..316dbb90bf500915ab59990d77504c2c87b15bfe 100644
--- a/ui/gfx/android/java_bitmap.cc
+++ b/ui/gfx/android/java_bitmap.cc
@@ -41,10 +41,29 @@ bool JavaBitmap::RegisterJavaBitmap(JNIEnv* env) {
return RegisterNativesImpl(env);
}
-static ScopedJavaLocalRef<jobject> CreateJavaBitmap(int width, int height,
- bool is565_config) {
- return Java_BitmapHelper_createBitmap(AttachCurrentThread(),
- width, height, is565_config);
+static ScopedJavaLocalRef<jobject> CreateJavaBitmap(int width,
+ int height,
+ int bitmap_config) {
+
+ return Java_BitmapHelper_createBitmap(
+ AttachCurrentThread(), width, height, bitmap_config);
+}
+
+static int SkBitmapConfigToBitmapFormat(SkBitmap::Config bitmap_config) {
+ switch (bitmap_config) {
+ case SkBitmap::kA8_Config:
+ return BITMAP_FORMAT_ALPHA_8;
+ case SkBitmap::kARGB_4444_Config:
+ return BITMAP_FORMAT_ARGB_4444;
+ case SkBitmap::kARGB_8888_Config:
+ return BITMAP_FORMAT_ARGB_8888;
+ case SkBitmap::kRGB_565_Config:
+ return BITMAP_FORMAT_RGB_565;
+ case SkBitmap::kNo_Config:
+ default:
+ NOTREACHED();
+ return BITMAP_FORMAT_NO_CONFIG;
+ }
}
ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) {
@@ -52,10 +71,9 @@ ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) {
SkBitmap::Config config = skbitmap->getConfig();
DCHECK((config == SkBitmap::kRGB_565_Config) ||
(config == SkBitmap::kARGB_8888_Config));
- // If the Config is not RGB565 it is default i.e ARGB8888
- ScopedJavaLocalRef<jobject> jbitmap =
- CreateJavaBitmap(skbitmap->width(), skbitmap->height(),
- (config == SkBitmap::kRGB_565_Config));
+ int java_bitmap_config = SkBitmapConfigToBitmapFormat(config);
+ ScopedJavaLocalRef<jobject> jbitmap = CreateJavaBitmap(
+ skbitmap->width(), skbitmap->height(), java_bitmap_config);
SkAutoLockPixels src_lock(*skbitmap);
JavaBitmap dst_lock(jbitmap.obj());
void* src_pixels = skbitmap->getPixels();
@@ -102,8 +120,8 @@ SkBitmap CreateSkBitmapFromResource(const char* name, gfx::Size size) {
}
SkBitmap::Config ConvertToSkiaConfig(jobject bitmap_config) {
- int jbitmap_config =
- Java_BitmapHelper_bitmapConfig(AttachCurrentThread(), bitmap_config);
+ int jbitmap_config = Java_BitmapHelper_getBitmapFormatForConfig(
+ AttachCurrentThread(), bitmap_config);
switch (jbitmap_config) {
case BITMAP_FORMAT_ALPHA_8:
return SkBitmap::kA8_Config;
« no previous file with comments | « ui/android/java/src/org/chromium/ui/gfx/BitmapHelper.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698