| 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/android/jni_weak_ref.h" |
| 13 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/cancelable_callback.h" | 14 #include "base/cancelable_callback.h" |
| 13 #include "base/macros.h" | 15 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 15 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 16 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 17 #include "cc/output/compositor_frame_ack.h" | 19 #include "cc/output/compositor_frame_ack.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/geometry/vector2d.h" | 21 #include "ui/gfx/geometry/vector2d.h" |
| 20 | 22 |
| 21 struct AwDrawGLInfo; | 23 struct AwDrawGLInfo; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 struct ReturnedResources { | 38 struct ReturnedResources { |
| 37 ReturnedResources(); | 39 ReturnedResources(); |
| 38 ~ReturnedResources(); | 40 ~ReturnedResources(); |
| 39 | 41 |
| 40 uint32_t output_surface_id; | 42 uint32_t output_surface_id; |
| 41 cc::ReturnedResourceArray resources; | 43 cc::ReturnedResourceArray resources; |
| 42 }; | 44 }; |
| 43 using ReturnedResourcesMap = std::map<uint32_t, ReturnedResources>; | 45 using ReturnedResourcesMap = std::map<uint32_t, ReturnedResources>; |
| 44 | 46 |
| 45 SharedRendererState( | 47 SharedRendererState( |
| 46 SharedRendererStateClient* client, | |
| 47 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop); | 48 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop); |
| 48 ~SharedRendererState(); | 49 ~SharedRendererState(); |
| 49 | 50 |
| 51 void SetClient(SharedRendererStateClient* client); |
| 52 |
| 50 // This function can be called from any thread. | 53 // This function can be called from any thread. |
| 51 void ClientRequestDrawGL(bool for_idle); | 54 void ClientRequestDrawGL(bool for_idle); |
| 52 | 55 |
| 53 // UI thread methods. | 56 // UI thread methods. |
| 54 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset); | 57 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset); |
| 55 void SetFrameOnUI(scoped_ptr<ChildFrame> frame); | 58 void SetFrameOnUI(scoped_ptr<ChildFrame> frame); |
| 56 void InitializeHardwareDrawIfNeededOnUI(); | 59 void InitializeHardwareDrawIfNeededOnUI(); |
| 57 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; | 60 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; |
| 58 void SwapReturnedResourcesOnUI(ReturnedResourcesMap* returned_resource_map); | 61 void SwapReturnedResourcesOnUI(ReturnedResourcesMap* returned_resource_map); |
| 59 bool ReturnedResourcesEmptyOnUI() const; | 62 bool ReturnedResourcesEmptyOnUI() const; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 88 | 91 |
| 89 // UI thread methods. | 92 // UI thread methods. |
| 90 void ResetRequestDrawGLCallback(); | 93 void ResetRequestDrawGLCallback(); |
| 91 void ClientRequestDrawGLOnUI(); | 94 void ClientRequestDrawGLOnUI(); |
| 92 void UpdateParentDrawConstraintsOnUI(); | 95 void UpdateParentDrawConstraintsOnUI(); |
| 93 bool IsInsideHardwareRelease() const; | 96 bool IsInsideHardwareRelease() const; |
| 94 void SetInsideHardwareRelease(bool inside); | 97 void SetInsideHardwareRelease(bool inside); |
| 95 | 98 |
| 96 // Accessed by UI thread. | 99 // Accessed by UI thread. |
| 97 scoped_refptr<base::SingleThreadTaskRunner> ui_loop_; | 100 scoped_refptr<base::SingleThreadTaskRunner> ui_loop_; |
| 98 SharedRendererStateClient* const client_; | 101 SharedRendererStateClient* client_; |
| 99 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; | 102 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; |
| 100 base::CancelableClosure request_draw_gl_cancelable_closure_; | 103 base::CancelableClosure request_draw_gl_cancelable_closure_; |
| 101 | 104 |
| 102 // Accessed by RT thread. | 105 // Accessed by RT thread. |
| 103 scoped_ptr<HardwareRenderer> hardware_renderer_; | 106 scoped_ptr<HardwareRenderer> hardware_renderer_; |
| 104 | 107 |
| 105 // 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. |
| 106 GLViewRendererManager::Key renderer_manager_key_; | 109 GLViewRendererManager::Key renderer_manager_key_; |
| 107 | 110 |
| 108 // Accessed by both UI and RT thread. | 111 // Accessed by both UI and RT thread. |
| 109 mutable base::Lock lock_; | 112 mutable base::Lock lock_; |
| 110 bool hardware_renderer_has_frame_; | 113 bool hardware_renderer_has_frame_; |
| 111 gfx::Vector2d scroll_offset_; | 114 gfx::Vector2d scroll_offset_; |
| 112 scoped_ptr<ChildFrame> child_frame_; | 115 scoped_ptr<ChildFrame> child_frame_; |
| 113 bool inside_hardware_release_; | 116 bool inside_hardware_release_; |
| 114 ParentCompositorDrawConstraints parent_draw_constraints_; | 117 ParentCompositorDrawConstraints parent_draw_constraints_; |
| 115 ReturnedResourcesMap returned_resources_map_; | 118 ReturnedResourcesMap returned_resources_map_; |
| 116 base::Closure request_draw_gl_closure_; | 119 base::Closure request_draw_gl_closure_; |
| 117 | 120 |
| 118 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; | 121 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_; |
| 119 | 122 |
| 120 DISALLOW_COPY_AND_ASSIGN(SharedRendererState); | 123 DISALLOW_COPY_AND_ASSIGN(SharedRendererState); |
| 121 }; | 124 }; |
| 122 | 125 |
| 126 bool RegisterSharedRendererState(JNIEnv* env); |
| 127 |
| 123 } // namespace android_webview | 128 } // namespace android_webview |
| 124 | 129 |
| 125 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ | 130 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
| OLD | NEW |