| 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 ~SingleThreadProxy() override; | 36 ~SingleThreadProxy() override; |
| 35 | 37 |
| 36 // Proxy implementation | 38 // Proxy implementation |
| 37 void FinishAllRendering() override; | 39 void FinishAllRendering() override; |
| 38 bool IsStarted() const override; | 40 bool IsStarted() const override; |
| 39 void SetOutputSurface(scoped_ptr<OutputSurface>) override; | 41 void SetOutputSurface(scoped_ptr<OutputSurface>) override; |
| 40 void SetLayerTreeHostClientReady() override; | 42 void SetLayerTreeHostClientReady() override; |
| 41 void SetVisible(bool visible) override; | 43 void SetVisible(bool visible) override; |
| 42 const RendererCapabilities& GetRendererCapabilities() const override; | 44 const RendererCapabilities& GetRendererCapabilities() const override; |
| 43 void SetNeedsAnimate() override; | 45 void SetNeedsAnimate() override; |
| 44 void SetNeedsUpdateLayers() override; | 46 void SetNeedsUpdateLayers() override; |
| 45 void SetNeedsCommit() override; | 47 void SetNeedsCommit() override; |
| 46 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; | 48 void SetNeedsRedraw(const gfx::Rect& damage_rect) override; |
| 47 void SetNextCommitWaitsForActivation() override; | 49 void SetNextCommitWaitsForActivation() override; |
| 48 void NotifyInputThrottledUntilCommit() override {} | 50 void NotifyInputThrottledUntilCommit() override {} |
| 49 void SetDeferCommits(bool defer_commits) override; | 51 void SetDeferCommits(bool defer_commits) override; |
| 50 bool CommitRequested() const override; | 52 bool CommitRequested() const override; |
| 51 bool BeginMainFrameRequested() const override; | 53 bool BeginMainFrameRequested() const override; |
| 52 void MainThreadHasStoppedFlinging() override {} | 54 void MainThreadHasStoppedFlinging() override {} |
| 53 void Start() override; | 55 void Start() override; |
| 54 void Stop() override; | 56 void Stop() override; |
| 55 size_t MaxPartialTextureUpdates() const override; | 57 size_t MaxPartialTextureUpdates() const override; |
| 56 void ForceSerializeOnSwapBuffers() override; | 58 void ForceSerializeOnSwapBuffers() override; |
| 57 bool SupportsImplScrolling() const override; | 59 bool SupportsImplScrolling() const override; |
| 58 void AsValueInto(base::debug::TracedValue* state) const override; | 60 void AsValueInto(base::debug::TracedValue* state) const override; |
| 59 bool MainFrameWillHappenForTesting() override; | 61 bool MainFrameWillHappenForTesting() override; |
| 60 | 62 |
| 61 // SchedulerClient implementation | 63 // SchedulerClient implementation |
| 62 BeginFrameSource* ExternalBeginFrameSource() override; | |
| 63 void WillBeginImplFrame(const BeginFrameArgs& args) override; | 64 void WillBeginImplFrame(const BeginFrameArgs& args) override; |
| 64 void ScheduledActionSendBeginMainFrame() override; | 65 void ScheduledActionSendBeginMainFrame() override; |
| 65 DrawResult ScheduledActionDrawAndSwapIfPossible() override; | 66 DrawResult ScheduledActionDrawAndSwapIfPossible() override; |
| 66 DrawResult ScheduledActionDrawAndSwapForced() override; | 67 DrawResult ScheduledActionDrawAndSwapForced() override; |
| 67 void ScheduledActionCommit() override; | 68 void ScheduledActionCommit() override; |
| 68 void ScheduledActionAnimate() override; | 69 void ScheduledActionAnimate() override; |
| 69 void ScheduledActionUpdateVisibleTiles() override; | 70 void ScheduledActionUpdateVisibleTiles() override; |
| 70 void ScheduledActionActivateSyncTree() override; | 71 void ScheduledActionActivateSyncTree() override; |
| 71 void ScheduledActionBeginOutputSurfaceCreation() override; | 72 void ScheduledActionBeginOutputSurfaceCreation() override; |
| 72 void ScheduledActionManageTiles() override; | 73 void ScheduledActionManageTiles() override; |
| 73 void DidAnticipatedDrawTimeChange(base::TimeTicks time) override; | 74 void DidAnticipatedDrawTimeChange(base::TimeTicks time) override; |
| 74 base::TimeDelta DrawDurationEstimate() override; | 75 base::TimeDelta DrawDurationEstimate() override; |
| 75 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; | 76 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override; |
| 76 base::TimeDelta CommitToActivateDurationEstimate() override; | 77 base::TimeDelta CommitToActivateDurationEstimate() override; |
| 77 void DidBeginImplFrameDeadline() override; | 78 void DidBeginImplFrameDeadline() override; |
| 78 | 79 |
| 79 // LayerTreeHostImplClient implementation | 80 // LayerTreeHostImplClient implementation |
| 80 void UpdateRendererCapabilitiesOnImplThread() override; | 81 void UpdateRendererCapabilitiesOnImplThread() override; |
| 81 void DidLoseOutputSurfaceOnImplThread() override; | 82 void DidLoseOutputSurfaceOnImplThread() override; |
| 82 void CommitVSyncParameters(base::TimeTicks timebase, | 83 void CommitVSyncParameters(base::TimeTicks timebase, |
| 83 base::TimeDelta interval) override {} | 84 base::TimeDelta interval) override {} |
| 84 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} | 85 void SetEstimatedParentDrawTime(base::TimeDelta draw_time) override {} |
| 85 void SetMaxSwapsPendingOnImplThread(int max) override {} | 86 void SetMaxSwapsPendingOnImplThread(int max) override {} |
| 86 void DidSwapBuffersOnImplThread() override; | 87 void DidSwapBuffersOnImplThread() override; |
| 87 void DidSwapBuffersCompleteOnImplThread() override; | 88 void DidSwapBuffersCompleteOnImplThread() override; |
| 88 void OnCanDrawStateChanged(bool can_draw) override; | 89 void OnCanDrawStateChanged(bool can_draw) override; |
| 89 void NotifyReadyToActivate() override; | 90 void NotifyReadyToActivate() override; |
| 91 void NotifyReadyToDraw() override; |
| 90 void SetNeedsRedrawOnImplThread() override; | 92 void SetNeedsRedrawOnImplThread() override; |
| 91 void SetNeedsRedrawRectOnImplThread(const gfx::Rect& dirty_rect) override; | 93 void SetNeedsRedrawRectOnImplThread(const gfx::Rect& dirty_rect) override; |
| 92 void SetNeedsAnimateOnImplThread() override; | 94 void SetNeedsAnimateOnImplThread() override; |
| 93 void SetNeedsManageTilesOnImplThread() override; | 95 void SetNeedsManageTilesOnImplThread() override; |
| 94 void DidInitializeVisibleTileOnImplThread() override; | 96 void DidInitializeVisibleTileOnImplThread() override; |
| 95 void SetNeedsCommitOnImplThread() override; | 97 void SetNeedsCommitOnImplThread() override; |
| 96 void PostAnimationEventsToMainThreadOnImplThread( | 98 void PostAnimationEventsToMainThreadOnImplThread( |
| 97 scoped_ptr<AnimationEventsVector> events) override; | 99 scoped_ptr<AnimationEventsVector> events) override; |
| 98 bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, | 100 bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, |
| 99 int priority_cutoff) override; | 101 int priority_cutoff) override; |
| 100 bool IsInsideDraw() override; | 102 bool IsInsideDraw() override; |
| 101 void RenewTreePriority() override {} | 103 void RenewTreePriority() override {} |
| 102 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, | 104 void PostDelayedScrollbarFadeOnImplThread(const base::Closure& start_fade, |
| 103 base::TimeDelta delay) override {} | 105 base::TimeDelta delay) override {} |
| 104 void DidActivateSyncTree() override; | 106 void DidActivateSyncTree() override; |
| 105 void DidManageTiles() override; | 107 void DidManageTiles() override; |
| 106 void SetDebugState(const LayerTreeDebugState& debug_state) override {} | 108 void SetDebugState(const LayerTreeDebugState& debug_state) override {} |
| 107 | 109 |
| 108 void RequestNewOutputSurface(); | 110 void RequestNewOutputSurface(); |
| 109 | 111 |
| 110 // Called by the legacy path where RenderWidget does the scheduling. | 112 // Called by the legacy path where RenderWidget does the scheduling. |
| 111 void CompositeImmediately(base::TimeTicks frame_begin_time); | 113 void CompositeImmediately(base::TimeTicks frame_begin_time); |
| 112 | 114 |
| 113 private: | 115 private: |
| 114 SingleThreadProxy( | 116 SingleThreadProxy( |
| 115 LayerTreeHost* layer_tree_host, | 117 LayerTreeHost* layer_tree_host, |
| 116 LayerTreeHostSingleThreadClient* client, | 118 LayerTreeHostSingleThreadClient* client, |
| 117 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner); | 119 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 120 scoped_ptr<BeginFrameSource> external_begin_frame_source); |
| 118 | 121 |
| 119 void BeginMainFrame(); | 122 void BeginMainFrame(); |
| 120 void BeginMainFrameAbortedOnImplThread(); | 123 void BeginMainFrameAbortedOnImplThread(); |
| 124 void DoAnimate(); |
| 121 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); | 125 void DoBeginMainFrame(const BeginFrameArgs& begin_frame_args); |
| 122 void DoCommit(); | 126 void DoCommit(); |
| 123 DrawResult DoComposite(base::TimeTicks frame_begin_time, | 127 DrawResult DoComposite(base::TimeTicks frame_begin_time, |
| 124 LayerTreeHostImpl::FrameData* frame); | 128 LayerTreeHostImpl::FrameData* frame); |
| 125 void DoSwap(); | 129 void DoSwap(); |
| 126 void DidCommitAndDrawFrame(); | 130 void DidCommitAndDrawFrame(); |
| 127 void CommitComplete(); | 131 void CommitComplete(); |
| 128 | 132 |
| 129 bool ShouldComposite() const; | 133 bool ShouldComposite() const; |
| 130 void UpdateBackgroundAnimateTicking(); | |
| 131 void ScheduleRequestNewOutputSurface(); | 134 void ScheduleRequestNewOutputSurface(); |
| 132 | 135 |
| 133 // Accessed on main thread only. | 136 // Accessed on main thread only. |
| 134 LayerTreeHost* layer_tree_host_; | 137 LayerTreeHost* layer_tree_host_; |
| 135 LayerTreeHostSingleThreadClient* client_; | 138 LayerTreeHostSingleThreadClient* client_; |
| 136 | 139 |
| 137 // Used on the Thread, but checked on main thread during | 140 // Used on the Thread, but checked on main thread during |
| 138 // initialization/shutdown. | 141 // initialization/shutdown. |
| 139 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; | 142 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; |
| 140 RendererCapabilities renderer_capabilities_for_main_thread_; | 143 RendererCapabilities renderer_capabilities_for_main_thread_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 153 bool commit_requested_; | 156 bool commit_requested_; |
| 154 bool inside_synchronous_composite_; | 157 bool inside_synchronous_composite_; |
| 155 | 158 |
| 156 // True if a request to the LayerTreeHostClient to create an output surface | 159 // True if a request to the LayerTreeHostClient to create an output surface |
| 157 // is still outstanding. | 160 // is still outstanding. |
| 158 bool output_surface_creation_requested_; | 161 bool output_surface_creation_requested_; |
| 159 | 162 |
| 160 // This is the callback for the scheduled RequestNewOutputSurface. | 163 // This is the callback for the scheduled RequestNewOutputSurface. |
| 161 base::CancelableClosure output_surface_creation_callback_; | 164 base::CancelableClosure output_surface_creation_callback_; |
| 162 | 165 |
| 166 scoped_ptr<BeginFrameSource> external_begin_frame_source_; |
| 167 |
| 163 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; | 168 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; |
| 164 | 169 |
| 165 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); | 170 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); |
| 166 }; | 171 }; |
| 167 | 172 |
| 168 // For use in the single-threaded case. In debug builds, it pretends that the | 173 // For use in the single-threaded case. In debug builds, it pretends that the |
| 169 // code is running on the impl thread to satisfy assertion checks. | 174 // code is running on the impl thread to satisfy assertion checks. |
| 170 class DebugScopedSetImplThread { | 175 class DebugScopedSetImplThread { |
| 171 public: | 176 public: |
| 172 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { | 177 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 private: | 227 private: |
| 223 DebugScopedSetImplThread impl_thread_; | 228 DebugScopedSetImplThread impl_thread_; |
| 224 DebugScopedSetMainThreadBlocked main_thread_blocked_; | 229 DebugScopedSetMainThreadBlocked main_thread_blocked_; |
| 225 | 230 |
| 226 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); | 231 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); |
| 227 }; | 232 }; |
| 228 | 233 |
| 229 } // namespace cc | 234 } // namespace cc |
| 230 | 235 |
| 231 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ | 236 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ |
| OLD | NEW |