Chromium Code Reviews| Index: android_webview/browser/shared_renderer_state.h |
| diff --git a/android_webview/browser/shared_renderer_state.h b/android_webview/browser/shared_renderer_state.h |
| index 270d3182f7fcf95c5a50f96001919cd388316a65..bd83555a501f79bc21d923e07c47470bfc1e39ea 100644 |
| --- a/android_webview/browser/shared_renderer_state.h |
| +++ b/android_webview/browser/shared_renderer_state.h |
| @@ -5,6 +5,7 @@ |
| #ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
| #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |
| +#include "android_webview/browser/gl_view_renderer_manager.h" |
| #include "android_webview/browser/parent_compositor_draw_constraints.h" |
| #include "base/cancelable_callback.h" |
| #include "base/memory/weak_ptr.h" |
| @@ -15,6 +16,8 @@ |
| #include "ui/gfx/geometry/rect.h" |
| #include "ui/gfx/geometry/vector2d.h" |
| +struct AwDrawGLInfo; |
| + |
| namespace android_webview { |
| namespace internal { |
| @@ -22,10 +25,10 @@ class RequestDrawGLTracker; |
| } |
| class BrowserViewRenderer; |
| +class HardwareRenderer; |
| class InsideHardwareReleaseReset; |
| // This class is used to pass data between UI thread and RenderThread. |
| -// TODO(hush): this class should own HardwareRenderer. |
| class SharedRendererState { |
| public: |
| SharedRendererState( |
| @@ -33,52 +36,60 @@ class SharedRendererState { |
| BrowserViewRenderer* browser_view_renderer); |
| ~SharedRendererState(); |
| + // This function can be called from any thread. |
| void ClientRequestDrawGL(); |
| - void DidDrawGLProcess(); |
| + // UI thread methods. |
| void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset); |
| - gfx::Vector2d GetScrollOffsetOnRT(); |
| - |
| bool HasCompositorFrameOnUI() const; |
| void SetCompositorFrameOnUI(scoped_ptr<cc::CompositorFrame> frame, |
| bool force_commit); |
| - // Right now this method is called on both UI and RT. |
| - // TODO(hush): Make it only called from RT. |
| - scoped_ptr<cc::CompositorFrame> PassCompositorFrame(); |
| - bool ForceCommitOnRT() const; |
| + void InitializeHardwareDrawIfNeededOnUI(); |
| + void ReleaseHardwareDrawIfNeededOnUI(); |
| + ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; |
| + void SetForceInvalidateOnNextDrawGLOnUI( |
| + bool needs_force_invalidate_on_next_draw_gl); |
| + bool NeedsForceInvalidateOnNextDrawGLOnUI() const; |
| + void SwapReturnedResourcesOnUI(cc::ReturnedResourceArray* resources); |
| + bool ReturnedResourcesEmptyOnUI() const; |
| - // TODO(hush): this will be private after DrawGL moves to this class. |
| - bool IsInsideHardwareRelease() const; |
| + // RT thread methods. |
| + gfx::Vector2d GetScrollOffsetOnRT(); |
| + scoped_ptr<cc::CompositorFrame> PassCompositorFrameOnRT(); |
| + bool ForceCommitOnRT() const; |
| + void DrawGL(AwDrawGLInfo* draw_info); |
| // Returns true if the draw constraints are updated. |
| bool UpdateDrawConstraintsOnRT( |
| const ParentCompositorDrawConstraints& parent_draw_constraints); |
| void PostExternalDrawConstraintsToChildCompositorOnRT( |
| const ParentCompositorDrawConstraints& parent_draw_constraints); |
| - ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const; |
| - |
| void DidSkipCommitFrameOnRT(); |
| - void SetForceInvalidateOnNextDrawGLOnUI( |
| - bool needs_force_invalidate_on_next_draw_gl); |
| - bool NeedsForceInvalidateOnNextDrawGLOnUI() const; |
| - |
| void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources); |
| - void SwapReturnedResourcesOnUI(cc::ReturnedResourceArray* resources); |
| - bool ReturnedResourcesEmpty() const; |
| private: |
| - friend class InsideHardwareReleaseReset; |
| friend class internal::RequestDrawGLTracker; |
| + // RT thread method. |
| + void DidDrawGLProcess(); |
| + |
| + // UI thread methods. |
| void ResetRequestDrawGLCallback(); |
| - void ClientRequestDrawGLOnUIThread(); |
| - void UpdateParentDrawConstraintsOnUIThread(); |
| + void ClientRequestDrawGLOnUI(); |
| + void UpdateParentDrawConstraintsOnUI(); |
| void DidSkipCommitFrameOnUI(); |
| + void ReturnUnusedResourceOnUI(); |
| + bool IsInsideHardwareRelease() const; |
| void SetInsideHardwareRelease(bool inside); |
| + // Accessed by UI thread. |
| scoped_refptr<base::SingleThreadTaskRunner> ui_loop_; |
| BrowserViewRenderer* browser_view_renderer_; |
| base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_; |
| base::CancelableClosure request_draw_gl_cancelable_closure_; |
| + GLViewRendererManager::Key renderer_manager_key_; |
|
boliu
2014/10/28 19:49:43
This is both UI and RT
Although...I think this ca
hush (inactive)
2014/10/29 19:57:04
I see. Make the pushback and removal of the key ha
|
| + |
| + // Accessed by RT thread. |
| + scoped_ptr<HardwareRenderer> hardware_renderer_; |
| // Accessed by both UI and RT thread. |
| mutable base::Lock lock_; |
| @@ -96,18 +107,6 @@ class SharedRendererState { |
| DISALLOW_COPY_AND_ASSIGN(SharedRendererState); |
| }; |
| -class InsideHardwareReleaseReset { |
| - public: |
| - explicit InsideHardwareReleaseReset( |
| - SharedRendererState* shared_renderer_state); |
| - ~InsideHardwareReleaseReset(); |
| - |
| - private: |
| - SharedRendererState* shared_renderer_state_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset); |
| -}; |
| - |
| } // namespace android_webview |
| #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_ |