| 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" | |
| 17 #include "cc/scheduler/commit_earlyout_reason.h" | 16 #include "cc/scheduler/commit_earlyout_reason.h" |
| 18 #include "cc/scheduler/scheduler.h" | 17 #include "cc/scheduler/scheduler.h" |
| 19 #include "cc/trees/layer_tree_host_impl.h" | 18 #include "cc/trees/layer_tree_host_impl.h" |
| 20 #include "cc/trees/proxy.h" | 19 #include "cc/trees/proxy.h" |
| 21 #include "cc/trees/proxy_timing_history.h" | 20 #include "cc/trees/proxy_timing_history.h" |
| 22 | 21 |
| 23 namespace base { | 22 namespace base { |
| 24 class SingleThreadTaskRunner; | 23 class SingleThreadTaskRunner; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace cc { | 26 namespace cc { |
| 28 | 27 |
| 29 class BeginFrameSource; | 28 class BeginFrameSource; |
| 30 class ContextProvider; | 29 class ContextProvider; |
| 31 class InputHandlerClient; | 30 class InputHandlerClient; |
| 32 class LayerTreeHost; | 31 class LayerTreeHost; |
| 33 class PrioritizedResourceManager; | 32 class PrioritizedResourceManager; |
| 34 class ResourceUpdateQueue; | |
| 35 class Scheduler; | 33 class Scheduler; |
| 36 class ScopedThreadProxy; | 34 class ScopedThreadProxy; |
| 37 | 35 |
| 38 class CC_EXPORT ThreadProxy : public Proxy, | 36 class CC_EXPORT ThreadProxy : public Proxy, |
| 39 NON_EXPORTED_BASE(LayerTreeHostImplClient), | 37 NON_EXPORTED_BASE(LayerTreeHostImplClient), |
| 40 NON_EXPORTED_BASE(SchedulerClient), | 38 NON_EXPORTED_BASE(SchedulerClient) { |
| 41 NON_EXPORTED_BASE(ResourceUpdateControllerClient) { | |
| 42 public: | 39 public: |
| 43 static scoped_ptr<Proxy> Create( | 40 static scoped_ptr<Proxy> Create( |
| 44 LayerTreeHost* layer_tree_host, | 41 LayerTreeHost* layer_tree_host, |
| 45 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 42 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 46 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 43 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 47 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 44 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| 48 | 45 |
| 49 ~ThreadProxy() override; | 46 ~ThreadProxy() override; |
| 50 | 47 |
| 51 struct BeginMainFrameAndCommitState { | 48 struct BeginMainFrameAndCommitState { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // Set when the main thread is waiting on a | 105 // Set when the main thread is waiting on a |
| 109 // ScheduledActionSendBeginMainFrame to be issued. | 106 // ScheduledActionSendBeginMainFrame to be issued. |
| 110 CompletionEvent* begin_main_frame_sent_completion_event; | 107 CompletionEvent* begin_main_frame_sent_completion_event; |
| 111 | 108 |
| 112 // Set when the main thread is waiting on a commit to complete. | 109 // Set when the main thread is waiting on a commit to complete. |
| 113 CompletionEvent* commit_completion_event; | 110 CompletionEvent* commit_completion_event; |
| 114 | 111 |
| 115 // Set when the main thread is waiting on a pending tree activation. | 112 // Set when the main thread is waiting on a pending tree activation. |
| 116 CompletionEvent* completion_event_for_commit_held_on_tree_activation; | 113 CompletionEvent* completion_event_for_commit_held_on_tree_activation; |
| 117 | 114 |
| 118 scoped_ptr<ResourceUpdateController> current_resource_update_controller; | |
| 119 | |
| 120 // Set when the next draw should post DidCommitAndDrawFrame to the main | 115 // Set when the next draw should post DidCommitAndDrawFrame to the main |
| 121 // thread. | 116 // thread. |
| 122 bool next_frame_is_newly_committed_frame; | 117 bool next_frame_is_newly_committed_frame; |
| 123 | 118 |
| 124 bool inside_draw; | 119 bool inside_draw; |
| 125 | 120 |
| 126 bool input_throttled_until_commit; | 121 bool input_throttled_until_commit; |
| 127 | 122 |
| 128 base::TimeTicks animation_time; | 123 base::TimeTicks animation_time; |
| 129 | 124 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 void SetNeedsCommit() override; | 158 void SetNeedsCommit() override; |
| 164 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | 159 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
| 165 void SetNextCommitWaitsForActivation() override; | 160 void SetNextCommitWaitsForActivation() override; |
| 166 void NotifyInputThrottledUntilCommit() override; | 161 void NotifyInputThrottledUntilCommit() override; |
| 167 void SetDeferCommits(bool defer_commits) override; | 162 void SetDeferCommits(bool defer_commits) override; |
| 168 bool CommitRequested() const override; | 163 bool CommitRequested() const override; |
| 169 bool BeginMainFrameRequested() const override; | 164 bool BeginMainFrameRequested() const override; |
| 170 void MainThreadHasStoppedFlinging() override; | 165 void MainThreadHasStoppedFlinging() override; |
| 171 void Start() override; | 166 void Start() override; |
| 172 void Stop() override; | 167 void Stop() override; |
| 173 size_t MaxPartialTextureUpdates() const override; | |
| 174 void ForceSerializeOnSwapBuffers() override; | 168 void ForceSerializeOnSwapBuffers() override; |
| 175 bool SupportsImplScrolling() const override; | 169 bool SupportsImplScrolling() const override; |
| 176 void SetDebugState(const LayerTreeDebugState& debug_state) override; | 170 void SetDebugState(const LayerTreeDebugState& debug_state) override; |
| 177 bool MainFrameWillHappenForTesting() override; | 171 bool MainFrameWillHappenForTesting() override; |
| 178 void SetChildrenNeedBeginFrames(bool children_need_begin_frames) override; | 172 void SetChildrenNeedBeginFrames(bool children_need_begin_frames) override; |
| 179 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) override; | 173 void SetAuthoritativeVSyncInterval(const base::TimeDelta& interval) override; |
| 180 | 174 |
| 181 // LayerTreeHostImplClient implementation | 175 // LayerTreeHostImplClient implementation |
| 182 void UpdateRendererCapabilitiesOnImplThread() override; | 176 void UpdateRendererCapabilitiesOnImplThread() override; |
| 183 void DidLoseOutputSurfaceOnImplThread() override; | 177 void DidLoseOutputSurfaceOnImplThread() override; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 void DidFinishImplFrame() override; | 214 void DidFinishImplFrame() override; |
| 221 void ScheduledActionSendBeginMainFrame() override; | 215 void ScheduledActionSendBeginMainFrame() override; |
| 222 DrawResult ScheduledActionDrawAndSwapIfPossible() override; | 216 DrawResult ScheduledActionDrawAndSwapIfPossible() override; |
| 223 DrawResult ScheduledActionDrawAndSwapForced() override; | 217 DrawResult ScheduledActionDrawAndSwapForced() override; |
| 224 void ScheduledActionAnimate() override; | 218 void ScheduledActionAnimate() override; |
| 225 void ScheduledActionCommit() override; | 219 void ScheduledActionCommit() override; |
| 226 void ScheduledActionActivateSyncTree() override; | 220 void ScheduledActionActivateSyncTree() override; |
| 227 void ScheduledActionBeginOutputSurfaceCreation() override; | 221 void ScheduledActionBeginOutputSurfaceCreation() override; |
| 228 void ScheduledActionPrepareTiles() override; | 222 void ScheduledActionPrepareTiles() override; |
| 229 void ScheduledActionInvalidateOutputSurface() override; | 223 void ScheduledActionInvalidateOutputSurface() override; |
| 230 void DidAnticipatedDrawTimeChange(base::TimeTicks time) override; | |
| 231 base::TimeDelta DrawDurationEstimate() override; | 224 base::TimeDelta DrawDurationEstimate() override; |
| 232 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; | 225 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; |
| 233 base::TimeDelta CommitToActivateDurationEstimate() override; | 226 base::TimeDelta CommitToActivateDurationEstimate() override; |
| 234 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; | 227 void SendBeginFramesToChildren(const BeginFrameArgs& args) override; |
| 235 void SendBeginMainFrameNotExpectedSoon() override; | 228 void SendBeginMainFrameNotExpectedSoon() override; |
| 236 | 229 |
| 237 // ResourceUpdateControllerClient implementation | |
| 238 void ReadyToFinalizeTextureUpdates() override; | |
| 239 | |
| 240 protected: | 230 protected: |
| 241 ThreadProxy( | 231 ThreadProxy( |
| 242 LayerTreeHost* layer_tree_host, | 232 LayerTreeHost* layer_tree_host, |
| 243 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 233 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 244 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 234 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 245 scoped_ptr<BeginFrameSource> external_begin_frame_source); | 235 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| 246 | 236 |
| 247 private: | 237 private: |
| 248 // Called on main thread. | 238 // Called on main thread. |
| 249 void SetRendererCapabilitiesMainThreadCopy( | 239 void SetRendererCapabilitiesMainThreadCopy( |
| 250 const RendererCapabilities& capabilities); | 240 const RendererCapabilities& capabilities); |
| 251 void BeginMainFrame( | 241 void BeginMainFrame( |
| 252 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); | 242 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); |
| 253 void BeginMainFrameNotExpectedSoon(); | 243 void BeginMainFrameNotExpectedSoon(); |
| 254 void DidCommitAndDrawFrame(); | 244 void DidCommitAndDrawFrame(); |
| 255 void DidCompleteSwapBuffers(); | 245 void DidCompleteSwapBuffers(); |
| 256 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); | 246 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); |
| 257 void DidLoseOutputSurface(); | 247 void DidLoseOutputSurface(); |
| 258 void RequestNewOutputSurface(); | 248 void RequestNewOutputSurface(); |
| 259 void DidInitializeOutputSurface(bool success, | 249 void DidInitializeOutputSurface(bool success, |
| 260 const RendererCapabilities& capabilities); | 250 const RendererCapabilities& capabilities); |
| 261 void SendCommitRequestToImplThreadIfNeeded(); | 251 void SendCommitRequestToImplThreadIfNeeded(); |
| 262 void DidCompletePageScaleAnimation(); | 252 void DidCompletePageScaleAnimation(); |
| 263 | 253 |
| 264 // Called on impl thread. | 254 // Called on impl thread. |
| 265 struct SchedulerStateRequest; | 255 struct SchedulerStateRequest; |
| 266 | 256 |
| 267 void StartCommitOnImplThread(CompletionEvent* completion, | 257 void StartCommitOnImplThread(CompletionEvent* completion); |
| 268 ResourceUpdateQueue* queue); | |
| 269 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); | 258 void BeginMainFrameAbortedOnImplThread(CommitEarlyOutReason reason); |
| 270 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | 259 void FinishAllRenderingOnImplThread(CompletionEvent* completion); |
| 271 void InitializeImplOnImplThread(CompletionEvent* completion); | 260 void InitializeImplOnImplThread(CompletionEvent* completion); |
| 272 void SetLayerTreeHostClientReadyOnImplThread(); | 261 void SetLayerTreeHostClientReadyOnImplThread(); |
| 273 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); | 262 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); |
| 274 void SetThrottleFrameProductionOnImplThread(bool throttle); | 263 void SetThrottleFrameProductionOnImplThread(bool throttle); |
| 275 void HasInitializedOutputSurfaceOnImplThread( | 264 void HasInitializedOutputSurfaceOnImplThread( |
| 276 CompletionEvent* completion, | 265 CompletionEvent* completion, |
| 277 bool* has_initialized_output_surface); | 266 bool* has_initialized_output_surface); |
| 278 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); | 267 void DeleteContentsTexturesOnImplThread(CompletionEvent* completion); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 299 |
| 311 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 300 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
| 312 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 301 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
| 313 | 302 |
| 314 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 303 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
| 315 }; | 304 }; |
| 316 | 305 |
| 317 } // namespace cc | 306 } // namespace cc |
| 318 | 307 |
| 319 #endif // CC_TREES_THREAD_PROXY_H_ | 308 #endif // CC_TREES_THREAD_PROXY_H_ |
| OLD | NEW |