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