OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 CC_TREES_SINGLE_THREAD_PROXY_H_ | 5 #ifndef CC_TREES_SINGLE_THREAD_PROXY_H_ |
6 #define CC_TREES_SINGLE_THREAD_PROXY_H_ | 6 #define CC_TREES_SINGLE_THREAD_PROXY_H_ |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "cc/animation/animation_events.h" | 12 #include "cc/animation/animation_events.h" |
13 #include "cc/output/begin_frame_args.h" | 13 #include "cc/output/begin_frame_args.h" |
14 #include "cc/scheduler/scheduler.h" | 14 #include "cc/scheduler/scheduler.h" |
15 #include "cc/trees/blocking_task_runner.h" | 15 #include "cc/trees/blocking_task_runner.h" |
16 #include "cc/trees/layer_tree_host_impl.h" | 16 #include "cc/trees/layer_tree_host_impl.h" |
17 #include "cc/trees/proxy.h" | 17 #include "cc/trees/proxy.h" |
18 #include "cc/trees/proxy_timing_history.h" | 18 #include "cc/trees/proxy_timing_history.h" |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 | 21 |
| 22 class BeginFrameSource; |
22 class ContextProvider; | 23 class ContextProvider; |
23 class LayerTreeHost; | 24 class LayerTreeHost; |
24 class LayerTreeHostSingleThreadClient; | 25 class LayerTreeHostSingleThreadClient; |
25 | 26 |
26 class CC_EXPORT SingleThreadProxy : public Proxy, | 27 class CC_EXPORT SingleThreadProxy : public Proxy, |
27 NON_EXPORTED_BASE(LayerTreeHostImplClient), | 28 NON_EXPORTED_BASE(LayerTreeHostImplClient), |
28 SchedulerClient { | 29 SchedulerClient { |
29 public: | 30 public: |
30 static scoped_ptr<Proxy> Create( | 31 static scoped_ptr<Proxy> Create( |
31 LayerTreeHost* layer_tree_host, | 32 LayerTreeHost* layer_tree_host, |
32 LayerTreeHostSingleThreadClient* client, | 33 LayerTreeHostSingleThreadClient* client, |
33 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 34 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 35 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
34 ~SingleThreadProxy() override; | 36 ~SingleThreadProxy() override; |
35 | 37 |
36 // Proxy implementation | 38 // Proxy implementation |
37 void FinishAllRendering() override; | 39 void FinishAllRendering() override; |
38 bool IsStarted() const override; | 40 bool IsStarted() const override; |
39 void SetOutputSurface(scoped_ptr<OutputSurface>) override; | 41 void SetOutputSurface(scoped_ptr<OutputSurface>) override; |
40 void SetLayerTreeHostClientReady() override; | 42 void SetLayerTreeHostClientReady() override; |
41 void SetVisible(bool visible) override; | 43 void SetVisible(bool visible) override; |
42 const RendererCapabilities& GetRendererCapabilities() const override; | 44 const RendererCapabilities& GetRendererCapabilities() const override; |
43 void SetNeedsAnimate() override; | 45 void SetNeedsAnimate() override; |
44 void SetNeedsUpdateLayers() override; | 46 void SetNeedsUpdateLayers() override; |
45 void SetNeedsCommit() override; | 47 void SetNeedsCommit() override; |
46 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | 48 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
47 void SetNextCommitWaitsForActivation() override; | 49 void SetNextCommitWaitsForActivation() override; |
48 void NotifyInputThrottledUntilCommit() override {} | 50 void NotifyInputThrottledUntilCommit() override {} |
49 void SetDeferCommits(bool defer_commits) override; | 51 void SetDeferCommits(bool defer_commits) override; |
50 bool CommitRequested() const override; | 52 bool CommitRequested() const override; |
51 bool BeginMainFrameRequested() const override; | 53 bool BeginMainFrameRequested() const override; |
52 void MainThreadHasStoppedFlinging() override {} | 54 void MainThreadHasStoppedFlinging() override {} |
53 void Start() override; | 55 void Start() override; |
54 void Stop() override; | 56 void Stop() override; |
55 size_t MaxPartialTextureUpdates() const override; | 57 size_t MaxPartialTextureUpdates() const override; |
56 void ForceSerializeOnSwapBuffers() override; | 58 void ForceSerializeOnSwapBuffers() override; |
57 bool SupportsImplScrolling() const override; | 59 bool SupportsImplScrolling() const override; |
58 void AsValueInto(base::debug::TracedValue* state) const override; | 60 void AsValueInto(base::debug::TracedValue* state) const override; |
59 bool MainFrameWillHappenForTesting() override; | 61 bool MainFrameWillHappenForTesting() override; |
60 | 62 |
61 // SchedulerClient implementation | 63 // SchedulerClient implementation |
62 BeginFrameSource* ExternalBeginFrameSource() override; | |
63 void WillBeginImplFrame(const BeginFrameArgs& args) override; | 64 void WillBeginImplFrame(const BeginFrameArgs& args) override; |
64 void ScheduledActionSendBeginMainFrame() override; | 65 void ScheduledActionSendBeginMainFrame() override; |
65 DrawResult ScheduledActionDrawAndSwapIfPossible() override; | 66 DrawResult ScheduledActionDrawAndSwapIfPossible() override; |
66 DrawResult ScheduledActionDrawAndSwapForced() override; | 67 DrawResult ScheduledActionDrawAndSwapForced() override; |
67 void ScheduledActionCommit() override; | 68 void ScheduledActionCommit() override; |
68 void ScheduledActionAnimate() override; | 69 void ScheduledActionAnimate() override; |
69 void ScheduledActionUpdateVisibleTiles() override; | 70 void ScheduledActionUpdateVisibleTiles() override; |
70 void ScheduledActionActivateSyncTree() override; | 71 void ScheduledActionActivateSyncTree() override; |
71 void ScheduledActionBeginOutputSurfaceCreation() override; | 72 void ScheduledActionBeginOutputSurfaceCreation() override; |
72 void ScheduledActionManageTiles() override; | 73 void ScheduledActionManageTiles() override; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 108 |
108 void RequestNewOutputSurface(); | 109 void RequestNewOutputSurface(); |
109 | 110 |
110 // Called by the legacy path where RenderWidget does the scheduling. | 111 // Called by the legacy path where RenderWidget does the scheduling. |
111 void CompositeImmediately(base::TimeTicks frame_begin_time); | 112 void CompositeImmediately(base::TimeTicks frame_begin_time); |
112 | 113 |
113 private: | 114 private: |
114 SingleThreadProxy( | 115 SingleThreadProxy( |
115 LayerTreeHost* layer_tree_host, | 116 LayerTreeHost* layer_tree_host, |
116 LayerTreeHostSingleThreadClient* client, | 117 LayerTreeHostSingleThreadClient* client, |
117 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 118 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 119 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
118 | 120 |
119 void BeginMainFrame(); | 121 void BeginMainFrame(); |
120 void BeginMainFrameAbortedOnImplThread(); | 122 void BeginMainFrameAbortedOnImplThread(); |
121 void DoAnimate(); | 123 void DoAnimate(); |
122 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); | 124 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); |
123 void DoCommit(); | 125 void DoCommit(); |
124 DrawResult DoComposite(base::TimeTicks frame_begin_time, | 126 DrawResult DoComposite(base::TimeTicks frame_begin_time, |
125 LayerTreeHostImpl::FrameData* frame); | 127 LayerTreeHostImpl::FrameData* frame); |
126 void DoSwap(); | 128 void DoSwap(); |
127 void DidCommitAndDrawFrame(); | 129 void DidCommitAndDrawFrame(); |
(...skipping 25 matching lines...) Expand all Loading... |
153 bool commit_requested_; | 155 bool commit_requested_; |
154 bool inside_synchronous_composite_; | 156 bool inside_synchronous_composite_; |
155 | 157 |
156 // True if a request to the LayerTreeHostClient to create an output surface | 158 // True if a request to the LayerTreeHostClient to create an output surface |
157 // is still outstanding. | 159 // is still outstanding. |
158 bool output_surface_creation_requested_; | 160 bool output_surface_creation_requested_; |
159 | 161 |
160 // This is the callback for the scheduled RequestNewOutputSurface. | 162 // This is the callback for the scheduled RequestNewOutputSurface. |
161 base::CancelableClosure output_surface_creation_callback_; | 163 base::CancelableClosure output_surface_creation_callback_; |
162 | 164 |
| 165 scoped_ptr<BeginFrameSource> external_begin_frame_source_; |
| 166 |
163 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; | 167 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; |
164 | 168 |
165 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); | 169 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); |
166 }; | 170 }; |
167 | 171 |
168 // For use in the single-threaded case. In debug builds, it pretends that the | 172 // For use in the single-threaded case. In debug builds, it pretends that the |
169 // code is running on the impl thread to satisfy assertion checks. | 173 // code is running on the impl thread to satisfy assertion checks. |
170 class DebugScopedSetImplThread { | 174 class DebugScopedSetImplThread { |
171 public: | 175 public: |
172 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { | 176 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 private: | 226 private: |
223 DebugScopedSetImplThread impl_thread_; | 227 DebugScopedSetImplThread impl_thread_; |
224 DebugScopedSetMainThreadBlocked main_thread_blocked_; | 228 DebugScopedSetMainThreadBlocked main_thread_blocked_; |
225 | 229 |
226 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); | 230 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); |
227 }; | 231 }; |
228 | 232 |
229 } // namespace cc | 233 } // namespace cc |
230 | 234 |
231 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ | 235 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ |
OLD | NEW |