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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; | 58 virtual void ForceSerializeOnSwapBuffers() OVERRIDE; |
59 virtual skia::RefPtr<SkPicture> CapturePicture() OVERRIDE; | 59 virtual skia::RefPtr<SkPicture> CapturePicture() OVERRIDE; |
60 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; | 60 virtual scoped_ptr<base::Value> AsValue() const OVERRIDE; |
61 virtual bool CommitPendingForTesting() OVERRIDE; | 61 virtual bool CommitPendingForTesting() OVERRIDE; |
62 | 62 |
63 // LayerTreeHostImplClient implementation | 63 // LayerTreeHostImplClient implementation |
64 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; | 64 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; |
65 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; | 65 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; |
66 virtual void OnVSyncParametersChanged(base::TimeTicks timebase, | 66 virtual void OnVSyncParametersChanged(base::TimeTicks timebase, |
67 base::TimeDelta interval) OVERRIDE; | 67 base::TimeDelta interval) OVERRIDE; |
68 virtual void DidVSync(base::TimeTicks frame_time) OVERRIDE; | 68 virtual void BeginFrameOnImplThread(base::TimeTicks frame_time) |
| 69 OVERRIDE; |
69 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; | 70 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; |
70 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE; | 71 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE; |
71 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; | 72 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; |
72 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE; | 73 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE; |
73 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; | 74 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; |
74 virtual void SetNeedsCommitOnImplThread() OVERRIDE; | 75 virtual void SetNeedsCommitOnImplThread() OVERRIDE; |
75 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; | 76 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; |
76 virtual void PostAnimationEventsToMainThreadOnImplThread( | 77 virtual void PostAnimationEventsToMainThreadOnImplThread( |
77 scoped_ptr<AnimationEventsVector> queue, | 78 scoped_ptr<AnimationEventsVector> queue, |
78 base::Time wall_clock_time) OVERRIDE; | 79 base::Time wall_clock_time) OVERRIDE; |
79 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, | 80 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, |
80 int priority_cutoff) | 81 int priority_cutoff) |
81 OVERRIDE; | 82 OVERRIDE; |
82 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE; | 83 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE; |
83 virtual void SendManagedMemoryStats() OVERRIDE; | 84 virtual void SendManagedMemoryStats() OVERRIDE; |
84 virtual bool IsInsideDraw() OVERRIDE; | 85 virtual bool IsInsideDraw() OVERRIDE; |
85 virtual void RenewTreePriority() OVERRIDE; | 86 virtual void RenewTreePriority() OVERRIDE; |
86 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) | 87 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) |
87 OVERRIDE; | 88 OVERRIDE; |
88 virtual void DidReceiveLastInputEventForVSync( | 89 virtual void DidReceiveLastInputEventForBeginFrameOnImplThread( |
89 base::TimeTicks frame_time) OVERRIDE; | 90 base::TimeTicks frame_time) OVERRIDE; |
90 virtual void DidActivatePendingTree() OVERRIDE; | 91 virtual void DidActivatePendingTree() OVERRIDE; |
91 | 92 |
92 // SchedulerClient implementation | 93 // SchedulerClient implementation |
93 virtual void ScheduledActionBeginFrame() OVERRIDE; | 94 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE; |
94 virtual ScheduledActionDrawAndSwapResult | 95 virtual ScheduledActionDrawAndSwapResult |
95 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; | 96 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; |
96 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 97 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() |
97 OVERRIDE; | 98 OVERRIDE; |
98 virtual void ScheduledActionCommit() OVERRIDE; | 99 virtual void ScheduledActionCommit() OVERRIDE; |
99 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; | 100 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; |
100 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; | 101 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; |
101 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; | 102 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; |
102 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; | 103 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; |
103 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; | 104 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; |
(...skipping 18 matching lines...) Expand all Loading... |
122 struct BeginFrameAndCommitState { | 123 struct BeginFrameAndCommitState { |
123 BeginFrameAndCommitState(); | 124 BeginFrameAndCommitState(); |
124 ~BeginFrameAndCommitState(); | 125 ~BeginFrameAndCommitState(); |
125 | 126 |
126 base::TimeTicks monotonic_frame_begin_time; | 127 base::TimeTicks monotonic_frame_begin_time; |
127 scoped_ptr<ScrollAndScaleSet> scroll_info; | 128 scoped_ptr<ScrollAndScaleSet> scroll_info; |
128 size_t memory_allocation_limit_bytes; | 129 size_t memory_allocation_limit_bytes; |
129 }; | 130 }; |
130 | 131 |
131 // Called on main thread. | 132 // Called on main thread. |
132 void BeginFrame(scoped_ptr<BeginFrameAndCommitState> begin_frame_state); | 133 void BeginFrameOnMainThread( |
| 134 scoped_ptr<BeginFrameAndCommitState> begin_frame_state); |
133 void DidCommitAndDrawFrame(); | 135 void DidCommitAndDrawFrame(); |
134 void DidCompleteSwapBuffers(); | 136 void DidCompleteSwapBuffers(); |
135 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue, | 137 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue, |
136 base::Time wall_clock_time); | 138 base::Time wall_clock_time); |
137 void DoCreateAndInitializeOutputSurface(); | 139 void DoCreateAndInitializeOutputSurface(); |
138 // |capabilities| is set only when |success| is true. | 140 // |capabilities| is set only when |success| is true. |
139 void OnOutputSurfaceInitializeAttempted( | 141 void OnOutputSurfaceInitializeAttempted( |
140 bool success, | 142 bool success, |
141 const RendererCapabilities& capabilities); | 143 const RendererCapabilities& capabilities); |
142 | 144 |
143 // Called on impl thread. | 145 // Called on impl thread. |
144 struct ReadbackRequest { | 146 struct ReadbackRequest { |
145 CompletionEvent completion; | 147 CompletionEvent completion; |
146 bool success; | 148 bool success; |
147 void* pixels; | 149 void* pixels; |
148 gfx::Rect rect; | 150 gfx::Rect rect; |
149 }; | 151 }; |
150 struct CommitPendingRequest { | 152 struct CommitPendingRequest { |
151 CompletionEvent completion; | 153 CompletionEvent completion; |
152 bool commit_pending; | 154 bool commit_pending; |
153 }; | 155 }; |
154 void ForceBeginFrameOnImplThread(CompletionEvent* completion); | 156 void ForceCommitOnImplThread(CompletionEvent* completion); |
155 void BeginFrameCompleteOnImplThread( | 157 void StartCommitOnImplThread( |
156 CompletionEvent* completion, | 158 CompletionEvent* completion, |
157 ResourceUpdateQueue* queue, | 159 ResourceUpdateQueue* queue, |
158 scoped_refptr<cc::ContextProvider> offscreen_context_provider); | 160 scoped_refptr<cc::ContextProvider> offscreen_context_provider); |
159 void BeginFrameAbortedOnImplThread(); | 161 void BeginFrameAbortedByMainThreadOnImplThread(); |
160 void RequestReadbackOnImplThread(ReadbackRequest* request); | 162 void RequestReadbackOnImplThread(ReadbackRequest* request); |
161 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | 163 void FinishAllRenderingOnImplThread(CompletionEvent* completion); |
162 void InitializeImplOnImplThread(CompletionEvent* completion); | 164 void InitializeImplOnImplThread(CompletionEvent* completion); |
163 void SetLayerTreeHostClientReadyOnImplThread(); | 165 void SetLayerTreeHostClientReadyOnImplThread(); |
164 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); | 166 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); |
165 void HasInitializedOutputSurfaceOnImplThread( | 167 void HasInitializedOutputSurfaceOnImplThread( |
166 CompletionEvent* completion, | 168 CompletionEvent* completion, |
167 bool* has_initialized_output_surface); | 169 bool* has_initialized_output_surface); |
168 void InitializeOutputSurfaceOnImplThread( | 170 void InitializeOutputSurfaceOnImplThread( |
169 CompletionEvent* completion, | 171 CompletionEvent* completion, |
170 scoped_ptr<OutputSurface> output_surface, | 172 scoped_ptr<OutputSurface> output_surface, |
171 scoped_refptr<ContextProvider> offscreen_context_provider, | 173 scoped_refptr<ContextProvider> offscreen_context_provider, |
172 bool* success, | 174 bool* success, |
173 RendererCapabilities* capabilities); | 175 RendererCapabilities* capabilities); |
174 void FinishGLOnImplThread(CompletionEvent* completion); | 176 void FinishGLOnImplThread(CompletionEvent* completion); |
175 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); | 177 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); |
176 void ManageTilesOnImplThread(); | 178 void ManageTilesOnImplThread(); |
177 void AcquireLayerTexturesForMainThreadOnImplThread( | 179 void AcquireLayerTexturesForMainThreadOnImplThread( |
178 CompletionEvent* completion); | 180 CompletionEvent* completion); |
179 ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapInternal( | 181 ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapInternal( |
180 bool forced_draw); | 182 bool forced_draw); |
181 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); | 183 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); |
182 void SetNeedsForcedCommitOnImplThread(); | |
183 void CheckOutputSurfaceStatusOnImplThread(); | 184 void CheckOutputSurfaceStatusOnImplThread(); |
184 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request); | 185 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request); |
185 void CapturePictureOnImplThread(CompletionEvent* completion, | 186 void CapturePictureOnImplThread(CompletionEvent* completion, |
186 skia::RefPtr<SkPicture>* picture); | 187 skia::RefPtr<SkPicture>* picture); |
187 void AsValueOnImplThread(CompletionEvent* completion, | 188 void AsValueOnImplThread(CompletionEvent* completion, |
188 base::DictionaryValue* state) const; | 189 base::DictionaryValue* state) const; |
189 void RenewTreePriorityOnImplThread(); | 190 void RenewTreePriorityOnImplThread(); |
190 void DidSwapUseIncompleteTileOnImplThread(); | 191 void DidSwapUseIncompleteTileOnImplThread(); |
191 void StartScrollbarAnimationOnImplThread(); | 192 void StartScrollbarAnimationOnImplThread(); |
192 void MainThreadHasStoppedFlingingOnImplThread(); | 193 void MainThreadHasStoppedFlingingOnImplThread(); |
193 | 194 |
194 // Accessed on main thread only. | 195 // Accessed on main thread only. |
195 | 196 |
196 // Set only when SetNeedsAnimate is called. | 197 // Set only when SetNeedsAnimate is called. |
197 bool animate_requested_; | 198 bool animate_requested_; |
198 // Set only when SetNeedsCommit is called. | 199 // Set only when SetNeedsCommit is called. |
199 bool commit_requested_; | 200 bool commit_requested_; |
200 // Set by SetNeedsCommit and SetNeedsAnimate. | 201 // Set by SetNeedsCommit and SetNeedsAnimate. |
201 bool commit_request_sent_to_impl_thread_; | 202 bool commit_request_sent_to_impl_thread_; |
202 // Set by BeginFrame | 203 // Set by BeginFrameOnMainThread |
203 bool created_offscreen_context_provider_; | 204 bool created_offscreen_context_provider_; |
204 base::CancelableClosure output_surface_creation_callback_; | 205 base::CancelableClosure output_surface_creation_callback_; |
205 LayerTreeHost* layer_tree_host_; | 206 LayerTreeHost* layer_tree_host_; |
206 RendererCapabilities renderer_capabilities_main_thread_copy_; | 207 RendererCapabilities renderer_capabilities_main_thread_copy_; |
207 bool started_; | 208 bool started_; |
208 bool textures_acquired_; | 209 bool textures_acquired_; |
209 bool in_composite_and_readback_; | 210 bool in_composite_and_readback_; |
210 bool manage_tiles_pending_; | 211 bool manage_tiles_pending_; |
211 // Weak pointer to use when posting tasks to the impl thread. | 212 // Weak pointer to use when posting tasks to the impl thread. |
212 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 213 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
213 // Holds the first output surface passed from Start. Should not be used for | 214 // Holds the first output surface passed from Start. Should not be used for |
214 // anything else. | 215 // anything else. |
215 scoped_ptr<OutputSurface> first_output_surface_; | 216 scoped_ptr<OutputSurface> first_output_surface_; |
216 | 217 |
217 base::WeakPtrFactory<ThreadProxy> weak_factory_on_impl_thread_; | 218 base::WeakPtrFactory<ThreadProxy> weak_factory_on_impl_thread_; |
218 | 219 |
219 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 220 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
220 base::WeakPtrFactory<ThreadProxy> weak_factory_; | 221 base::WeakPtrFactory<ThreadProxy> weak_factory_; |
221 | 222 |
222 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; | 223 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; |
223 | 224 |
224 scoped_ptr<Scheduler> scheduler_on_impl_thread_; | 225 scoped_ptr<Scheduler> scheduler_on_impl_thread_; |
225 | 226 |
226 // Set when the main thread is waiting on a ScheduledActionBeginFrame to be | 227 // Set when the main thread is waiting on a |
227 // issued. | 228 // ScheduledActionSendBeginFrameToMainThread to be issued. |
228 CompletionEvent* begin_frame_completion_event_on_impl_thread_; | 229 CompletionEvent* |
| 230 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_; |
229 | 231 |
230 // Set when the main thread is waiting on a readback. | 232 // Set when the main thread is waiting on a readback. |
231 ReadbackRequest* readback_request_on_impl_thread_; | 233 ReadbackRequest* readback_request_on_impl_thread_; |
232 | 234 |
233 // Set when the main thread is waiting on a commit to complete. | 235 // Set when the main thread is waiting on a commit to complete. |
234 CompletionEvent* commit_completion_event_on_impl_thread_; | 236 CompletionEvent* commit_completion_event_on_impl_thread_; |
235 | 237 |
236 // Set when the main thread is waiting on a pending tree activation. | 238 // Set when the main thread is waiting on a pending tree activation. |
237 CompletionEvent* completion_event_for_commit_held_on_tree_activation_; | 239 CompletionEvent* completion_event_for_commit_held_on_tree_activation_; |
238 | 240 |
239 // Set when the main thread is waiting on layers to be drawn. | 241 // Set when the main thread is waiting on layers to be drawn. |
240 CompletionEvent* texture_acquisition_completion_event_on_impl_thread_; | 242 CompletionEvent* texture_acquisition_completion_event_on_impl_thread_; |
241 | 243 |
242 scoped_ptr<ResourceUpdateController> | 244 scoped_ptr<ResourceUpdateController> |
243 current_resource_update_controller_on_impl_thread_; | 245 current_resource_update_controller_on_impl_thread_; |
244 | 246 |
245 // Set when the next draw should post DidCommitAndDrawFrame to the main | 247 // Set when the next draw should post DidCommitAndDrawFrame to the main |
246 // thread. | 248 // thread. |
247 bool next_frame_is_newly_committed_frame_on_impl_thread_; | 249 bool next_frame_is_newly_committed_frame_on_impl_thread_; |
248 | 250 |
249 bool render_vsync_enabled_; | 251 bool throttle_frame_production_; |
250 bool render_vsync_notification_enabled_; | 252 bool render_parent_drives_begin_frame__; |
251 bool synchronously_disable_vsync_; | 253 bool using_synchronous_renderer_compositor_; |
252 VSyncClient* vsync_client_; | 254 VSyncClient* vsync_client_; |
253 | 255 |
254 bool inside_draw_; | 256 bool inside_draw_; |
255 | 257 |
256 bool defer_commits_; | 258 bool defer_commits_; |
257 scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_; | 259 scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_; |
258 | 260 |
259 base::TimeTicks smoothness_takes_priority_expiration_time_; | 261 base::TimeTicks smoothness_takes_priority_expiration_time_; |
260 bool renew_tree_priority_on_impl_thread_pending_; | 262 bool renew_tree_priority_on_impl_thread_pending_; |
261 | 263 |
262 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 264 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
263 }; | 265 }; |
264 | 266 |
265 } // namespace cc | 267 } // namespace cc |
266 | 268 |
267 #endif // CC_TREES_THREAD_PROXY_H_ | 269 #endif // CC_TREES_THREAD_PROXY_H_ |
OLD | NEW |