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

Side by Side Diff: android_webview/native/aw_contents.h

Issue 12041009: [Android WebView] Migrate the rendering code to a separate set of classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated and rebased. Created 7 years, 10 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 ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 6 #define ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 10
11 #include "android_webview/browser/browser_view_renderer.h"
11 #include "android_webview/browser/find_helper.h" 12 #include "android_webview/browser/find_helper.h"
12 #include "android_webview/browser/icon_helper.h" 13 #include "android_webview/browser/icon_helper.h"
13 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" 14 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h"
14 #include "android_webview/public/browser/draw_gl.h"
15 #include "base/android/scoped_java_ref.h" 15 #include "base/android/scoped_java_ref.h"
16 #include "base/android/jni_helper.h" 16 #include "base/android/jni_helper.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "content/public/browser/android/compositor.h"
19 #include "content/public/browser/javascript_dialog_manager.h" 18 #include "content/public/browser/javascript_dialog_manager.h"
20 #include "skia/ext/refptr.h"
21 #include "third_party/skia/include/core/SkPicture.h"
22 19
23 typedef void* EGLContext;
24 class SkBitmap; 20 class SkBitmap;
25 class TabContents; 21 class TabContents;
26 22
27 namespace cc {
28 class Layer;
29 }
30
31 namespace content { 23 namespace content {
32 class Compositor;
33 class WebContents; 24 class WebContents;
34 } 25 }
35 26
36 namespace android_webview { 27 namespace android_webview {
37 28
38 class AwContentsContainer; 29 class AwContentsContainer;
39 class AwWebContentsDelegate; 30 class AwWebContentsDelegate;
40 31
41 // Native side of java-class of same name. 32 // Native side of java-class of same name.
42 // Provides the ownership of and access to browser components required for 33 // Provides the ownership of and access to browser components required for
43 // WebView functionality; analogous to chrome's TabContents, but with a 34 // WebView functionality; analogous to chrome's TabContents, but with a
44 // level of indirection provided by the AwContentsContainer abstraction. 35 // level of indirection provided by the AwContentsContainer abstraction.
45 class AwContents : public FindHelper::Listener, 36 class AwContents : public FindHelper::Listener,
46 public IconHelper::Listener, 37 public IconHelper::Listener,
47 public content::Compositor::Client, 38 public BrowserViewRenderer::Client {
48 public AwRenderViewHostExt::Client {
49 public: 39 public:
50 enum OnNewPictureMode { 40 enum OnNewPictureMode {
51 kOnNewPictureDisabled = 0, 41 kOnNewPictureDisabled = 0,
52 kOnNewPictureEnabled, 42 kOnNewPictureEnabled,
53 kOnNewPictureInvalidationOnly, 43 kOnNewPictureInvalidationOnly,
54 }; 44 };
55 45
56 // Returns the AwContents instance associated with |web_contents|, or NULL. 46 // Returns the AwContents instance associated with |web_contents|, or NULL.
57 static AwContents* FromWebContents(content::WebContents* web_contents); 47 static AwContents* FromWebContents(content::WebContents* web_contents);
58 48
59 AwContents(JNIEnv* env, 49 AwContents(JNIEnv* env,
60 jobject obj, 50 jobject obj,
61 jobject web_contents_delegate); 51 jobject web_contents_delegate);
62 virtual ~AwContents(); 52 virtual ~AwContents();
63 53
64 void DrawGL(AwDrawGLInfo* draw_info);
65 bool DrawSW(JNIEnv* env,
66 jobject obj,
67 jobject canvas,
68 jint clip_x,
69 jint clip_y,
70 jint clip_w,
71 jint clip_h);
72
73 void RunJavaScriptDialog( 54 void RunJavaScriptDialog(
74 content::JavaScriptMessageType message_type, 55 content::JavaScriptMessageType message_type,
75 const GURL& origin_url, 56 const GURL& origin_url,
76 const string16& message_text, 57 const string16& message_text,
77 const string16& default_prompt_text, 58 const string16& default_prompt_text,
78 const base::android::ScopedJavaLocalRef<jobject>& js_result); 59 const base::android::ScopedJavaLocalRef<jobject>& js_result);
79 60
80 void RunBeforeUnloadDialog( 61 void RunBeforeUnloadDialog(
81 const GURL& origin_url, 62 const GURL& origin_url,
82 const string16& message_text, 63 const string16& message_text,
(...skipping 26 matching lines...) Expand all
109 void UpdateLastHitTestData(JNIEnv* env, jobject obj); 90 void UpdateLastHitTestData(JNIEnv* env, jobject obj);
110 void OnSizeChanged(JNIEnv* env, jobject obj, int w, int h, int ow, int oh); 91 void OnSizeChanged(JNIEnv* env, jobject obj, int w, int h, int ow, int oh);
111 void SetWindowViewVisibility(JNIEnv* env, jobject obj, 92 void SetWindowViewVisibility(JNIEnv* env, jobject obj,
112 bool window_visible, 93 bool window_visible,
113 bool view_visible); 94 bool view_visible);
114 void OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h); 95 void OnAttachedToWindow(JNIEnv* env, jobject obj, int w, int h);
115 void OnDetachedFromWindow(JNIEnv* env, jobject obj); 96 void OnDetachedFromWindow(JNIEnv* env, jobject obj);
116 base::android::ScopedJavaLocalRef<jbyteArray> GetOpaqueState( 97 base::android::ScopedJavaLocalRef<jbyteArray> GetOpaqueState(
117 JNIEnv* env, jobject obj); 98 JNIEnv* env, jobject obj);
118 jboolean RestoreFromOpaqueState(JNIEnv* env, jobject obj, jbyteArray state); 99 jboolean RestoreFromOpaqueState(JNIEnv* env, jobject obj, jbyteArray state);
100 void FocusFirstNode(JNIEnv* env, jobject obj);
101 bool DrawSW(JNIEnv* env,
102 jobject obj,
103 jobject canvas,
104 jint clip_x,
105 jint clip_y,
106 jint clip_w,
107 jint clip_h);
119 void SetScrollForHWFrame(JNIEnv* env, jobject obj, 108 void SetScrollForHWFrame(JNIEnv* env, jobject obj,
120 int scroll_x, int scroll_y); 109 int scroll_x, int scroll_y);
121 void FocusFirstNode(JNIEnv* env, jobject obj); 110 jint GetAwDrawGLViewContext(JNIEnv* env, jobject obj);
122 base::android::ScopedJavaLocalRef<jobject> CapturePicture(JNIEnv* env, 111 base::android::ScopedJavaLocalRef<jobject> CapturePicture(JNIEnv* env,
123 jobject obj); 112 jobject obj);
124 void EnableOnNewPicture(JNIEnv* env, 113 void EnableOnNewPicture(JNIEnv* env,
125 jobject obj, 114 jobject obj,
126 jboolean enabled, 115 jboolean enabled,
127 jboolean invalidation_only); 116 jboolean invalidation_only);
128 117
129 // Geolocation API support 118 // Geolocation API support
130 void OnGeolocationShowPrompt(int render_process_id, 119 void OnGeolocationShowPrompt(int render_process_id,
131 int render_view_id, 120 int render_view_id,
132 int bridge_id, 121 int bridge_id,
133 const GURL& requesting_frame); 122 const GURL& requesting_frame);
134 void OnGeolocationHidePrompt(); 123 void OnGeolocationHidePrompt();
135 124
136 // Find-in-page API and related methods. 125 // Find-in-page API and related methods.
137 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string); 126 jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string);
138 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string); 127 void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string);
139 void FindNext(JNIEnv* env, jobject obj, jboolean forward); 128 void FindNext(JNIEnv* env, jobject obj, jboolean forward);
140 void ClearMatches(JNIEnv* env, jobject obj); 129 void ClearMatches(JNIEnv* env, jobject obj);
141 void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files);
142
143 FindHelper* GetFindHelper(); 130 FindHelper* GetFindHelper();
144 131
145 // FindHelper::Listener implementation. 132 // FindHelper::Listener implementation.
146 virtual void OnFindResultReceived(int active_ordinal, 133 virtual void OnFindResultReceived(int active_ordinal,
147 int match_count, 134 int match_count,
148 bool finished) OVERRIDE; 135 bool finished) OVERRIDE;
149 // IconHelper::Listener implementation. 136 // IconHelper::Listener implementation.
150 virtual void OnReceivedIcon(const SkBitmap& bitmap) OVERRIDE; 137 virtual void OnReceivedIcon(const SkBitmap& bitmap) OVERRIDE;
151 virtual void OnReceivedTouchIconUrl(const std::string& url, 138 virtual void OnReceivedTouchIconUrl(const std::string& url,
152 const bool precomposed) OVERRIDE; 139 const bool precomposed) OVERRIDE;
153 140
154 // content::Compositor::Client implementation. 141 // BrowserViewRenderer::Client implementation.
155 virtual void ScheduleComposite() OVERRIDE; 142 virtual void Invalidate() OVERRIDE;
156 virtual void OnSwapBuffersCompleted() OVERRIDE; 143 virtual void OnNewPicture(
144 const base::android::JavaRef<jobject>& picture) OVERRIDE;
157 145
146 void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files);
158 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending); 147 void SetPendingWebContentsForPopup(scoped_ptr<content::WebContents> pending);
159 jint ReleasePopupWebContents(JNIEnv* env, jobject obj); 148 jint ReleasePopupWebContents(JNIEnv* env, jobject obj);
160 149
161 // AwRenderViewHostExt::Client implementation.
162 virtual void OnPictureUpdated(int process_id, int render_view_id) OVERRIDE;
163
164 // Returns the latest locally available picture if any.
165 // If none is available will synchronously request the latest one
166 // and block until the result is received.
167 skia::RefPtr<SkPicture> GetLastCapturedPicture();
168
169 private: 150 private:
170 void Invalidate();
171 void SetWebContents(content::WebContents* web_contents); 151 void SetWebContents(content::WebContents* web_contents);
172 void SetCompositorVisibility(bool visible);
173 void ResetCompositor();
174 void AttachLayerTree();
175 bool RenderSW(SkCanvas* canvas);
176 bool RenderPicture(SkCanvas* canvas);
177 152
178 JavaObjectWeakGlobalRef java_ref_; 153 JavaObjectWeakGlobalRef java_ref_;
179 scoped_ptr<content::WebContents> web_contents_; 154 scoped_ptr<content::WebContents> web_contents_;
180 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_; 155 scoped_ptr<AwWebContentsDelegate> web_contents_delegate_;
181 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_; 156 scoped_ptr<AwRenderViewHostExt> render_view_host_ext_;
182 scoped_ptr<FindHelper> find_helper_; 157 scoped_ptr<FindHelper> find_helper_;
183 scoped_ptr<IconHelper> icon_helper_; 158 scoped_ptr<IconHelper> icon_helper_;
184 scoped_ptr<content::WebContents> pending_contents_; 159 scoped_ptr<content::WebContents> pending_contents_;
185 160 scoped_ptr<BrowserViewRenderer> browser_view_renderer_;
186 // Compositor-specific state.
187 scoped_ptr<content::Compositor> compositor_;
188 scoped_refptr<cc::Layer> scissor_clip_layer_;
189 scoped_refptr<cc::Layer> transform_layer_;
190 scoped_refptr<cc::Layer> view_clip_layer_;
191 gfx::Point hw_rendering_scroll_;
192 gfx::Size view_size_;
193 bool view_visible_;
194 bool compositor_visible_;
195 bool is_composite_pending_;
196 float dpi_scale_;
197 OnNewPictureMode on_new_picture_mode_;
198
199 // Used only for detecting Android View System context changes.
200 // Not to be used between draw calls.
201 EGLContext last_frame_context_;
202 161
203 DISALLOW_COPY_AND_ASSIGN(AwContents); 162 DISALLOW_COPY_AND_ASSIGN(AwContents);
204 }; 163 };
205 164
206 bool RegisterAwContents(JNIEnv* env); 165 bool RegisterAwContents(JNIEnv* env);
207 166
208 } // namespace android_webview 167 } // namespace android_webview
209 168
210 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_ 169 #endif // ANDROID_WEBVIEW_NATIVE_AW_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698