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 "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 | 15 |
16 // Define Bitmap Config values like BITMAP_CONFIG_ARGB_8888 in a | 16 // A Java counterpart will be generated for this enum. |
17 // way that ensures they're always the same than their Java counterpart. | 17 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.gfx |
18 | 18 enum BitmapFormat { |
19 enum BitmapConfig { | 19 BITMAP_FORMAT_NO_CONFIG, |
20 #define DEFINE_BITMAP_CONFIG(x, y) BITMAP_##x = y, | 20 BITMAP_FORMAT_ALPHA_8, |
21 #include "bitmap_config_list.h" | 21 BITMAP_FORMAT_ARGB_4444, |
22 #undef DEFINE_BITMAP_CONFIG | 22 BITMAP_FORMAT_ARGB_8888, |
| 23 BITMAP_FORMAT_RGB_565, |
23 }; | 24 }; |
24 | 25 |
25 // This class wraps a JNI AndroidBitmap object to make it easier to use. It | 26 // This class wraps a JNI AndroidBitmap object to make it easier to use. It |
26 // handles locking and unlocking of the underlying pixels, along with wrapping | 27 // handles locking and unlocking of the underlying pixels, along with wrapping |
27 // various JNI methods. | 28 // various JNI methods. |
28 class GFX_EXPORT JavaBitmap { | 29 class GFX_EXPORT JavaBitmap { |
29 public: | 30 public: |
30 explicit JavaBitmap(jobject bitmap); | 31 explicit JavaBitmap(jobject bitmap); |
31 ~JavaBitmap(); | 32 ~JavaBitmap(); |
32 | 33 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // Converts |bitmap| to an SkBitmap of the same size and format. | 74 // Converts |bitmap| to an SkBitmap of the same size and format. |
74 // Note: |jbitmap| is assumed to be non-null, non-empty and of format RGBA_8888. | 75 // Note: |jbitmap| is assumed to be non-null, non-empty and of format RGBA_8888. |
75 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap); | 76 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap); |
76 | 77 |
77 // Returns a Skia color type value for the requested input java Bitmap.Config. | 78 // Returns a Skia color type value for the requested input java Bitmap.Config. |
78 GFX_EXPORT SkColorType ConvertToSkiaColorType(jobject jbitmap_config); | 79 GFX_EXPORT SkColorType ConvertToSkiaColorType(jobject jbitmap_config); |
79 | 80 |
80 } // namespace gfx | 81 } // namespace gfx |
81 | 82 |
82 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ | 83 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ |
OLD | NEW |