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/time/time.h" | 10 #include "base/time/time.h" |
11 #include "cc/animation/animation_events.h" | 11 #include "cc/animation/animation_events.h" |
12 #include "cc/output/begin_frame_args.h" | 12 #include "cc/output/begin_frame_args.h" |
13 #include "cc/scheduler/scheduler.h" | 13 #include "cc/scheduler/scheduler.h" |
14 #include "cc/trees/blocking_task_runner.h" | 14 #include "cc/trees/blocking_task_runner.h" |
15 #include "cc/trees/layer_tree_host_impl.h" | 15 #include "cc/trees/layer_tree_host_impl.h" |
16 #include "cc/trees/proxy.h" | 16 #include "cc/trees/proxy.h" |
17 #include "cc/trees/proxy_timing_history.h" | 17 #include "cc/trees/proxy_timing_history.h" |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 | 20 |
21 class ContextProvider; | 21 class ContextProvider; |
| 22 class ExternalBeginFrameSource; |
22 class LayerTreeHost; | 23 class LayerTreeHost; |
23 class LayerTreeHostSingleThreadClient; | 24 class LayerTreeHostSingleThreadClient; |
24 | 25 |
25 class CC_EXPORT SingleThreadProxy : public Proxy, | 26 class CC_EXPORT SingleThreadProxy : public Proxy, |
26 NON_EXPORTED_BASE(LayerTreeHostImplClient), | 27 NON_EXPORTED_BASE(LayerTreeHostImplClient), |
27 SchedulerClient { | 28 SchedulerClient { |
28 public: | 29 public: |
29 static scoped_ptr<Proxy> Create( | 30 static scoped_ptr<Proxy> Create( |
30 LayerTreeHost* layer_tree_host, | 31 LayerTreeHost* layer_tree_host, |
31 LayerTreeHostSingleThreadClient* client, | 32 LayerTreeHostSingleThreadClient* client, |
32 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 33 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 34 scoped_ptr<ExternalBeginFrameSource> external_begin_frame_source); |
33 virtual ~SingleThreadProxy(); | 35 virtual ~SingleThreadProxy(); |
34 | 36 |
35 // Proxy implementation | 37 // Proxy implementation |
36 virtual void FinishAllRendering() override; | 38 virtual void FinishAllRendering() override; |
37 virtual bool IsStarted() const override; | 39 virtual bool IsStarted() const override; |
38 virtual void SetOutputSurface(scoped_ptr<OutputSurface>) override; | 40 virtual void SetOutputSurface(scoped_ptr<OutputSurface>) override; |
39 virtual void SetLayerTreeHostClientReady() override; | 41 virtual void SetLayerTreeHostClientReady() override; |
40 virtual void SetVisible(bool visible) override; | 42 virtual void SetVisible(bool visible) override; |
41 virtual const RendererCapabilities& GetRendererCapabilities() const override; | 43 virtual const RendererCapabilities& GetRendererCapabilities() const override; |
42 virtual void SetNeedsAnimate() override; | 44 virtual void SetNeedsAnimate() override; |
43 virtual void SetNeedsUpdateLayers() override; | 45 virtual void SetNeedsUpdateLayers() override; |
44 virtual void SetNeedsCommit() override; | 46 virtual void SetNeedsCommit() override; |
45 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | 47 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
46 virtual void SetNextCommitWaitsForActivation() override; | 48 virtual void SetNextCommitWaitsForActivation() override; |
47 virtual void NotifyInputThrottledUntilCommit() override {} | 49 virtual void NotifyInputThrottledUntilCommit() override {} |
48 virtual void SetDeferCommits(bool defer_commits) override; | 50 virtual void SetDeferCommits(bool defer_commits) override; |
49 virtual bool CommitRequested() const override; | 51 virtual bool CommitRequested() const override; |
50 virtual bool BeginMainFrameRequested() const override; | 52 virtual bool BeginMainFrameRequested() const override; |
51 virtual void MainThreadHasStoppedFlinging() override {} | 53 virtual void MainThreadHasStoppedFlinging() override {} |
52 virtual void Start() override; | 54 virtual void Start() override; |
53 virtual void Stop() override; | 55 virtual void Stop() override; |
54 virtual size_t MaxPartialTextureUpdates() const override; | 56 virtual size_t MaxPartialTextureUpdates() const override; |
55 virtual void ForceSerializeOnSwapBuffers() override; | 57 virtual void ForceSerializeOnSwapBuffers() override; |
56 virtual bool SupportsImplScrolling() const override; | 58 virtual bool SupportsImplScrolling() const override; |
57 virtual void AsValueInto(base::debug::TracedValue* state) const override; | 59 virtual void AsValueInto(base::debug::TracedValue* state) const override; |
58 virtual bool MainFrameWillHappenForTesting() override; | 60 virtual bool MainFrameWillHappenForTesting() override; |
59 | 61 |
60 // SchedulerClient implementation | 62 // SchedulerClient implementation |
61 virtual BeginFrameSource* ExternalBeginFrameSource() override; | |
62 virtual void WillBeginImplFrame(const BeginFrameArgs& args) override; | 63 virtual void WillBeginImplFrame(const BeginFrameArgs& args) override; |
63 virtual void ScheduledActionSendBeginMainFrame() override; | 64 virtual void ScheduledActionSendBeginMainFrame() override; |
64 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() override; | 65 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() override; |
65 virtual DrawResult ScheduledActionDrawAndSwapForced() override; | 66 virtual DrawResult ScheduledActionDrawAndSwapForced() override; |
66 virtual void ScheduledActionCommit() override; | 67 virtual void ScheduledActionCommit() override; |
67 virtual void ScheduledActionAnimate() override; | 68 virtual void ScheduledActionAnimate() override; |
68 virtual void ScheduledActionUpdateVisibleTiles() override; | 69 virtual void ScheduledActionUpdateVisibleTiles() override; |
69 virtual void ScheduledActionActivateSyncTree() override; | 70 virtual void ScheduledActionActivateSyncTree() override; |
70 virtual void ScheduledActionBeginOutputSurfaceCreation() override; | 71 virtual void ScheduledActionBeginOutputSurfaceCreation() override; |
71 virtual void ScheduledActionManageTiles() override; | 72 virtual void ScheduledActionManageTiles() override; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 110 |
110 void RequestNewOutputSurface(); | 111 void RequestNewOutputSurface(); |
111 | 112 |
112 // Called by the legacy path where RenderWidget does the scheduling. | 113 // Called by the legacy path where RenderWidget does the scheduling. |
113 void CompositeImmediately(base::TimeTicks frame_begin_time); | 114 void CompositeImmediately(base::TimeTicks frame_begin_time); |
114 | 115 |
115 private: | 116 private: |
116 SingleThreadProxy( | 117 SingleThreadProxy( |
117 LayerTreeHost* layer_tree_host, | 118 LayerTreeHost* layer_tree_host, |
118 LayerTreeHostSingleThreadClient* client, | 119 LayerTreeHostSingleThreadClient* client, |
119 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 120 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 121 scoped_ptr<ExternalBeginFrameSource> external_begin_frame_source); |
120 | 122 |
121 void BeginMainFrame(); | 123 void BeginMainFrame(); |
122 void BeginMainFrameAbortedOnImplThread(); | 124 void BeginMainFrameAbortedOnImplThread(); |
123 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); | 125 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); |
124 void DoCommit(); | 126 void DoCommit(); |
125 DrawResult DoComposite(base::TimeTicks frame_begin_time, | 127 DrawResult DoComposite(base::TimeTicks frame_begin_time, |
126 LayerTreeHostImpl::FrameData* frame); | 128 LayerTreeHostImpl::FrameData* frame); |
127 void DoSwap(); | 129 void DoSwap(); |
128 void DidCommitAndDrawFrame(); | 130 void DidCommitAndDrawFrame(); |
129 void CommitComplete(); | 131 void CommitComplete(); |
(...skipping 16 matching lines...) Expand all Loading... |
146 | 148 |
147 scoped_ptr<BlockingTaskRunner::CapturePostTasks> commit_blocking_task_runner_; | 149 scoped_ptr<BlockingTaskRunner::CapturePostTasks> commit_blocking_task_runner_; |
148 scoped_ptr<ResourceUpdateQueue> queue_for_commit_; | 150 scoped_ptr<ResourceUpdateQueue> queue_for_commit_; |
149 bool next_frame_is_newly_committed_frame_; | 151 bool next_frame_is_newly_committed_frame_; |
150 | 152 |
151 bool inside_draw_; | 153 bool inside_draw_; |
152 bool defer_commits_; | 154 bool defer_commits_; |
153 bool commit_was_deferred_; | 155 bool commit_was_deferred_; |
154 bool commit_requested_; | 156 bool commit_requested_; |
155 | 157 |
| 158 scoped_ptr<ExternalBeginFrameSource> external_begin_frame_source_; |
| 159 |
156 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; | 160 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; |
157 | 161 |
158 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); | 162 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); |
159 }; | 163 }; |
160 | 164 |
161 // For use in the single-threaded case. In debug builds, it pretends that the | 165 // For use in the single-threaded case. In debug builds, it pretends that the |
162 // code is running on the impl thread to satisfy assertion checks. | 166 // code is running on the impl thread to satisfy assertion checks. |
163 class DebugScopedSetImplThread { | 167 class DebugScopedSetImplThread { |
164 public: | 168 public: |
165 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { | 169 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 private: | 219 private: |
216 DebugScopedSetImplThread impl_thread_; | 220 DebugScopedSetImplThread impl_thread_; |
217 DebugScopedSetMainThreadBlocked main_thread_blocked_; | 221 DebugScopedSetMainThreadBlocked main_thread_blocked_; |
218 | 222 |
219 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); | 223 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); |
220 }; | 224 }; |
221 | 225 |
222 } // namespace cc | 226 } // namespace cc |
223 | 227 |
224 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ | 228 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ |
OLD | NEW |