| 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..d0555b7295d89d5d2cd1ee84d6d32b9c15432177 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,53 +36,72 @@ 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;
|
| + scoped_ptr<cc::CompositorFrame> PassUncommittedFrameOnUI();
|
|
|
| - // 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;
|
| + class InsideHardwareReleaseReset {
|
| + public:
|
| + explicit InsideHardwareReleaseReset(
|
| + SharedRendererState* shared_renderer_state);
|
| + ~InsideHardwareReleaseReset();
|
|
|
| + private:
|
| + SharedRendererState* shared_renderer_state_;
|
| + };
|
| +
|
| + // RT thread method.
|
| + void DidDrawGLProcess();
|
| +
|
| + // UI thread methods.
|
| void ResetRequestDrawGLCallback();
|
| - void ClientRequestDrawGLOnUIThread();
|
| - void UpdateParentDrawConstraintsOnUIThread();
|
| + void ClientRequestDrawGLOnUI();
|
| + void UpdateParentDrawConstraintsOnUI();
|
| void DidSkipCommitFrameOnUI();
|
| + 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_;
|
|
|
| + // Accessed by RT thread.
|
| + scoped_ptr<HardwareRenderer> hardware_renderer_;
|
| +
|
| + // This is accessed by both UI and RT now. TODO(hush): move to RT only.
|
| + GLViewRendererManager::Key renderer_manager_key_;
|
| +
|
| // Accessed by both UI and RT thread.
|
| mutable base::Lock lock_;
|
| gfx::Vector2d scroll_offset_;
|
| @@ -96,18 +118,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_
|
|
|