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_THREAD_PROXY_H_ | 5 #ifndef CC_TREES_THREAD_PROXY_H_ |
6 #define CC_TREES_THREAD_PROXY_H_ | 6 #define CC_TREES_THREAD_PROXY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "cc/animation/animation_events.h" | 13 #include "cc/animation/animation_events.h" |
14 #include "cc/base/completion_event.h" | 14 #include "cc/base/completion_event.h" |
15 #include "cc/base/delayed_unique_notifier.h" | 15 #include "cc/base/delayed_unique_notifier.h" |
16 #include "cc/resources/resource_update_controller.h" | 16 #include "cc/resources/resource_update_controller.h" |
17 #include "cc/scheduler/scheduler.h" | 17 #include "cc/scheduler/scheduler.h" |
18 #include "cc/trees/layer_tree_host_impl.h" | 18 #include "cc/trees/layer_tree_host_impl.h" |
19 #include "cc/trees/proxy.h" | 19 #include "cc/trees/proxy.h" |
20 #include "cc/trees/proxy_timing_history.h" | 20 #include "cc/trees/proxy_timing_history.h" |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class SingleThreadTaskRunner; | 23 class SingleThreadTaskRunner; |
24 } | 24 } |
25 | 25 |
26 namespace cc { | 26 namespace cc { |
27 | 27 |
| 28 class BeginFrameSource; |
28 class ContextProvider; | 29 class ContextProvider; |
29 class InputHandlerClient; | 30 class InputHandlerClient; |
30 class LayerTreeHost; | 31 class LayerTreeHost; |
31 class ResourceUpdateQueue; | 32 class ResourceUpdateQueue; |
32 class Scheduler; | 33 class Scheduler; |
33 class ScopedThreadProxy; | 34 class ScopedThreadProxy; |
34 | 35 |
35 class CC_EXPORT ThreadProxy : public Proxy, | 36 class CC_EXPORT ThreadProxy : public Proxy, |
36 NON_EXPORTED_BASE(LayerTreeHostImplClient), | 37 NON_EXPORTED_BASE(LayerTreeHostImplClient), |
37 NON_EXPORTED_BASE(SchedulerClient), | 38 NON_EXPORTED_BASE(SchedulerClient), |
38 NON_EXPORTED_BASE(ResourceUpdateControllerClient) { | 39 NON_EXPORTED_BASE(ResourceUpdateControllerClient) { |
39 public: | 40 public: |
40 static scoped_ptr<Proxy> Create( | 41 static scoped_ptr<Proxy> Create( |
41 LayerTreeHost* layer_tree_host, | 42 LayerTreeHost* layer_tree_host, |
42 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 43 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
43 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 44 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 45 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
44 | 46 |
45 ~ThreadProxy() override; | 47 ~ThreadProxy() override; |
46 | 48 |
47 struct BeginMainFrameAndCommitState { | 49 struct BeginMainFrameAndCommitState { |
48 BeginMainFrameAndCommitState(); | 50 BeginMainFrameAndCommitState(); |
49 ~BeginMainFrameAndCommitState(); | 51 ~BeginMainFrameAndCommitState(); |
50 | 52 |
51 unsigned int begin_frame_id; | 53 unsigned int begin_frame_id; |
52 BeginFrameArgs begin_frame_args; | 54 BeginFrameArgs begin_frame_args; |
53 scoped_ptr<ScrollAndScaleSet> scroll_info; | 55 scoped_ptr<ScrollAndScaleSet> scroll_info; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 91 |
90 LayerTreeHost* layer_tree_host; | 92 LayerTreeHost* layer_tree_host; |
91 bool commit_waits_for_activation; | 93 bool commit_waits_for_activation; |
92 bool main_thread_inside_commit; | 94 bool main_thread_inside_commit; |
93 }; | 95 }; |
94 | 96 |
95 struct CompositorThreadOnly { | 97 struct CompositorThreadOnly { |
96 CompositorThreadOnly( | 98 CompositorThreadOnly( |
97 ThreadProxy* proxy, | 99 ThreadProxy* proxy, |
98 int layer_tree_host_id, | 100 int layer_tree_host_id, |
99 RenderingStatsInstrumentation* rendering_stats_instrumentation); | 101 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 102 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
100 ~CompositorThreadOnly(); | 103 ~CompositorThreadOnly(); |
101 | 104 |
102 const int layer_tree_host_id; | 105 const int layer_tree_host_id; |
103 | 106 |
104 // Copy of the main thread side contents texture manager for work | 107 // Copy of the main thread side contents texture manager for work |
105 // that needs to be done on the compositor thread. | 108 // that needs to be done on the compositor thread. |
106 PrioritizedResourceManager* contents_texture_manager; | 109 PrioritizedResourceManager* contents_texture_manager; |
107 | 110 |
108 scoped_ptr<Scheduler> scheduler; | 111 scoped_ptr<Scheduler> scheduler; |
109 | 112 |
(...skipping 20 matching lines...) Expand all Loading... |
130 base::TimeTicks animation_time; | 133 base::TimeTicks animation_time; |
131 | 134 |
132 // Whether a commit has been completed since the last time animations were | 135 // Whether a commit has been completed since the last time animations were |
133 // ticked. If this happens, we need to animate again. | 136 // ticked. If this happens, we need to animate again. |
134 bool did_commit_after_animating; | 137 bool did_commit_after_animating; |
135 | 138 |
136 DelayedUniqueNotifier smoothness_priority_expiration_notifier; | 139 DelayedUniqueNotifier smoothness_priority_expiration_notifier; |
137 | 140 |
138 ProxyTimingHistory timing_history; | 141 ProxyTimingHistory timing_history; |
139 | 142 |
| 143 scoped_ptr<BeginFrameSource> external_begin_frame_source; |
| 144 |
140 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl; | 145 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl; |
141 base::WeakPtrFactory<ThreadProxy> weak_factory; | 146 base::WeakPtrFactory<ThreadProxy> weak_factory; |
142 }; | 147 }; |
143 | 148 |
144 const MainThreadOnly& main() const; | 149 const MainThreadOnly& main() const; |
145 const MainThreadOrBlockedMainThread& blocked_main() const; | 150 const MainThreadOrBlockedMainThread& blocked_main() const; |
146 const CompositorThreadOnly& impl() const; | 151 const CompositorThreadOnly& impl() const; |
147 | 152 |
148 // Proxy implementation | 153 // Proxy implementation |
149 void FinishAllRendering() override; | 154 void FinishAllRendering() override; |
(...skipping 25 matching lines...) Expand all Loading... |
175 void UpdateRendererCapabilitiesOnImplThread() override; | 180 void UpdateRendererCapabilitiesOnImplThread() override; |
176 void DidLoseOutputSurfaceOnImplThread() override; | 181 void DidLoseOutputSurfaceOnImplThread() override; |
177 void CommitVSyncParameters(base::TimeTicks timebase, | 182 void CommitVSyncParameters(base::TimeTicks timebase, |
178 base::TimeDelta interval) override; | 183 base::TimeDelta interval) override; |
179 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override; | 184 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override; |
180 void SetMaxSwapsPendingOnImplThread(int max) override; | 185 void SetMaxSwapsPendingOnImplThread(int max) override; |
181 void DidSwapBuffersOnImplThread() override; | 186 void DidSwapBuffersOnImplThread() override; |
182 void DidSwapBuffersCompleteOnImplThread() override; | 187 void DidSwapBuffersCompleteOnImplThread() override; |
183 void OnCanDrawStateChanged(bool can_draw) override; | 188 void OnCanDrawStateChanged(bool can_draw) override; |
184 void NotifyReadyToActivate() override; | 189 void NotifyReadyToActivate() override; |
| 190 void NotifyReadyToDraw() override; |
185 // Please call these 3 functions through | 191 // Please call these 3 functions through |
186 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and | 192 // LayerTreeHostImpl's SetNeedsRedraw(), SetNeedsRedrawRect() and |
187 // SetNeedsAnimate(). | 193 // SetNeedsAnimate(). |
188 void SetNeedsRedrawOnImplThread() override; | 194 void SetNeedsRedrawOnImplThread() override; |
189 void SetNeedsRedrawRectOnImplThread(const gfx::Rect& dirty_rect) override; | 195 void SetNeedsRedrawRectOnImplThread(const gfx::Rect& dirty_rect) override; |
190 void SetNeedsAnimateOnImplThread() override; | 196 void SetNeedsAnimateOnImplThread() override; |
191 void SetNeedsManageTilesOnImplThread() override; | 197 void SetNeedsManageTilesOnImplThread() override; |
192 void DidInitializeVisibleTileOnImplThread() override; | 198 void DidInitializeVisibleTileOnImplThread() override; |
193 void SetNeedsCommitOnImplThread() override; | 199 void SetNeedsCommitOnImplThread() override; |
194 void PostAnimationEventsToMainThreadOnImplThread( | 200 void PostAnimationEventsToMainThreadOnImplThread( |
195 scoped_ptr<AnimationEventsVector> queue) override; | 201 scoped_ptr<AnimationEventsVector> queue) override; |
196 bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, | 202 bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, |
197 int priority_cutoff) override; | 203 int priority_cutoff) override; |
198 bool IsInsideDraw() override; | 204 bool IsInsideDraw() override; |
199 void RenewTreePriority() override; | 205 void RenewTreePriority() override; |
200 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, | 206 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, |
201 base::TimeDelta delay) override; | 207 base::TimeDelta delay) override; |
202 void DidActivateSyncTree() override; | 208 void DidActivateSyncTree() override; |
203 void DidManageTiles() override; | 209 void DidManageTiles() override; |
204 | 210 |
205 // SchedulerClient implementation | 211 // SchedulerClient implementation |
206 BeginFrameSource* ExternalBeginFrameSource() override; | |
207 void WillBeginImplFrame(const BeginFrameArgs& args) override; | 212 void WillBeginImplFrame(const BeginFrameArgs& args) override; |
208 void ScheduledActionSendBeginMainFrame() override; | 213 void ScheduledActionSendBeginMainFrame() override; |
209 DrawResult ScheduledActionDrawAndSwapIfPossible() override; | 214 DrawResult ScheduledActionDrawAndSwapIfPossible() override; |
210 DrawResult ScheduledActionDrawAndSwapForced() override; | 215 DrawResult ScheduledActionDrawAndSwapForced() override; |
211 void ScheduledActionAnimate() override; | 216 void ScheduledActionAnimate() override; |
212 void ScheduledActionCommit() override; | 217 void ScheduledActionCommit() override; |
213 void ScheduledActionUpdateVisibleTiles() override; | 218 void ScheduledActionUpdateVisibleTiles() override; |
214 void ScheduledActionActivateSyncTree() override; | 219 void ScheduledActionActivateSyncTree() override; |
215 void ScheduledActionBeginOutputSurfaceCreation() override; | 220 void ScheduledActionBeginOutputSurfaceCreation() override; |
216 void ScheduledActionManageTiles() override; | 221 void ScheduledActionManageTiles() override; |
217 void DidAnticipatedDrawTimeChange(base::TimeTicks time) override; | 222 void DidAnticipatedDrawTimeChange(base::TimeTicks time) override; |
218 base::TimeDelta DrawDurationEstimate() override; | 223 base::TimeDelta DrawDurationEstimate() override; |
219 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; | 224 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; |
220 base::TimeDelta CommitToActivateDurationEstimate() override; | 225 base::TimeDelta CommitToActivateDurationEstimate() override; |
221 void DidBeginImplFrameDeadline() override; | 226 void DidBeginImplFrameDeadline() override; |
222 | 227 |
223 // ResourceUpdateControllerClient implementation | 228 // ResourceUpdateControllerClient implementation |
224 void ReadyToFinalizeTextureUpdates() override; | 229 void ReadyToFinalizeTextureUpdates() override; |
225 | 230 |
226 protected: | 231 protected: |
227 ThreadProxy(LayerTreeHost* layer_tree_host, | 232 ThreadProxy( |
228 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 233 LayerTreeHost* layer_tree_host, |
229 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 234 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 235 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 236 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
230 | 237 |
231 private: | 238 private: |
232 // Called on main thread. | 239 // Called on main thread. |
233 void SetRendererCapabilitiesMainThreadCopy( | 240 void SetRendererCapabilitiesMainThreadCopy( |
234 const RendererCapabilities& capabilities); | 241 const RendererCapabilities& capabilities); |
235 void BeginMainFrame( | 242 void BeginMainFrame( |
236 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); | 243 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); |
237 void DidCommitAndDrawFrame(); | 244 void DidCommitAndDrawFrame(); |
238 void DidCompleteSwapBuffers(); | 245 void DidCompleteSwapBuffers(); |
239 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); | 246 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); |
240 void DidLoseOutputSurface(); | 247 void DidLoseOutputSurface(); |
241 void RequestNewOutputSurface(); | 248 void RequestNewOutputSurface(); |
242 void DidInitializeOutputSurface(bool success, | 249 void DidInitializeOutputSurface(bool success, |
243 const RendererCapabilities& capabilities); | 250 const RendererCapabilities& capabilities); |
244 void SendCommitRequestToImplThreadIfNeeded(); | 251 void SendCommitRequestToImplThreadIfNeeded(); |
245 | 252 |
246 // Called on impl thread. | 253 // Called on impl thread. |
247 struct SchedulerStateRequest; | 254 struct SchedulerStateRequest; |
248 | 255 |
249 void StartCommitOnImplThread(CompletionEvent* completion, | 256 void StartCommitOnImplThread(CompletionEvent* completion, |
250 ResourceUpdateQueue* queue); | 257 ResourceUpdateQueue* queue); |
251 void BeginMainFrameAbortedOnImplThread(bool did_handle); | 258 void BeginMainFrameAbortedOnImplThread(bool did_handle); |
252 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | 259 void FinishAllRenderingOnImplThread(CompletionEvent* completion); |
253 void InitializeImplOnImplThread(CompletionEvent* completion); | 260 void InitializeImplOnImplThread(CompletionEvent* completion); |
254 void SetLayerTreeHostClientReadyOnImplThread(); | 261 void SetLayerTreeHostClientReadyOnImplThread(); |
255 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); | 262 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); |
256 void UpdateBackgroundAnimateTicking(); | |
257 void HasInitializedOutputSurfaceOnImplThread( | 263 void HasInitializedOutputSurfaceOnImplThread( |
258 CompletionEvent* completion, | 264 CompletionEvent* completion, |
259 bool* has_initialized_output_surface); | 265 bool* has_initialized_output_surface); |
260 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); | 266 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); |
261 void InitializeOutputSurfaceOnImplThread( | 267 void InitializeOutputSurfaceOnImplThread( |
262 scoped_ptr<OutputSurface> output_surface); | 268 scoped_ptr<OutputSurface> output_surface); |
263 void FinishGLOnImplThread(CompletionEvent* completion); | 269 void FinishGLOnImplThread(CompletionEvent* completion); |
264 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); | 270 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); |
265 DrawResult DrawSwapInternal(bool forced_draw); | 271 DrawResult DrawSwapInternal(bool forced_draw); |
266 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); | 272 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); |
(...skipping 23 matching lines...) Expand all Loading... |
290 | 296 |
291 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 297 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
292 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 298 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
293 | 299 |
294 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 300 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
295 }; | 301 }; |
296 | 302 |
297 } // namespace cc | 303 } // namespace cc |
298 | 304 |
299 #endif // CC_TREES_THREAD_PROXY_H_ | 305 #endif // CC_TREES_THREAD_PROXY_H_ |
OLD | NEW |