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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 // Compositor object to take care of GPU painting. | 130 // Compositor object to take care of GPU painting. |
131 // A Browser compositor object is responsible for generating the final | 131 // A Browser compositor object is responsible for generating the final |
132 // displayable form of pixels comprising a single widget's contents. It draws an | 132 // 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 | 133 // appropriately transformed texture for each transformed view in the widget's |
134 // view hierarchy. | 134 // view hierarchy. |
135 class COMPOSITOR_EXPORT Compositor | 135 class COMPOSITOR_EXPORT Compositor |
136 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 136 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
137 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { | 137 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { |
138 public: | 138 public: |
| 139 // This is deprecated, and will be removed shortly. |
| 140 // TODO(sky): remove this. |
139 explicit Compositor(gfx::AcceleratedWidget widget); | 141 explicit Compositor(gfx::AcceleratedWidget widget); |
| 142 Compositor(gfx::AcceleratedWidget widget, |
| 143 ui::ContextFactory* context_factory); |
140 virtual ~Compositor(); | 144 virtual ~Compositor(); |
141 | 145 |
| 146 ui::ContextFactory* context_factory() { return context_factory_; } |
| 147 |
142 // Schedules a redraw of the layer tree associated with this compositor. | 148 // Schedules a redraw of the layer tree associated with this compositor. |
143 void ScheduleDraw(); | 149 void ScheduleDraw(); |
144 | 150 |
145 // Sets the root of the layer tree drawn by this Compositor. The root layer | 151 // Sets the root of the layer tree drawn by this Compositor. The root layer |
146 // must have no parent. The compositor's root layer is reset if the root layer | 152 // must have no parent. The compositor's root layer is reset if the root layer |
147 // is destroyed. NULL can be passed to reset the root layer, in which case the | 153 // is destroyed. NULL can be passed to reset the root layer, in which case the |
148 // compositor will stop drawing anything. | 154 // compositor will stop drawing anything. |
149 // The Compositor does not own the root layer. | 155 // The Compositor does not own the root layer. |
150 const Layer* root_layer() const { return root_layer_; } | 156 const Layer* root_layer() const { return root_layer_; } |
151 Layer* root_layer() { return root_layer_; } | 157 Layer* root_layer() { return root_layer_; } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 247 |
242 bool IsLocked() { return compositor_lock_ != NULL; } | 248 bool IsLocked() { return compositor_lock_ != NULL; } |
243 | 249 |
244 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 250 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
245 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 251 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
246 | 252 |
247 private: | 253 private: |
248 friend class base::RefCounted<Compositor>; | 254 friend class base::RefCounted<Compositor>; |
249 friend class CompositorLock; | 255 friend class CompositorLock; |
250 | 256 |
| 257 // Called from both constructors. It's temporary while we have both |
| 258 // constructors. |
| 259 // TODO(sky): nuke this. |
| 260 void Init(); |
| 261 |
251 // Called by CompositorLock. | 262 // Called by CompositorLock. |
252 void UnlockCompositor(); | 263 void UnlockCompositor(); |
253 | 264 |
254 // Called to release any pending CompositorLock | 265 // Called to release any pending CompositorLock |
255 void CancelCompositorLock(); | 266 void CancelCompositorLock(); |
256 | 267 |
257 // Notifies the compositor that compositing is complete. | 268 // Notifies the compositor that compositing is complete. |
258 void NotifyEnd(); | 269 void NotifyEnd(); |
259 | 270 |
260 gfx::Size size_; | 271 gfx::Size size_; |
261 | 272 |
| 273 ui::ContextFactory* context_factory_; |
| 274 |
262 // The root of the Layer tree drawn by this compositor. | 275 // The root of the Layer tree drawn by this compositor. |
263 Layer* root_layer_; | 276 Layer* root_layer_; |
264 | 277 |
265 ObserverList<CompositorObserver> observer_list_; | 278 ObserverList<CompositorObserver> observer_list_; |
266 | 279 |
267 gfx::AcceleratedWidget widget_; | 280 gfx::AcceleratedWidget widget_; |
268 scoped_refptr<cc::Layer> root_web_layer_; | 281 scoped_refptr<cc::Layer> root_web_layer_; |
269 scoped_ptr<cc::LayerTreeHost> host_; | 282 scoped_ptr<cc::LayerTreeHost> host_; |
270 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; | 283 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; |
271 | 284 |
(...skipping 21 matching lines...) Expand all Loading... |
293 SwapState swap_state_; | 306 SwapState swap_state_; |
294 | 307 |
295 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 308 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
296 | 309 |
297 DISALLOW_COPY_AND_ASSIGN(Compositor); | 310 DISALLOW_COPY_AND_ASSIGN(Compositor); |
298 }; | 311 }; |
299 | 312 |
300 } // namespace ui | 313 } // namespace ui |
301 | 314 |
302 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 315 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |