Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 250 float top_controls_delta) override {} | 257 float top_controls_delta) override {} |
| 251 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 258 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
| 252 float page_scale, | 259 float page_scale, |
| 253 float top_controls_delta) override {} | 260 float top_controls_delta) override {} |
| 254 void RequestNewOutputSurface(bool fallback) override; | 261 void RequestNewOutputSurface(bool fallback) override; |
| 255 void DidInitializeOutputSurface() override {} | 262 void DidInitializeOutputSurface() override {} |
| 256 void WillCommit() override {} | 263 void WillCommit() override {} |
| 257 void DidCommit() override; | 264 void DidCommit() override; |
| 258 void DidCommitAndDrawFrame() override; | 265 void DidCommitAndDrawFrame() override; |
| 259 void DidCompleteSwapBuffers() override; | 266 void DidCompleteSwapBuffers() override; |
| 267 void SendBeginFramesToChildren(const cc::BeginFrameArgs& args) override; | |
| 260 | 268 |
| 261 // cc::LayerTreeHostSingleThreadClient implementation. | 269 // cc::LayerTreeHostSingleThreadClient implementation. |
| 262 void DidPostSwapBuffers() override; | 270 void DidPostSwapBuffers() override; |
| 263 void DidAbortSwapBuffers() override; | 271 void DidAbortSwapBuffers() override; |
| 264 | 272 |
| 265 bool IsLocked() { return compositor_lock_ != NULL; } | 273 bool IsLocked() { return compositor_lock_ != NULL; } |
| 266 | 274 |
| 267 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 275 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
| 268 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 276 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
| 269 const cc::RendererSettings& GetRendererSettings() const; | 277 const cc::RendererSettings& GetRendererSettings() const; |
| 270 | 278 |
| 271 LayerAnimatorCollection* layer_animator_collection() { | 279 LayerAnimatorCollection* layer_animator_collection() { |
| 272 return &layer_animator_collection_; | 280 return &layer_animator_collection_; |
| 273 } | 281 } |
| 274 | 282 |
| 275 cc::SurfaceIdAllocator* surface_id_allocator() { | 283 cc::SurfaceIdAllocator* surface_id_allocator() { |
| 276 return surface_id_allocator_.get(); | 284 return surface_id_allocator_.get(); |
| 277 } | 285 } |
| 278 | 286 |
| 279 private: | 287 private: |
| 280 friend class base::RefCounted<Compositor>; | 288 friend class base::RefCounted<Compositor>; |
| 281 friend class CompositorLock; | 289 friend class CompositorLock; |
| 282 | 290 |
| 283 // Called by CompositorLock. | 291 // Called by CompositorLock. |
| 284 void UnlockCompositor(); | 292 void UnlockCompositor(); |
| 285 | 293 |
| 286 // Called to release any pending CompositorLock | 294 // Called to release any pending CompositorLock |
| 287 void CancelCompositorLock(); | 295 void CancelCompositorLock(); |
| 288 | 296 |
| 297 // Request scheduling of next BeginFrame to LayerTreeHost. | |
| 298 void SetChildrenNeedBeginFrames(bool need_begin_frame); | |
| 299 | |
| 289 gfx::Size size_; | 300 gfx::Size size_; |
| 290 | 301 |
| 291 ui::ContextFactory* context_factory_; | 302 ui::ContextFactory* context_factory_; |
| 292 | 303 |
| 293 // The root of the Layer tree drawn by this compositor. | 304 // The root of the Layer tree drawn by this compositor. |
| 294 Layer* root_layer_; | 305 Layer* root_layer_; |
| 295 | 306 |
| 296 ObserverList<CompositorObserver> observer_list_; | 307 ObserverList<CompositorObserver> observer_list_; |
| 297 ObserverList<CompositorAnimationObserver> animation_observer_list_; | 308 ObserverList<CompositorAnimationObserver> animation_observer_list_; |
| 309 ObserverList<CompositorBeginFrameObserver> begin_frame_observer_list_; | |
| 298 | 310 |
| 299 gfx::AcceleratedWidget widget_; | 311 gfx::AcceleratedWidget widget_; |
| 300 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | 312 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
| 301 scoped_refptr<cc::Layer> root_web_layer_; | 313 scoped_refptr<cc::Layer> root_web_layer_; |
| 302 scoped_ptr<cc::LayerTreeHost> host_; | 314 scoped_ptr<cc::LayerTreeHost> host_; |
| 303 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; | 315 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; |
| 304 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 316 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 305 | 317 |
| 306 // The manager of vsync parameters for this compositor. | 318 // The manager of vsync parameters for this compositor. |
| 307 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 319 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
| 308 | 320 |
| 309 // The device scale factor of the monitor that this compositor is compositing | 321 // The device scale factor of the monitor that this compositor is compositing |
| 310 // layers on. | 322 // layers on. |
| 311 float device_scale_factor_; | 323 float device_scale_factor_; |
| 312 | 324 |
| 313 int last_started_frame_; | 325 int last_started_frame_; |
| 314 int last_ended_frame_; | 326 int last_ended_frame_; |
| 315 | 327 |
| 316 bool disable_schedule_composite_; | 328 bool disable_schedule_composite_; |
| 317 | 329 |
| 318 CompositorLock* compositor_lock_; | 330 CompositorLock* compositor_lock_; |
| 319 | 331 |
| 320 LayerAnimatorCollection layer_animator_collection_; | 332 LayerAnimatorCollection layer_animator_collection_; |
| 321 | 333 |
| 334 // Used to send to any new CompositorBeginFrameObserver immediately. | |
|
mithro-old
2014/12/16 10:50:58
BTW Do we actually want this functionality?
simonhong
2014/12/16 15:13:30
I think this is useful when new observer is added.
| |
| 335 cc::BeginFrameArgs missed_begin_frame_args_; | |
| 336 | |
| 322 base::WeakPtrFactory<Compositor> weak_ptr_factory_; | 337 base::WeakPtrFactory<Compositor> weak_ptr_factory_; |
| 323 | 338 |
| 324 DISALLOW_COPY_AND_ASSIGN(Compositor); | 339 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 325 }; | 340 }; |
| 326 | 341 |
| 327 } // namespace ui | 342 } // namespace ui |
| 328 | 343 |
| 329 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 344 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |