| 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 #ifndef UI_GFX_ANDROID_JAVA_BITMAP_H_ | 5 #ifndef UI_GFX_ANDROID_JAVA_BITMAP_H_ |
| 6 #define UI_GFX_ANDROID_JAVA_BITMAP_H_ | 6 #define UI_GFX_ANDROID_JAVA_BITMAP_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "ui/gfx/size.h" | 11 #include "ui/gfx/size.h" |
| 12 | 12 |
| 13 class SkBitmap; | 13 class SkBitmap; |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 | 16 |
| 17 // This class wraps a JNI AndroidBitmap object to make it easier to use. It | 17 // This class wraps a JNI AndroidBitmap object to make it easier to use. It |
| 18 // handles locking and unlocking of the underlying pixels, along with wrapping | 18 // handles locking and unlocking of the underlying pixels, along with wrapping |
| 19 // various JNI methods. | 19 // various JNI methods. |
| 20 class UI_EXPORT JavaBitmap { | 20 class GFX_EXPORT JavaBitmap { |
| 21 public: | 21 public: |
| 22 explicit JavaBitmap(jobject bitmap); | 22 explicit JavaBitmap(jobject bitmap); |
| 23 ~JavaBitmap(); | 23 ~JavaBitmap(); |
| 24 | 24 |
| 25 inline void* pixels() { return pixels_; } | 25 inline void* pixels() { return pixels_; } |
| 26 inline const gfx::Size& size() const { return size_; } | 26 inline const gfx::Size& size() const { return size_; } |
| 27 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888 | 27 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888 |
| 28 inline int format() const { return format_; } | 28 inline int format() const { return format_; } |
| 29 inline uint32_t stride() const { return stride_; } | 29 inline uint32_t stride() const { return stride_; } |
| 30 | 30 |
| 31 // Registers methods with JNI and returns true if succeeded. | 31 // Registers methods with JNI and returns true if succeeded. |
| 32 static bool RegisterJavaBitmap(JNIEnv* env); | 32 static bool RegisterJavaBitmap(JNIEnv* env); |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 jobject bitmap_; | 35 jobject bitmap_; |
| 36 void* pixels_; | 36 void* pixels_; |
| 37 gfx::Size size_; | 37 gfx::Size size_; |
| 38 int format_; | 38 int format_; |
| 39 uint32_t stride_; | 39 uint32_t stride_; |
| 40 | 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(JavaBitmap); | 41 DISALLOW_COPY_AND_ASSIGN(JavaBitmap); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 UI_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( | 44 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( |
| 45 const SkBitmap* skbitmap); | 45 const SkBitmap* skbitmap); |
| 46 | 46 |
| 47 UI_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(JavaBitmap& jbitmap); | 47 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(JavaBitmap& jbitmap); |
| 48 | 48 |
| 49 // If the resource loads successfully, it will be resized to |size|. | 49 // If the resource loads successfully, it will be resized to |size|. |
| 50 // Note: If the source resource is smaller than |size|, quality may suffer. | 50 // Note: If the source resource is smaller than |size|, quality may suffer. |
| 51 UI_EXPORT SkBitmap CreateSkBitmapFromResource(const char* name, gfx::Size size); | 51 GFX_EXPORT SkBitmap CreateSkBitmapFromResource(const char* name, |
| 52 gfx::Size size); |
| 52 | 53 |
| 53 } // namespace gfx | 54 } // namespace gfx |
| 54 | 55 |
| 55 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ | 56 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ |
| OLD | NEW |