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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 DISALLOW_COPY_AND_ASSIGN(JavaBitmap); | 51 DISALLOW_COPY_AND_ASSIGN(JavaBitmap); |
52 }; | 52 }; |
53 | 53 |
54 // Allocates a Java-backed bitmap (android.graphics.Bitmap) with the given | 54 // Allocates a Java-backed bitmap (android.graphics.Bitmap) with the given |
55 // (non-empty!) size and color type. | 55 // (non-empty!) size and color type. |
56 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap( | 56 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap( |
57 int width, | 57 int width, |
58 int height, | 58 int height, |
59 SkColorType color_type); | 59 SkColorType color_type); |
60 | 60 |
61 // Loads an SkBitmap from the provided drawable resource identifier (e.g., | |
62 // android:drawable/overscroll_glow). If the resource loads successfully, it | |
63 // will be integrally scaled down, preserving aspect ratio, to a size no smaller | |
64 // than |size|. Otherwise, an empty bitmap is returned. | |
65 GFX_EXPORT SkBitmap | |
66 CreateSkBitmapFromAndroidResource(const char* name, gfx::Size size); | |
67 | |
68 // Converts |skbitmap| to a Java-backed bitmap (android.graphics.Bitmap). | 61 // Converts |skbitmap| to a Java-backed bitmap (android.graphics.Bitmap). |
69 // Note: |skbitmap| is assumed to be non-null, non-empty and one of RGBA_8888 or | 62 // Note: |skbitmap| is assumed to be non-null, non-empty and one of RGBA_8888 or |
70 // RGB_565 formats. | 63 // RGB_565 formats. |
71 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( | 64 GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( |
72 const SkBitmap* skbitmap); | 65 const SkBitmap* skbitmap); |
73 | 66 |
74 // Converts |bitmap| to an SkBitmap of the same size and format. | 67 // Converts |bitmap| to an SkBitmap of the same size and format. |
75 // Note: |jbitmap| is assumed to be non-null, non-empty and of format RGBA_8888. | 68 // Note: |jbitmap| is assumed to be non-null, non-empty and of format RGBA_8888. |
76 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap); | 69 GFX_EXPORT SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap); |
77 | 70 |
78 // Returns a Skia color type value for the requested input java Bitmap.Config. | 71 // Returns a Skia color type value for the requested input java Bitmap.Config. |
79 GFX_EXPORT SkColorType ConvertToSkiaColorType(jobject jbitmap_config); | 72 GFX_EXPORT SkColorType ConvertToSkiaColorType(jobject jbitmap_config); |
80 | 73 |
81 } // namespace gfx | 74 } // namespace gfx |
82 | 75 |
83 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ | 76 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ |
OLD | NEW |