Mailbox support for texture layers.
[chromium-blink-merge.git] / ui / gfx / android / java_bitmap.h
blob061bb76e537e740767947b183482e873f0c63b39
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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_ANDROID_JAVA_BITMAP_H_
6 #define UI_GFX_ANDROID_JAVA_BITMAP_H_
8 #include "base/android/scoped_java_ref.h"
9 #include "ui/gfx/size.h"
11 class SkBitmap;
13 namespace gfx {
15 // This class wraps a JNI AndroidBitmap object to make it easier to use. It
16 // handles locking and unlocking of the underlying pixels, along with wrapping
17 // various JNI methods.
18 class UI_EXPORT JavaBitmap {
19 public:
20 explicit JavaBitmap(jobject bitmap);
21 ~JavaBitmap();
23 inline void* pixels() { return pixels_; }
24 inline const gfx::Size& size() const { return size_; }
25 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888
26 inline int format() const { return format_; }
27 inline uint32_t stride() const { return stride_; }
29 private:
30 jobject bitmap_;
31 void* pixels_;
32 gfx::Size size_;
33 int format_;
34 uint32_t stride_;
36 DISALLOW_COPY_AND_ASSIGN(JavaBitmap);
39 UI_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap(
40 const gfx::Size& size);
42 UI_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(
43 const SkBitmap* skbitmap);
45 SkBitmap CreateSkBitmapFromResource(const char* name);
47 } // namespace gfx
49 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_