Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Side by Side Diff: ui/gfx/android/java_bitmap.h

Issue 157033007: API to Convert Java Bitmap Config to SkBitmap::Config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code changed as per review comments. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ui/gfx/size.h" 12 #include "ui/gfx/size.h"
12 13
13 class SkBitmap;
14
15 namespace gfx { 14 namespace gfx {
16 15
17 // This class wraps a JNI AndroidBitmap object to make it easier to use. It 16 // 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 17 // handles locking and unlocking of the underlying pixels, along with wrapping
19 // various JNI methods. 18 // various JNI methods.
20 class GFX_EXPORT JavaBitmap { 19 class GFX_EXPORT JavaBitmap {
21 public: 20 public:
21 enum {
22 BITMAP_CONFIG_NO_CONFIG = 0,
bulach 2014/02/17 10:33:58 as above, let's extract this to avoid duplication.
sivag 2014/02/18 16:06:22 Done.
23 BITMAP_CONFIG_ALPHA_8,
24 BITMAP_CONFIG_ARGB_4444,
25 BITMAP_CONFIG_ARGB_8888,
26 BITMAP_CONFIG_RGB_565
27 };
28
22 explicit JavaBitmap(jobject bitmap); 29 explicit JavaBitmap(jobject bitmap);
23 ~JavaBitmap(); 30 ~JavaBitmap();
24 31
25 inline void* pixels() { return pixels_; } 32 inline void* pixels() { return pixels_; }
26 inline const gfx::Size& size() const { return size_; } 33 inline const gfx::Size& size() const { return size_; }
27 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888 34 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888
28 inline int format() const { return format_; } 35 inline int format() const { return format_; }
29 inline uint32_t stride() const { return stride_; } 36 inline uint32_t stride() const { return stride_; }
30 37
31 // Registers methods with JNI and returns true if succeeded. 38 // Registers methods with JNI and returns true if succeeded.
(...skipping 12 matching lines...) Expand all
44 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( 51 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(
45 const SkBitmap* skbitmap); 52 const SkBitmap* skbitmap);
46 53
47 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(JavaBitmap& jbitmap); 54 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(JavaBitmap& jbitmap);
48 55
49 // If the resource loads successfully, it will be resized to |size|. 56 // If the resource loads successfully, it will be resized to |size|.
50 // Note: If the source resource is smaller than |size|, quality may suffer. 57 // Note: If the source resource is smaller than |size|, quality may suffer.
51 GFX_EXPORT SkBitmap CreateSkBitmapFromResource(const char* name, 58 GFX_EXPORT SkBitmap CreateSkBitmapFromResource(const char* name,
52 gfx::Size size); 59 gfx::Size size);
53 60
61 // Returns a Skia config value for the requested input java Bitmap.Config.
62 GFX_EXPORT SkBitmap::Config ConvertToSkiaConfig(jobject bitmap_config);
63
54 } // namespace gfx 64 } // namespace gfx
55 65
56 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ 66 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698