Index: android_webview/browser/compositor_proxy.h |
diff --git a/android_webview/browser/compositor_proxy.h b/android_webview/browser/compositor_proxy.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1674da6e2a4cda01c571670975826f254dd94f4d |
--- /dev/null |
+++ b/android_webview/browser/compositor_proxy.h |
@@ -0,0 +1,121 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ANDROID_WEBVIEW_BROWSER_COMPOSITOR_PROXY_H_ |
+#define ANDROID_WEBVIEW_BROWSER_COMPOSITOR_PROXY_H_ |
+ |
+#include "android_webview/browser/browser_view_renderer.h" |
+#include "android_webview/browser/browser_view_renderer_proxy.h" |
+#include "android_webview/browser/gl_view_renderer_manager.h" |
+#include "android_webview/browser/hardware_renderer.h" |
+#include "android_webview/browser/hardware_renderer_proxy.h" |
+#include "android_webview/browser/parent_compositor_draw_constraints.h" |
+#include "base/cancelable_callback.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/message_loop/message_loop_proxy.h" |
+#include "base/synchronization/lock.h" |
+#include "cc/output/compositor_frame.h" |
+#include "cc/output/compositor_frame_ack.h" |
+#include "ui/gfx/geometry/rect.h" |
+#include "ui/gfx/geometry/vector2d.h" |
+ |
+struct AwDrawGLInfo; |
+ |
+namespace android_webview { |
+ |
+namespace internal { |
+class RequestDrawGLTracker; |
+} |
+ |
+class AwGLMethods; |
+class BrowserViewRenderer; |
+class InsideHardwareReleaseReset; |
+ |
+// This class is used to pass data between UI thread and RenderThread. |
+class CompositorProxy : public BrowserViewRendererProxy, |
+ public HardwareRendererProxy { |
+ public: |
+ CompositorProxy(scoped_refptr<base::MessageLoopProxy> ui_loop, |
+ AwGLMethods* gl_methods); |
+ ~CompositorProxy(); |
boliu
2014/10/23 16:40:05
virtual
|
+ |
+ void ClientRequestDrawGL(); |
+ void DidDrawGLProcess(); |
+ |
+ bool IsInsideHardwareRelease() const; |
+ void SetBrowserViewRenderer(BrowserViewRenderer* browser_view_renderer); |
+ |
+ // BrowserViewRendererProxy overrides. |
+ virtual void SetScrollOffset(gfx::Vector2d scroll_offset) override; |
+ virtual void SetCompositorFrame(scoped_ptr<cc::CompositorFrame> frame, |
+ bool force_commit) override; |
+ virtual bool HasCompositorFrame() const override; |
+ virtual const ParentCompositorDrawConstraints GetParentDrawConstraints() |
+ const override; |
+ virtual void SwapReturnedResources( |
+ cc::ReturnedResourceArray* resources) override; |
+ virtual void SetForceInvalidateOnNextDrawGL( |
+ bool needs_force_invalidate_on_next_draw_gl) override; |
+ virtual bool NeedsForceInvalidateOnNextDrawGL() const override; |
+ |
+ // HardwareRendererProxy overrides. |
+ virtual gfx::Vector2d GetScrollOffset() override; |
+ virtual scoped_ptr<cc::CompositorFrame> PassCompositorFrame() override; |
+ virtual bool SetParentCompositorDrawConstraints( |
+ const ParentCompositorDrawConstraints& parent_draw_constraints) override; |
+ virtual void PostExternalDrawConstraintsToChildCompositor( |
+ const ParentCompositorDrawConstraints& parent_draw_constraints) override; |
+ virtual void InsertReturnedResources( |
+ const cc::ReturnedResourceArray& resources) override; |
+ virtual bool ForceCommit() const override; |
+ virtual void DidSkipCommitFrame() override; |
+ |
+ private: |
+ friend class InsideHardwareReleaseReset; |
+ friend class internal::RequestDrawGLTracker; |
+ |
+ void ResetRequestDrawGLCallback(); |
+ void ClientRequestDrawGLOnUIThread(); |
+ void SetParentDrawConstraintsOnUIThread(); |
+ void DidSkipCommitFrameOnUIThread(); |
+ void SetInsideHardwareRelease(bool inside_hardware_release); |
+ void ReturnUnusedResources(); |
+ |
+ scoped_refptr<base::MessageLoopProxy> ui_loop_; |
+ AwGLMethods* gl_methods_on_ui_; |
+ base::WeakPtr<CompositorProxy> ui_thread_weak_ptr_; |
+ base::CancelableClosure request_draw_gl_cancelable_closure_; |
+ |
+ // Accessed by both UI and RT thread. |
+ mutable base::Lock lock_; |
+ gfx::Vector2d scroll_offset_; |
+ scoped_ptr<cc::CompositorFrame> compositor_frame_; |
+ bool force_commit_; |
+ bool inside_hardware_release_; |
+ bool needs_force_invalidate_on_next_draw_gl_; |
+ ParentCompositorDrawConstraints parent_draw_constraints_; |
+ cc::ReturnedResourceArray returned_resources_; |
+ base::Closure request_draw_gl_closure_; |
+ |
+ base::WeakPtrFactory<CompositorProxy> weak_factory_on_ui_thread_; |
+ |
+ BrowserViewRenderer* browser_view_renderer_; |
boliu
2014/10/23 16:40:05
this is in the "ui only" category, move it up ther
hush (inactive)
2014/10/24 21:31:33
Done.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(CompositorProxy); |
+}; |
+ |
+class InsideHardwareReleaseReset { |
+ public: |
+ explicit InsideHardwareReleaseReset(CompositorProxy* compositor_proxy); |
+ ~InsideHardwareReleaseReset(); |
+ |
+ private: |
+ CompositorProxy* compositor_proxy_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset); |
+}; |
+ |
+} // namespace android_webview |
+ |
+#endif // ANDROID_WEBVIEW_BROWSER_COMPOSITOR_PROXY_H_ |