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 DidBeginImplFrame(base::TimeTicks frame_time) OVERRIDE; |
69 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; | 69 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; |
70 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE; | 70 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE; |
71 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; | 71 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; |
72 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE; | 72 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE; |
73 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; | 73 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; |
74 virtual void SetNeedsCommitOnImplThread() OVERRIDE; | 74 virtual void SetNeedsCommitOnImplThread() OVERRIDE; |
75 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; | 75 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE; |
76 virtual void PostAnimationEventsToMainThreadOnImplThread( | 76 virtual void PostAnimationEventsToMainThreadOnImplThread( |
77 scoped_ptr<AnimationEventsVector> queue, | 77 scoped_ptr<AnimationEventsVector> queue, |
78 base::Time wall_clock_time) OVERRIDE; | 78 base::Time wall_clock_time) OVERRIDE; |
79 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, | 79 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, |
80 int priority_cutoff) | 80 int priority_cutoff) |
81 OVERRIDE; | 81 OVERRIDE; |
82 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE; | 82 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE; |
83 virtual void SendManagedMemoryStats() OVERRIDE; | 83 virtual void SendManagedMemoryStats() OVERRIDE; |
84 virtual bool IsInsideDraw() OVERRIDE; | 84 virtual bool IsInsideDraw() OVERRIDE; |
85 virtual void RenewTreePriority() OVERRIDE; | 85 virtual void RenewTreePriority() OVERRIDE; |
86 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) | 86 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) |
87 OVERRIDE; | 87 OVERRIDE; |
88 virtual void DidReceiveLastInputEventForVSync( | 88 virtual void DidReceiveLastInputEventForBeginImplFrame( |
89 base::TimeTicks frame_time) OVERRIDE; | 89 base::TimeTicks frame_time) OVERRIDE; |
90 virtual void DidActivatePendingTree() OVERRIDE; | 90 virtual void DidActivatePendingTree() OVERRIDE; |
91 | 91 |
92 // SchedulerClient implementation | 92 // SchedulerClient implementation |
93 virtual void ScheduledActionBeginFrame() OVERRIDE; | 93 virtual void ScheduledActionBeginMainFrame() OVERRIDE; |
94 virtual ScheduledActionDrawAndSwapResult | 94 virtual ScheduledActionDrawAndSwapResult |
95 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; | 95 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; |
96 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 96 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() |
97 OVERRIDE; | 97 OVERRIDE; |
98 virtual void ScheduledActionCommit() OVERRIDE; | 98 virtual void ScheduledActionCommit() OVERRIDE; |
99 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; | 99 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; |
100 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; | 100 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; |
101 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; | 101 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; |
102 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; | 102 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; |
103 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; | 103 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; |
104 | 104 |
105 // ResourceUpdateControllerClient implementation | 105 // ResourceUpdateControllerClient implementation |
106 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; | 106 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; |
107 | 107 |
108 // VSyncProvider implementation | 108 // VSyncProvider implementation |
109 virtual void RequestVSyncNotification(VSyncClient* client) OVERRIDE; | 109 virtual void RequestVSyncNotification(VSyncClient* client) OVERRIDE; |
110 | 110 |
111 int MaxFramesPendingForTesting() const { | 111 int MaxFramesPendingForTesting() const { |
112 return scheduler_on_impl_thread_->MaxFramesPending(); | 112 return scheduler_on_impl_thread_->MaxFramesPending(); |
113 } | 113 } |
114 | 114 |
115 int NumFramesPendingForTesting() const { | 115 int NumFramesPendingForTesting() const { |
116 return scheduler_on_impl_thread_->NumFramesPendingForTesting(); | 116 return scheduler_on_impl_thread_->NumFramesPendingForTesting(); |
117 } | 117 } |
118 | 118 |
119 private: | 119 private: |
120 ThreadProxy(LayerTreeHost* layer_tree_host, scoped_ptr<Thread> impl_thread); | 120 ThreadProxy(LayerTreeHost* layer_tree_host, scoped_ptr<Thread> impl_thread); |
121 | 121 |
122 struct BeginFrameAndCommitState { | 122 struct BeginMainFrameAndCommitState { |
123 BeginFrameAndCommitState(); | 123 BeginMainFrameAndCommitState(); |
124 ~BeginFrameAndCommitState(); | 124 ~BeginMainFrameAndCommitState(); |
125 | 125 |
126 base::TimeTicks monotonic_frame_begin_time; | 126 base::TimeTicks monotonic_frame_begin_time; |
127 scoped_ptr<ScrollAndScaleSet> scroll_info; | 127 scoped_ptr<ScrollAndScaleSet> scroll_info; |
128 size_t memory_allocation_limit_bytes; | 128 size_t memory_allocation_limit_bytes; |
129 }; | 129 }; |
130 | 130 |
131 // Called on main thread. | 131 // Called on main thread. |
132 void BeginFrame(scoped_ptr<BeginFrameAndCommitState> begin_frame_state); | 132 void BeginMainFrame( |
| 133 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); |
133 void DidCommitAndDrawFrame(); | 134 void DidCommitAndDrawFrame(); |
134 void DidCompleteSwapBuffers(); | 135 void DidCompleteSwapBuffers(); |
135 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue, | 136 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue, |
136 base::Time wall_clock_time); | 137 base::Time wall_clock_time); |
137 void DoCreateAndInitializeOutputSurface(); | 138 void DoCreateAndInitializeOutputSurface(); |
138 // |capabilities| is set only when |success| is true. | 139 // |capabilities| is set only when |success| is true. |
139 void OnOutputSurfaceInitializeAttempted( | 140 void OnOutputSurfaceInitializeAttempted( |
140 bool success, | 141 bool success, |
141 const RendererCapabilities& capabilities); | 142 const RendererCapabilities& capabilities); |
142 | 143 |
143 // Called on impl thread. | 144 // Called on impl thread. |
144 struct ReadbackRequest { | 145 struct ReadbackRequest { |
145 CompletionEvent completion; | 146 CompletionEvent completion; |
146 bool success; | 147 bool success; |
147 void* pixels; | 148 void* pixels; |
148 gfx::Rect rect; | 149 gfx::Rect rect; |
149 }; | 150 }; |
150 struct CommitPendingRequest { | 151 struct CommitPendingRequest { |
151 CompletionEvent completion; | 152 CompletionEvent completion; |
152 bool commit_pending; | 153 bool commit_pending; |
153 }; | 154 }; |
154 void ForceBeginFrameOnImplThread(CompletionEvent* completion); | 155 void ForceBeginMainFrameOnImplThread(CompletionEvent* completion); |
155 void BeginFrameCompleteOnImplThread( | 156 void BeginMainFrameCompleteOnImplThread( |
156 CompletionEvent* completion, | 157 CompletionEvent* completion, |
157 ResourceUpdateQueue* queue, | 158 ResourceUpdateQueue* queue, |
158 scoped_refptr<cc::ContextProvider> offscreen_context_provider); | 159 scoped_refptr<cc::ContextProvider> offscreen_context_provider); |
159 void BeginFrameAbortedOnImplThread(); | 160 void BeginMainFrameAbortedOnImplThread(); |
160 void RequestReadbackOnImplThread(ReadbackRequest* request); | 161 void RequestReadbackOnImplThread(ReadbackRequest* request); |
161 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | 162 void FinishAllRenderingOnImplThread(CompletionEvent* completion); |
162 void InitializeImplOnImplThread(CompletionEvent* completion, | 163 void InitializeImplOnImplThread(CompletionEvent* completion, |
163 InputHandlerClient* input_handler_client); | 164 InputHandlerClient* input_handler_client); |
164 void SetLayerTreeHostClientReadyOnImplThread(); | 165 void SetLayerTreeHostClientReadyOnImplThread(); |
165 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); | 166 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); |
166 void HasInitializedOutputSurfaceOnImplThread( | 167 void HasInitializedOutputSurfaceOnImplThread( |
167 CompletionEvent* completion, | 168 CompletionEvent* completion, |
168 bool* has_initialized_output_surface); | 169 bool* has_initialized_output_surface); |
169 void InitializeOutputSurfaceOnImplThread( | 170 void InitializeOutputSurfaceOnImplThread( |
(...skipping 23 matching lines...) Expand all Loading... |
193 void MainThreadHasStoppedFlingingOnImplThread(); | 194 void MainThreadHasStoppedFlingingOnImplThread(); |
194 | 195 |
195 // Accessed on main thread only. | 196 // Accessed on main thread only. |
196 | 197 |
197 // Set only when SetNeedsAnimate is called. | 198 // Set only when SetNeedsAnimate is called. |
198 bool animate_requested_; | 199 bool animate_requested_; |
199 // Set only when SetNeedsCommit is called. | 200 // Set only when SetNeedsCommit is called. |
200 bool commit_requested_; | 201 bool commit_requested_; |
201 // Set by SetNeedsCommit and SetNeedsAnimate. | 202 // Set by SetNeedsCommit and SetNeedsAnimate. |
202 bool commit_request_sent_to_impl_thread_; | 203 bool commit_request_sent_to_impl_thread_; |
203 // Set by BeginFrame | 204 // Set by BeginMainFrame |
204 bool created_offscreen_context_provider_; | 205 bool created_offscreen_context_provider_; |
205 base::CancelableClosure output_surface_creation_callback_; | 206 base::CancelableClosure output_surface_creation_callback_; |
206 LayerTreeHost* layer_tree_host_; | 207 LayerTreeHost* layer_tree_host_; |
207 RendererCapabilities renderer_capabilities_main_thread_copy_; | 208 RendererCapabilities renderer_capabilities_main_thread_copy_; |
208 bool started_; | 209 bool started_; |
209 bool textures_acquired_; | 210 bool textures_acquired_; |
210 bool in_composite_and_readback_; | 211 bool in_composite_and_readback_; |
211 bool manage_tiles_pending_; | 212 bool manage_tiles_pending_; |
212 // Weak pointer to use when posting tasks to the impl thread. | 213 // Weak pointer to use when posting tasks to the impl thread. |
213 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; | 214 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; |
214 // Holds the first output surface passed from Start. Should not be used for | 215 // Holds the first output surface passed from Start. Should not be used for |
215 // anything else. | 216 // anything else. |
216 scoped_ptr<OutputSurface> first_output_surface_; | 217 scoped_ptr<OutputSurface> first_output_surface_; |
217 | 218 |
218 base::WeakPtrFactory<ThreadProxy> weak_factory_on_impl_thread_; | 219 base::WeakPtrFactory<ThreadProxy> weak_factory_on_impl_thread_; |
219 | 220 |
220 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 221 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
221 base::WeakPtrFactory<ThreadProxy> weak_factory_; | 222 base::WeakPtrFactory<ThreadProxy> weak_factory_; |
222 | 223 |
223 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; | 224 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; |
224 | 225 |
225 scoped_ptr<InputHandlerClient> input_handler_client_on_impl_thread_; | 226 scoped_ptr<InputHandlerClient> input_handler_client_on_impl_thread_; |
226 | 227 |
227 scoped_ptr<Scheduler> scheduler_on_impl_thread_; | 228 scoped_ptr<Scheduler> scheduler_on_impl_thread_; |
228 | 229 |
229 // Set when the main thread is waiting on a ScheduledActionBeginFrame to be | 230 // Set when the main thread is waiting on a ScheduledActionBeginMainFrame to |
230 // issued. | 231 // be issued. |
231 CompletionEvent* begin_frame_completion_event_on_impl_thread_; | 232 CompletionEvent* begin_main_frame_completion_event_on_impl_thread_; |
232 | 233 |
233 // Set when the main thread is waiting on a readback. | 234 // Set when the main thread is waiting on a readback. |
234 ReadbackRequest* readback_request_on_impl_thread_; | 235 ReadbackRequest* readback_request_on_impl_thread_; |
235 | 236 |
236 // Set when the main thread is waiting on a commit to complete. | 237 // Set when the main thread is waiting on a commit to complete. |
237 CompletionEvent* commit_completion_event_on_impl_thread_; | 238 CompletionEvent* commit_completion_event_on_impl_thread_; |
238 | 239 |
239 // Set when the main thread is waiting on a pending tree activation. | 240 // Set when the main thread is waiting on a pending tree activation. |
240 CompletionEvent* completion_event_for_commit_held_on_tree_activation_; | 241 CompletionEvent* completion_event_for_commit_held_on_tree_activation_; |
241 | 242 |
242 // Set when the main thread is waiting on layers to be drawn. | 243 // Set when the main thread is waiting on layers to be drawn. |
243 CompletionEvent* texture_acquisition_completion_event_on_impl_thread_; | 244 CompletionEvent* texture_acquisition_completion_event_on_impl_thread_; |
244 | 245 |
245 scoped_ptr<ResourceUpdateController> | 246 scoped_ptr<ResourceUpdateController> |
246 current_resource_update_controller_on_impl_thread_; | 247 current_resource_update_controller_on_impl_thread_; |
247 | 248 |
248 // Set when the next draw should post DidCommitAndDrawFrame to the main | 249 // Set when the next draw should post DidCommitAndDrawFrame to the main |
249 // thread. | 250 // thread. |
250 bool next_frame_is_newly_committed_frame_on_impl_thread_; | 251 bool next_frame_is_newly_committed_frame_on_impl_thread_; |
251 | 252 |
252 bool render_vsync_enabled_; | 253 bool throttle_frame_production_; |
253 bool render_vsync_notification_enabled_; | 254 bool render_parent_drives_begin_impl_frame__; |
254 bool synchronously_disable_vsync_; | 255 bool using_synchronous_renderer_compositor_; |
255 VSyncClient* vsync_client_; | 256 VSyncClient* vsync_client_; |
256 | 257 |
257 bool inside_draw_; | 258 bool inside_draw_; |
258 | 259 |
259 bool defer_commits_; | 260 bool defer_commits_; |
260 scoped_ptr<BeginFrameAndCommitState> pending_deferred_commit_; | 261 scoped_ptr<BeginMainFrameAndCommitState> pending_deferred_commit_; |
261 | 262 |
262 base::TimeTicks smoothness_takes_priority_expiration_time_; | 263 base::TimeTicks smoothness_takes_priority_expiration_time_; |
263 bool renew_tree_priority_on_impl_thread_pending_; | 264 bool renew_tree_priority_on_impl_thread_pending_; |
264 | 265 |
265 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 266 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
266 }; | 267 }; |
267 | 268 |
268 } // namespace cc | 269 } // namespace cc |
269 | 270 |
270 #endif // CC_TREES_THREAD_PROXY_H_ | 271 #endif // CC_TREES_THREAD_PROXY_H_ |
OLD | NEW |