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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 class BrowserViewRenderer; | 29 class BrowserViewRenderer; |
30 class ChildFrame; | 30 class ChildFrame; |
31 class HardwareRenderer; | 31 class HardwareRenderer; |
32 class InsideHardwareReleaseReset; | 32 class InsideHardwareReleaseReset; |
33 | 33 |
34 // This class is used to pass data between UI thread and RenderThread. | 34 // This class is used to pass data between UI thread and RenderThread. |
35 class SharedRendererState { | 35 class SharedRendererState { |
36 public: | 36 public: |
| 37 struct ReturnedResources { |
| 38 ReturnedResources(); |
| 39 |
| 40 uint32_t output_surface_id; |
| 41 cc::ReturnedResourceArray resources; |
| 42 }; |
| 43 using ReturnedResourcesMap = std::map<uint32_t, ReturnedResources>; |
| 44 |
37 SharedRendererState( | 45 SharedRendererState( |
38 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop, | 46 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop, |
39 BrowserViewRenderer* browser_view_renderer); | 47 BrowserViewRenderer* browser_view_renderer); |
40 ~SharedRendererState(); | 48 ~SharedRendererState(); |
41 | 49 |
42 // This function can be called from any thread. | 50 // This function can be called from any thread. |
43 void ClientRequestDrawGL(bool for_idle); | 51 void ClientRequestDrawGL(bool for_idle); |
44 | 52 |
45 // UI thread methods. | 53 // UI thread methods. |
46 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset); | 54 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset); |
47 void SetCompositorFrameOnUI(scoped_ptr<ChildFrame> frame); | 55 void SetCompositorFrameOnUI(scoped_ptr<ChildFrame> frame); |
48 void InitializeHardwareDrawIfNeededOnUI(); | 56 void InitializeHardwareDrawIfNeededOnUI(); |
49 void ReleaseHardwareDrawIfNeededOnUI(); | 57 void ReleaseHardwareDrawIfNeededOnUI(); |
50 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; | 58 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; |
51 void SwapReturnedResourcesOnUI( | 59 void SwapReturnedResourcesOnUI(ReturnedResourcesMap* returned_resource_map); |
52 std::map<uint32_t, cc::ReturnedResourceArray>* returned_resource_map); | |
53 bool ReturnedResourcesEmptyOnUI() const; | 60 bool ReturnedResourcesEmptyOnUI() const; |
54 scoped_ptr<ChildFrame> PassUncommittedFrameOnUI(); | 61 scoped_ptr<ChildFrame> PassUncommittedFrameOnUI(); |
55 void DeleteHardwareRendererOnUI(); | 62 void DeleteHardwareRendererOnUI(); |
56 bool HasFrameOnUI() const; | 63 bool HasFrameOnUI() const; |
57 | 64 |
58 // RT thread methods. | 65 // RT thread methods. |
59 gfx::Vector2d GetScrollOffsetOnRT(); | 66 gfx::Vector2d GetScrollOffsetOnRT(); |
60 scoped_ptr<ChildFrame> PassCompositorFrameOnRT(); | 67 scoped_ptr<ChildFrame> PassCompositorFrameOnRT(); |
61 void DrawGL(AwDrawGLInfo* draw_info); | 68 void DrawGL(AwDrawGLInfo* draw_info); |
62 void PostExternalDrawConstraintsToChildCompositorOnRT( | 69 void PostExternalDrawConstraintsToChildCompositorOnRT( |
63 const ParentCompositorDrawConstraints& parent_draw_constraints); | 70 const ParentCompositorDrawConstraints& parent_draw_constraints); |
64 void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources, | 71 void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources, |
65 uint32_t compositor_id); | 72 uint32_t compositor_id, |
| 73 uint32_t output_surface_id); |
66 | 74 |
67 private: | 75 private: |
68 friend class internal::RequestDrawGLTracker; | 76 friend class internal::RequestDrawGLTracker; |
69 class InsideHardwareReleaseReset { | 77 class InsideHardwareReleaseReset { |
70 public: | 78 public: |
71 explicit InsideHardwareReleaseReset( | 79 explicit InsideHardwareReleaseReset( |
72 SharedRendererState* shared_renderer_state); | 80 SharedRendererState* shared_renderer_state); |
73 ~InsideHardwareReleaseReset(); | 81 ~InsideHardwareReleaseReset(); |
74 | 82 |
75 private: | 83 private: |
(...skipping 23 matching lines...) Expand all Loading... |
99 // This is accessed by both UI and RT now. TODO(hush): move to RT only. | 107 // This is accessed by both UI and RT now. TODO(hush): move to RT only. |
100 GLViewRendererManager::Key renderer_manager_key_; | 108 GLViewRendererManager::Key renderer_manager_key_; |
101 | 109 |
102 // Accessed by both UI and RT thread. | 110 // Accessed by both UI and RT thread. |
103 mutable base::Lock lock_; | 111 mutable base::Lock lock_; |
104 bool hardware_renderer_has_frame_; | 112 bool hardware_renderer_has_frame_; |
105 gfx::Vector2d scroll_offset_; | 113 gfx::Vector2d scroll_offset_; |
106 scoped_ptr<ChildFrame> child_frame_; | 114 scoped_ptr<ChildFrame> child_frame_; |
107 bool inside_hardware_release_; | 115 bool inside_hardware_release_; |
108 ParentCompositorDrawConstraints parent_draw_constraints_; | 116 ParentCompositorDrawConstraints parent_draw_constraints_; |
109 // A map from compositor's ID to the resources that belong to the compositor. | 117 ReturnedResourcesMap returned_resources_map_; |
110 std::map<uint32_t, cc::ReturnedResourceArray> returned_resources_map_; | |
111 base::Closure request_draw_gl_closure_; | 118 base::Closure request_draw_gl_closure_; |
112 | 119 |
113 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; | 120 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; |
114 | 121 |
115 DISALLOW_COPY_AND_ASSIGN(SharedRendererState); | 122 DISALLOW_COPY_AND_ASSIGN(SharedRendererState); |
116 }; | 123 }; |
117 | 124 |
118 } // namespace android_webview | 125 } // namespace android_webview |
119 | 126 |
120 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ | 127 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
OLD | NEW |