OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ANDROID_WEBVIEW_BROWSER_COMPOSITOR_PROXY_H_ | |
6 #define ANDROID_WEBVIEW_BROWSER_COMPOSITOR_PROXY_H_ | |
7 | |
8 #include "android_webview/browser/browser_view_renderer.h" | |
9 #include "android_webview/browser/browser_view_renderer_proxy.h" | |
10 #include "android_webview/browser/gl_view_renderer_manager.h" | |
11 #include "android_webview/browser/hardware_renderer.h" | |
12 #include "android_webview/browser/hardware_renderer_proxy.h" | |
13 #include "android_webview/browser/parent_compositor_draw_constraints.h" | |
14 #include "base/cancelable_callback.h" | |
15 #include "base/memory/weak_ptr.h" | |
16 #include "base/message_loop/message_loop_proxy.h" | |
17 #include "base/synchronization/lock.h" | |
18 #include "cc/output/compositor_frame.h" | |
19 #include "cc/output/compositor_frame_ack.h" | |
20 #include "ui/gfx/geometry/rect.h" | |
21 #include "ui/gfx/geometry/vector2d.h" | |
22 | |
23 struct AwDrawGLInfo; | |
24 | |
25 namespace android_webview { | |
26 | |
27 namespace internal { | |
28 class RequestDrawGLTracker; | |
29 } | |
30 | |
31 class AwGLMethods; | |
32 class BrowserViewRenderer; | |
33 class InsideHardwareReleaseReset; | |
34 | |
35 // This class is used to pass data between UI thread and RenderThread. | |
36 class CompositorProxy : public BrowserViewRendererProxy, | |
37 public HardwareRendererProxy { | |
38 public: | |
39 CompositorProxy(scoped_refptr<base::MessageLoopProxy> ui_loop, | |
40 AwGLMethods* gl_methods); | |
41 ~CompositorProxy(); | |
boliu
2014/10/23 16:40:05
virtual
| |
42 | |
43 void ClientRequestDrawGL(); | |
44 void DidDrawGLProcess(); | |
45 | |
46 bool IsInsideHardwareRelease() const; | |
47 void SetBrowserViewRenderer(BrowserViewRenderer* browser_view_renderer); | |
48 | |
49 // BrowserViewRendererProxy overrides. | |
50 virtual void SetScrollOffset(gfx::Vector2d scroll_offset) override; | |
51 virtual void SetCompositorFrame(scoped_ptr<cc::CompositorFrame> frame, | |
52 bool force_commit) override; | |
53 virtual bool HasCompositorFrame() const override; | |
54 virtual const ParentCompositorDrawConstraints GetParentDrawConstraints() | |
55 const override; | |
56 virtual void SwapReturnedResources( | |
57 cc::ReturnedResourceArray* resources) override; | |
58 virtual void SetForceInvalidateOnNextDrawGL( | |
59 bool needs_force_invalidate_on_next_draw_gl) override; | |
60 virtual bool NeedsForceInvalidateOnNextDrawGL() const override; | |
61 | |
62 // HardwareRendererProxy overrides. | |
63 virtual gfx::Vector2d GetScrollOffset() override; | |
64 virtual scoped_ptr<cc::CompositorFrame> PassCompositorFrame() override; | |
65 virtual bool SetParentCompositorDrawConstraints( | |
66 const ParentCompositorDrawConstraints& parent_draw_constraints) override; | |
67 virtual void PostExternalDrawConstraintsToChildCompositor( | |
68 const ParentCompositorDrawConstraints& parent_draw_constraints) override; | |
69 virtual void InsertReturnedResources( | |
70 const cc::ReturnedResourceArray& resources) override; | |
71 virtual bool ForceCommit() const override; | |
72 virtual void DidSkipCommitFrame() override; | |
73 | |
74 private: | |
75 friend class InsideHardwareReleaseReset; | |
76 friend class internal::RequestDrawGLTracker; | |
77 | |
78 void ResetRequestDrawGLCallback(); | |
79 void ClientRequestDrawGLOnUIThread(); | |
80 void SetParentDrawConstraintsOnUIThread(); | |
81 void DidSkipCommitFrameOnUIThread(); | |
82 void SetInsideHardwareRelease(bool inside_hardware_release); | |
83 void ReturnUnusedResources(); | |
84 | |
85 scoped_refptr<base::MessageLoopProxy> ui_loop_; | |
86 AwGLMethods* gl_methods_on_ui_; | |
87 base::WeakPtr<CompositorProxy> ui_thread_weak_ptr_; | |
88 base::CancelableClosure request_draw_gl_cancelable_closure_; | |
89 | |
90 // Accessed by both UI and RT thread. | |
91 mutable base::Lock lock_; | |
92 gfx::Vector2d scroll_offset_; | |
93 scoped_ptr<cc::CompositorFrame> compositor_frame_; | |
94 bool force_commit_; | |
95 bool inside_hardware_release_; | |
96 bool needs_force_invalidate_on_next_draw_gl_; | |
97 ParentCompositorDrawConstraints parent_draw_constraints_; | |
98 cc::ReturnedResourceArray returned_resources_; | |
99 base::Closure request_draw_gl_closure_; | |
100 | |
101 base::WeakPtrFactory<CompositorProxy> weak_factory_on_ui_thread_; | |
102 | |
103 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.
| |
104 | |
105 DISALLOW_COPY_AND_ASSIGN(CompositorProxy); | |
106 }; | |
107 | |
108 class InsideHardwareReleaseReset { | |
109 public: | |
110 explicit InsideHardwareReleaseReset(CompositorProxy* compositor_proxy); | |
111 ~InsideHardwareReleaseReset(); | |
112 | |
113 private: | |
114 CompositorProxy* compositor_proxy_; | |
115 | |
116 DISALLOW_COPY_AND_ASSIGN(InsideHardwareReleaseReset); | |
117 }; | |
118 | |
119 } // namespace android_webview | |
120 | |
121 #endif // ANDROID_WEBVIEW_BROWSER_COMPOSITOR_PROXY_H_ | |
OLD | NEW |