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 BeginFrameSource; |
23 class ContextProvider; | 23 class ContextProvider; |
24 class LayerTreeHost; | 24 class LayerTreeHost; |
25 class LayerTreeHostSingleThreadClient; | 25 class LayerTreeHostSingleThreadClient; |
| 26 class ProxyBeginFrameSource; |
26 | 27 |
27 class CC_EXPORT SingleThreadProxy : public Proxy, | 28 class CC_EXPORT SingleThreadProxy : public Proxy, |
28 NON_EXPORTED_BASE(LayerTreeHostImplClient), | 29 NON_EXPORTED_BASE(LayerTreeHostImplClient), |
29 SchedulerClient { | 30 SchedulerClient { |
30 public: | 31 public: |
31 static scoped_ptr<Proxy> Create( | 32 static scoped_ptr<Proxy> Create( |
32 LayerTreeHost* layer_tree_host, | 33 LayerTreeHost* layer_tree_host, |
33 LayerTreeHostSingleThreadClient* client, | 34 LayerTreeHostSingleThreadClient* client, |
34 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 35 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
35 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 36 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 37 ProxyBeginFrameSource* proxy_begin_frame_source); |
36 ~SingleThreadProxy() override; | 38 ~SingleThreadProxy() override; |
37 | 39 |
38 // Proxy implementation | 40 // Proxy implementation |
39 void FinishAllRendering() override; | 41 void FinishAllRendering() override; |
40 bool IsStarted() const override; | 42 bool IsStarted() const override; |
41 void SetOutputSurface(scoped_ptr<OutputSurface>) override; | 43 void SetOutputSurface(scoped_ptr<OutputSurface>) override; |
42 void SetLayerTreeHostClientReady() override; | 44 void SetLayerTreeHostClientReady() override; |
43 void SetVisible(bool visible) override; | 45 void SetVisible(bool visible) override; |
44 void SetThrottleFrameProduction(bool throttle) override; | 46 void SetThrottleFrameProduction(bool throttle) override; |
45 const RendererCapabilities& GetRendererCapabilities() const override; | 47 const RendererCapabilities& GetRendererCapabilities() const override; |
46 void SetNeedsAnimate() override; | 48 void SetNeedsAnimate() override; |
47 void SetNeedsUpdateLayers() override; | 49 void SetNeedsUpdateLayers() override; |
48 void SetNeedsCommit() override; | 50 void SetNeedsCommit() override; |
49 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | 51 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
50 void SetNextCommitWaitsForActivation() override; | 52 void SetNextCommitWaitsForActivation() override; |
51 void NotifyInputThrottledUntilCommit() override {} | 53 void NotifyInputThrottledUntilCommit() override {} |
52 void SetDeferCommits(bool defer_commits) override; | 54 void SetDeferCommits(bool defer_commits) override; |
53 bool CommitRequested() const override; | 55 bool CommitRequested() const override; |
54 bool BeginMainFrameRequested() const override; | 56 bool BeginMainFrameRequested() const override; |
55 void MainThreadHasStoppedFlinging() override {} | 57 void MainThreadHasStoppedFlinging() override {} |
56 void Start() override; | 58 void Start() override; |
57 void Stop() override; | 59 void Stop() override; |
58 size_t MaxPartialTextureUpdates() const override; | 60 size_t MaxPartialTextureUpdates() const override; |
59 void ForceSerializeOnSwapBuffers() override; | 61 void ForceSerializeOnSwapBuffers() override; |
60 bool SupportsImplScrolling() const override; | 62 bool SupportsImplScrolling() const override; |
61 void AsValueInto(base::debug::TracedValue* state) const override; | 63 void AsValueInto(base::debug::TracedValue* state) const override; |
62 bool MainFrameWillHappenForTesting() override; | 64 bool MainFrameWillHappenForTesting() override; |
63 void SetChildrenNeedBeginFrames(bool children_need_begin_frames) override; | |
64 | 65 |
65 // SchedulerClient implementation | 66 // SchedulerClient implementation |
66 void WillBeginImplFrame(const BeginFrameArgs& args) override; | 67 void WillBeginImplFrame(const BeginFrameArgs& args) override; |
67 void ScheduledActionSendBeginMainFrame() override; | 68 void ScheduledActionSendBeginMainFrame() override; |
68 DrawResult ScheduledActionDrawAndSwapIfPossible() override; | 69 DrawResult ScheduledActionDrawAndSwapIfPossible() override; |
69 DrawResult ScheduledActionDrawAndSwapForced() override; | 70 DrawResult ScheduledActionDrawAndSwapForced() override; |
70 void ScheduledActionCommit() override; | 71 void ScheduledActionCommit() override; |
71 void ScheduledActionAnimate() override; | 72 void ScheduledActionAnimate() override; |
72 void ScheduledActionActivateSyncTree() override; | 73 void ScheduledActionActivateSyncTree() override; |
73 void ScheduledActionBeginOutputSurfaceCreation() override; | 74 void ScheduledActionBeginOutputSurfaceCreation() override; |
74 void ScheduledActionPrepareTiles() override; | 75 void ScheduledActionPrepareTiles() override; |
75 void DidAnticipatedDrawTimeChange(base::TimeTicks time) override; | 76 void DidAnticipatedDrawTimeChange(base::TimeTicks time) override; |
76 base::TimeDelta DrawDurationEstimate() override; | 77 base::TimeDelta DrawDurationEstimate() override; |
77 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; | 78 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; |
78 base::TimeDelta CommitToActivateDurationEstimate() override; | 79 base::TimeDelta CommitToActivateDurationEstimate() override; |
79 void DidBeginImplFrameDeadline() override; | 80 void DidBeginImplFrameDeadline() override; |
80 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; | |
81 | 81 |
82 // LayerTreeHostImplClient implementation | 82 // LayerTreeHostImplClient implementation |
83 void UpdateRendererCapabilitiesOnImplThread() override; | 83 void UpdateRendererCapabilitiesOnImplThread() override; |
84 void DidLoseOutputSurfaceOnImplThread() override; | 84 void DidLoseOutputSurfaceOnImplThread() override; |
85 void CommitVSyncParameters(base::TimeTicks timebase, | 85 void CommitVSyncParameters(base::TimeTicks timebase, |
86 base::TimeDelta interval) override; | 86 base::TimeDelta interval) override; |
87 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} | 87 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} |
88 void SetMaxSwapsPendingOnImplThread(int max) override {} | 88 void SetMaxSwapsPendingOnImplThread(int max) override {} |
89 void DidSwapBuffersOnImplThread() override; | 89 void DidSwapBuffersOnImplThread() override; |
90 void DidSwapBuffersCompleteOnImplThread() override; | 90 void DidSwapBuffersCompleteOnImplThread() override; |
(...skipping 21 matching lines...) Expand all Loading... |
112 void RequestNewOutputSurface(); | 112 void RequestNewOutputSurface(); |
113 | 113 |
114 // Called by the legacy path where RenderWidget does the scheduling. | 114 // Called by the legacy path where RenderWidget does the scheduling. |
115 void CompositeImmediately(base::TimeTicks frame_begin_time); | 115 void CompositeImmediately(base::TimeTicks frame_begin_time); |
116 | 116 |
117 private: | 117 private: |
118 SingleThreadProxy( | 118 SingleThreadProxy( |
119 LayerTreeHost* layer_tree_host, | 119 LayerTreeHost* layer_tree_host, |
120 LayerTreeHostSingleThreadClient* client, | 120 LayerTreeHostSingleThreadClient* client, |
121 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 121 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
122 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 122 scoped_ptr<BeginFrameSource> external_begin_frame_source, |
| 123 ProxyBeginFrameSource* proxy_begin_frame_source); |
123 | 124 |
124 void BeginMainFrame(); | 125 void BeginMainFrame(); |
125 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); | 126 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); |
126 void DoAnimate(); | 127 void DoAnimate(); |
127 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); | 128 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); |
128 void DoCommit(); | 129 void DoCommit(); |
129 DrawResult DoComposite(base::TimeTicks frame_begin_time, | 130 DrawResult DoComposite(base::TimeTicks frame_begin_time, |
130 LayerTreeHostImpl::FrameData* frame); | 131 LayerTreeHostImpl::FrameData* frame); |
131 void DoSwap(); | 132 void DoSwap(); |
132 void DidCommitAndDrawFrame(); | 133 void DidCommitAndDrawFrame(); |
(...skipping 27 matching lines...) Expand all Loading... |
160 | 161 |
161 // True if a request to the LayerTreeHostClient to create an output surface | 162 // True if a request to the LayerTreeHostClient to create an output surface |
162 // is still outstanding. | 163 // is still outstanding. |
163 bool output_surface_creation_requested_; | 164 bool output_surface_creation_requested_; |
164 | 165 |
165 // This is the callback for the scheduled RequestNewOutputSurface. | 166 // This is the callback for the scheduled RequestNewOutputSurface. |
166 base::CancelableClosure output_surface_creation_callback_; | 167 base::CancelableClosure output_surface_creation_callback_; |
167 | 168 |
168 scoped_ptr<BeginFrameSource> external_begin_frame_source_; | 169 scoped_ptr<BeginFrameSource> external_begin_frame_source_; |
169 | 170 |
| 171 ProxyBeginFrameSource* proxy_begin_frame_source_; |
| 172 |
170 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; | 173 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; |
171 | 174 |
172 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); | 175 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); |
173 }; | 176 }; |
174 | 177 |
175 // For use in the single-threaded case. In debug builds, it pretends that the | 178 // For use in the single-threaded case. In debug builds, it pretends that the |
176 // code is running on the impl thread to satisfy assertion checks. | 179 // code is running on the impl thread to satisfy assertion checks. |
177 class DebugScopedSetImplThread { | 180 class DebugScopedSetImplThread { |
178 public: | 181 public: |
179 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { | 182 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 private: | 232 private: |
230 DebugScopedSetImplThread impl_thread_; | 233 DebugScopedSetImplThread impl_thread_; |
231 DebugScopedSetMainThreadBlocked main_thread_blocked_; | 234 DebugScopedSetMainThreadBlocked main_thread_blocked_; |
232 | 235 |
233 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); | 236 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); |
234 }; | 237 }; |
235 | 238 |
236 } // namespace cc | 239 } // namespace cc |
237 | 240 |
238 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ | 241 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ |
OLD | NEW |