| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/android/java_bitmap.h" | 5 #include "ui/gfx/android/java_bitmap.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "jni/BitmapHelper_jni.h" | 11 #include "jni/BitmapHelper_jni.h" |
| 12 #include "skia/ext/image_operations.h" | 12 #include "skia/ext/image_operations.h" |
| 13 #include "third_party/skia/include/core/SkBitmap.h" | |
| 14 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
| 15 | 14 |
| 16 using base::android::AttachCurrentThread; | 15 using base::android::AttachCurrentThread; |
| 17 | 16 |
| 18 namespace gfx { | 17 namespace gfx { |
| 19 | 18 |
| 20 JavaBitmap::JavaBitmap(jobject bitmap) | 19 JavaBitmap::JavaBitmap(jobject bitmap) |
| 21 : bitmap_(bitmap), | 20 : bitmap_(bitmap), |
| 22 pixels_(NULL) { | 21 pixels_(NULL) { |
| 23 int err = AndroidBitmap_lockPixels(AttachCurrentThread(), bitmap_, &pixels_); | 22 int err = AndroidBitmap_lockPixels(AttachCurrentThread(), bitmap_, &pixels_); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 env, jname.obj(), size.width(), size.height())); | 94 env, jname.obj(), size.width(), size.height())); |
| 96 if (jobj.is_null()) | 95 if (jobj.is_null()) |
| 97 return SkBitmap(); | 96 return SkBitmap(); |
| 98 | 97 |
| 99 JavaBitmap jbitmap(jobj.obj()); | 98 JavaBitmap jbitmap(jobj.obj()); |
| 100 SkBitmap bitmap = CreateSkBitmapFromJavaBitmap(jbitmap); | 99 SkBitmap bitmap = CreateSkBitmapFromJavaBitmap(jbitmap); |
| 101 return skia::ImageOperations::Resize( | 100 return skia::ImageOperations::Resize( |
| 102 bitmap, skia::ImageOperations::RESIZE_BOX, size.width(), size.height()); | 101 bitmap, skia::ImageOperations::RESIZE_BOX, size.width(), size.height()); |
| 103 } | 102 } |
| 104 | 103 |
| 104 SkBitmap::Config ConvertToSkiaConfig(jobject bitmap_config) { |
| 105 int jbitmap_config = |
| 106 Java_BitmapHelper_bitmapConfig(AttachCurrentThread(), bitmap_config); |
| 107 switch (jbitmap_config) { |
| 108 case BITMAP_FORMAT_ALPHA_8: |
| 109 return SkBitmap::kA8_Config; |
| 110 case BITMAP_FORMAT_ARGB_4444: |
| 111 return SkBitmap::kARGB_4444_Config; |
| 112 case BITMAP_FORMAT_ARGB_8888: |
| 113 return SkBitmap::kARGB_8888_Config; |
| 114 case BITMAP_FORMAT_RGB_565: |
| 115 return SkBitmap::kRGB_565_Config; |
| 116 case BITMAP_FORMAT_NO_CONFIG: |
| 117 default: |
| 118 return SkBitmap::kNo_Config; |
| 119 } |
| 120 } |
| 121 |
| 105 } // namespace gfx | 122 } // namespace gfx |
| OLD | NEW |