| 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" | |
| 14 #include "cc/trees/layer_tree_host_impl.h" | 13 #include "cc/trees/layer_tree_host_impl.h" |
| 15 #include "cc/trees/proxy.h" | 14 #include "cc/trees/proxy.h" |
| 16 #include "cc/trees/proxy_timing_history.h" | |
| 17 | 15 |
| 18 namespace cc { | 16 namespace cc { |
| 19 | 17 |
| 20 class ContextProvider; | 18 class ContextProvider; |
| 21 class LayerTreeHost; | 19 class LayerTreeHost; |
| 22 class LayerTreeHostSingleThreadClient; | 20 class LayerTreeHostSingleThreadClient; |
| 23 | 21 |
| 24 class CC_EXPORT SingleThreadProxy : public Proxy, | 22 class CC_EXPORT SingleThreadProxy : public Proxy, |
| 25 NON_EXPORTED_BASE(LayerTreeHostImplClient), | 23 NON_EXPORTED_BASE(LayerTreeHostImplClient) { |
| 26 SchedulerClient { | |
| 27 public: | 24 public: |
| 28 static scoped_ptr<Proxy> Create( | 25 static scoped_ptr<Proxy> Create( |
| 29 LayerTreeHost* layer_tree_host, | 26 LayerTreeHost* layer_tree_host, |
| 30 LayerTreeHostSingleThreadClient* client); | 27 LayerTreeHostSingleThreadClient* client); |
| 31 virtual ~SingleThreadProxy(); | 28 virtual ~SingleThreadProxy(); |
| 32 | 29 |
| 33 // Proxy implementation | 30 // Proxy implementation |
| 34 virtual void FinishAllRendering() OVERRIDE; | 31 virtual void FinishAllRendering() OVERRIDE; |
| 35 virtual bool IsStarted() const OVERRIDE; | 32 virtual bool IsStarted() const OVERRIDE; |
| 36 virtual void SetLayerTreeHostClientReady() OVERRIDE; | 33 virtual void SetLayerTreeHostClientReady() OVERRIDE; |
| 37 virtual void SetVisible(bool visible) OVERRIDE; | 34 virtual void SetVisible(bool visible) OVERRIDE; |
| 38 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; | 35 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; |
| 39 virtual void SetNeedsAnimate() OVERRIDE; | 36 virtual void SetNeedsAnimate() OVERRIDE; |
| 40 virtual void SetNeedsUpdateLayers() OVERRIDE; | 37 virtual void SetNeedsUpdateLayers() OVERRIDE; |
| 41 virtual void SetNeedsCommit() OVERRIDE; | 38 virtual void SetNeedsCommit() OVERRIDE; |
| 42 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) OVERRIDE; | 39 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) OVERRIDE; |
| 43 virtual void SetNextCommitWaitsForActivation() OVERRIDE; | 40 virtual void SetNextCommitWaitsForActivation() OVERRIDE; |
| 44 virtual void NotifyInputThrottledUntilCommit() OVERRIDE {} | 41 virtual void NotifyInputThrottledUntilCommit() OVERRIDE {} |
| 45 virtual void SetDeferCommits(bool defer_commits) OVERRIDE; | 42 virtual void SetDeferCommits(bool defer_commits) OVERRIDE; |
| 46 virtual bool CommitRequested() const OVERRIDE; | 43 virtual bool CommitRequested() const OVERRIDE; |
| 47 virtual bool BeginMainFrameRequested() const OVERRIDE; | 44 virtual bool BeginMainFrameRequested() const OVERRIDE; |
| 48 virtual void MainThreadHasStoppedFlinging() OVERRIDE {} | 45 virtual void MainThreadHasStoppedFlinging() OVERRIDE {} |
| 49 virtual void Start() OVERRIDE; | 46 virtual void Start() OVERRIDE; |
| 50 virtual void Stop() OVERRIDE; | 47 virtual void Stop() OVERRIDE; |
| 51 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; | 48 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; |
| 52 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; | 49 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; |
| 53 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; | 50 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; |
| 54 virtual bool CommitPendingForTesting() OVERRIDE; | 51 virtual bool CommitPendingForTesting() OVERRIDE; |
| 55 virtual scoped_ptr<base::Value> SchedulerAsValueForTesting() OVERRIDE; | |
| 56 | |
| 57 // SchedulerClient implementation | |
| 58 virtual void SetNeedsBeginFrame(bool enable) OVERRIDE; | |
| 59 virtual void WillBeginImplFrame(const BeginFrameArgs& args) OVERRIDE; | |
| 60 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE; | |
| 61 virtual DrawResult ScheduledActionDrawAndSwapIfPossible() OVERRIDE; | |
| 62 virtual DrawResult ScheduledActionDrawAndSwapForced() OVERRIDE; | |
| 63 virtual void ScheduledActionCommit() OVERRIDE; | |
| 64 virtual void ScheduledActionAnimate() OVERRIDE; | |
| 65 virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE; | |
| 66 virtual void ScheduledActionActivatePendingTree() OVERRIDE; | |
| 67 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; | |
| 68 virtual void ScheduledActionManageTiles() OVERRIDE; | |
| 69 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; | |
| 70 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE; | |
| 71 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE; | |
| 72 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE; | |
| 73 virtual void DidBeginImplFrameDeadline() OVERRIDE; | |
| 74 | 52 |
| 75 // LayerTreeHostImplClient implementation | 53 // LayerTreeHostImplClient implementation |
| 76 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE; | 54 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE; |
| 77 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; | 55 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; |
| 78 virtual void CommitVSyncParameters(base::TimeTicks timebase, | 56 virtual void CommitVSyncParameters(base::TimeTicks timebase, |
| 79 base::TimeDelta interval) OVERRIDE {} | 57 base::TimeDelta interval) OVERRIDE {} |
| 80 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) OVERRIDE {} | 58 virtual void SetEstimatedParentDrawTime(base::TimeDelta draw_time) OVERRIDE {} |
| 81 virtual void SetMaxSwapsPendingOnImplThread(int max) OVERRIDE {} | 59 virtual void SetMaxSwapsPendingOnImplThread(int max) OVERRIDE {} |
| 82 virtual void DidSwapBuffersOnImplThread() OVERRIDE; | 60 virtual void DidSwapBuffersOnImplThread() OVERRIDE; |
| 83 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE; | 61 virtual void DidSwapBuffersCompleteOnImplThread() OVERRIDE; |
| 84 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE; | 62 virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {} |
| 85 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; | 63 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; |
| 86 virtual void NotifyReadyToActivate() OVERRIDE; | 64 virtual void NotifyReadyToActivate() OVERRIDE; |
| 87 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; | 65 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; |
| 88 virtual void SetNeedsRedrawRectOnImplThread( | 66 virtual void SetNeedsRedrawRectOnImplThread( |
| 89 const gfx::Rect& dirty_rect) OVERRIDE; | 67 const gfx::Rect& dirty_rect) OVERRIDE; |
| 90 virtual void SetNeedsAnimateOnImplThread() OVERRIDE; | 68 virtual void SetNeedsAnimateOnImplThread() OVERRIDE; |
| 91 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; | 69 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; |
| 92 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; | 70 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; |
| 93 virtual void SetNeedsCommitOnImplThread() OVERRIDE; | 71 virtual void SetNeedsCommitOnImplThread() OVERRIDE; |
| 94 virtual void PostAnimationEventsToMainThreadOnImplThread( | 72 virtual void PostAnimationEventsToMainThreadOnImplThread( |
| 95 scoped_ptr<AnimationEventsVector> events) OVERRIDE; | 73 scoped_ptr<AnimationEventsVector> events) OVERRIDE; |
| 96 virtual bool ReduceContentsTextureMemoryOnImplThread( | 74 virtual bool ReduceContentsTextureMemoryOnImplThread( |
| 97 size_t limit_bytes, | 75 size_t limit_bytes, |
| 98 int priority_cutoff) OVERRIDE; | 76 int priority_cutoff) OVERRIDE; |
| 99 virtual bool IsInsideDraw() OVERRIDE; | 77 virtual bool IsInsideDraw() OVERRIDE; |
| 100 virtual void RenewTreePriority() OVERRIDE {} | 78 virtual void RenewTreePriority() OVERRIDE {} |
| 101 virtual void PostDelayedScrollbarFadeOnImplThread( | 79 virtual void PostDelayedScrollbarFadeOnImplThread( |
| 102 const base::Closure& start_fade, | 80 const base::Closure& start_fade, |
| 103 base::TimeDelta delay) OVERRIDE {} | 81 base::TimeDelta delay) OVERRIDE {} |
| 104 virtual void DidActivatePendingTree() OVERRIDE; | 82 virtual void DidActivatePendingTree() OVERRIDE {} |
| 105 virtual void DidManageTiles() OVERRIDE; | 83 virtual void DidManageTiles() OVERRIDE {} |
| 106 virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {} | 84 virtual void SetDebugState(const LayerTreeDebugState& debug_state) OVERRIDE {} |
| 107 | 85 |
| 108 // Attempts to create the context and renderer synchronously. Calls | 86 // Attempts to create the context and renderer synchronously. Calls |
| 109 // LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted with the result. | 87 // LayerTreeHost::OnCreateAndInitializeOutputSurfaceAttempted with the result. |
| 110 void CreateAndInitializeOutputSurface(); | 88 void CreateAndInitializeOutputSurface(); |
| 111 | 89 |
| 112 // Called by the legacy path where RenderWidget does the scheduling. | 90 // Called by the legacy path where RenderWidget does the scheduling. |
| 113 void CompositeImmediately(base::TimeTicks frame_begin_time); | 91 void CompositeImmediately(base::TimeTicks frame_begin_time); |
| 114 | 92 |
| 115 private: | 93 private: |
| 116 SingleThreadProxy(LayerTreeHost* layer_tree_host, | 94 SingleThreadProxy(LayerTreeHost* layer_tree_host, |
| 117 LayerTreeHostSingleThreadClient* client); | 95 LayerTreeHostSingleThreadClient* client); |
| 118 | 96 |
| 119 void DoCommit(base::TimeTicks frame_begin_time); | 97 void DoCommit(scoped_ptr<ResourceUpdateQueue> queue); |
| 120 DrawResult DoComposite(base::TimeTicks frame_begin_time, | 98 bool DoComposite(base::TimeTicks frame_begin_time, |
| 121 LayerTreeHostImpl::FrameData* frame); | 99 LayerTreeHostImpl::FrameData* frame); |
| 122 void DoSwap(); | 100 void DidSwapFrame(); |
| 123 void DidCommitAndDrawFrame(); | |
| 124 | 101 |
| 125 bool ShouldComposite() const; | 102 bool ShouldComposite() const; |
| 126 void UpdateBackgroundAnimateTicking(); | 103 void UpdateBackgroundAnimateTicking(); |
| 127 | 104 |
| 128 // Accessed on main thread only. | 105 // Accessed on main thread only. |
| 129 LayerTreeHost* layer_tree_host_; | 106 LayerTreeHost* layer_tree_host_; |
| 130 LayerTreeHostSingleThreadClient* client_; | 107 LayerTreeHostSingleThreadClient* client_; |
| 131 | 108 |
| 132 // Used on the Thread, but checked on main thread during | 109 // Used on the Thread, but checked on main thread during |
| 133 // initialization/shutdown. | 110 // initialization/shutdown. |
| 134 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; | 111 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; |
| 135 RendererCapabilities renderer_capabilities_for_main_thread_; | 112 RendererCapabilities renderer_capabilities_for_main_thread_; |
| 136 | 113 |
| 137 // Accessed from both threads. | |
| 138 scoped_ptr<Scheduler> scheduler_on_impl_thread_; | |
| 139 ProxyTimingHistory timing_history_; | |
| 140 | |
| 141 bool next_frame_is_newly_committed_frame_; | 114 bool next_frame_is_newly_committed_frame_; |
| 142 | 115 |
| 143 bool inside_draw_; | 116 bool inside_draw_; |
| 144 bool defer_commits_; | |
| 145 bool commit_was_deferred_; | |
| 146 bool commit_requested_; | |
| 147 | |
| 148 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; | |
| 149 | 117 |
| 150 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); | 118 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); |
| 151 }; | 119 }; |
| 152 | 120 |
| 153 // For use in the single-threaded case. In debug builds, it pretends that the | 121 // For use in the single-threaded case. In debug builds, it pretends that the |
| 154 // code is running on the impl thread to satisfy assertion checks. | 122 // code is running on the impl thread to satisfy assertion checks. |
| 155 class DebugScopedSetImplThread { | 123 class DebugScopedSetImplThread { |
| 156 public: | 124 public: |
| 157 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { | 125 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { |
| 158 #if DCHECK_IS_ON | 126 #if DCHECK_IS_ON |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 private: | 175 private: |
| 208 DebugScopedSetImplThread impl_thread_; | 176 DebugScopedSetImplThread impl_thread_; |
| 209 DebugScopedSetMainThreadBlocked main_thread_blocked_; | 177 DebugScopedSetMainThreadBlocked main_thread_blocked_; |
| 210 | 178 |
| 211 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); | 179 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); |
| 212 }; | 180 }; |
| 213 | 181 |
| 214 } // namespace cc | 182 } // namespace cc |
| 215 | 183 |
| 216 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ | 184 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ |
| OLD | NEW |