| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BROWSER_SHARED_RENDERER_STATE_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
| 6 #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "android_webview/browser/gl_view_renderer_manager.h" | 10 #include "android_webview/browser/gl_view_renderer_manager.h" |
| 11 #include "android_webview/browser/parent_compositor_draw_constraints.h" | 11 #include "android_webview/browser/parent_compositor_draw_constraints.h" |
| 12 #include "base/cancelable_callback.h" | 12 #include "base/cancelable_callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "cc/output/compositor_frame_ack.h" | 17 #include "cc/output/compositor_frame_ack.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/geometry/vector2d.h" | 19 #include "ui/gfx/geometry/vector2d.h" |
| 20 | 20 |
| 21 struct AwDrawGLInfo; | 21 struct AwDrawGLInfo; |
| 22 | |
| 23 namespace android_webview { | 22 namespace android_webview { |
| 24 | 23 |
| 25 namespace internal { | 24 namespace internal { |
| 26 class RequestDrawGLTracker; | 25 class RequestDrawGLTracker; |
| 27 } | 26 } |
| 28 | 27 |
| 29 class BrowserViewRenderer; | 28 class BrowserViewRenderer; |
| 30 class ChildFrame; | 29 class ChildFrame; |
| 31 class HardwareRenderer; | 30 class HardwareRenderer; |
| 32 class InsideHardwareReleaseReset; | 31 class InsideHardwareReleaseReset; |
| 33 | 32 |
| 34 // This class is used to pass data between UI thread and RenderThread. | 33 // This class is used to pass data between UI thread and RenderThread. |
| 35 class SharedRendererState { | 34 class SharedRendererState { |
| 36 public: | 35 public: |
| 37 struct ReturnedResources { | 36 struct ReturnedResources { |
| 38 ReturnedResources(); | 37 ReturnedResources(); |
| 39 ~ReturnedResources(); | 38 ~ReturnedResources(); |
| 40 | 39 |
| 41 uint32_t output_surface_id; | 40 uint32_t output_surface_id; |
| 42 cc::ReturnedResourceArray resources; | 41 cc::ReturnedResourceArray resources; |
| 43 }; | 42 }; |
| 44 using ReturnedResourcesMap = std::map<uint32_t, ReturnedResources>; | 43 using ReturnedResourcesMap = std::map<uint32_t, ReturnedResources>; |
| 45 | 44 |
| 46 SharedRendererState( | 45 SharedRendererState( |
| 47 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop, | 46 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop); |
| 48 BrowserViewRenderer* browser_view_renderer); | |
| 49 ~SharedRendererState(); | 47 ~SharedRendererState(); |
| 50 | 48 |
| 51 // This function can be called from any thread. | 49 // This function can be called from any thread. |
| 52 void ClientRequestDrawGL(bool for_idle); | 50 void ClientRequestDrawGL(bool for_idle); |
| 53 | 51 |
| 54 // UI thread methods. | 52 // UI thread methods. |
| 53 void SetBrowserViewRendererOnUI(BrowserViewRenderer* browser_view_renderer); |
| 55 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset); | 54 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset); |
| 56 void SetCompositorFrameOnUI(scoped_ptr<ChildFrame> frame); | 55 void SetCompositorFrameOnUI(scoped_ptr<ChildFrame> frame); |
| 57 void InitializeHardwareDrawIfNeededOnUI(); | 56 void InitializeHardwareDrawIfNeededOnUI(); |
| 58 void ReleaseHardwareDrawIfNeededOnUI(); | |
| 59 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; | 57 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; |
| 60 void SwapReturnedResourcesOnUI(ReturnedResourcesMap* returned_resource_map); | 58 void SwapReturnedResourcesOnUI(ReturnedResourcesMap* returned_resource_map); |
| 61 bool ReturnedResourcesEmptyOnUI() const; | 59 bool ReturnedResourcesEmptyOnUI() const; |
| 62 scoped_ptr<ChildFrame> PassUncommittedFrameOnUI(); | 60 scoped_ptr<ChildFrame> PassUncommittedFrameOnUI(); |
| 63 void DeleteHardwareRendererOnUI(); | |
| 64 bool HasFrameOnUI() const; | 61 bool HasFrameOnUI() const; |
| 62 void TrimMemoryOnUI(int level); |
| 63 void ReleaseCompositorResourcesIfNeededOnUI(); |
| 65 | 64 |
| 66 // RT thread methods. | 65 // RT thread methods. |
| 67 gfx::Vector2d GetScrollOffsetOnRT(); | 66 gfx::Vector2d GetScrollOffsetOnRT(); |
| 68 scoped_ptr<ChildFrame> PassCompositorFrameOnRT(); | 67 scoped_ptr<ChildFrame> PassCompositorFrameOnRT(); |
| 69 void DrawGL(AwDrawGLInfo* draw_info); | 68 void DrawGL(AwDrawGLInfo* draw_info); |
| 70 void PostExternalDrawConstraintsToChildCompositorOnRT( | 69 void PostExternalDrawConstraintsToChildCompositorOnRT( |
| 71 const ParentCompositorDrawConstraints& parent_draw_constraints); | 70 const ParentCompositorDrawConstraints& parent_draw_constraints); |
| 72 void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources, | 71 void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources, |
| 73 uint32_t compositor_id, | 72 uint32_t compositor_id, |
| 74 uint32_t output_surface_id); | 73 uint32_t output_surface_id); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 87 | 86 |
| 88 // RT thread method. | 87 // RT thread method. |
| 89 void DidDrawGLProcess(); | 88 void DidDrawGLProcess(); |
| 90 | 89 |
| 91 // UI thread methods. | 90 // UI thread methods. |
| 92 void ResetRequestDrawGLCallback(); | 91 void ResetRequestDrawGLCallback(); |
| 93 void ClientRequestDrawGLOnUI(); | 92 void ClientRequestDrawGLOnUI(); |
| 94 void UpdateParentDrawConstraintsOnUI(); | 93 void UpdateParentDrawConstraintsOnUI(); |
| 95 bool IsInsideHardwareRelease() const; | 94 bool IsInsideHardwareRelease() const; |
| 96 void SetInsideHardwareRelease(bool inside); | 95 void SetInsideHardwareRelease(bool inside); |
| 97 void ReleaseCompositorResourcesIfNeededOnUI(bool release_hardware_draw); | |
| 98 | 96 |
| 99 // Accessed by UI thread. | 97 // Accessed by UI thread. |
| 100 scoped_refptr<base::SingleThreadTaskRunner> ui_loop_; | 98 scoped_refptr<base::SingleThreadTaskRunner> ui_loop_; |
| 101 BrowserViewRenderer* browser_view_renderer_; | 99 BrowserViewRenderer* browser_view_renderer_; |
| 102 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; | 100 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; |
| 103 base::CancelableClosure request_draw_gl_cancelable_closure_; | 101 base::CancelableClosure request_draw_gl_cancelable_closure_; |
| 104 | 102 |
| 105 // Accessed by RT thread. | 103 // Accessed by RT thread. |
| 106 scoped_ptr<HardwareRenderer> hardware_renderer_; | 104 scoped_ptr<HardwareRenderer> hardware_renderer_; |
| 107 | 105 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 119 base::Closure request_draw_gl_closure_; | 117 base::Closure request_draw_gl_closure_; |
| 120 | 118 |
| 121 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; | 119 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; |
| 122 | 120 |
| 123 DISALLOW_COPY_AND_ASSIGN(SharedRendererState); | 121 DISALLOW_COPY_AND_ASSIGN(SharedRendererState); |
| 124 }; | 122 }; |
| 125 | 123 |
| 126 } // namespace android_webview | 124 } // namespace android_webview |
| 127 | 125 |
| 128 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ | 126 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
| OLD | NEW |