| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 void DidBeginMainFrame() override {} | 244 void DidBeginMainFrame() override {} |
| 245 void BeginMainFrame(const cc::BeginFrameArgs& args) override; | 245 void BeginMainFrame(const cc::BeginFrameArgs& args) override; |
| 246 void Layout() override; | 246 void Layout() override; |
| 247 void ApplyViewportDeltas(const gfx::Vector2d& inner_delta, | 247 void ApplyViewportDeltas(const gfx::Vector2d& inner_delta, |
| 248 const gfx::Vector2d& outer_delta, | 248 const gfx::Vector2d& outer_delta, |
| 249 float page_scale, | 249 float page_scale, |
| 250 float top_controls_delta) override {} | 250 float top_controls_delta) override {} |
| 251 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 251 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
| 252 float page_scale, | 252 float page_scale, |
| 253 float top_controls_delta) override {} | 253 float top_controls_delta) override {} |
| 254 void RequestNewOutputSurface(bool fallback) override; | 254 void RequestNewOutputSurface() override; |
| 255 void DidInitializeOutputSurface() override {} | 255 void DidInitializeOutputSurface() override; |
| 256 void DidFailToInitializeOutputSurface() override; |
| 256 void WillCommit() override {} | 257 void WillCommit() override {} |
| 257 void DidCommit() override; | 258 void DidCommit() override; |
| 258 void DidCommitAndDrawFrame() override; | 259 void DidCommitAndDrawFrame() override; |
| 259 void DidCompleteSwapBuffers() override; | 260 void DidCompleteSwapBuffers() override; |
| 260 | 261 |
| 261 // cc::LayerTreeHostSingleThreadClient implementation. | 262 // cc::LayerTreeHostSingleThreadClient implementation. |
| 262 void ScheduleComposite() override; | 263 void ScheduleComposite() override; |
| 263 void ScheduleAnimation() override; | 264 void ScheduleAnimation() override; |
| 264 void DidPostSwapBuffers() override; | 265 void DidPostSwapBuffers() override; |
| 265 void DidAbortSwapBuffers() override; | 266 void DidAbortSwapBuffers() override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 278 } | 279 } |
| 279 | 280 |
| 280 cc::SurfaceIdAllocator* surface_id_allocator() { | 281 cc::SurfaceIdAllocator* surface_id_allocator() { |
| 281 return surface_id_allocator_.get(); | 282 return surface_id_allocator_.get(); |
| 282 } | 283 } |
| 283 | 284 |
| 284 private: | 285 private: |
| 285 friend class base::RefCounted<Compositor>; | 286 friend class base::RefCounted<Compositor>; |
| 286 friend class CompositorLock; | 287 friend class CompositorLock; |
| 287 | 288 |
| 289 enum { |
| 290 OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK = 4, |
| 291 MAX_OUTPUT_SURFACE_RETRIES = 5, |
| 292 }; |
| 293 |
| 288 // Called by CompositorLock. | 294 // Called by CompositorLock. |
| 289 void UnlockCompositor(); | 295 void UnlockCompositor(); |
| 290 | 296 |
| 291 // Called to release any pending CompositorLock | 297 // Called to release any pending CompositorLock |
| 292 void CancelCompositorLock(); | 298 void CancelCompositorLock(); |
| 293 | 299 |
| 294 // Notifies the compositor that compositing is complete. | 300 // Notifies the compositor that compositing is complete. |
| 295 void NotifyEnd(); | 301 void NotifyEnd(); |
| 296 | 302 |
| 297 gfx::Size size_; | 303 gfx::Size size_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 314 // The manager of vsync parameters for this compositor. | 320 // The manager of vsync parameters for this compositor. |
| 315 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 321 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
| 316 | 322 |
| 317 // The device scale factor of the monitor that this compositor is compositing | 323 // The device scale factor of the monitor that this compositor is compositing |
| 318 // layers on. | 324 // layers on. |
| 319 float device_scale_factor_; | 325 float device_scale_factor_; |
| 320 | 326 |
| 321 int last_started_frame_; | 327 int last_started_frame_; |
| 322 int last_ended_frame_; | 328 int last_ended_frame_; |
| 323 | 329 |
| 330 int num_failed_recreate_attempts_; |
| 331 |
| 324 bool disable_schedule_composite_; | 332 bool disable_schedule_composite_; |
| 325 | 333 |
| 326 CompositorLock* compositor_lock_; | 334 CompositorLock* compositor_lock_; |
| 327 | 335 |
| 328 // Prevent more than one draw from being scheduled. | 336 // Prevent more than one draw from being scheduled. |
| 329 bool defer_draw_scheduling_; | 337 bool defer_draw_scheduling_; |
| 330 | 338 |
| 331 // Used to prevent Draw()s while a composite is in progress. | 339 // Used to prevent Draw()s while a composite is in progress. |
| 332 bool waiting_on_compositing_end_; | 340 bool waiting_on_compositing_end_; |
| 333 bool draw_on_compositing_end_; | 341 bool draw_on_compositing_end_; |
| 334 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; | 342 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; |
| 335 SwapState swap_state_; | 343 SwapState swap_state_; |
| 336 | 344 |
| 337 LayerAnimatorCollection layer_animator_collection_; | 345 LayerAnimatorCollection layer_animator_collection_; |
| 338 | 346 |
| 339 base::WeakPtrFactory<Compositor> weak_ptr_factory_; | 347 base::WeakPtrFactory<Compositor> weak_ptr_factory_; |
| 340 | 348 |
| 341 DISALLOW_COPY_AND_ASSIGN(Compositor); | 349 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 342 }; | 350 }; |
| 343 | 351 |
| 344 } // namespace ui | 352 } // namespace ui |
| 345 | 353 |
| 346 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 354 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |