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 virtual ~SingleThreadProxy(); | 36 virtual ~SingleThreadProxy(); |
35 | 37 |
36 // Proxy implementation | 38 // Proxy implementation |
37 virtual void FinishAllRendering() override; | 39 virtual void FinishAllRendering() override; |
38 virtual bool IsStarted() const override; | 40 virtual bool IsStarted() const override; |
39 virtual void SetOutputSurface(scoped_ptr<OutputSurface>) override; | 41 virtual void SetOutputSurface(scoped_ptr<OutputSurface>) override; |
40 virtual void SetLayerTreeHostClientReady() override; | 42 virtual void SetLayerTreeHostClientReady() override; |
41 virtual void SetVisible(bool visible) override; | 43 virtual void SetVisible(bool visible) override; |
42 virtual const RendererCapabilities& GetRendererCapabilities() const override; | 44 virtual const RendererCapabilities& GetRendererCapabilities() const override; |
43 virtual void SetNeedsAnimate() override; | 45 virtual void SetNeedsAnimate() override; |
44 virtual void SetNeedsUpdateLayers() override; | 46 virtual void SetNeedsUpdateLayers() override; |
45 virtual void SetNeedsCommit() override; | 47 virtual void SetNeedsCommit() override; |
46 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | 48 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
47 virtual void SetNextCommitWaitsForActivation() override; | 49 virtual void SetNextCommitWaitsForActivation() override; |
48 virtual void NotifyInputThrottledUntilCommit() override {} | 50 virtual void NotifyInputThrottledUntilCommit() override {} |
49 virtual void SetDeferCommits(bool defer_commits) override; | 51 virtual void SetDeferCommits(bool defer_commits) override; |
50 virtual bool CommitRequested() const override; | 52 virtual bool CommitRequested() const override; |
51 virtual bool BeginMainFrameRequested() const override; | 53 virtual bool BeginMainFrameRequested() const override; |
52 virtual void MainThreadHasStoppedFlinging() override {} | 54 virtual void MainThreadHasStoppedFlinging() override {} |
53 virtual void Start() override; | 55 virtual void Start() override; |
54 virtual void Stop() override; | 56 virtual void Stop() override; |
55 virtual size_t MaxPartialTextureUpdates() const override; | 57 virtual size_t MaxPartialTextureUpdates() const override; |
56 virtual void ForceSerializeOnSwapBuffers() override; | 58 virtual void ForceSerializeOnSwapBuffers() override; |
57 virtual bool SupportsImplScrolling() const override; | 59 virtual bool SupportsImplScrolling() const override; |
58 virtual void AsValueInto(base::debug::TracedValue* state) const override; | 60 virtual void AsValueInto(base::debug::TracedValue* state) const override; |
59 virtual bool MainFrameWillHappenForTesting() override; | 61 virtual bool MainFrameWillHappenForTesting() override; |
60 | 62 |
61 // SchedulerClient implementation | 63 // SchedulerClient implementation |
62 virtual BeginFrameSource* ExternalBeginFrameSource() override; | |
63 virtual void WillBeginImplFrame(const BeginFrameArgs& args) override; | 64 virtual void WillBeginImplFrame(const BeginFrameArgs& args) override; |
64 virtual void ScheduledActionSendBeginMainFrame() override; | 65 virtual void ScheduledActionSendBeginMainFrame() override; |
65 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() override; | 66 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() override; |
66 virtual DrawResult ScheduledActionDrawAndSwapForced() override; | 67 virtual DrawResult ScheduledActionDrawAndSwapForced() override; |
67 virtual void ScheduledActionCommit() override; | 68 virtual void ScheduledActionCommit() override; |
68 virtual void ScheduledActionAnimate() override; | 69 virtual void ScheduledActionAnimate() override; |
69 virtual void ScheduledActionUpdateVisibleTiles() override; | 70 virtual void ScheduledActionUpdateVisibleTiles() override; |
70 virtual void ScheduledActionActivateSyncTree() override; | 71 virtual void ScheduledActionActivateSyncTree() override; |
71 virtual void ScheduledActionBeginOutputSurfaceCreation() override; | 72 virtual void ScheduledActionBeginOutputSurfaceCreation() override; |
72 virtual void ScheduledActionManageTiles() override; | 73 virtual void ScheduledActionManageTiles() override; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 111 |
111 void RequestNewOutputSurface(); | 112 void RequestNewOutputSurface(); |
112 | 113 |
113 // Called by the legacy path where RenderWidget does the scheduling. | 114 // Called by the legacy path where RenderWidget does the scheduling. |
114 void CompositeImmediately(base::TimeTicks frame_begin_time); | 115 void CompositeImmediately(base::TimeTicks frame_begin_time); |
115 | 116 |
116 private: | 117 private: |
117 SingleThreadProxy( | 118 SingleThreadProxy( |
118 LayerTreeHost* layer_tree_host, | 119 LayerTreeHost* layer_tree_host, |
119 LayerTreeHostSingleThreadClient* client, | 120 LayerTreeHostSingleThreadClient* client, |
120 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 121 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 122 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
121 | 123 |
122 void BeginMainFrame(); | 124 void BeginMainFrame(); |
123 void BeginMainFrameAbortedOnImplThread(); | 125 void BeginMainFrameAbortedOnImplThread(); |
124 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); | 126 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); |
125 void DoCommit(); | 127 void DoCommit(); |
126 DrawResult DoComposite(base::TimeTicks frame_begin_time, | 128 DrawResult DoComposite(base::TimeTicks frame_begin_time, |
127 LayerTreeHostImpl::FrameData* frame); | 129 LayerTreeHostImpl::FrameData* frame); |
128 void DoSwap(); | 130 void DoSwap(); |
129 void DidCommitAndDrawFrame(); | 131 void DidCommitAndDrawFrame(); |
130 void CommitComplete(); | 132 void CommitComplete(); |
(...skipping 24 matching lines...) Expand all Loading... |
155 bool commit_was_deferred_; | 157 bool commit_was_deferred_; |
156 bool commit_requested_; | 158 bool commit_requested_; |
157 | 159 |
158 // True if a request to the LayerTreeHostClient to create an output surface | 160 // True if a request to the LayerTreeHostClient to create an output surface |
159 // is still outstanding. | 161 // is still outstanding. |
160 bool output_surface_creation_requested_; | 162 bool output_surface_creation_requested_; |
161 | 163 |
162 // This is the callback for the scheduled RequestNewOutputSurface. | 164 // This is the callback for the scheduled RequestNewOutputSurface. |
163 base::CancelableClosure output_surface_creation_callback_; | 165 base::CancelableClosure output_surface_creation_callback_; |
164 | 166 |
| 167 scoped_ptr<BeginFrameSource> external_begin_frame_source_; |
| 168 |
165 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; | 169 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; |
166 | 170 |
167 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); | 171 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); |
168 }; | 172 }; |
169 | 173 |
170 // For use in the single-threaded case. In debug builds, it pretends that the | 174 // For use in the single-threaded case. In debug builds, it pretends that the |
171 // code is running on the impl thread to satisfy assertion checks. | 175 // code is running on the impl thread to satisfy assertion checks. |
172 class DebugScopedSetImplThread { | 176 class DebugScopedSetImplThread { |
173 public: | 177 public: |
174 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { | 178 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 private: | 228 private: |
225 DebugScopedSetImplThread impl_thread_; | 229 DebugScopedSetImplThread impl_thread_; |
226 DebugScopedSetMainThreadBlocked main_thread_blocked_; | 230 DebugScopedSetMainThreadBlocked main_thread_blocked_; |
227 | 231 |
228 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); | 232 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); |
229 }; | 233 }; |
230 | 234 |
231 } // namespace cc | 235 } // namespace cc |
232 | 236 |
233 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ | 237 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ |
OLD | NEW |