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 "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
9 #include "ui/gfx/size.h" | 9 #include "ui/gfx/size.h" |
10 | 10 |
11 class SkBitmap; | 11 class SkBitmap; |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 | 14 |
15 // This class wraps a JNI AndroidBitmap object to make it easier to use. It | 15 // This class wraps a JNI AndroidBitmap object to make it easier to use. It |
16 // handles locking and unlocking of the underlying pixels, along with wrapping | 16 // handles locking and unlocking of the underlying pixels, along with wrapping |
17 // various JNI methods. | 17 // various JNI methods. |
18 UI_EXPORT class JavaBitmap { | 18 class UI_EXPORT JavaBitmap { |
19 public: | 19 public: |
20 explicit JavaBitmap(jobject bitmap); | 20 explicit JavaBitmap(jobject bitmap); |
21 ~JavaBitmap(); | 21 ~JavaBitmap(); |
22 | 22 |
23 inline void* pixels() { return pixels_; } | 23 inline void* pixels() { return pixels_; } |
24 inline const gfx::Size& size() const { return size_; } | 24 inline const gfx::Size& size() const { return size_; } |
25 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888 | 25 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888 |
26 inline int format() const { return format_; } | 26 inline int format() const { return format_; } |
27 inline uint32_t stride() const { return stride_; } | 27 inline uint32_t stride() const { return stride_; } |
28 | 28 |
29 private: | 29 private: |
30 jobject bitmap_; | 30 jobject bitmap_; |
31 void* pixels_; | 31 void* pixels_; |
32 gfx::Size size_; | 32 gfx::Size size_; |
33 int format_; | 33 int format_; |
34 uint32_t stride_; | 34 uint32_t stride_; |
35 | 35 |
36 DISALLOW_COPY_AND_ASSIGN(JavaBitmap); | 36 DISALLOW_COPY_AND_ASSIGN(JavaBitmap); |
37 }; | 37 }; |
38 | 38 |
39 base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap( | 39 UI_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap( |
40 const gfx::Size& size); | 40 const gfx::Size& size); |
41 | 41 |
42 base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( | 42 UI_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( |
43 const SkBitmap* skbitmap); | 43 const SkBitmap* skbitmap); |
44 | 44 |
45 SkBitmap CreateSkBitmapFromResource(const char* name); | 45 SkBitmap CreateSkBitmapFromResource(const char* name); |
46 | 46 |
47 } // namespace gfx | 47 } // namespace gfx |
48 | 48 |
49 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ | 49 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ |
OLD | NEW |