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 // Define Bitmap Config values like BITMAP_CONFIG_ARGB_8888 in a |
Sami
2014/09/03 19:04:59
nit: Update the example in the comment. Or maybe t
mkosiba (inactive)
2014/09/04 11:31:22
ok, I assumed the comment meant these are supposed
| |
17 // way that ensures they're always the same than their Java counterpart. | 17 // way that ensures they're always the same as their Java counterpart. |
18 | 18 // |
19 enum BitmapConfig { | 19 // A Java counterpart will be generated for this enum. |
20 #define DEFINE_BITMAP_CONFIG(x, y) BITMAP_##x = y, | 20 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.gfx |
21 #include "bitmap_config_list.h" | 21 enum BitmapFormat { |
22 #undef DEFINE_BITMAP_CONFIG | 22 BITMAP_FORMAT_NO_CONFIG, |
23 BITMAP_FORMAT_ALPHA_8, | |
24 BITMAP_FORMAT_ARGB_4444, | |
25 BITMAP_FORMAT_ARGB_8888, | |
26 BITMAP_FORMAT_RGB_565, | |
23 }; | 27 }; |
24 | 28 |
25 // This class wraps a JNI AndroidBitmap object to make it easier to use. It | 29 // 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 | 30 // handles locking and unlocking of the underlying pixels, along with wrapping |
27 // various JNI methods. | 31 // various JNI methods. |
28 class GFX_EXPORT JavaBitmap { | 32 class GFX_EXPORT JavaBitmap { |
29 public: | 33 public: |
30 explicit JavaBitmap(jobject bitmap); | 34 explicit JavaBitmap(jobject bitmap); |
31 ~JavaBitmap(); | 35 ~JavaBitmap(); |
32 | 36 |
(...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. | 77 // 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. | 78 // Note: |jbitmap| is assumed to be non-null, non-empty and of format RGBA_8888. |
75 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap); | 79 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap); |
76 | 80 |
77 // Returns a Skia color type value for the requested input java Bitmap.Config. | 81 // Returns a Skia color type value for the requested input java Bitmap.Config. |
78 GFX_EXPORT SkColorType ConvertToSkiaColorType(jobject jbitmap_config); | 82 GFX_EXPORT SkColorType ConvertToSkiaColorType(jobject jbitmap_config); |
79 | 83 |
80 } // namespace gfx | 84 } // namespace gfx |
81 | 85 |
82 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ | 86 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ |
OLD | NEW |