| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, | 201 bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, |
| 197 int priority_cutoff) override; | 202 int priority_cutoff) override; |
| 198 bool IsInsideDraw() override; | 203 bool IsInsideDraw() override; |
| 199 void RenewTreePriority() override; | 204 void RenewTreePriority() override; |
| 200 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, | 205 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, |
| 201 base::TimeDelta delay) override; | 206 base::TimeDelta delay) override; |
| 202 void DidActivateSyncTree() override; | 207 void DidActivateSyncTree() override; |
| 203 void DidManageTiles() override; | 208 void DidManageTiles() override; |
| 204 | 209 |
| 205 // SchedulerClient implementation | 210 // SchedulerClient implementation |
| 206 BeginFrameSource* ExternalBeginFrameSource() override; | |
| 207 void WillBeginImplFrame(const BeginFrameArgs& args) override; | 211 void WillBeginImplFrame(const BeginFrameArgs& args) override; |
| 208 void ScheduledActionSendBeginMainFrame() override; | 212 void ScheduledActionSendBeginMainFrame() override; |
| 209 DrawResult ScheduledActionDrawAndSwapIfPossible() override; | 213 DrawResult ScheduledActionDrawAndSwapIfPossible() override; |
| 210 DrawResult ScheduledActionDrawAndSwapForced() override; | 214 DrawResult ScheduledActionDrawAndSwapForced() override; |
| 211 void ScheduledActionAnimate() override; | 215 void ScheduledActionAnimate() override; |
| 212 void ScheduledActionCommit() override; | 216 void ScheduledActionCommit() override; |
| 213 void ScheduledActionUpdateVisibleTiles() override; | 217 void ScheduledActionUpdateVisibleTiles() override; |
| 214 void ScheduledActionActivateSyncTree() override; | 218 void ScheduledActionActivateSyncTree() override; |
| 215 void ScheduledActionBeginOutputSurfaceCreation() override; | 219 void ScheduledActionBeginOutputSurfaceCreation() override; |
| 216 void ScheduledActionManageTiles() override; | 220 void ScheduledActionManageTiles() override; |
| 217 void DidAnticipatedDrawTimeChange(base::TimeTicks time) override; | 221 void DidAnticipatedDrawTimeChange(base::TimeTicks time) override; |
| 218 base::TimeDelta DrawDurationEstimate() override; | 222 base::TimeDelta DrawDurationEstimate() override; |
| 219 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; | 223 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; |
| 220 base::TimeDelta CommitToActivateDurationEstimate() override; | 224 base::TimeDelta CommitToActivateDurationEstimate() override; |
| 221 void DidBeginImplFrameDeadline() override; | 225 void DidBeginImplFrameDeadline() override; |
| 222 | 226 |
| 223 // ResourceUpdateControllerClient implementation | 227 // ResourceUpdateControllerClient implementation |
| 224 void ReadyToFinalizeTextureUpdates() override; | 228 void ReadyToFinalizeTextureUpdates() override; |
| 225 | 229 |
| 226 protected: | 230 protected: |
| 227 ThreadProxy(LayerTreeHost* layer_tree_host, | 231 ThreadProxy( |
| 228 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 232 LayerTreeHost* layer_tree_host, |
| 229 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 233 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 234 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
| 235 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| 230 | 236 |
| 231 private: | 237 private: |
| 232 // Called on main thread. | 238 // Called on main thread. |
| 233 void SetRendererCapabilitiesMainThreadCopy( | 239 void SetRendererCapabilitiesMainThreadCopy( |
| 234 const RendererCapabilities& capabilities); | 240 const RendererCapabilities& capabilities); |
| 235 void BeginMainFrame( | 241 void BeginMainFrame( |
| 236 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); | 242 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); |
| 237 void DidCommitAndDrawFrame(); | 243 void DidCommitAndDrawFrame(); |
| 238 void DidCompleteSwapBuffers(); | 244 void DidCompleteSwapBuffers(); |
| 239 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); | 245 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 295 |
| 290 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 296 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
| 291 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 297 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
| 292 | 298 |
| 293 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 299 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
| 294 }; | 300 }; |
| 295 | 301 |
| 296 } // namespace cc | 302 } // namespace cc |
| 297 | 303 |
| 298 #endif // CC_TREES_THREAD_PROXY_H_ | 304 #endif // CC_TREES_THREAD_PROXY_H_ |
| OLD | NEW |