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

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

Issue 11886074: Use correct favicon scale factor on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed and added JavaBitmap JNI registration to .h Created 7 years, 11 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 | Annotate | Revision Log
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>
9
8 #include "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
9 #include "ui/gfx/size.h" 11 #include "ui/gfx/size.h"
10 12
11 class SkBitmap; 13 class SkBitmap;
12 14
13 namespace gfx { 15 namespace gfx {
14 16
15 // This class wraps a JNI AndroidBitmap object to make it easier to use. It 17 // 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 18 // handles locking and unlocking of the underlying pixels, along with wrapping
17 // various JNI methods. 19 // various JNI methods.
18 class UI_EXPORT JavaBitmap { 20 class UI_EXPORT JavaBitmap {
19 public: 21 public:
20 explicit JavaBitmap(jobject bitmap); 22 explicit JavaBitmap(jobject bitmap);
21 ~JavaBitmap(); 23 ~JavaBitmap();
22 24
23 inline void* pixels() { return pixels_; } 25 inline void* pixels() { return pixels_; }
24 inline const gfx::Size& size() const { return size_; } 26 inline const gfx::Size& size() const { return size_; }
25 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888 27 // Formats are in android/bitmap.h; e.g. ANDROID_BITMAP_FORMAT_RGBA_8888
26 inline int format() const { return format_; } 28 inline int format() const { return format_; }
27 inline uint32_t stride() const { return stride_; } 29 inline uint32_t stride() const { return stride_; }
28 30
31 // Registers methods with JNI and returns true if succeeded.
32 static bool RegisterJavaBitmap(JNIEnv* env);
33
29 private: 34 private:
30 jobject bitmap_; 35 jobject bitmap_;
31 void* pixels_; 36 void* pixels_;
32 gfx::Size size_; 37 gfx::Size size_;
33 int format_; 38 int format_;
34 uint32_t stride_; 39 uint32_t stride_;
35 40
36 DISALLOW_COPY_AND_ASSIGN(JavaBitmap); 41 DISALLOW_COPY_AND_ASSIGN(JavaBitmap);
37 }; 42 };
38 43
39 UI_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap( 44 UI_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap(
40 const gfx::Size& size); 45 const gfx::Size& size);
41 46
42 UI_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( 47 UI_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(
43 const SkBitmap* skbitmap); 48 const SkBitmap* skbitmap);
44 49
45 SkBitmap CreateSkBitmapFromResource(const char* name); 50 SkBitmap CreateSkBitmapFromResource(const char* name);
46 51
47 } // namespace gfx 52 } // namespace gfx
48 53
49 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_ 54 #endif // UI_GFX_ANDROID_JAVA_BITMAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698