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

Side by Side Diff: content/public/browser/android/bitmap_holder.h

Issue 10532155: Upstream some more content/ DEPS-related cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 CONTENT_BROWSER_ANDROID_JNI_HELPER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_ANDROID_BITMAP_HOLDER_H_
6 #define CONTENT_BROWSER_ANDROID_JNI_HELPER_H_ 6 #define CONTENT_PUBLIC_BROWSER_ANDROID_BITMAP_HOLDER_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
15 15
16 class SkBitmap; 16 class SkBitmap;
17 namespace gfx { 17 namespace gfx {
18 class Size; 18 class Size;
19 } 19 }
20 20
21 namespace content {
22
23 // TODO: Remove this and use ScopedJavaLocalRef instead.
Yaron 2012/06/15 17:40:35 add your name
no sievers 2012/06/15 20:34:41 Done.
21 // Auto creator/destructor for a JNI frame for local references. This allows 24 // Auto creator/destructor for a JNI frame for local references. This allows
22 // safely having more than 16 local references, and avoids calls to 25 // safely having more than 16 local references, and avoids calls to
23 // DeleteLocalRef. 26 // DeleteLocalRef.
24 // This should be created on the stack. 27 // This should be created on the stack.
25 class AutoLocalFrame { 28 class AutoLocalFrame {
26 public: 29 public:
27 AutoLocalFrame(int capacity); 30 AutoLocalFrame(int capacity);
28 ~AutoLocalFrame(); 31 ~AutoLocalFrame();
29 32
30 private: 33 private:
(...skipping 15 matching lines...) Expand all
46 int format() const; 49 int format() const;
47 uint32_t stride() const; 50 uint32_t stride() const;
48 51
49 private: 52 private:
50 jobject bitmap_; 53 jobject bitmap_;
51 void* pixels_; 54 void* pixels_;
52 55
53 DISALLOW_COPY_AND_ASSIGN(AutoLockJavaBitmap); 56 DISALLOW_COPY_AND_ASSIGN(AutoLockJavaBitmap);
54 }; 57 };
55 58
56 // Tell Java to write its current stack trace into Android logs. Note that the
57 // trace will stop at the entry point into C++ code.
58 void PrintJavaStackTrace();
59
60 // Fills in the given vector<string> from a java String[].
61 void ConvertJavaArrayOfStringsToVectorOfStrings(
62 JNIEnv* env,
63 jobjectArray jstrings,
64 std::vector<std::string>* vec);
65
66 // Helper method to create an Android Java Bitmap object. You can use the 59 // Helper method to create an Android Java Bitmap object. You can use the
67 // AutoLockJavaBitmap class to manipulate its pixels, and pass it back up 60 // AutoLockJavaBitmap class to manipulate its pixels, and pass it back up
68 // to Java code for drawing. Returns a JNI local reference to the bitmap. 61 // to Java code for drawing. Returns a JNI local reference to the bitmap.
69 // If 'keep' is true, then a reference will be kept in a static Java data 62 // If 'keep' is true, then a reference will be kept in a static Java data
70 // structure to prevent GC. In that case, you must call DeleteJavaBitmap() to 63 // structure to prevent GC. In that case, you must call DeleteJavaBitmap() to
71 // garbage collect it. 64 // garbage collect it.
72 base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap( 65 base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap(
73 const gfx::Size& size, bool keep); 66 const gfx::Size& size, bool keep);
74 void DeleteJavaBitmap(jobject bitmap); 67 void DeleteJavaBitmap(jobject bitmap);
75 68
76 // Paint one java bitmap into another. Scale if needed. 69 // Paint one java bitmap into another. Scale if needed.
77 void PaintJavaBitmapToJavaBitmap(jobject sourceBitmap, 70 void PaintJavaBitmapToJavaBitmap(jobject sourceBitmap,
78 const gfx::Rect& sourceRect, 71 const gfx::Rect& sourceRect,
79 jobject destBitmap, 72 jobject destBitmap,
80 const gfx::Rect& destRect); 73 const gfx::Rect& destRect);
81 74
82 // Copy the Chromium Skia bitmap into a new Java bitmap. Useful for small UI 75 // Copy the Chromium Skia bitmap into a new Java bitmap. Useful for small UI
83 // bitmaps originating from WebKit that we want to manipulate in Java (such as 76 // bitmaps originating from WebKit that we want to manipulate in Java (such as
84 // favicons). Due to the extra copy, should be avoided for large or frequently 77 // favicons). Due to the extra copy, should be avoided for large or frequently
85 // used bitmaps. Returns a local reference to the new bitmap. 78 // used bitmaps. Returns a local reference to the new bitmap.
86 base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap( 79 base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(
87 const SkBitmap* skbitmap); 80 const SkBitmap* skbitmap);
88 81
89 // Registers our JNI methods. 82 } // namespace content
90 bool RegisterJniHelper(JNIEnv* env);
91 83
92 #endif // CONTENT_BROWSER_ANDROID_JNI_HELPER_H_ 84 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_BITMAP_HOLDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698