| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 class Reflector; | 53 class Reflector; |
| 54 class Texture; | 54 class Texture; |
| 55 struct LatencyInfo; | 55 struct LatencyInfo; |
| 56 | 56 |
| 57 // This class abstracts the creation of the 3D context for the compositor. It is | 57 // This class abstracts the creation of the 3D context for the compositor. It is |
| 58 // a global object. | 58 // a global object. |
| 59 class COMPOSITOR_EXPORT ContextFactory { | 59 class COMPOSITOR_EXPORT ContextFactory { |
| 60 public: | 60 public: |
| 61 virtual ~ContextFactory() {} | 61 virtual ~ContextFactory() {} |
| 62 | 62 |
| 63 // Gets the global instance. | |
| 64 static ContextFactory* GetInstance(); | |
| 65 | |
| 66 // Sets the global instance. Caller keeps ownership. | |
| 67 // If this function isn't called (for tests), a "default" factory will be | |
| 68 // created on the first call of GetInstance. | |
| 69 static void SetInstance(ContextFactory* instance); | |
| 70 | |
| 71 // Creates an output surface for the given compositor. The factory may keep | 63 // Creates an output surface for the given compositor. The factory may keep |
| 72 // per-compositor data (e.g. a shared context), that needs to be cleaned up | 64 // per-compositor data (e.g. a shared context), that needs to be cleaned up |
| 73 // by calling RemoveCompositor when the compositor gets destroyed. | 65 // by calling RemoveCompositor when the compositor gets destroyed. |
| 74 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | 66 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( |
| 75 Compositor* compositor, bool software_fallback) = 0; | 67 Compositor* compositor, bool software_fallback) = 0; |
| 76 | 68 |
| 77 // Creates a reflector that copies the content of the |mirrored_compositor| | 69 // Creates a reflector that copies the content of the |mirrored_compositor| |
| 78 // onto |mirroing_layer|. | 70 // onto |mirroing_layer|. |
| 79 virtual scoped_refptr<Reflector> CreateReflector( | 71 virtual scoped_refptr<Reflector> CreateReflector( |
| 80 Compositor* mirrored_compositor, | 72 Compositor* mirrored_compositor, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 121 |
| 130 // Compositor object to take care of GPU painting. | 122 // Compositor object to take care of GPU painting. |
| 131 // A Browser compositor object is responsible for generating the final | 123 // A Browser compositor object is responsible for generating the final |
| 132 // displayable form of pixels comprising a single widget's contents. It draws an | 124 // displayable form of pixels comprising a single widget's contents. It draws an |
| 133 // appropriately transformed texture for each transformed view in the widget's | 125 // appropriately transformed texture for each transformed view in the widget's |
| 134 // view hierarchy. | 126 // view hierarchy. |
| 135 class COMPOSITOR_EXPORT Compositor | 127 class COMPOSITOR_EXPORT Compositor |
| 136 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 128 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
| 137 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { | 129 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { |
| 138 public: | 130 public: |
| 139 // This is deprecated, and will be removed shortly. | |
| 140 // TODO(sky): remove this. | |
| 141 explicit Compositor(gfx::AcceleratedWidget widget); | |
| 142 Compositor(gfx::AcceleratedWidget widget, | 131 Compositor(gfx::AcceleratedWidget widget, |
| 143 ui::ContextFactory* context_factory); | 132 ui::ContextFactory* context_factory); |
| 144 virtual ~Compositor(); | 133 virtual ~Compositor(); |
| 145 | 134 |
| 146 ui::ContextFactory* context_factory() { return context_factory_; } | 135 ui::ContextFactory* context_factory() { return context_factory_; } |
| 147 | 136 |
| 148 // Schedules a redraw of the layer tree associated with this compositor. | 137 // Schedules a redraw of the layer tree associated with this compositor. |
| 149 void ScheduleDraw(); | 138 void ScheduleDraw(); |
| 150 | 139 |
| 151 // Sets the root of the layer tree drawn by this Compositor. The root layer | 140 // Sets the root of the layer tree drawn by this Compositor. The root layer |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 236 |
| 248 bool IsLocked() { return compositor_lock_ != NULL; } | 237 bool IsLocked() { return compositor_lock_ != NULL; } |
| 249 | 238 |
| 250 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 239 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
| 251 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 240 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
| 252 | 241 |
| 253 private: | 242 private: |
| 254 friend class base::RefCounted<Compositor>; | 243 friend class base::RefCounted<Compositor>; |
| 255 friend class CompositorLock; | 244 friend class CompositorLock; |
| 256 | 245 |
| 257 // Called from both constructors. It's temporary while we have both | |
| 258 // constructors. | |
| 259 // TODO(sky): nuke this. | |
| 260 void Init(); | |
| 261 | |
| 262 // Called by CompositorLock. | 246 // Called by CompositorLock. |
| 263 void UnlockCompositor(); | 247 void UnlockCompositor(); |
| 264 | 248 |
| 265 // Called to release any pending CompositorLock | 249 // Called to release any pending CompositorLock |
| 266 void CancelCompositorLock(); | 250 void CancelCompositorLock(); |
| 267 | 251 |
| 268 // Notifies the compositor that compositing is complete. | 252 // Notifies the compositor that compositing is complete. |
| 269 void NotifyEnd(); | 253 void NotifyEnd(); |
| 270 | 254 |
| 271 gfx::Size size_; | 255 gfx::Size size_; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 SwapState swap_state_; | 290 SwapState swap_state_; |
| 307 | 291 |
| 308 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 292 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
| 309 | 293 |
| 310 DISALLOW_COPY_AND_ASSIGN(Compositor); | 294 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 311 }; | 295 }; |
| 312 | 296 |
| 313 } // namespace ui | 297 } // namespace ui |
| 314 | 298 |
| 315 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 299 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |