| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 explicit CompositorLock(Compositor* compositor); | 141 explicit CompositorLock(Compositor* compositor); |
| 142 ~CompositorLock(); | 142 ~CompositorLock(); |
| 143 | 143 |
| 144 void CancelLock(); | 144 void CancelLock(); |
| 145 | 145 |
| 146 Compositor* compositor_; | 146 Compositor* compositor_; |
| 147 DISALLOW_COPY_AND_ASSIGN(CompositorLock); | 147 DISALLOW_COPY_AND_ASSIGN(CompositorLock); |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 // This class observes BeginFrame notification from LayerTreeHost. | |
| 151 class COMPOSITOR_EXPORT CompositorBeginFrameObserver { | |
| 152 public: | |
| 153 virtual ~CompositorBeginFrameObserver() {} | |
| 154 virtual void OnSendBeginFrame(const cc::BeginFrameArgs& args) = 0; | |
| 155 }; | |
| 156 | |
| 157 // Compositor object to take care of GPU painting. | 150 // Compositor object to take care of GPU painting. |
| 158 // A Browser compositor object is responsible for generating the final | 151 // A Browser compositor object is responsible for generating the final |
| 159 // displayable form of pixels comprising a single widget's contents. It draws an | 152 // displayable form of pixels comprising a single widget's contents. It draws an |
| 160 // appropriately transformed texture for each transformed view in the widget's | 153 // appropriately transformed texture for each transformed view in the widget's |
| 161 // view hierarchy. | 154 // view hierarchy. |
| 162 class COMPOSITOR_EXPORT Compositor | 155 class COMPOSITOR_EXPORT Compositor |
| 163 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 156 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
| 164 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { | 157 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { |
| 165 public: | 158 public: |
| 166 Compositor(ui::ContextFactory* context_factory, | 159 Compositor(ui::ContextFactory* context_factory, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // Compositor does not own observers. It is the responsibility of the | 249 // Compositor does not own observers. It is the responsibility of the |
| 257 // observer to remove itself when it is done observing. | 250 // observer to remove itself when it is done observing. |
| 258 void AddObserver(CompositorObserver* observer); | 251 void AddObserver(CompositorObserver* observer); |
| 259 void RemoveObserver(CompositorObserver* observer); | 252 void RemoveObserver(CompositorObserver* observer); |
| 260 bool HasObserver(const CompositorObserver* observer) const; | 253 bool HasObserver(const CompositorObserver* observer) const; |
| 261 | 254 |
| 262 void AddAnimationObserver(CompositorAnimationObserver* observer); | 255 void AddAnimationObserver(CompositorAnimationObserver* observer); |
| 263 void RemoveAnimationObserver(CompositorAnimationObserver* observer); | 256 void RemoveAnimationObserver(CompositorAnimationObserver* observer); |
| 264 bool HasAnimationObserver(const CompositorAnimationObserver* observer) const; | 257 bool HasAnimationObserver(const CompositorAnimationObserver* observer) const; |
| 265 | 258 |
| 266 void AddBeginFrameObserver(CompositorBeginFrameObserver* observer); | |
| 267 void RemoveBeginFrameObserver(CompositorBeginFrameObserver* observer); | |
| 268 | |
| 269 // Change the timeout behavior for all future locks that are created. Locks | 259 // Change the timeout behavior for all future locks that are created. Locks |
| 270 // should time out if there is an expectation that the compositor will be | 260 // should time out if there is an expectation that the compositor will be |
| 271 // responsive. | 261 // responsive. |
| 272 void SetLocksWillTimeOut(bool locks_will_time_out) { | 262 void SetLocksWillTimeOut(bool locks_will_time_out) { |
| 273 locks_will_time_out_ = locks_will_time_out; | 263 locks_will_time_out_ = locks_will_time_out; |
| 274 } | 264 } |
| 275 | 265 |
| 276 // Creates a compositor lock. Returns NULL if it is not possible to lock at | 266 // Creates a compositor lock. Returns NULL if it is not possible to lock at |
| 277 // this time (i.e. we're waiting to complete a previous unlock). | 267 // this time (i.e. we're waiting to complete a previous unlock). |
| 278 scoped_refptr<CompositorLock> GetCompositorLock(); | 268 scoped_refptr<CompositorLock> GetCompositorLock(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 301 float page_scale, | 291 float page_scale, |
| 302 float top_controls_delta) override {} | 292 float top_controls_delta) override {} |
| 303 void RequestNewOutputSurface() override; | 293 void RequestNewOutputSurface() override; |
| 304 void DidInitializeOutputSurface() override; | 294 void DidInitializeOutputSurface() override; |
| 305 void DidFailToInitializeOutputSurface() override; | 295 void DidFailToInitializeOutputSurface() override; |
| 306 void WillCommit() override {} | 296 void WillCommit() override {} |
| 307 void DidCommit() override; | 297 void DidCommit() override; |
| 308 void DidCommitAndDrawFrame() override; | 298 void DidCommitAndDrawFrame() override; |
| 309 void DidCompleteSwapBuffers() override; | 299 void DidCompleteSwapBuffers() override; |
| 310 void DidCompletePageScaleAnimation() override {} | 300 void DidCompletePageScaleAnimation() override {} |
| 311 void SendBeginFramesToChildren(const cc::BeginFrameArgs& args) override; | |
| 312 void RecordFrameTimingEvents( | 301 void RecordFrameTimingEvents( |
| 313 std::unique_ptr<cc::FrameTimingTracker::CompositeTimingSet> | 302 std::unique_ptr<cc::FrameTimingTracker::CompositeTimingSet> |
| 314 composite_events, | 303 composite_events, |
| 315 std::unique_ptr<cc::FrameTimingTracker::MainFrameTimingSet> | 304 std::unique_ptr<cc::FrameTimingTracker::MainFrameTimingSet> |
| 316 main_frame_events) override {} | 305 main_frame_events) override {} |
| 317 | 306 |
| 318 // cc::LayerTreeHostSingleThreadClient implementation. | 307 // cc::LayerTreeHostSingleThreadClient implementation. |
| 319 void DidPostSwapBuffers() override; | 308 void DidPostSwapBuffers() override; |
| 320 void DidAbortSwapBuffers() override; | 309 void DidAbortSwapBuffers() override; |
| 321 | 310 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 347 | 336 |
| 348 gfx::Size size_; | 337 gfx::Size size_; |
| 349 | 338 |
| 350 ui::ContextFactory* context_factory_; | 339 ui::ContextFactory* context_factory_; |
| 351 | 340 |
| 352 // The root of the Layer tree drawn by this compositor. | 341 // The root of the Layer tree drawn by this compositor. |
| 353 Layer* root_layer_; | 342 Layer* root_layer_; |
| 354 | 343 |
| 355 base::ObserverList<CompositorObserver, true> observer_list_; | 344 base::ObserverList<CompositorObserver, true> observer_list_; |
| 356 base::ObserverList<CompositorAnimationObserver> animation_observer_list_; | 345 base::ObserverList<CompositorAnimationObserver> animation_observer_list_; |
| 357 base::ObserverList<CompositorBeginFrameObserver, true> | |
| 358 begin_frame_observer_list_; | |
| 359 | 346 |
| 360 gfx::AcceleratedWidget widget_; | 347 gfx::AcceleratedWidget widget_; |
| 361 bool widget_valid_; | 348 bool widget_valid_; |
| 362 bool output_surface_requested_; | 349 bool output_surface_requested_; |
| 363 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | 350 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
| 364 scoped_refptr<cc::Layer> root_web_layer_; | 351 scoped_refptr<cc::Layer> root_web_layer_; |
| 365 std::unique_ptr<cc::LayerTreeHost> host_; | 352 std::unique_ptr<cc::LayerTreeHost> host_; |
| 366 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 353 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 367 | 354 |
| 368 // The manager of vsync parameters for this compositor. | 355 // The manager of vsync parameters for this compositor. |
| 369 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 356 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
| 370 | 357 |
| 371 // The device scale factor of the monitor that this compositor is compositing | 358 // The device scale factor of the monitor that this compositor is compositing |
| 372 // layers on. | 359 // layers on. |
| 373 float device_scale_factor_; | 360 float device_scale_factor_; |
| 374 | 361 |
| 375 int last_started_frame_; | 362 int last_started_frame_; |
| 376 int last_ended_frame_; | 363 int last_ended_frame_; |
| 377 | 364 |
| 378 bool locks_will_time_out_; | 365 bool locks_will_time_out_; |
| 379 CompositorLock* compositor_lock_; | 366 CompositorLock* compositor_lock_; |
| 380 | 367 |
| 381 LayerAnimatorCollection layer_animator_collection_; | 368 LayerAnimatorCollection layer_animator_collection_; |
| 382 scoped_refptr<cc::AnimationTimeline> animation_timeline_; | 369 scoped_refptr<cc::AnimationTimeline> animation_timeline_; |
| 383 | 370 |
| 384 // Used to send to any new CompositorBeginFrameObserver immediately. | |
| 385 cc::BeginFrameArgs missed_begin_frame_args_; | |
| 386 | |
| 387 base::WeakPtrFactory<Compositor> weak_ptr_factory_; | 371 base::WeakPtrFactory<Compositor> weak_ptr_factory_; |
| 388 | 372 |
| 389 DISALLOW_COPY_AND_ASSIGN(Compositor); | 373 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 390 }; | 374 }; |
| 391 | 375 |
| 392 } // namespace ui | 376 } // namespace ui |
| 393 | 377 |
| 394 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 378 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |