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