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

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: Makes proxy test more general for single & threaded proxy 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
« cc/test/layer_tree_test.h ('K') | « 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 LayerTreeHostImplClient,
36 SchedulerClient, 36 SchedulerClient,
37 ResourceUpdateControllerClient { 37 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 void CreateAndInitializeOutputSurface() OVERRIDE; 155 virtual void CreateAndInitializeOutputSurface() OVERRIDE;
51 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE; 156 virtual const RendererCapabilities& GetRendererCapabilities() const OVERRIDE;
52 virtual void SetNeedsAnimate() OVERRIDE; 157 virtual void SetNeedsAnimate() OVERRIDE;
53 virtual void SetNeedsUpdateLayers() OVERRIDE; 158 virtual void SetNeedsUpdateLayers() OVERRIDE;
54 virtual void SetNeedsCommit() OVERRIDE; 159 virtual void SetNeedsCommit() OVERRIDE;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 virtual void ScheduledActionManageTiles() OVERRIDE; 224 virtual void ScheduledActionManageTiles() OVERRIDE;
120 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE; 225 virtual void DidAnticipatedDrawTimeChange(base::TimeTicks time) OVERRIDE;
121 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE; 226 virtual base::TimeDelta DrawDurationEstimate() OVERRIDE;
122 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE; 227 virtual base::TimeDelta BeginMainFrameToCommitDurationEstimate() OVERRIDE;
123 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE; 228 virtual base::TimeDelta CommitToActivateDurationEstimate() OVERRIDE;
124 virtual void DidBeginImplFrameDeadline() OVERRIDE; 229 virtual void DidBeginImplFrameDeadline() OVERRIDE;
125 230
126 // ResourceUpdateControllerClient implementation 231 // ResourceUpdateControllerClient implementation
127 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE; 232 virtual void ReadyToFinalizeTextureUpdates() OVERRIDE;
128 233
129 private: 234 protected:
130 ThreadProxy(LayerTreeHost* layer_tree_host, 235 ThreadProxy(LayerTreeHost* layer_tree_host,
131 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); 236 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner);
132 237
133 struct BeginMainFrameAndCommitState { 238 private:
134 BeginMainFrameAndCommitState();
135 ~BeginMainFrameAndCommitState();
136
137 base::TimeTicks monotonic_frame_begin_time;
138 scoped_ptr<ScrollAndScaleSet> scroll_info;
139 size_t memory_allocation_limit_bytes;
140 int memory_allocation_priority_cutoff;
141 bool evicted_ui_resources;
142 };
143
144 // Called on main thread. 239 // Called on main thread.
145 void SetRendererCapabilitiesMainThreadCopy( 240 void SetRendererCapabilitiesMainThreadCopy(
146 const RendererCapabilities& capabilities); 241 const RendererCapabilities& capabilities);
147 void BeginMainFrame( 242 void BeginMainFrame(
148 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state); 243 scoped_ptr<BeginMainFrameAndCommitState> begin_main_frame_state);
149 void DidCommitAndDrawFrame(); 244 void DidCommitAndDrawFrame();
150 void DidCompleteSwapBuffers(); 245 void DidCompleteSwapBuffers();
151 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue); 246 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> queue);
152 void DoCreateAndInitializeOutputSurface(); 247 void DoCreateAndInitializeOutputSurface();
153 void SendCommitRequestToImplThreadIfNeeded(); 248 void SendCommitRequestToImplThreadIfNeeded();
(...skipping 29 matching lines...) Expand all
183 base::DictionaryValue* state) const; 278 base::DictionaryValue* state) const;
184 void RenewTreePriorityOnImplThread(); 279 void RenewTreePriorityOnImplThread();
185 void SetSwapUsedIncompleteTileOnImplThread(bool used_incomplete_tile); 280 void SetSwapUsedIncompleteTileOnImplThread(bool used_incomplete_tile);
186 void MainThreadHasStoppedFlingingOnImplThread(); 281 void MainThreadHasStoppedFlingingOnImplThread();
187 void SetInputThrottledUntilCommitOnImplThread(bool is_throttled); 282 void SetInputThrottledUntilCommitOnImplThread(bool is_throttled);
188 void SetDebugStateOnImplThread(const LayerTreeDebugState& debug_state); 283 void SetDebugStateOnImplThread(const LayerTreeDebugState& debug_state);
189 284
190 LayerTreeHost* layer_tree_host(); 285 LayerTreeHost* layer_tree_host();
191 const LayerTreeHost* layer_tree_host() const; 286 const LayerTreeHost* layer_tree_host() const;
192 287
193 struct MainThreadOnly {
194 MainThreadOnly(ThreadProxy* proxy, int layer_tree_host_id);
195 ~MainThreadOnly();
196
197 const int layer_tree_host_id;
198
199 // Set only when SetNeedsAnimate is called.
200 bool animate_requested;
201 // Set only when SetNeedsCommit is called.
202 bool commit_requested;
203 // Set by SetNeedsAnimate, SetNeedsUpdateLayers, and SetNeedsCommit.
204 bool commit_request_sent_to_impl_thread;
205
206 bool started;
207 bool manage_tiles_pending;
208 bool can_cancel_commit;
209 bool defer_commits;
210
211 base::CancelableClosure output_surface_creation_callback;
212 RendererCapabilities renderer_capabilities_main_thread_copy;
213
214 scoped_ptr<BeginMainFrameAndCommitState> pending_deferred_commit;
215 base::WeakPtrFactory<ThreadProxy> weak_factory;
216 };
217 // Use accessors instead of this variable directly. 288 // Use accessors instead of this variable directly.
218 MainThreadOnly main_thread_only_vars_unsafe_; 289 MainThreadOnly main_thread_only_vars_unsafe_;
219 MainThreadOnly& main(); 290 MainThreadOnly& main();
220 const MainThreadOnly& main() const;
221 291
222 // Accessed on the main thread, or when main thread is blocked.
223 struct MainThreadOrBlockedMainThread {
224 explicit MainThreadOrBlockedMainThread(LayerTreeHost* host);
225 ~MainThreadOrBlockedMainThread();
226
227 PrioritizedResourceManager* contents_texture_manager();
228
229 LayerTreeHost* layer_tree_host;
230 bool commit_waits_for_activation;
231 bool main_thread_inside_commit;
232
233 base::TimeTicks last_monotonic_frame_begin_time;
234 };
235 // Use accessors instead of this variable directly. 292 // Use accessors instead of this variable directly.
236 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_; 293 MainThreadOrBlockedMainThread main_thread_or_blocked_vars_unsafe_;
237 MainThreadOrBlockedMainThread& blocked_main(); 294 MainThreadOrBlockedMainThread& blocked_main();
238 const MainThreadOrBlockedMainThread& blocked_main() const;
239 295
240 struct CompositorThreadOnly {
241 CompositorThreadOnly(ThreadProxy* proxy, int layer_tree_host_id);
242 ~CompositorThreadOnly();
243
244 const int layer_tree_host_id;
245
246 // Copy of the main thread side contents texture manager for work
247 // that needs to be done on the compositor thread.
248 PrioritizedResourceManager* contents_texture_manager;
249
250 scoped_ptr<Scheduler> scheduler;
251
252 // Set when the main thread is waiting on a
253 // ScheduledActionSendBeginMainFrame to be issued.
254 CompletionEvent* begin_main_frame_sent_completion_event;
255
256 // Set when the main thread is waiting on a commit to complete.
257 CompletionEvent* commit_completion_event;
258
259 // Set when the main thread is waiting on a pending tree activation.
260 CompletionEvent* completion_event_for_commit_held_on_tree_activation;
261
262 scoped_ptr<ResourceUpdateController> current_resource_update_controller;
263
264 // Set when the next draw should post DidCommitAndDrawFrame to the main
265 // thread.
266 bool next_frame_is_newly_committed_frame;
267
268 bool inside_draw;
269
270 bool input_throttled_until_commit;
271
272 // Set when we freeze animations to avoid checkerboarding.
273 bool animations_frozen_until_next_draw;
274 base::TimeTicks animation_time;
275
276 // Whether a commit has been completed since the last time animations were
277 // ticked. If this happens, we need to animate again.
278 bool did_commit_after_animating;
279
280 base::TimeTicks smoothness_takes_priority_expiration_time;
281 bool renew_tree_priority_pending;
282
283 ProxyTimingHistory timing_history;
284
285 scoped_ptr<LayerTreeHostImpl> layer_tree_host_impl;
286 base::WeakPtrFactory<ThreadProxy> weak_factory;
287 };
288 // Use accessors instead of this variable directly. 296 // Use accessors instead of this variable directly.
289 CompositorThreadOnly compositor_thread_vars_unsafe_; 297 CompositorThreadOnly compositor_thread_vars_unsafe_;
290 CompositorThreadOnly& impl(); 298 CompositorThreadOnly& impl();
291 const CompositorThreadOnly& impl() const;
292 299
293 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_; 300 base::WeakPtr<ThreadProxy> main_thread_weak_ptr_;
294 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_; 301 base::WeakPtr<ThreadProxy> impl_thread_weak_ptr_;
295 302
296 DISALLOW_COPY_AND_ASSIGN(ThreadProxy); 303 DISALLOW_COPY_AND_ASSIGN(ThreadProxy);
297 }; 304 };
298 305
299 } // namespace cc 306 } // namespace cc
300 307
301 #endif // CC_TREES_THREAD_PROXY_H_ 308 #endif // CC_TREES_THREAD_PROXY_H_
OLDNEW
« cc/test/layer_tree_test.h ('K') | « cc/trees/single_thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698