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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 #include <queue> | 13 #include <queue> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/i18n/rtl.h" | 17 #include "base/i18n/rtl.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/process/process.h" | 20 #include "base/process/process.h" |
21 #include "cc/input/selection.h" | 21 #include "cc/input/selection.h" |
22 #include "cc/layers/surface_layer.h" | |
23 #include "cc/output/begin_frame_args.h" | 22 #include "cc/output/begin_frame_args.h" |
24 #include "cc/surfaces/surface_factory_client.h" | |
25 #include "cc/surfaces/surface_id.h" | |
26 #include "content/browser/accessibility/browser_accessibility_manager.h" | 23 #include "content/browser/accessibility/browser_accessibility_manager.h" |
27 #include "content/browser/android/content_view_core_impl_observer.h" | 24 #include "content/browser/android/content_view_core_impl_observer.h" |
28 #include "content/browser/renderer_host/delegated_frame_evictor.h" | 25 #include "content/browser/renderer_host/delegated_frame_evictor.h" |
29 #include "content/browser/renderer_host/ime_adapter_android.h" | 26 #include "content/browser/renderer_host/ime_adapter_android.h" |
30 #include "content/browser/renderer_host/input/stylus_text_selector.h" | 27 #include "content/browser/renderer_host/input/stylus_text_selector.h" |
31 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 28 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
32 #include "content/common/content_export.h" | 29 #include "content/common/content_export.h" |
33 #include "content/public/browser/readback_types.h" | 30 #include "content/public/browser/readback_types.h" |
34 #include "gpu/command_buffer/common/mailbox.h" | 31 #include "gpu/command_buffer/common/mailbox.h" |
35 #include "third_party/skia/include/core/SkColor.h" | 32 #include "third_party/skia/include/core/SkColor.h" |
(...skipping 11 matching lines...) Expand all Loading... |
47 class SurfaceFactory; | 44 class SurfaceFactory; |
48 class SurfaceIdAllocator; | 45 class SurfaceIdAllocator; |
49 } | 46 } |
50 | 47 |
51 namespace blink { | 48 namespace blink { |
52 class WebExternalTextureLayer; | 49 class WebExternalTextureLayer; |
53 class WebTouchEvent; | 50 class WebTouchEvent; |
54 class WebMouseEvent; | 51 class WebMouseEvent; |
55 } | 52 } |
56 | 53 |
| 54 namespace ui { |
| 55 class DelegatedFrameHostAndroid; |
| 56 } |
| 57 |
57 namespace content { | 58 namespace content { |
58 class ContentViewCoreImpl; | 59 class ContentViewCoreImpl; |
59 class ContentViewCoreObserver; | 60 class ContentViewCoreObserver; |
60 class OverscrollControllerAndroid; | 61 class OverscrollControllerAndroid; |
61 class RenderWidgetHost; | 62 class RenderWidgetHost; |
62 class RenderWidgetHostImpl; | 63 class RenderWidgetHostImpl; |
63 class SynchronousCompositorHost; | 64 class SynchronousCompositorHost; |
64 struct DidOverscrollParams; | 65 struct DidOverscrollParams; |
65 struct NativeWebKeyboardEvent; | 66 struct NativeWebKeyboardEvent; |
66 struct TextInputState; | 67 struct TextInputState; |
67 | 68 |
68 // ----------------------------------------------------------------------------- | 69 // ----------------------------------------------------------------------------- |
69 // See comments in render_widget_host_view.h about this class and its members. | 70 // See comments in render_widget_host_view.h about this class and its members. |
70 // ----------------------------------------------------------------------------- | 71 // ----------------------------------------------------------------------------- |
71 class CONTENT_EXPORT RenderWidgetHostViewAndroid | 72 class CONTENT_EXPORT RenderWidgetHostViewAndroid |
72 : public RenderWidgetHostViewBase, | 73 : public RenderWidgetHostViewBase, |
73 public cc::SurfaceFactoryClient, | |
74 public ui::GestureProviderClient, | 74 public ui::GestureProviderClient, |
75 public ui::WindowAndroidObserver, | 75 public ui::WindowAndroidObserver, |
76 public DelegatedFrameEvictorClient, | 76 public DelegatedFrameEvictorClient, |
77 public StylusTextSelectorClient, | 77 public StylusTextSelectorClient, |
78 public ui::TouchSelectionControllerClient, | 78 public ui::TouchSelectionControllerClient, |
79 public content::ContentViewCoreImplObserver { | 79 public content::ContentViewCoreImplObserver { |
80 public: | 80 public: |
81 RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget, | 81 RenderWidgetHostViewAndroid(RenderWidgetHostImpl* widget, |
82 ContentViewCoreImpl* content_view_core); | 82 ContentViewCoreImpl* content_view_core); |
83 ~RenderWidgetHostViewAndroid() override; | 83 ~RenderWidgetHostViewAndroid() override; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 void DidStopFlinging() override; | 155 void DidStopFlinging() override; |
156 uint32_t GetSurfaceClientId() override; | 156 uint32_t GetSurfaceClientId() override; |
157 void ShowDisambiguationPopup(const gfx::Rect& rect_pixels, | 157 void ShowDisambiguationPopup(const gfx::Rect& rect_pixels, |
158 const SkBitmap& zoomed_bitmap) override; | 158 const SkBitmap& zoomed_bitmap) override; |
159 std::unique_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() | 159 std::unique_ptr<SyntheticGestureTarget> CreateSyntheticGestureTarget() |
160 override; | 160 override; |
161 void LockCompositingSurface() override; | 161 void LockCompositingSurface() override; |
162 void UnlockCompositingSurface() override; | 162 void UnlockCompositingSurface() override; |
163 void OnDidNavigateMainFrameToNewPage() override; | 163 void OnDidNavigateMainFrameToNewPage() override; |
164 | 164 |
165 // cc::SurfaceFactoryClient implementation. | |
166 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | |
167 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | |
168 | |
169 // ui::GestureProviderClient implementation. | 165 // ui::GestureProviderClient implementation. |
170 void OnGestureEvent(const ui::GestureEventData& gesture) override; | 166 void OnGestureEvent(const ui::GestureEventData& gesture) override; |
171 | 167 |
172 // ui::WindowAndroidObserver implementation. | 168 // ui::WindowAndroidObserver implementation. |
173 void OnCompositingDidCommit() override; | 169 void OnCompositingDidCommit() override; |
174 void OnRootWindowVisibilityChanged(bool visible) override; | 170 void OnRootWindowVisibilityChanged(bool visible) override; |
175 void OnAttachCompositor() override; | 171 void OnAttachCompositor() override; |
176 void OnDetachCompositor() override; | 172 void OnDetachCompositor() override; |
177 void OnVSync(base::TimeTicks frame_time, | 173 void OnVSync(base::TimeTicks frame_time, |
178 base::TimeDelta vsync_period) override; | 174 base::TimeDelta vsync_period) override; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 void ShowInternal(); | 258 void ShowInternal(); |
263 void HideInternal(); | 259 void HideInternal(); |
264 void AttachLayers(); | 260 void AttachLayers(); |
265 void RemoveLayers(); | 261 void RemoveLayers(); |
266 | 262 |
267 void UpdateBackgroundColor(SkColor color); | 263 void UpdateBackgroundColor(SkColor color); |
268 | 264 |
269 // Called after async screenshot task completes. Scales and crops the result | 265 // Called after async screenshot task completes. Scales and crops the result |
270 // of the copy. | 266 // of the copy. |
271 static void PrepareTextureCopyOutputResult( | 267 static void PrepareTextureCopyOutputResult( |
272 base::WeakPtr<RenderWidgetHostViewAndroid> rwhva, | |
273 scoped_refptr<cc::Layer> readback_layer, | |
274 const gfx::Size& dst_size_in_pixel, | 268 const gfx::Size& dst_size_in_pixel, |
275 SkColorType color_type, | 269 SkColorType color_type, |
276 const base::TimeTicks& start_time, | 270 const base::TimeTicks& start_time, |
277 const ReadbackRequestCallback& callback, | 271 const ReadbackRequestCallback& callback, |
278 std::unique_ptr<cc::CopyOutputResult> result); | 272 std::unique_ptr<cc::CopyOutputResult> result); |
279 | 273 |
280 // DevTools ScreenCast support for Android WebView. | 274 // DevTools ScreenCast support for Android WebView. |
281 void SynchronousCopyContents(const gfx::Rect& src_subrect_in_pixel, | 275 void SynchronousCopyContents(const gfx::Rect& src_subrect_in_pixel, |
282 const gfx::Size& dst_size_in_pixel, | 276 const gfx::Size& dst_size_in_pixel, |
283 const ReadbackRequestCallback& callback, | 277 const ReadbackRequestCallback& callback, |
284 const SkColorType color_type); | 278 const SkColorType color_type); |
285 | 279 |
286 // If we have locks on a frame during a ContentViewCore swap or a context | 280 // If we have locks on a frame during a ContentViewCore swap or a context |
287 // lost, the frame is no longer valid and we can safely release all the locks. | 281 // lost, the frame is no longer valid and we can safely release all the locks. |
288 // Use this method to release all the locks. | 282 // Use this method to release all the locks. |
289 void ReleaseLocksOnSurface(); | 283 void ReleaseLocksOnSurface(); |
290 | 284 |
291 // Drop any incoming frames from the renderer when there are locks on the | 285 // Drop any incoming frames from the renderer when there are locks on the |
292 // current frame. | 286 // current frame. |
293 void RetainFrame(uint32_t output_surface_id, cc::CompositorFrame frame); | 287 void RetainFrame(uint32_t output_surface_id, cc::CompositorFrame frame); |
294 | 288 |
295 void InternalSwapCompositorFrame(uint32_t output_surface_id, | 289 void InternalSwapCompositorFrame(uint32_t output_surface_id, |
296 cc::CompositorFrame frame); | 290 cc::CompositorFrame frame); |
297 void OnLostResources(); | 291 void OnLostResources(); |
298 | 292 |
| 293 void ReturnResources(const cc::ReturnedResourceArray& resources); |
| 294 |
299 enum VSyncRequestType { | 295 enum VSyncRequestType { |
300 FLUSH_INPUT = 1 << 0, | 296 FLUSH_INPUT = 1 << 0, |
301 BEGIN_FRAME = 1 << 1, | 297 BEGIN_FRAME = 1 << 1, |
302 PERSISTENT_BEGIN_FRAME = 1 << 2 | 298 PERSISTENT_BEGIN_FRAME = 1 << 2 |
303 }; | 299 }; |
304 void RequestVSyncUpdate(uint32_t requests); | 300 void RequestVSyncUpdate(uint32_t requests); |
305 void StartObservingRootWindow(); | 301 void StartObservingRootWindow(); |
306 void StopObservingRootWindow(); | 302 void StopObservingRootWindow(); |
307 void SendBeginFrame(base::TimeTicks frame_time, base::TimeDelta vsync_period); | 303 void SendBeginFrame(base::TimeTicks frame_time, base::TimeDelta vsync_period); |
308 bool Animate(base::TimeTicks frame_time); | 304 bool Animate(base::TimeTicks frame_time); |
(...skipping 18 matching lines...) Expand all Loading... |
327 // ContentViewCoreImpl is our interface to the view system. | 323 // ContentViewCoreImpl is our interface to the view system. |
328 ContentViewCoreImpl* content_view_core_; | 324 ContentViewCoreImpl* content_view_core_; |
329 | 325 |
330 ImeAdapterAndroid ime_adapter_android_; | 326 ImeAdapterAndroid ime_adapter_android_; |
331 | 327 |
332 // Body background color of the underlying document. | 328 // Body background color of the underlying document. |
333 SkColor cached_background_color_; | 329 SkColor cached_background_color_; |
334 | 330 |
335 mutable ui::ViewAndroid view_; | 331 mutable ui::ViewAndroid view_; |
336 | 332 |
337 std::unique_ptr<cc::SurfaceIdAllocator> id_allocator_; | 333 // Manages the Compositor Frames received from the renderer. |
338 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | 334 std::unique_ptr<ui::DelegatedFrameHostAndroid> delegated_frame_host_; |
339 cc::SurfaceId surface_id_; | 335 |
| 336 cc::ReturnedResourceArray surface_returned_resources_; |
| 337 |
| 338 // The most recent surface size that was pushed to the surface layer. |
340 gfx::Size current_surface_size_; | 339 gfx::Size current_surface_size_; |
341 cc::ReturnedResourceArray surface_returned_resources_; | |
342 gfx::Vector2dF location_bar_content_translation_; | |
343 cc::Selection<gfx::SelectionBound> current_viewport_selection_; | |
344 | |
345 // The most recent texture size that was pushed to the texture layer. | |
346 gfx::Size texture_size_in_layer_; | |
347 | 340 |
348 // The output surface id of the last received frame. | 341 // The output surface id of the last received frame. |
349 uint32_t last_output_surface_id_; | 342 uint32_t last_output_surface_id_; |
350 | 343 |
351 | 344 |
352 std::queue<base::Closure> ack_callbacks_; | 345 std::queue<base::Closure> ack_callbacks_; |
353 | 346 |
354 // Used to control and render overscroll-related effects. | 347 // Used to control and render overscroll-related effects. |
355 std::unique_ptr<OverscrollControllerAndroid> overscroll_controller_; | 348 std::unique_ptr<OverscrollControllerAndroid> overscroll_controller_; |
356 | 349 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 gfx::Vector2dF last_scroll_offset_; | 382 gfx::Vector2dF last_scroll_offset_; |
390 | 383 |
391 base::WeakPtrFactory<RenderWidgetHostViewAndroid> weak_ptr_factory_; | 384 base::WeakPtrFactory<RenderWidgetHostViewAndroid> weak_ptr_factory_; |
392 | 385 |
393 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); | 386 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAndroid); |
394 }; | 387 }; |
395 | 388 |
396 } // namespace content | 389 } // namespace content |
397 | 390 |
398 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ | 391 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_ANDROID_H_ |
OLD | NEW |