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