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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 virtual bool CommitPendingForTesting() OVERRIDE; | 64 virtual bool CommitPendingForTesting() OVERRIDE; |
65 virtual std::string SchedulerStateAsStringForTesting() OVERRIDE; | 65 virtual std::string SchedulerStateAsStringForTesting() OVERRIDE; |
66 | 66 |
67 // LayerTreeHostImplClient implementation | 67 // LayerTreeHostImplClient implementation |
68 virtual void DidTryInitializeRendererOnImplThread( | 68 virtual void DidTryInitializeRendererOnImplThread( |
69 bool success, | 69 bool success, |
70 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE; | 70 scoped_refptr<ContextProvider> offscreen_context_provider) OVERRIDE; |
71 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; | 71 virtual void DidLoseOutputSurfaceOnImplThread() OVERRIDE; |
72 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; | 72 virtual void OnSwapBuffersCompleteOnImplThread() OVERRIDE; |
73 virtual void BeginFrameOnImplThread(const BeginFrameArgs& args) OVERRIDE; | 73 virtual void BeginFrameOnImplThread(const BeginFrameArgs& args) OVERRIDE; |
| 74 virtual void DidBeginFrameDeadlineOnImplThread() OVERRIDE; |
74 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; | 75 virtual void OnCanDrawStateChanged(bool can_draw) OVERRIDE; |
75 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE; | 76 virtual void OnHasPendingTreeStateChanged(bool has_pending_tree) OVERRIDE; |
76 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; | 77 virtual void SetNeedsRedrawOnImplThread() OVERRIDE; |
77 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE; | 78 virtual void SetNeedsRedrawRectOnImplThread(gfx::Rect dirty_rect) OVERRIDE; |
78 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; | 79 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE; |
79 virtual void SetNeedsCommitOnImplThread() OVERRIDE; | 80 virtual void SetNeedsCommitOnImplThread() OVERRIDE; |
80 virtual void PostAnimationEventsToMainThreadOnImplThread( | 81 virtual void PostAnimationEventsToMainThreadOnImplThread( |
81 scoped_ptr<AnimationEventsVector> queue, | 82 scoped_ptr<AnimationEventsVector> queue, |
82 base::Time wall_clock_time) OVERRIDE; | 83 base::Time wall_clock_time) OVERRIDE; |
83 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, | 84 virtual bool ReduceContentsTextureMemoryOnImplThread(size_t limit_bytes, |
84 int priority_cutoff) | 85 int priority_cutoff) |
85 OVERRIDE; | 86 OVERRIDE; |
86 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE; | 87 virtual void ReduceWastedContentsTextureMemoryOnImplThread() OVERRIDE; |
87 virtual void SendManagedMemoryStats() OVERRIDE; | 88 virtual void SendManagedMemoryStats() OVERRIDE; |
88 virtual bool IsInsideDraw() OVERRIDE; | 89 virtual bool IsInsideDraw() OVERRIDE; |
89 virtual void RenewTreePriority() OVERRIDE; | 90 virtual void RenewTreePriority() OVERRIDE; |
90 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) | 91 virtual void RequestScrollbarAnimationOnImplThread(base::TimeDelta delay) |
91 OVERRIDE; | 92 OVERRIDE; |
92 virtual void DidActivatePendingTree() OVERRIDE; | 93 virtual void DidActivatePendingTree() OVERRIDE; |
93 | 94 |
94 // SchedulerClient implementation | 95 // SchedulerClient implementation |
95 virtual void SetNeedsBeginFrameOnImplThread(bool enable) OVERRIDE; | 96 virtual void SetNeedsBeginFrameOnImplThread(bool enable) OVERRIDE; |
96 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE; | 97 virtual void ScheduledActionSendBeginFrameToMainThread() OVERRIDE; |
97 virtual ScheduledActionDrawAndSwapResult | 98 virtual ScheduledActionDrawSwapReadbackResult |
98 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; | 99 ScheduledActionDrawAndSwapIfPossible() OVERRIDE; |
99 virtual ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapForced() | 100 virtual ScheduledActionDrawSwapReadbackResult |
100 OVERRIDE; | 101 ScheduledActionDrawAndSwapForced() OVERRIDE; |
| 102 virtual ScheduledActionDrawSwapReadbackResult |
| 103 ScheduledActionDrawAndReadback() OVERRIDE; |
101 virtual void ScheduledActionCommit() OVERRIDE; | 104 virtual void ScheduledActionCommit() OVERRIDE; |
102 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; | 105 virtual void ScheduledActionCheckForCompletedTileUploads() OVERRIDE; |
103 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; | 106 virtual void ScheduledActionActivatePendingTreeIfNeeded() OVERRIDE; |
104 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; | 107 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE; |
105 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; | 108 virtual void ScheduledActionAcquireLayerTexturesForMainThread() OVERRIDE; |
106 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; | 109 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; |
107 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE; | 110 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE; |
| 111 virtual void PostBeginFrameDeadline(const base::Closure& closure, |
| 112 base::TimeTicks deadline) OVERRIDE; |
108 | 113 |
109 // ResourceUpdateControllerClient implementation | 114 // ResourceUpdateControllerClient implementation |
110 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; | 115 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; |
111 | 116 |
112 private: | 117 private: |
113 ThreadProxy(LayerTreeHost* layer_tree_host, | 118 ThreadProxy(LayerTreeHost* layer_tree_host, |
114 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); | 119 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
115 | 120 |
116 struct BeginFrameAndCommitState { | 121 struct BeginFrameAndCommitState { |
117 BeginFrameAndCommitState(); | 122 BeginFrameAndCommitState(); |
(...skipping 15 matching lines...) Expand all Loading... |
133 // |capabilities| is set only when |success| is true. | 138 // |capabilities| is set only when |success| is true. |
134 void OnOutputSurfaceInitializeAttempted( | 139 void OnOutputSurfaceInitializeAttempted( |
135 bool success, | 140 bool success, |
136 const RendererCapabilities& capabilities); | 141 const RendererCapabilities& capabilities); |
137 | 142 |
138 // Called on impl thread. | 143 // Called on impl thread. |
139 struct ReadbackRequest; | 144 struct ReadbackRequest; |
140 struct CommitPendingRequest; | 145 struct CommitPendingRequest; |
141 struct SchedulerStateRequest; | 146 struct SchedulerStateRequest; |
142 | 147 |
143 void ForceCommitOnImplThread(CompletionEvent* completion); | 148 void ForceCommitForReadbackOnImplThread( |
| 149 CompletionEvent* completion, |
| 150 ReadbackRequest *request); |
144 void StartCommitOnImplThread( | 151 void StartCommitOnImplThread( |
145 CompletionEvent* completion, | 152 CompletionEvent* completion, |
146 ResourceUpdateQueue* queue, | 153 ResourceUpdateQueue* queue, |
147 scoped_refptr<cc::ContextProvider> offscreen_context_provider); | 154 scoped_refptr<cc::ContextProvider> offscreen_context_provider); |
148 void BeginFrameAbortedByMainThreadOnImplThread(); | 155 void BeginFrameAbortedByMainThreadOnImplThread(); |
149 void RequestReadbackOnImplThread(ReadbackRequest* request); | |
150 void FinishAllRenderingOnImplThread(CompletionEvent* completion); | 156 void FinishAllRenderingOnImplThread(CompletionEvent* completion); |
151 void InitializeImplOnImplThread(CompletionEvent* completion); | 157 void InitializeImplOnImplThread(CompletionEvent* completion); |
152 void SetLayerTreeHostClientReadyOnImplThread(); | 158 void SetLayerTreeHostClientReadyOnImplThread(); |
153 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); | 159 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); |
154 void HasInitializedOutputSurfaceOnImplThread( | 160 void HasInitializedOutputSurfaceOnImplThread( |
155 CompletionEvent* completion, | 161 CompletionEvent* completion, |
156 bool* has_initialized_output_surface); | 162 bool* has_initialized_output_surface); |
157 void InitializeOutputSurfaceOnImplThread( | 163 void InitializeOutputSurfaceOnImplThread( |
158 CompletionEvent* completion, | 164 CompletionEvent* completion, |
159 scoped_ptr<OutputSurface> output_surface, | 165 scoped_ptr<OutputSurface> output_surface, |
160 scoped_refptr<ContextProvider> offscreen_context_provider, | 166 scoped_refptr<ContextProvider> offscreen_context_provider, |
161 bool* success, | 167 bool* success, |
162 RendererCapabilities* capabilities); | 168 RendererCapabilities* capabilities); |
163 void FinishGLOnImplThread(CompletionEvent* completion); | 169 void FinishGLOnImplThread(CompletionEvent* completion); |
164 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); | 170 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); |
165 void AcquireLayerTexturesForMainThreadOnImplThread( | 171 void AcquireLayerTexturesForMainThreadOnImplThread( |
166 CompletionEvent* completion); | 172 CompletionEvent* completion); |
167 ScheduledActionDrawAndSwapResult ScheduledActionDrawAndSwapInternal( | 173 ScheduledActionDrawSwapReadbackResult ScheduledActionDrawSwapReadbackInternal( |
168 bool forced_draw); | 174 bool forced_draw, bool swap_requested, bool readback_requested); |
169 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); | 175 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); |
170 void CheckOutputSurfaceStatusOnImplThread(); | 176 void CheckOutputSurfaceStatusOnImplThread(); |
171 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request); | 177 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request); |
172 void SchedulerStateAsStringOnImplThreadForTesting( | 178 void SchedulerStateAsStringOnImplThreadForTesting( |
173 SchedulerStateRequest* request); | 179 SchedulerStateRequest* request); |
174 void CapturePictureOnImplThread(CompletionEvent* completion, | 180 void CapturePictureOnImplThread(CompletionEvent* completion, |
175 skia::RefPtr<SkPicture>* picture); | 181 skia::RefPtr<SkPicture>* picture); |
176 void AsValueOnImplThread(CompletionEvent* completion, | 182 void AsValueOnImplThread(CompletionEvent* completion, |
177 base::DictionaryValue* state) const; | 183 base::DictionaryValue* state) const; |
178 void RenewTreePriorityOnImplThread(); | 184 void RenewTreePriorityOnImplThread(); |
(...skipping 25 matching lines...) Expand all Loading... |
204 scoped_ptr<OutputSurface> first_output_surface_; | 210 scoped_ptr<OutputSurface> first_output_surface_; |
205 | 211 |
206 base::WeakPtrFactory<ThreadProxy> weak_factory_on_impl_thread_; | 212 base::WeakPtrFactory<ThreadProxy> weak_factory_on_impl_thread_; |
207 | 213 |
208 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; | 214 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; |
209 base::WeakPtrFactory<ThreadProxy> weak_factory_; | 215 base::WeakPtrFactory<ThreadProxy> weak_factory_; |
210 | 216 |
211 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; | 217 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl_; |
212 | 218 |
213 scoped_ptr<Scheduler> scheduler_on_impl_thread_; | 219 scoped_ptr<Scheduler> scheduler_on_impl_thread_; |
| 220 bool frame_did_draw_; |
214 | 221 |
215 // Set when the main thread is waiting on a | 222 // Set when the main thread is waiting on a |
216 // ScheduledActionSendBeginFrameToMainThread to be issued. | 223 // ScheduledActionSendBeginFrameToMainThread to be issued. |
217 CompletionEvent* | 224 CompletionEvent* |
218 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_; | 225 begin_frame_sent_to_main_thread_completion_event_on_impl_thread_; |
219 | 226 |
| 227 // Set when there is a pending tree on a commit. |
| 228 base::Closure deferred_start_commit_on_impl_thread_; |
| 229 |
220 // Set when the main thread is waiting on a readback. | 230 // Set when the main thread is waiting on a readback. |
221 ReadbackRequest* readback_request_on_impl_thread_; | 231 ReadbackRequest* readback_request_on_impl_thread_; |
222 | 232 |
223 // Set when the main thread is waiting on a commit to complete. | 233 // Set when the main thread is waiting on a commit to complete. |
224 CompletionEvent* commit_completion_event_on_impl_thread_; | 234 CompletionEvent* commit_completion_event_on_impl_thread_; |
225 | 235 |
226 // Set when the main thread is waiting on a pending tree activation. | 236 // Set when the main thread is waiting on a pending tree activation. |
227 CompletionEvent* completion_event_for_commit_held_on_tree_activation_; | 237 CompletionEvent* completion_event_for_commit_held_on_tree_activation_; |
228 | 238 |
229 // Set when the main thread is waiting on layers to be drawn. | 239 // Set when the main thread is waiting on layers to be drawn. |
(...skipping 19 matching lines...) Expand all Loading... |
249 bool renew_tree_priority_on_impl_thread_pending_; | 259 bool renew_tree_priority_on_impl_thread_pending_; |
250 | 260 |
251 RollingTimeDeltaHistory draw_duration_history_; | 261 RollingTimeDeltaHistory draw_duration_history_; |
252 | 262 |
253 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); | 263 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); |
254 }; | 264 }; |
255 | 265 |
256 } // namespace cc | 266 } // namespace cc |
257 | 267 |
258 #endif // CC_TREES_THREAD_PROXY_H_ | 268 #endif // CC_TREES_THREAD_PROXY_H_ |
OLD | NEW |