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 CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/process.h" | 14 #include "base/process.h" |
| 15 #include "base/timer.h" |
15 #include "content/browser/renderer_host/ime_adapter_android.h" | 16 #include "content/browser/renderer_host/ime_adapter_android.h" |
16 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 17 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
17 #include "gpu/command_buffer/common/mailbox.h" | 18 #include "gpu/command_buffer/common/mailbox.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
21 #include "ui/gfx/vector2d_f.h" | 22 #include "ui/gfx/vector2d_f.h" |
22 | 23 |
23 struct ViewHostMsg_TextInputState_Params; | 24 struct ViewHostMsg_TextInputState_Params; |
24 | 25 |
25 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; | 26 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; |
26 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; | 27 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; |
27 | 28 |
28 namespace cc { | 29 namespace cc { |
29 class Layer; | 30 class Layer; |
30 class TextureLayer; | 31 class TextureLayer; |
31 } | 32 } |
32 | 33 |
33 namespace WebKit { | 34 namespace WebKit { |
34 class WebExternalTextureLayer; | 35 class WebExternalTextureLayer; |
35 class WebTouchEvent; | 36 class WebTouchEvent; |
36 class WebMouseEvent; | 37 class WebMouseEvent; |
37 } | 38 } |
38 | 39 |
39 namespace content { | 40 namespace content { |
40 class ContentViewCoreImpl; | 41 class ContentViewCoreImpl; |
| 42 class OverscrollGlow; |
41 class RenderWidgetHost; | 43 class RenderWidgetHost; |
42 class RenderWidgetHostImpl; | 44 class RenderWidgetHostImpl; |
43 class SurfaceTextureTransportClient; | 45 class SurfaceTextureTransportClient; |
44 struct NativeWebKeyboardEvent; | 46 struct NativeWebKeyboardEvent; |
45 | 47 |
46 // ----------------------------------------------------------------------------- | 48 // ----------------------------------------------------------------------------- |
47 // See comments in render_widget_host_view.h about this class and its members. | 49 // See comments in render_widget_host_view.h about this class and its members. |
48 // ----------------------------------------------------------------------------- | 50 // ----------------------------------------------------------------------------- |
49 class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase { | 51 class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase { |
50 public: | 52 public: |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 virtual void OnSwapCompositorFrame( | 147 virtual void OnSwapCompositorFrame( |
146 scoped_ptr<cc::CompositorFrame> frame) OVERRIDE; | 148 scoped_ptr<cc::CompositorFrame> frame) OVERRIDE; |
147 virtual void UpdateFrameInfo(const gfx::Vector2dF& scroll_offset, | 149 virtual void UpdateFrameInfo(const gfx::Vector2dF& scroll_offset, |
148 float page_scale_factor, | 150 float page_scale_factor, |
149 const gfx::Vector2dF& page_scale_factor_limits, | 151 const gfx::Vector2dF& page_scale_factor_limits, |
150 const gfx::SizeF& content_size, | 152 const gfx::SizeF& content_size, |
151 const gfx::SizeF& viewport_size, | 153 const gfx::SizeF& viewport_size, |
152 const gfx::Vector2dF& controls_offset, | 154 const gfx::Vector2dF& controls_offset, |
153 const gfx::Vector2dF& content_offset, | 155 const gfx::Vector2dF& content_offset, |
154 float overdraw_bottom_height) OVERRIDE; | 156 float overdraw_bottom_height) OVERRIDE; |
| 157 virtual void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll, |
| 158 const gfx::Vector2dF& current_fling_velocity) |
| 159 OVERRIDE; |
155 virtual void ShowDisambiguationPopup(const gfx::Rect& target_rect, | 160 virtual void ShowDisambiguationPopup(const gfx::Rect& target_rect, |
156 const SkBitmap& zoomed_bitmap) OVERRIDE; | 161 const SkBitmap& zoomed_bitmap) OVERRIDE; |
157 | 162 |
158 // Non-virtual methods | 163 // Non-virtual methods |
159 void SetContentViewCore(ContentViewCoreImpl* content_view_core); | 164 void SetContentViewCore(ContentViewCoreImpl* content_view_core); |
160 SkColor GetCachedBackgroundColor() const; | 165 SkColor GetCachedBackgroundColor() const; |
161 void SendKeyEvent(const NativeWebKeyboardEvent& event); | 166 void SendKeyEvent(const NativeWebKeyboardEvent& event); |
162 void SendTouchEvent(const WebKit::WebTouchEvent& event); | 167 void SendTouchEvent(const WebKit::WebTouchEvent& event); |
163 void SendMouseEvent(const WebKit::WebMouseEvent& event); | 168 void SendMouseEvent(const WebKit::WebMouseEvent& event); |
164 void SendMouseWheelEvent(const WebKit::WebMouseWheelEvent& event); | 169 void SendMouseWheelEvent(const WebKit::WebMouseWheelEvent& event); |
165 void SendGestureEvent(const WebKit::WebGestureEvent& event); | 170 void SendGestureEvent(const WebKit::WebGestureEvent& event); |
166 | 171 |
167 void OnProcessImeBatchStateAck(bool is_begin); | 172 void OnProcessImeBatchStateAck(bool is_begin); |
168 void OnDidChangeBodyBackgroundColor(SkColor color); | 173 void OnDidChangeBodyBackgroundColor(SkColor color); |
169 void OnStartContentIntent(const GURL& content_url); | 174 void OnStartContentIntent(const GURL& content_url); |
| 175 void OnSetOverscrollResources(); |
170 | 176 |
171 int GetNativeImeAdapter(); | 177 int GetNativeImeAdapter(); |
172 | 178 |
173 void WasResized(); | 179 void WasResized(); |
174 | 180 |
175 WebKit::WebGLId GetScaledContentTexture(float scale, gfx::Size* out_size); | 181 WebKit::WebGLId GetScaledContentTexture(float scale, gfx::Size* out_size); |
176 bool PopulateBitmapWithContents(jobject jbitmap); | 182 bool PopulateBitmapWithContents(jobject jbitmap); |
177 | 183 |
178 bool HasValidFrame() const; | 184 bool HasValidFrame() const; |
179 | 185 |
180 // Select all text between the given coordinates. | 186 // Select all text between the given coordinates. |
181 void SelectRange(const gfx::Point& start, const gfx::Point& end); | 187 void SelectRange(const gfx::Point& start, const gfx::Point& end); |
182 | 188 |
183 void MoveCaret(const gfx::Point& point); | 189 void MoveCaret(const gfx::Point& point); |
184 | 190 |
185 private: | 191 private: |
186 void BuffersSwapped(const gpu::Mailbox& mailbox, | 192 void BuffersSwapped(const gpu::Mailbox& mailbox, |
187 const gfx::Size texture_size, | 193 const gfx::Size texture_size, |
188 const gfx::SizeF content_size, | 194 const gfx::SizeF content_size, |
189 const base::Closure& ack_callback); | 195 const base::Closure& ack_callback); |
| 196 void AttachLayers(); |
| 197 void RemoveLayers(); |
| 198 |
| 199 void SetOverscrollEffect(scoped_ptr<OverscrollGlow> overscroll_effect); |
| 200 void AnimationCallback(); |
| 201 void AnimateIfNeeded(); |
| 202 |
| 203 enum { kDesiredAnimationIntervalInMs = 16 }; |
190 | 204 |
191 // The model object. | 205 // The model object. |
192 RenderWidgetHostImpl* host_; | 206 RenderWidgetHostImpl* host_; |
193 | 207 |
194 // Whether or not this widget is potentially attached to the view hierarchy. | 208 // Whether or not this widget is potentially attached to the view hierarchy. |
195 // This view may not actually be attached if this is true, but it should be | 209 // This view may not actually be attached if this is true, but it should be |
196 // treated as such, because as soon as a ContentViewCore is set the layer | 210 // treated as such, because as soon as a ContentViewCore is set the layer |
197 // will be attached automatically. | 211 // will be attached automatically. |
198 bool is_layer_attached_; | 212 bool are_layers_attached_; |
199 | 213 |
200 // ContentViewCoreImpl is our interface to the view system. | 214 // ContentViewCoreImpl is our interface to the view system. |
201 ContentViewCoreImpl* content_view_core_; | 215 ContentViewCoreImpl* content_view_core_; |
202 | 216 |
203 ImeAdapterAndroid ime_adapter_android_; | 217 ImeAdapterAndroid ime_adapter_android_; |
204 | 218 |
205 // Body background color of the underlying document. | 219 // Body background color of the underlying document. |
206 SkColor cached_background_color_; | 220 SkColor cached_background_color_; |
207 | 221 |
208 // The texture layer for this view when using browser-side compositing. | 222 // The texture layer for this view when using browser-side compositing. |
209 scoped_refptr<cc::TextureLayer> texture_layer_; | 223 scoped_refptr<cc::TextureLayer> texture_layer_; |
210 | 224 |
211 // The layer used for rendering the contents of this view. | 225 // Layer used for rendering the contents of this view. |
212 // It is either owned by texture_layer_ or surface_texture_transport_ | |
213 // depending on the mode. | |
214 scoped_refptr<cc::Layer> layer_; | 226 scoped_refptr<cc::Layer> layer_; |
215 | 227 |
216 // The most recent texture id that was pushed to the texture layer. | 228 // The most recent texture id that was pushed to the texture layer. |
217 unsigned int texture_id_in_layer_; | 229 unsigned int texture_id_in_layer_; |
218 | 230 |
219 // The most recent texture size that was pushed to the texture layer. | 231 // The most recent texture size that was pushed to the texture layer. |
220 gfx::Size texture_size_in_layer_; | 232 gfx::Size texture_size_in_layer_; |
221 | 233 |
222 // Used for image transport when needing to share resources across threads. | 234 // Used for image transport when needing to share resources across threads. |
223 scoped_ptr<SurfaceTextureTransportClient> surface_texture_transport_; | 235 scoped_ptr<SurfaceTextureTransportClient> surface_texture_transport_; |
224 | 236 |
225 // The mailbox of the previously received frame. | 237 // The mailbox of the previously received frame. |
226 gpu::Mailbox current_mailbox_; | 238 gpu::Mailbox current_mailbox_; |
227 | 239 |
228 // The mailbox of the frame we last returned. | 240 // The mailbox of the frame we last returned. |
229 gpu::Mailbox last_mailbox_; | 241 gpu::Mailbox last_mailbox_; |
230 | 242 |
| 243 // Used to render overscroll overlays |
| 244 bool overscroll_resources_updated_; |
| 245 scoped_ptr<OverscrollGlow> overscroll_effect_; |
| 246 base::OneShotTimer<RenderWidgetHostViewAndroid> animation_timer_; |
| 247 |
231 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); | 248 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); |
232 }; | 249 }; |
233 | 250 |
234 } // namespace content | 251 } // namespace content |
235 | 252 |
236 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 253 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
OLD | NEW |