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

Side by Side Diff: ui/compositor/compositor.h

Issue 775143003: cc: Implement unified BeginFrame on aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_COMPOSITOR_COMPOSITOR_H_ 5 #ifndef UI_COMPOSITOR_COMPOSITOR_H_
6 #define UI_COMPOSITOR_COMPOSITOR_H_ 6 #define UI_COMPOSITOR_COMPOSITOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "cc/output/begin_frame_args.h"
16 #include "cc/surfaces/surface_sequence.h" 17 #include "cc/surfaces/surface_sequence.h"
17 #include "cc/trees/layer_tree_host_client.h" 18 #include "cc/trees/layer_tree_host_client.h"
18 #include "cc/trees/layer_tree_host_single_thread_client.h" 19 #include "cc/trees/layer_tree_host_single_thread_client.h"
19 #include "third_party/skia/include/core/SkColor.h" 20 #include "third_party/skia/include/core/SkColor.h"
21 #include "ui/base/compositor/compositor_begin_frame_observer.h"
20 #include "ui/compositor/compositor_animation_observer.h" 22 #include "ui/compositor/compositor_animation_observer.h"
21 #include "ui/compositor/compositor_export.h" 23 #include "ui/compositor/compositor_export.h"
22 #include "ui/compositor/compositor_observer.h" 24 #include "ui/compositor/compositor_observer.h"
23 #include "ui/compositor/layer_animator_collection.h" 25 #include "ui/compositor/layer_animator_collection.h"
24 #include "ui/gfx/native_widget_types.h" 26 #include "ui/gfx/native_widget_types.h"
25 #include "ui/gfx/size.h" 27 #include "ui/gfx/size.h"
26 #include "ui/gfx/vector2d.h" 28 #include "ui/gfx/vector2d.h"
27 29
28 namespace base { 30 namespace base {
29 class MessageLoopProxy; 31 class MessageLoopProxy;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Compositor does not own observers. It is the responsibility of the 218 // Compositor does not own observers. It is the responsibility of the
217 // observer to remove itself when it is done observing. 219 // observer to remove itself when it is done observing.
218 void AddObserver(CompositorObserver* observer); 220 void AddObserver(CompositorObserver* observer);
219 void RemoveObserver(CompositorObserver* observer); 221 void RemoveObserver(CompositorObserver* observer);
220 bool HasObserver(const CompositorObserver* observer) const; 222 bool HasObserver(const CompositorObserver* observer) const;
221 223
222 void AddAnimationObserver(CompositorAnimationObserver* observer); 224 void AddAnimationObserver(CompositorAnimationObserver* observer);
223 void RemoveAnimationObserver(CompositorAnimationObserver* observer); 225 void RemoveAnimationObserver(CompositorAnimationObserver* observer);
224 bool HasAnimationObserver(const CompositorAnimationObserver* observer) const; 226 bool HasAnimationObserver(const CompositorAnimationObserver* observer) const;
225 227
228 void AddBeginFrameObserver(
229 CompositorBeginFrameObserver* observer,
230 const cc::BeginFrameArgs& last_begin_frame_args_sent_to_observer);
231 void RemoveBeginFrameObserver(CompositorBeginFrameObserver* observer);
232
226 // Creates a compositor lock. Returns NULL if it is not possible to lock at 233 // Creates a compositor lock. Returns NULL if it is not possible to lock at
227 // this time (i.e. we're waiting to complete a previous unlock). 234 // this time (i.e. we're waiting to complete a previous unlock).
228 scoped_refptr<CompositorLock> GetCompositorLock(); 235 scoped_refptr<CompositorLock> GetCompositorLock();
229 236
230 // Internal functions, called back by command-buffer contexts on swap buffer 237 // Internal functions, called back by command-buffer contexts on swap buffer
231 // events. 238 // events.
232 239
233 // Signals swap has been posted. 240 // Signals swap has been posted.
234 void OnSwapBuffersPosted(); 241 void OnSwapBuffersPosted();
235 242
236 // Signals swap has completed. 243 // Signals swap has completed.
237 void OnSwapBuffersComplete(); 244 void OnSwapBuffersComplete();
238 245
239 // Signals swap has aborted (e.g. lost context). 246 // Signals swap has aborted (e.g. lost context).
240 void OnSwapBuffersAborted(); 247 void OnSwapBuffersAborted();
241 248
249 // The "authoritative" vsync interval, if provided, will override interval
250 // reported from 3D context. This is typically the value reported by a more
251 // reliable source, e.g, the platform display configuration.
252 // In the particular case of ChromeOS -- this is the value queried through
253 // XRandR, which is more reliable than the value queried through the 3D
254 // context.
255 void SetAuthoritativeVSyncInterval(base::TimeDelta interval) const;
256
242 // LayerTreeHostClient implementation. 257 // LayerTreeHostClient implementation.
243 void WillBeginMainFrame(int frame_id) override {} 258 void WillBeginMainFrame(int frame_id) override {}
244 void DidBeginMainFrame() override {} 259 void DidBeginMainFrame() override {}
245 void BeginMainFrame(const cc::BeginFrameArgs& args) override; 260 void BeginMainFrame(const cc::BeginFrameArgs& args) override;
246 void Layout() override; 261 void Layout() override;
247 void ApplyViewportDeltas(const gfx::Vector2d& inner_delta, 262 void ApplyViewportDeltas(const gfx::Vector2d& inner_delta,
248 const gfx::Vector2d& outer_delta, 263 const gfx::Vector2d& outer_delta,
249 float page_scale, 264 float page_scale,
250 float top_controls_delta) override {} 265 float top_controls_delta) override {}
251 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, 266 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
252 float page_scale, 267 float page_scale,
253 float top_controls_delta) override {} 268 float top_controls_delta) override {}
254 void RequestNewOutputSurface(bool fallback) override; 269 void RequestNewOutputSurface(bool fallback) override;
255 void DidInitializeOutputSurface() override {} 270 void DidInitializeOutputSurface() override {}
256 void WillCommit() override {} 271 void WillCommit() override {}
257 void DidCommit() override; 272 void DidCommit() override;
258 void DidCommitAndDrawFrame() override; 273 void DidCommitAndDrawFrame() override;
259 void DidCompleteSwapBuffers() override; 274 void DidCompleteSwapBuffers() override;
275 void SendBeginFramesToChildren(const cc::BeginFrameArgs& args) override;
260 276
261 // cc::LayerTreeHostSingleThreadClient implementation. 277 // cc::LayerTreeHostSingleThreadClient implementation.
262 void DidPostSwapBuffers() override; 278 void DidPostSwapBuffers() override;
263 void DidAbortSwapBuffers() override; 279 void DidAbortSwapBuffers() override;
264 280
265 bool IsLocked() { return compositor_lock_ != NULL; } 281 bool IsLocked() { return compositor_lock_ != NULL; }
266 282
267 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; 283 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const;
268 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); 284 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state);
269 const cc::RendererSettings& GetRendererSettings() const; 285 const cc::RendererSettings& GetRendererSettings() const;
270 286
271 LayerAnimatorCollection* layer_animator_collection() { 287 LayerAnimatorCollection* layer_animator_collection() {
272 return &layer_animator_collection_; 288 return &layer_animator_collection_;
273 } 289 }
274 290
275 cc::SurfaceIdAllocator* surface_id_allocator() { 291 cc::SurfaceIdAllocator* surface_id_allocator() {
276 return surface_id_allocator_.get(); 292 return surface_id_allocator_.get();
277 } 293 }
278 294
279 private: 295 private:
280 friend class base::RefCounted<Compositor>; 296 friend class base::RefCounted<Compositor>;
281 friend class CompositorLock; 297 friend class CompositorLock;
282 298
283 // Called by CompositorLock. 299 // Called by CompositorLock.
284 void UnlockCompositor(); 300 void UnlockCompositor();
285 301
286 // Called to release any pending CompositorLock 302 // Called to release any pending CompositorLock
287 void CancelCompositorLock(); 303 void CancelCompositorLock();
288 304
305 // Request scheduling of next BeginFrame to LayerTreeHost.
306 void SetChildrenNeedBeginFrames(bool need_begin_frame);
307
289 gfx::Size size_; 308 gfx::Size size_;
290 309
291 ui::ContextFactory* context_factory_; 310 ui::ContextFactory* context_factory_;
292 311
293 // The root of the Layer tree drawn by this compositor. 312 // The root of the Layer tree drawn by this compositor.
294 Layer* root_layer_; 313 Layer* root_layer_;
295 314
296 ObserverList<CompositorObserver> observer_list_; 315 ObserverList<CompositorObserver> observer_list_;
297 ObserverList<CompositorAnimationObserver> animation_observer_list_; 316 ObserverList<CompositorAnimationObserver> animation_observer_list_;
317 ObserverList<CompositorBeginFrameObserver> begin_frame_observer_list_;
298 318
299 gfx::AcceleratedWidget widget_; 319 gfx::AcceleratedWidget widget_;
300 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; 320 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
301 scoped_refptr<cc::Layer> root_web_layer_; 321 scoped_refptr<cc::Layer> root_web_layer_;
302 scoped_ptr<cc::LayerTreeHost> host_; 322 scoped_ptr<cc::LayerTreeHost> host_;
303 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; 323 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_;
304 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 324 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
305 325
306 // The manager of vsync parameters for this compositor. 326 // The manager of vsync parameters for this compositor.
327 // TODO(simonhong): Remove CompositorVSyncManager when cros uses STP.
307 scoped_refptr<CompositorVSyncManager> vsync_manager_; 328 scoped_refptr<CompositorVSyncManager> vsync_manager_;
308 329
309 // The device scale factor of the monitor that this compositor is compositing 330 // The device scale factor of the monitor that this compositor is compositing
310 // layers on. 331 // layers on.
311 float device_scale_factor_; 332 float device_scale_factor_;
312 333
313 int last_started_frame_; 334 int last_started_frame_;
314 int last_ended_frame_; 335 int last_ended_frame_;
315 336
316 bool disable_schedule_composite_; 337 bool disable_schedule_composite_;
317 338
318 CompositorLock* compositor_lock_; 339 CompositorLock* compositor_lock_;
319 340
320 LayerAnimatorCollection layer_animator_collection_; 341 LayerAnimatorCollection layer_animator_collection_;
321 342
343 // Used to send to any new CompositorBeginFrameObserver immediately.
344 cc::BeginFrameArgs missed_begin_frame_args_;
345
322 base::WeakPtrFactory<Compositor> weak_ptr_factory_; 346 base::WeakPtrFactory<Compositor> weak_ptr_factory_;
323 347
324 DISALLOW_COPY_AND_ASSIGN(Compositor); 348 DISALLOW_COPY_AND_ASSIGN(Compositor);
325 }; 349 };
326 350
327 } // namespace ui 351 } // namespace ui
328 352
329 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 353 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698