Chromium Code Reviews| Index: ui/gfx/android/java_bitmap.cc |
| diff --git a/ui/gfx/android/java_bitmap.cc b/ui/gfx/android/java_bitmap.cc |
| index 0127ec8ae2c051b15cd0a17073556900bf3663e0..d87938b3e5aa93cf7271addec1fa485d9bdd05bc 100644 |
| --- a/ui/gfx/android/java_bitmap.cc |
| +++ b/ui/gfx/android/java_bitmap.cc |
| @@ -10,13 +10,19 @@ |
| #include "base/logging.h" |
| #include "jni/BitmapHelper_jni.h" |
| #include "skia/ext/image_operations.h" |
| -#include "third_party/skia/include/core/SkBitmap.h" |
| #include "ui/gfx/size.h" |
| using base::android::AttachCurrentThread; |
| namespace gfx { |
| +static const char kALPHA_8[] = "ALPHA_8"; |
| +static const char kARGB_4444[] = "kARGB_4444"; |
| +static const char kARGB_8888[] = "ARGB_8888"; |
| +static const char kRGB_565[] = "RGB_565"; |
| +static const char kBitmapConfigClassPath[] = "android/graphics/Bitmap$Config"; |
| +static base::subtle::AtomicWord g_BitmapConfig_method = 0; |
| + |
| JavaBitmap::JavaBitmap(jobject bitmap) |
| : bitmap_(bitmap), |
| pixels_(NULL) { |
| @@ -102,4 +108,36 @@ SkBitmap CreateSkBitmapFromResource(const char* name, gfx::Size size) { |
| bitmap, skia::ImageOperations::RESIZE_BOX, size.width(), size.height()); |
| } |
| +SkBitmap::Config ToSkiaBitmapConfig(JNIEnv* env, |
| + jobject bitmap_config) |
| +{ |
| + static jclass g_BitmapConfig_clazz = reinterpret_cast<jclass> |
| + (env->NewGlobalRef(base::android::GetClass(env, |
| + kBitmapConfigClassPath).obj())); |
| + DCHECK(g_BitmapConfig_clazz); |
| + jmethodID method_id = base::android::MethodID::LazyGet< |
| + base::android::MethodID::TYPE_INSTANCE>(env, |
| + g_BitmapConfig_clazz, |
| + "name", |
| + "()Ljava/lang/String;", |
| + &g_BitmapConfig_method); |
| + |
| + jstring value = (jstring)env->CallObjectMethod(bitmap_config, method_id); |
| + const std::string config_value = base::android::ConvertJavaStringToUTF8(env, |
|
vivekg
2014/02/11 17:59:02
const std::string&
sivag
2014/02/13 16:31:52
Done.
|
| + value); |
| + base::android::CheckException(env); |
| + |
| + if (config_value.compare(kARGB_8888) == 0) { |
| + return SkBitmap::kARGB_8888_Config; |
| + } else if (config_value.compare(kRGB_565) == 0) { |
| + return SkBitmap::kRGB_565_Config; |
| + } else if (config_value.compare(kALPHA_8) == 0) { |
| + return SkBitmap::kA8_Config; |
| + } else if (config_value.compare(kARGB_4444) == 0) { |
| + return SkBitmap::kARGB_4444_Config; |
| + } |
| + |
| + return SkBitmap::kNo_Config; |
| +} |
| + |
| } // namespace gfx |