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