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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 public: | 30 public: |
31 explicit JavaBitmap(jobject bitmap); | 31 explicit JavaBitmap(jobject bitmap); |
32 ~JavaBitmap(); | 32 ~JavaBitmap(); |
33 | 33 |
34 inline void* pixels() { return pixels_; } | 34 inline void* pixels() { return pixels_; } |
35 inline const void* pixels() const { return pixels_; } | 35 inline const void* pixels() const { return pixels_; } |
36 inline const gfx::Size& size() const { return size_; } | 36 inline const gfx::Size& size() const { return size_; } |
37 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888 | 37 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888 |
38 inline int format() const { return format_; } | 38 inline int format() const { return format_; } |
39 inline uint32_t stride() const { return stride_; } | 39 inline uint32_t stride() const { return stride_; } |
| 40 inline int byte_count() const { return byte_count_; } |
40 | 41 |
41 // Registers methods with JNI and returns true if succeeded. | 42 // Registers methods with JNI and returns true if succeeded. |
42 static bool RegisterJavaBitmap(JNIEnv* env); | 43 static bool RegisterJavaBitmap(JNIEnv* env); |
43 | 44 |
44 private: | 45 private: |
45 jobject bitmap_; | 46 jobject bitmap_; |
46 void* pixels_; | 47 void* pixels_; |
47 gfx::Size size_; | 48 gfx::Size size_; |
48 int format_; | 49 int format_; |
49 uint32_t stride_; | 50 uint32_t stride_; |
| 51 int byte_count_; |
50 | 52 |
51 DISALLOW_COPY_AND_ASSIGN(JavaBitmap); | 53 DISALLOW_COPY_AND_ASSIGN(JavaBitmap); |
52 }; | 54 }; |
53 | 55 |
54 // Allocates a Java-backed bitmap (android.graphics.Bitmap) with the given | 56 // Allocates a Java-backed bitmap (android.graphics.Bitmap) with the given |
55 // (non-empty!) size and color type. | 57 // (non-empty!) size and color type. |
56 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap( | 58 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap( |
57 int width, | 59 int width, |
58 int height, | 60 int height, |
59 SkColorType color_type); | 61 SkColorType color_type); |
60 | 62 |
61 // Converts |skbitmap| to a Java-backed bitmap (android.graphics.Bitmap). | 63 // Converts |skbitmap| to a Java-backed bitmap (android.graphics.Bitmap). |
62 // Note: |skbitmap| is assumed to be non-null, non-empty and one of RGBA_8888 or | 64 // Note: |skbitmap| is assumed to be non-null, non-empty and one of RGBA_8888 or |
63 // RGB_565 formats. | 65 // RGB_565 formats. |
64 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( | 66 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( |
65 const SkBitmap* skbitmap); | 67 const SkBitmap* skbitmap); |
66 | 68 |
67 // Converts |bitmap| to an SkBitmap of the same size and format. | 69 // Converts |bitmap| to an SkBitmap of the same size and format. |
68 // Note: |jbitmap| is assumed to be non-null, non-empty and of format RGBA_8888. | 70 // Note: |jbitmap| is assumed to be non-null, non-empty and of format RGBA_8888. |
69 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap); | 71 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap); |
70 | 72 |
71 // Returns a Skia color type value for the requested input java Bitmap.Config. | 73 // Returns a Skia color type value for the requested input java Bitmap.Config. |
72 GFX_EXPORT SkColorType ConvertToSkiaColorType(jobject jbitmap_config); | 74 GFX_EXPORT SkColorType ConvertToSkiaColorType(jobject jbitmap_config); |
73 | 75 |
74 } // namespace gfx | 76 } // namespace gfx |
75 | 77 |
76 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ | 78 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ |
OLD | NEW |