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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // This class abstracts the creation of the 3D context for the compositor. It is | 63 // This class abstracts the creation of the 3D context for the compositor. It is |
64 // a global object. | 64 // a global object. |
65 class COMPOSITOR_EXPORT ContextFactory { | 65 class COMPOSITOR_EXPORT ContextFactory { |
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 void CreateOutputSurface(base::WeakPtr<Compositor> compositor, |
73 Compositor* compositor, bool software_fallback) = 0; | 73 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 |mirroring_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 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 140 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
141 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { | 141 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { |
142 public: | 142 public: |
143 Compositor(gfx::AcceleratedWidget widget, | 143 Compositor(gfx::AcceleratedWidget widget, |
144 ui::ContextFactory* context_factory, | 144 ui::ContextFactory* context_factory, |
145 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 145 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
146 ~Compositor() override; | 146 ~Compositor() override; |
147 | 147 |
148 ui::ContextFactory* context_factory() { return context_factory_; } | 148 ui::ContextFactory* context_factory() { return context_factory_; } |
149 | 149 |
| 150 void SetOutputSurface(scoped_ptr<cc::OutputSurface> surface); |
| 151 |
150 // Schedules a redraw of the layer tree associated with this compositor. | 152 // Schedules a redraw of the layer tree associated with this compositor. |
151 void ScheduleDraw(); | 153 void ScheduleDraw(); |
152 | 154 |
153 // Sets the root of the layer tree drawn by this Compositor. The root layer | 155 // Sets the root of the layer tree drawn by this Compositor. The root layer |
154 // must have no parent. The compositor's root layer is reset if the root layer | 156 // must have no parent. The compositor's root layer is reset if the root layer |
155 // is destroyed. NULL can be passed to reset the root layer, in which case the | 157 // is destroyed. NULL can be passed to reset the root layer, in which case the |
156 // compositor will stop drawing anything. | 158 // compositor will stop drawing anything. |
157 // The Compositor does not own the root layer. | 159 // The Compositor does not own the root layer. |
158 const Layer* root_layer() const { return root_layer_; } | 160 const Layer* root_layer() const { return root_layer_; } |
159 Layer* root_layer() { return root_layer_; } | 161 Layer* root_layer() { return root_layer_; } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 cc::SurfaceSequence InsertSurfaceSequenceForNextFrame(); | 282 cc::SurfaceSequence InsertSurfaceSequenceForNextFrame(); |
281 | 283 |
282 cc::SurfaceIdAllocator* surface_id_allocator() { | 284 cc::SurfaceIdAllocator* surface_id_allocator() { |
283 return surface_id_allocator_.get(); | 285 return surface_id_allocator_.get(); |
284 } | 286 } |
285 | 287 |
286 private: | 288 private: |
287 friend class base::RefCounted<Compositor>; | 289 friend class base::RefCounted<Compositor>; |
288 friend class CompositorLock; | 290 friend class CompositorLock; |
289 | 291 |
290 enum { | |
291 OUTPUT_SURFACE_RETRIES_BEFORE_FALLBACK = 4, | |
292 MAX_OUTPUT_SURFACE_RETRIES = 5, | |
293 }; | |
294 // Called by CompositorLock. | 292 // Called by CompositorLock. |
295 void UnlockCompositor(); | 293 void UnlockCompositor(); |
296 | 294 |
297 // Called to release any pending CompositorLock | 295 // Called to release any pending CompositorLock |
298 void CancelCompositorLock(); | 296 void CancelCompositorLock(); |
299 | 297 |
300 // Notifies the compositor that compositing is complete. | 298 // Notifies the compositor that compositing is complete. |
301 void NotifyEnd(); | 299 void NotifyEnd(); |
302 | 300 |
303 gfx::Size size_; | 301 gfx::Size size_; |
(...skipping 17 matching lines...) Expand all Loading... |
321 // The manager of vsync parameters for this compositor. | 319 // The manager of vsync parameters for this compositor. |
322 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 320 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
323 | 321 |
324 // The device scale factor of the monitor that this compositor is compositing | 322 // The device scale factor of the monitor that this compositor is compositing |
325 // layers on. | 323 // layers on. |
326 float device_scale_factor_; | 324 float device_scale_factor_; |
327 | 325 |
328 int last_started_frame_; | 326 int last_started_frame_; |
329 int last_ended_frame_; | 327 int last_ended_frame_; |
330 | 328 |
331 int num_failed_recreate_attempts_; | |
332 | |
333 bool disable_schedule_composite_; | 329 bool disable_schedule_composite_; |
334 | 330 |
335 CompositorLock* compositor_lock_; | 331 CompositorLock* compositor_lock_; |
336 | 332 |
337 // Prevent more than one draw from being scheduled. | 333 // Prevent more than one draw from being scheduled. |
338 bool defer_draw_scheduling_; | 334 bool defer_draw_scheduling_; |
339 | 335 |
340 // Used to prevent Draw()s while a composite is in progress. | 336 // Used to prevent Draw()s while a composite is in progress. |
341 bool waiting_on_compositing_end_; | 337 bool waiting_on_compositing_end_; |
342 bool draw_on_compositing_end_; | 338 bool draw_on_compositing_end_; |
343 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; | 339 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; |
344 SwapState swap_state_; | 340 SwapState swap_state_; |
345 | 341 |
346 LayerAnimatorCollection layer_animator_collection_; | 342 LayerAnimatorCollection layer_animator_collection_; |
347 | 343 |
348 base::WeakPtrFactory<Compositor> weak_ptr_factory_; | 344 base::WeakPtrFactory<Compositor> weak_ptr_factory_; |
349 | 345 |
350 DISALLOW_COPY_AND_ASSIGN(Compositor); | 346 DISALLOW_COPY_AND_ASSIGN(Compositor); |
351 }; | 347 }; |
352 | 348 |
353 } // namespace ui | 349 } // namespace ui |
354 | 350 |
355 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 351 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |