Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: cc/trees/thread_proxy.h

Issue 242783003: cc: Add testing stubs for proxy test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use NON_EXPORTED_BASE for non-exported base class Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 24
25 namespace cc { 25 namespace cc {
26 26
27 class ContextProvider; 27 class ContextProvider;
28 class InputHandlerClient; 28 class InputHandlerClient;
29 class LayerTreeHost; 29 class LayerTreeHost;
30 class ResourceUpdateQueue; 30 class ResourceUpdateQueue;
31 class Scheduler; 31 class Scheduler;
32 class ScopedThreadProxy; 32 class ScopedThreadProxy;
33 33
34 class ThreadProxy : public Proxy, 34 class CC_EXPORT ThreadProxy : public Proxy,
35 LayerTreeHostImplClient, 35 NON_EXPORTED_BASE(LayerTreeHostImplClient),
36 SchedulerClient, 36 NON_EXPORTED_BASE(SchedulerClient),
37 ResourceUpdateControllerClient { 37 NON_EXPORTED_BASE(ResourceUpdateControllerClient) {
38 public: 38 public:
39 static scoped_ptr<Proxy> Create( 39 static scoped_ptr<Proxy> Create(
40 LayerTreeHost* layer_tree_host, 40 LayerTreeHost* layer_tree_host,
41 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); 41 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
42 42
43 virtual ~ThreadProxy(); 43 virtual ~ThreadProxy();
44 44
45 struct BeginMainFrameAndCommitState {
46 BeginMainFrameAndCommitState();
47 ~BeginMainFrameAndCommitState();
48
49 base::TimeTicks monotonic_frame_begin_time;
50 scoped_ptr<ScrollAndScaleSet> scroll_info;
51 size_t memory_allocation_limit_bytes;
52 int memory_allocation_priority_cutoff;
53 bool evicted_ui_resources;
54 };
55
56 struct MainThreadOnly {
57 MainThreadOnly(ThreadProxy* proxy, int layer_tree_host_id);
58 ~MainThreadOnly();
59
60 const int layer_tree_host_id;
61
62 // Set only when SetNeedsAnimate is called.
63 bool animate_requested;
64 // Set only when SetNeedsCommit is called.
65 bool commit_requested;
66 // Set by SetNeedsAnimate, SetNeedsUpdateLayers, and SetNeedsCommit.
67 bool commit_request_sent_to_impl_thread;
68
69 bool started;
70 bool manage_tiles_pending;
71 bool can_cancel_commit;
72 bool defer_commits;
73
74 base::CancelableClosure output_surface_creation_callback;
75 RendererCapabilities renderer_capabilities_main_thread_copy;
76
77 scoped_ptr<BeginMainFrameAndCommitState> pending_deferred_commit;
78 base::WeakPtrFactory<ThreadProxy> weak_factory;
79 };
80
81 // Accessed on the main thread, or when main thread is blocked.
82 struct MainThreadOrBlockedMainThread {
83 explicit MainThreadOrBlockedMainThread(LayerTreeHost* host);
84 ~MainThreadOrBlockedMainThread();
85
86 PrioritizedResourceManager* contents_texture_manager();
87
88 LayerTreeHost* layer_tree_host;
89 bool commit_waits_for_activation;
90 bool main_thread_inside_commit;
91
92 base::TimeTicks last_monotonic_frame_begin_time;
93 };
94
95 struct ReadbackRequest;
96
97 struct CompositorThreadOnly {
98 CompositorThreadOnly(ThreadProxy* proxy, int layer_tree_host_id);
99 ~CompositorThreadOnly();
100
101 const int layer_tree_host_id;
102
103 // Copy of the main thread side contents texture manager for work
104 // that needs to be done on the compositor thread.
105 PrioritizedResourceManager* contents_texture_manager;
106
107 scoped_ptr<Scheduler> scheduler;
108
109 // Set when the main thread is waiting on a
110 // ScheduledActionSendBeginMainFrame to be issued.
111 CompletionEvent* begin_main_frame_sent_completion_event;
112
113 // Set when the main thread is waiting on a commit to complete.
114 CompletionEvent* commit_completion_event;
115
116 // Set when the main thread is waiting on a pending tree activation.
117 CompletionEvent* completion_event_for_commit_held_on_tree_activation;
118
119 scoped_ptr<ResourceUpdateController> current_resource_update_controller;
120
121 // Set when the next draw should post DidCommitAndDrawFrame to the main
122 // thread.
123 bool next_frame_is_newly_committed_frame;
124
125 bool inside_draw;
126
127 bool input_throttled_until_commit;
128
129 // Set when we freeze animations to avoid checkerboarding.
130 bool animations_frozen_until_next_draw;
131 base::TimeTicks animation_time;
132
133 // Whether a commit has been completed since the last time animations were
134 // ticked. If this happens, we need to animate again.
135 bool did_commit_after_animating;
136
137 base::TimeTicks smoothness_takes_priority_expiration_time;
138 bool renew_tree_priority_pending;
139
140 ProxyTimingHistory timing_history;
141
142 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl;
143 base::WeakPtrFactory<ThreadProxy> weak_factory;
144 };
145
146 const MainThreadOnly& main() const;
147 const MainThreadOrBlockedMainThread& blocked_main() const;
148 const CompositorThreadOnly& impl() const;
149
45 // Proxy implementation 150 // Proxy implementation
46 virtual void FinishAllRendering() OVERRIDE; 151 virtual void FinishAllRendering() OVERRIDE;
47 virtual bool IsStarted() const OVERRIDE; 152 virtual bool IsStarted() const OVERRIDE;
48 virtual void SetLayerTreeHostClientReady() OVERRIDE; 153 virtual void SetLayerTreeHostClientReady() OVERRIDE;
49 virtual void SetVisible(bool visible) OVERRIDE; 154 virtual void SetVisible(bool visible) OVERRIDE;
50 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; 155 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE;
51 virtual void SetNeedsAnimate() OVERRIDE; 156 virtual void SetNeedsAnimate() OVERRIDE;
52 virtual void SetNeedsUpdateLayers() OVERRIDE; 157 virtual void SetNeedsUpdateLayers() OVERRIDE;
53 virtual void SetNeedsCommit() OVERRIDE; 158 virtual void SetNeedsCommit() OVERRIDE;
54 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) OVERRIDE; 159 virtual void SetNeedsRedraw(const gfx::Rect& damage_rect) OVERRIDE;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 virtual void ScheduledActionManageTiles() OVERRIDE; 222 virtual void ScheduledActionManageTiles() OVERRIDE;
118 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; 223 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE;
119 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE; 224 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE;
120 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE; 225 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE;
121 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE; 226 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE;
122 virtual void DidBeginImplFrameDeadline() OVERRIDE; 227 virtual void DidBeginImplFrameDeadline() OVERRIDE;
123 228
124 // ResourceUpdateControllerClient implementation 229 // ResourceUpdateControllerClient implementation
125 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; 230 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE;
126 231
127 private: 232 protected:
128 ThreadProxy(LayerTreeHost* layer_tree_host, 233 ThreadProxy(LayerTreeHost* layer_tree_host,
129 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); 234 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
130 235
131 struct BeginMainFrameAndCommitState { 236 private:
132 BeginMainFrameAndCommitState();
133 ~BeginMainFrameAndCommitState();
134
135 base::TimeTicks monotonic_frame_begin_time;
136 scoped_ptr<ScrollAndScaleSet> scroll_info;
137 size_t memory_allocation_limit_bytes;
138 int memory_allocation_priority_cutoff;
139 bool evicted_ui_resources;
140 };
141
142 // Called on main thread. 237 // Called on main thread.
143 void SetRendererCapabilitiesMainThreadCopy( 238 void SetRendererCapabilitiesMainThreadCopy(
144 const RendererCapabilities& capabilities); 239 const RendererCapabilities& capabilities);
145 void BeginMainFrame( 240 void BeginMainFrame(
146 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); 241 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state);
147 void DidCommitAndDrawFrame(); 242 void DidCommitAndDrawFrame();
148 void DidCompleteSwapBuffers(); 243 void DidCompleteSwapBuffers();
149 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); 244 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue);
150 void CreateAndInitializeOutputSurface(); 245 void CreateAndInitializeOutputSurface();
151 void DoCreateAndInitializeOutputSurface(); 246 void DoCreateAndInitializeOutputSurface();
152 void SendCommitRequestToImplThreadIfNeeded(); 247 void SendCommitRequestToImplThreadIfNeeded();
153 248
154 // Called on impl thread. 249 // Called on impl thread.
155 struct CommitPendingRequest; 250 struct CommitPendingRequest;
156 struct SchedulerStateRequest; 251 struct SchedulerStateRequest;
157 252
158 void StartCommitOnImplThread(CompletionEvent* completion, 253 void StartCommitOnImplThread(CompletionEvent* completion,
159 ResourceUpdateQueue* queue); 254 ResourceUpdateQueue* queue);
160 void BeginMainFrameAbortedOnImplThread(bool did_handle); 255 void BeginMainFrameAbortedOnImplThread(bool did_handle);
161 void FinishAllRenderingOnImplThread(CompletionEvent* completion); 256 void FinishAllRenderingOnImplThread(CompletionEvent* completion);
162 void InitializeImplOnImplThread(CompletionEvent* completion); 257 void InitializeImplOnImplThread(CompletionEvent* completion);
163 void SetLayerTreeHostClientReadyOnImplThread(); 258 void SetLayerTreeHostClientReadyOnImplThread();
164 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); 259 void SetVisibleOnImplThread(CompletionEvent* completion, bool visible);
165 void UpdateBackgroundAnimateTicking(); 260 void UpdateBackgroundAnimateTicking();
166 void HasInitializedOutputSurfaceOnImplThread( 261 void HasInitializedOutputSurfaceOnImplThread(
167 CompletionEvent* completion, 262 CompletionEvent* completion,
168 bool* has_initialized_output_surface); 263 bool* has_initialized_output_surface);
169 void InitializeOutputSurfaceOnImplThread( 264 virtual void InitializeOutputSurfaceOnImplThread(
170 CompletionEvent* completion, 265 CompletionEvent* completion,
171 scoped_ptr<OutputSurface> output_surface, 266 scoped_ptr<OutputSurface> output_surface,
172 bool* success, 267 bool* success,
173 RendererCapabilities* capabilities); 268 RendererCapabilities* capabilities);
174 void FinishGLOnImplThread(CompletionEvent* completion); 269 void FinishGLOnImplThread(CompletionEvent* completion);
175 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion); 270 void LayerTreeHostClosedOnImplThread(CompletionEvent* completion);
176 DrawResult DrawSwapInternal(bool forced_draw); 271 DrawResult DrawSwapInternal(bool forced_draw);
177 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion); 272 void ForceSerializeOnSwapBuffersOnImplThread(CompletionEvent* completion);
178 void CheckOutputSurfaceStatusOnImplThread(); 273 void CheckOutputSurfaceStatusOnImplThread();
179 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request); 274 void CommitPendingOnImplThreadForTesting(CommitPendingRequest* request);
180 void SchedulerAsValueOnImplThreadForTesting(SchedulerStateRequest* request); 275 void SchedulerAsValueOnImplThreadForTesting(SchedulerStateRequest* request);
181 void AsValueOnImplThread(CompletionEvent* completion, 276 void AsValueOnImplThread(CompletionEvent* completion,
182 base::DictionaryValue* state) const; 277 base::DictionaryValue* state) const;
183 void RenewTreePriorityOnImplThread(); 278 void RenewTreePriorityOnImplThread();
184 void SetSwapUsedIncompleteTileOnImplThread(bool used_incomplete_tile); 279 void SetSwapUsedIncompleteTileOnImplThread(bool used_incomplete_tile);
185 void MainThreadHasStoppedFlingingOnImplThread(); 280 void MainThreadHasStoppedFlingingOnImplThread();
186 void SetInputThrottledUntilCommitOnImplThread(bool is_throttled); 281 void SetInputThrottledUntilCommitOnImplThread(bool is_throttled);
187 void SetDebugStateOnImplThread(const LayerTreeDebugState& debug_state); 282 void SetDebugStateOnImplThread(const LayerTreeDebugState& debug_state);
188 283
189 LayerTreeHost* layer_tree_host(); 284 LayerTreeHost* layer_tree_host();
190 const LayerTreeHost* layer_tree_host() const; 285 const LayerTreeHost* layer_tree_host() const;
191 286
192 struct MainThreadOnly {
193 MainThreadOnly(ThreadProxy* proxy, int layer_tree_host_id);
194 ~MainThreadOnly();
195
196 const int layer_tree_host_id;
197
198 // Set only when SetNeedsAnimate is called.
199 bool animate_requested;
200 // Set only when SetNeedsCommit is called.
201 bool commit_requested;
202 // Set by SetNeedsAnimate, SetNeedsUpdateLayers, and SetNeedsCommit.
203 bool commit_request_sent_to_impl_thread;
204
205 bool started;
206 bool manage_tiles_pending;
207 bool can_cancel_commit;
208 bool defer_commits;
209
210 base::CancelableClosure output_surface_creation_callback;
211 RendererCapabilities renderer_capabilities_main_thread_copy;
212
213 scoped_ptr<BeginMainFrameAndCommitState> pending_deferred_commit;
214 base::WeakPtrFactory<ThreadProxy> weak_factory;
215 };
216 // Use accessors instead of this variable directly. 287 // Use accessors instead of this variable directly.
217 MainThreadOnly main_thread_only_vars_unsafe_; 288 MainThreadOnly main_thread_only_vars_unsafe_;
218 MainThreadOnly& main(); 289 MainThreadOnly& main();
219 const MainThreadOnly& main() const;
220 290
221 // Accessed on the main thread, or when main thread is blocked.
222 struct MainThreadOrBlockedMainThread {
223 explicit MainThreadOrBlockedMainThread(LayerTreeHost* host);
224 ~MainThreadOrBlockedMainThread();
225
226 PrioritizedResourceManager* contents_texture_manager();
227
228 LayerTreeHost* layer_tree_host;
229 bool commit_waits_for_activation;
230 bool main_thread_inside_commit;
231
232 base::TimeTicks last_monotonic_frame_begin_time;
233 };
234 // Use accessors instead of this variable directly. 291 // Use accessors instead of this variable directly.
235 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; 292 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_;
236 MainThreadOrBlockedMainThread& blocked_main(); 293 MainThreadOrBlockedMainThread& blocked_main();
237 const MainThreadOrBlockedMainThread& blocked_main() const;
238 294
239 struct CompositorThreadOnly {
240 CompositorThreadOnly(ThreadProxy* proxy, int layer_tree_host_id);
241 ~CompositorThreadOnly();
242
243 const int layer_tree_host_id;
244
245 // Copy of the main thread side contents texture manager for work
246 // that needs to be done on the compositor thread.
247 PrioritizedResourceManager* contents_texture_manager;
248
249 scoped_ptr<Scheduler> scheduler;
250
251 // Set when the main thread is waiting on a
252 // ScheduledActionSendBeginMainFrame to be issued.
253 CompletionEvent* begin_main_frame_sent_completion_event;
254
255 // Set when the main thread is waiting on a commit to complete.
256 CompletionEvent* commit_completion_event;
257
258 // Set when the main thread is waiting on a pending tree activation.
259 CompletionEvent* completion_event_for_commit_held_on_tree_activation;
260
261 scoped_ptr<ResourceUpdateController> current_resource_update_controller;
262
263 // Set when the next draw should post DidCommitAndDrawFrame to the main
264 // thread.
265 bool next_frame_is_newly_committed_frame;
266
267 bool inside_draw;
268
269 bool input_throttled_until_commit;
270
271 // Set when we freeze animations to avoid checkerboarding.
272 bool animations_frozen_until_next_draw;
273 base::TimeTicks animation_time;
274
275 // Whether a commit has been completed since the last time animations were
276 // ticked. If this happens, we need to animate again.
277 bool did_commit_after_animating;
278
279 base::TimeTicks smoothness_takes_priority_expiration_time;
280 bool renew_tree_priority_pending;
281
282 ProxyTimingHistory timing_history;
283
284 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl;
285 base::WeakPtrFactory<ThreadProxy> weak_factory;
286 };
287 // Use accessors instead of this variable directly. 295 // Use accessors instead of this variable directly.
288 CompositorThreadOnly compositor_thread_vars_unsafe_; 296 CompositorThreadOnly compositor_thread_vars_unsafe_;
289 CompositorThreadOnly& impl(); 297 CompositorThreadOnly& impl();
290 const CompositorThreadOnly& impl() const;
291 298
292 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; 299 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_;
293 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; 300 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_;
294 301
295 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); 302 DISALLOW_COPY_AND_ASSIGN(ThreadProxy);
296 }; 303 };
297 304
298 } // namespace cc 305 } // namespace cc
299 306
300 #endif // CC_TREES_THREAD_PROXY_H_ 307 #endif // CC_TREES_THREAD_PROXY_H_
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698