| 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" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 public: | 67 public: |
| 68 virtual ~ContextFactory() {} | 68 virtual ~ContextFactory() {} |
| 69 | 69 |
| 70 // Creates an output surface for the given compositor. The factory may keep | 70 // Creates an output surface for the given compositor. The factory may keep |
| 71 // per-compositor data (e.g. a shared context), that needs to be cleaned up | 71 // per-compositor data (e.g. a shared context), that needs to be cleaned up |
| 72 // by calling RemoveCompositor when the compositor gets destroyed. | 72 // by calling RemoveCompositor when the compositor gets destroyed. |
| 73 virtual void CreateOutputSurface(base::WeakPtr<Compositor> compositor, | 73 virtual void CreateOutputSurface(base::WeakPtr<Compositor> compositor, |
| 74 bool software_fallback) = 0; | 74 bool software_fallback) = 0; |
| 75 | 75 |
| 76 // Creates a reflector that copies the content of the |mirrored_compositor| | 76 // Creates a reflector that copies the content of the |mirrored_compositor| |
| 77 // onto |mirroing_layer|. | 77 // onto |mirroring_layer|. |
| 78 virtual scoped_refptr<Reflector> CreateReflector( | 78 virtual scoped_refptr<Reflector> CreateReflector( |
| 79 Compositor* mirrored_compositor, | 79 Compositor* mirrored_compositor, |
| 80 Layer* mirroring_layer) = 0; | 80 Layer* mirroring_layer) = 0; |
| 81 // Removes the reflector, which stops the mirroring. | 81 // Removes the reflector, which stops the mirroring. |
| 82 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) = 0; | 82 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) = 0; |
| 83 | 83 |
| 84 // Return a reference to a shared offscreen context provider usable from the | 84 // Return a reference to a shared offscreen context provider usable from the |
| 85 // main thread. | 85 // main thread. |
| 86 virtual scoped_refptr<cc::ContextProvider> | 86 virtual scoped_refptr<cc::ContextProvider> |
| 87 SharedMainThreadContextProvider() = 0; | 87 SharedMainThreadContextProvider() = 0; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 void BeginMainFrame(const cc::BeginFrameArgs& args) override; | 250 void BeginMainFrame(const cc::BeginFrameArgs& args) override; |
| 251 void Layout() override; | 251 void Layout() override; |
| 252 void ApplyViewportDeltas(const gfx::Vector2d& inner_delta, | 252 void ApplyViewportDeltas(const gfx::Vector2d& inner_delta, |
| 253 const gfx::Vector2d& outer_delta, | 253 const gfx::Vector2d& outer_delta, |
| 254 const gfx::Vector2dF& elastic_overscroll_delta, | 254 const gfx::Vector2dF& elastic_overscroll_delta, |
| 255 float page_scale, | 255 float page_scale, |
| 256 float top_controls_delta) override {} | 256 float top_controls_delta) override {} |
| 257 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 257 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
| 258 float page_scale, | 258 float page_scale, |
| 259 float top_controls_delta) override {} | 259 float top_controls_delta) override {} |
| 260 void RequestNewOutputSurface(bool fallback) override; | 260 void RequestNewOutputSurface() override; |
| 261 void DidInitializeOutputSurface() override {} | 261 void DidInitializeOutputSurface() override; |
| 262 void DidFailToInitializeOutputSurface() override; |
| 262 void WillCommit() override {} | 263 void WillCommit() override {} |
| 263 void DidCommit() override; | 264 void DidCommit() override; |
| 264 void DidCommitAndDrawFrame() override; | 265 void DidCommitAndDrawFrame() override; |
| 265 void DidCompleteSwapBuffers() override; | 266 void DidCompleteSwapBuffers() override; |
| 266 | 267 |
| 267 // cc::LayerTreeHostSingleThreadClient implementation. | 268 // cc::LayerTreeHostSingleThreadClient implementation. |
| 268 void ScheduleComposite() override; | 269 void ScheduleComposite() override; |
| 269 void ScheduleAnimation() override; | 270 void ScheduleAnimation() override; |
| 270 void DidPostSwapBuffers() override; | 271 void DidPostSwapBuffers() override; |
| 271 void DidAbortSwapBuffers() override; | 272 void DidAbortSwapBuffers() override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 284 } | 285 } |
| 285 | 286 |
| 286 cc::SurfaceIdAllocator* surface_id_allocator() { | 287 cc::SurfaceIdAllocator* surface_id_allocator() { |
| 287 return surface_id_allocator_.get(); | 288 return surface_id_allocator_.get(); |
| 288 } | 289 } |
| 289 | 290 |
| 290 private: | 291 private: |
| 291 friend class base::RefCounted<Compositor>; | 292 friend class base::RefCounted<Compositor>; |
| 292 friend class CompositorLock; | 293 friend class CompositorLock; |
| 293 | 294 |
| 295 enum { |
| 296 OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK = 4, |
| 297 MAX_OUTPUT_SURFACE_RETRIES = 5, |
| 298 }; |
| 299 |
| 294 // Called by CompositorLock. | 300 // Called by CompositorLock. |
| 295 void UnlockCompositor(); | 301 void UnlockCompositor(); |
| 296 | 302 |
| 297 // Called to release any pending CompositorLock | 303 // Called to release any pending CompositorLock |
| 298 void CancelCompositorLock(); | 304 void CancelCompositorLock(); |
| 299 | 305 |
| 300 // Notifies the compositor that compositing is complete. | 306 // Notifies the compositor that compositing is complete. |
| 301 void NotifyEnd(); | 307 void NotifyEnd(); |
| 302 | 308 |
| 303 gfx::Size size_; | 309 gfx::Size size_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 320 // The manager of vsync parameters for this compositor. | 326 // The manager of vsync parameters for this compositor. |
| 321 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 327 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
| 322 | 328 |
| 323 // The device scale factor of the monitor that this compositor is compositing | 329 // The device scale factor of the monitor that this compositor is compositing |
| 324 // layers on. | 330 // layers on. |
| 325 float device_scale_factor_; | 331 float device_scale_factor_; |
| 326 | 332 |
| 327 int last_started_frame_; | 333 int last_started_frame_; |
| 328 int last_ended_frame_; | 334 int last_ended_frame_; |
| 329 | 335 |
| 336 int num_failed_recreate_attempts_; |
| 337 |
| 330 bool disable_schedule_composite_; | 338 bool disable_schedule_composite_; |
| 331 | 339 |
| 332 CompositorLock* compositor_lock_; | 340 CompositorLock* compositor_lock_; |
| 333 | 341 |
| 334 // Prevent more than one draw from being scheduled. | 342 // Prevent more than one draw from being scheduled. |
| 335 bool defer_draw_scheduling_; | 343 bool defer_draw_scheduling_; |
| 336 | 344 |
| 337 // Used to prevent Draw()s while a composite is in progress. | 345 // Used to prevent Draw()s while a composite is in progress. |
| 338 bool waiting_on_compositing_end_; | 346 bool waiting_on_compositing_end_; |
| 339 bool draw_on_compositing_end_; | 347 bool draw_on_compositing_end_; |
| 340 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; | 348 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; |
| 341 SwapState swap_state_; | 349 SwapState swap_state_; |
| 342 | 350 |
| 343 LayerAnimatorCollection layer_animator_collection_; | 351 LayerAnimatorCollection layer_animator_collection_; |
| 344 | 352 |
| 345 base::WeakPtrFactory<Compositor> weak_ptr_factory_; | 353 base::WeakPtrFactory<Compositor> weak_ptr_factory_; |
| 346 | 354 |
| 347 DISALLOW_COPY_AND_ASSIGN(Compositor); | 355 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 348 }; | 356 }; |
| 349 | 357 |
| 350 } // namespace ui | 358 } // namespace ui |
| 351 | 359 |
| 352 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 360 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |