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" |
13 #include "cc/trees/layer_tree_host_impl.h" | 14 #include "cc/trees/layer_tree_host_impl.h" |
14 #include "cc/trees/proxy.h" | 15 #include "cc/trees/proxy.h" |
| 16 #include "cc/trees/proxy_timing_history.h" |
15 | 17 |
16 namespace cc { | 18 namespace cc { |
17 | 19 |
18 class ContextProvider; | 20 class ContextProvider; |
19 class LayerTreeHost; | 21 class LayerTreeHost; |
20 class LayerTreeHostSingleThreadClient; | 22 class LayerTreeHostSingleThreadClient; |
21 | 23 |
22 class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { | 24 class SingleThreadProxy : public Proxy, |
| 25 LayerTreeHostImplClient, |
| 26 SchedulerClient { |
23 public: | 27 public: |
24 static scoped_ptr<Proxy> Create( | 28 static scoped_ptr<Proxy> Create( |
25 LayerTreeHost* layer_tree_host, | 29 LayerTreeHost* layer_tree_host, |
26 LayerTreeHostSingleThreadClient* client); | 30 LayerTreeHostSingleThreadClient* client); |
27 virtual ~SingleThreadProxy(); | 31 virtual ~SingleThreadProxy(); |
28 | 32 |
29 // Proxy implementation | 33 // Proxy implementation |
30 virtual bool CompositeAndReadback(void* pixels, | 34 virtual bool CompositeAndReadback(void* pixels, |
31 const gfx::Rect& rect) OVERRIDE; | 35 const gfx::Rect& rect) OVERRIDE; |
32 virtual void FinishAllRendering() OVERRIDE; | 36 virtual void FinishAllRendering() OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
45 virtual bool CommitRequested() const OVERRIDE; | 49 virtual bool CommitRequested() const OVERRIDE; |
46 virtual bool BeginMainFrameRequested() const OVERRIDE; | 50 virtual bool BeginMainFrameRequested() const OVERRIDE; |
47 virtual void MainThreadHasStoppedFlinging() OVERRIDE {} | 51 virtual void MainThreadHasStoppedFlinging() OVERRIDE {} |
48 virtual void Start() OVERRIDE; | 52 virtual void Start() OVERRIDE; |
49 virtual void Stop() OVERRIDE; | 53 virtual void Stop() OVERRIDE; |
50 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; | 54 virtual size_t MaxPartialTextureUpdates() const OVERRIDE; |
51 virtual void AcquireLayerTextures() OVERRIDE {} | 55 virtual void AcquireLayerTextures() OVERRIDE {} |
52 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; | 56 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; |
53 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; | 57 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; |
54 virtual bool CommitPendingForTesting() OVERRIDE; | 58 virtual bool CommitPendingForTesting() OVERRIDE; |
| 59 virtual scoped_ptr<base::Value> SchedulerStateAsValueForTesting() OVERRIDE; |
| 60 |
| 61 // SchedulerClient implementation |
| 62 virtual void SetNeedsBeginImplFrame(bool enable) OVERRIDE; |
| 63 virtual void ScheduledActionSendBeginMainFrame() OVERRIDE; |
| 64 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapIfPossible() |
| 65 OVERRIDE; |
| 66 virtual DrawSwapReadbackResult ScheduledActionDrawAndSwapForced() OVERRIDE; |
| 67 virtual DrawSwapReadbackResult ScheduledActionDrawAndReadback() OVERRIDE; |
| 68 virtual void ScheduledActionCommit() OVERRIDE; |
| 69 virtual void ScheduledActionUpdateVisibleTiles() OVERRIDE; |
| 70 virtual void ScheduledActionActivatePendingTree() OVERRIDE; |
| 71 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; |
| 72 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; |
| 73 virtual void ScheduledActionManageTiles() OVERRIDE; |
| 74 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; |
| 75 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE; |
| 76 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE; |
| 77 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE; |
| 78 virtual void PostBeginImplFrameDeadline(const base::Closure& closure, |
| 79 base::TimeTicks deadline) OVERRIDE; |
| 80 virtual void DidBeginImplFrameDeadline() OVERRIDE; |
55 | 81 |
56 // LayerTreeHostImplClient implementation | 82 // LayerTreeHostImplClient implementation |
57 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE; | 83 virtual void UpdateRendererCapabilitiesOnImplThread() OVERRIDE; |
58 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; | 84 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; |
59 virtual void DidSwapBuffersOnImplThread() OVERRIDE; | 85 virtual void DidSwapBuffersOnImplThread() OVERRIDE; |
60 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; | 86 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; |
61 virtual void BeginImplFrame(const BeginFrameArgs& args) | 87 virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE; |
62 OVERRIDE {} | |
63 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; | 88 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; |
64 virtual void NotifyReadyToActivate() OVERRIDE; | 89 virtual void NotifyReadyToActivate() OVERRIDE; |
65 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; | 90 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; |
66 virtual void SetNeedsRedrawRectOnImplThread( | 91 virtual void SetNeedsRedrawRectOnImplThread( |
67 const gfx::Rect& dirty_rect) OVERRIDE; | 92 const gfx::Rect& dirty_rect) OVERRIDE; |
68 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; | 93 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; |
69 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; | 94 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; |
70 virtual void SetNeedsCommitOnImplThread() OVERRIDE; | 95 virtual void SetNeedsCommitOnImplThread() OVERRIDE; |
71 virtual void PostAnimationEventsToMainThreadOnImplThread( | 96 virtual void PostAnimationEventsToMainThreadOnImplThread( |
72 scoped_ptr<AnimationEventsVector> events, | 97 scoped_ptr<AnimationEventsVector> events, |
73 base::Time wall_clock_time) OVERRIDE; | 98 base::Time wall_clock_time) OVERRIDE; |
74 virtual bool ReduceContentsTextureMemoryOnImplThread( | 99 virtual bool ReduceContentsTextureMemoryOnImplThread( |
75 size_t limit_bytes, | 100 size_t limit_bytes, |
76 int priority_cutoff) OVERRIDE; | 101 int priority_cutoff) OVERRIDE; |
77 virtual void SendManagedMemoryStats() OVERRIDE; | 102 virtual void SendManagedMemoryStats() OVERRIDE; |
78 virtual bool IsInsideDraw() OVERRIDE; | 103 virtual bool IsInsideDraw() OVERRIDE; |
79 virtual void RenewTreePriority() OVERRIDE {} | 104 virtual void RenewTreePriority() OVERRIDE {} |
80 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) | 105 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) |
81 OVERRIDE {} | 106 OVERRIDE {} |
82 virtual void DidActivatePendingTree() OVERRIDE {} | 107 virtual void DidActivatePendingTree() OVERRIDE; |
83 virtual void DidManageTiles() OVERRIDE {} | 108 virtual void DidManageTiles() OVERRIDE; |
84 | 109 |
85 // Called by the legacy path where RenderWidget does the scheduling. | 110 // Called by the legacy path where RenderWidget does the scheduling. |
86 void CompositeImmediately(base::TimeTicks frame_begin_time); | 111 void CompositeImmediately(base::TimeTicks frame_begin_time); |
87 | 112 |
88 private: | 113 private: |
89 SingleThreadProxy(LayerTreeHost* layer_tree_host, | 114 SingleThreadProxy(LayerTreeHost* layer_tree_host, |
90 LayerTreeHostSingleThreadClient* client); | 115 LayerTreeHostSingleThreadClient* client); |
91 | 116 |
92 void OnOutputSurfaceInitializeAttempted(bool success); | 117 void OnOutputSurfaceInitializeAttempted(bool success); |
93 bool CommitAndComposite(base::TimeTicks frame_begin_time, | 118 void DoCommit(base::TimeTicks frame_begin_time); |
94 const gfx::Rect& device_viewport_damage_rect, | 119 DrawSwapReadbackResult::DrawResult DoComposite( |
95 bool for_readback, | 120 scoped_refptr<ContextProvider> offscreen_context_provider, |
96 LayerTreeHostImpl::FrameData* frame); | 121 base::TimeTicks frame_begin_time, |
97 void DoCommit(scoped_ptr<ResourceUpdateQueue> queue); | 122 const gfx::Rect& device_viewport_damage_rect, |
98 bool DoComposite(scoped_refptr<ContextProvider> offscreen_context_provider, | 123 bool for_readback, |
99 base::TimeTicks frame_begin_time, | 124 LayerTreeHostImpl::FrameData* frame); |
100 const gfx::Rect& device_viewport_damage_rect, | 125 DrawSwapReadbackResult CommitAndCompositeInternal( |
101 bool for_readback, | 126 base::TimeTicks frame_begin_time, |
102 LayerTreeHostImpl::FrameData* frame); | 127 gfx::Rect device_viewport_damage_rect, |
103 void DidSwapFrame(); | 128 bool do_commit, |
| 129 bool for_readback); |
| 130 void DidCommitAndDrawFrame(); |
104 | 131 |
105 bool ShouldComposite() const; | 132 bool ShouldComposite() const; |
106 void UpdateBackgroundAnimateTicking(); | 133 void UpdateBackgroundAnimateTicking(); |
| 134 scoped_refptr<ContextProvider> OffscreenContextProvider(); |
107 | 135 |
108 // Accessed on main thread only. | 136 // Accessed on main thread only. |
109 LayerTreeHost* layer_tree_host_; | 137 LayerTreeHost* layer_tree_host_; |
110 LayerTreeHostSingleThreadClient* client_; | 138 LayerTreeHostSingleThreadClient* client_; |
111 bool created_offscreen_context_provider_; | 139 bool created_offscreen_context_provider_; |
112 | 140 |
113 // Used on the Thread, but checked on main thread during | 141 // Used on the Thread, but checked on main thread during |
114 // initialization/shutdown. | 142 // initialization/shutdown. |
115 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; | 143 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; |
116 RendererCapabilities renderer_capabilities_for_main_thread_; | 144 RendererCapabilities renderer_capabilities_for_main_thread_; |
117 | 145 |
| 146 // Accessed from both threads. |
| 147 scoped_ptr<Scheduler> scheduler_on_impl_thread_; |
| 148 ProxyTimingHistory timing_history_; |
| 149 |
118 bool next_frame_is_newly_committed_frame_; | 150 bool next_frame_is_newly_committed_frame_; |
119 | 151 |
120 bool inside_draw_; | 152 bool inside_draw_; |
| 153 bool defer_commits_; |
| 154 bool finish_commit_deferred_; |
| 155 |
| 156 base::WeakPtrFactory<SingleThreadProxy> weak_factory_; |
121 | 157 |
122 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); | 158 DISALLOW_COPY_AND_ASSIGN(SingleThreadProxy); |
123 }; | 159 }; |
124 | 160 |
125 // For use in the single-threaded case. In debug builds, it pretends that the | 161 // For use in the single-threaded case. In debug builds, it pretends that the |
126 // code is running on the impl thread to satisfy assertion checks. | 162 // code is running on the impl thread to satisfy assertion checks. |
127 class DebugScopedSetImplThread { | 163 class DebugScopedSetImplThread { |
128 public: | 164 public: |
129 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { | 165 explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { |
130 #ifndef NDEBUG | 166 #ifndef NDEBUG |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 private: | 215 private: |
180 DebugScopedSetImplThread impl_thread_; | 216 DebugScopedSetImplThread impl_thread_; |
181 DebugScopedSetMainThreadBlocked main_thread_blocked_; | 217 DebugScopedSetMainThreadBlocked main_thread_blocked_; |
182 | 218 |
183 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); | 219 DISALLOW_COPY_AND_ASSIGN(DebugScopedSetImplThreadAndMainThreadBlocked); |
184 }; | 220 }; |
185 | 221 |
186 } // namespace cc | 222 } // namespace cc |
187 | 223 |
188 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ | 224 #endif // CC_TREES_SINGLE_THREAD_PROXY_H_ |
OLD | NEW |