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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 // Destroys per-compositor data. | 90 // Destroys per-compositor data. |
91 virtual void RemoveCompositor(Compositor* compositor) = 0; | 91 virtual void RemoveCompositor(Compositor* compositor) = 0; |
92 | 92 |
93 // When true, the factory uses test contexts that do not do real GL | 93 // When true, the factory uses test contexts that do not do real GL |
94 // operations. | 94 // operations. |
95 virtual bool DoesCreateTestContexts() = 0; | 95 virtual bool DoesCreateTestContexts() = 0; |
96 | 96 |
97 // Gets the shared bitmap manager for software mode. | 97 // Gets the shared bitmap manager for software mode. |
98 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; | 98 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; |
| 99 |
| 100 // Gets the compositor message loop, or NULL if not using threaded |
| 101 // compositing. |
| 102 virtual base::MessageLoopProxy* GetCompositorMessageLoop() = 0; |
99 }; | 103 }; |
100 | 104 |
101 // This class represents a lock on the compositor, that can be used to prevent | 105 // This class represents a lock on the compositor, that can be used to prevent |
102 // commits to the compositor tree while we're waiting for an asynchronous | 106 // commits to the compositor tree while we're waiting for an asynchronous |
103 // event. The typical use case is when waiting for a renderer to produce a frame | 107 // event. The typical use case is when waiting for a renderer to produce a frame |
104 // at the right size. The caller keeps a reference on this object, and drops the | 108 // at the right size. The caller keeps a reference on this object, and drops the |
105 // reference once it desires to release the lock. | 109 // reference once it desires to release the lock. |
106 // Note however that the lock is cancelled after a short timeout to ensure | 110 // Note however that the lock is cancelled after a short timeout to ensure |
107 // responsiveness of the UI, so the compositor tree should be kept in a | 111 // responsiveness of the UI, so the compositor tree should be kept in a |
108 // "reasonable" state while the lock is held. | 112 // "reasonable" state while the lock is held. |
(...skipping 19 matching lines...) Expand all Loading... |
128 // 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 |
129 // appropriately transformed texture for each transformed view in the widget's | 133 // appropriately transformed texture for each transformed view in the widget's |
130 // view hierarchy. | 134 // view hierarchy. |
131 class COMPOSITOR_EXPORT Compositor | 135 class COMPOSITOR_EXPORT Compositor |
132 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 136 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
133 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { | 137 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { |
134 public: | 138 public: |
135 explicit Compositor(gfx::AcceleratedWidget widget); | 139 explicit Compositor(gfx::AcceleratedWidget widget); |
136 virtual ~Compositor(); | 140 virtual ~Compositor(); |
137 | 141 |
138 static void Initialize(); | |
139 static bool WasInitializedWithThread(); | |
140 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); | |
141 static void Terminate(); | |
142 | |
143 // Schedules a redraw of the layer tree associated with this compositor. | 142 // Schedules a redraw of the layer tree associated with this compositor. |
144 void ScheduleDraw(); | 143 void ScheduleDraw(); |
145 | 144 |
146 // Sets the root of the layer tree drawn by this Compositor. The root layer | 145 // Sets the root of the layer tree drawn by this Compositor. The root layer |
147 // must have no parent. The compositor's root layer is reset if the root layer | 146 // must have no parent. The compositor's root layer is reset if the root layer |
148 // is destroyed. NULL can be passed to reset the root layer, in which case the | 147 // is destroyed. NULL can be passed to reset the root layer, in which case the |
149 // compositor will stop drawing anything. | 148 // compositor will stop drawing anything. |
150 // The Compositor does not own the root layer. | 149 // The Compositor does not own the root layer. |
151 const Layer* root_layer() const { return root_layer_; } | 150 const Layer* root_layer() const { return root_layer_; } |
152 Layer* root_layer() { return root_layer_; } | 151 Layer* root_layer() { return root_layer_; } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 gfx::Size size_; | 257 gfx::Size size_; |
259 | 258 |
260 // The root of the Layer tree drawn by this compositor. | 259 // The root of the Layer tree drawn by this compositor. |
261 Layer* root_layer_; | 260 Layer* root_layer_; |
262 | 261 |
263 ObserverList<CompositorObserver> observer_list_; | 262 ObserverList<CompositorObserver> observer_list_; |
264 | 263 |
265 gfx::AcceleratedWidget widget_; | 264 gfx::AcceleratedWidget widget_; |
266 scoped_refptr<cc::Layer> root_web_layer_; | 265 scoped_refptr<cc::Layer> root_web_layer_; |
267 scoped_ptr<cc::LayerTreeHost> host_; | 266 scoped_ptr<cc::LayerTreeHost> host_; |
| 267 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; |
268 | 268 |
269 // The manager of vsync parameters for this compositor. | 269 // The manager of vsync parameters for this compositor. |
270 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 270 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
271 | 271 |
272 // The device scale factor of the monitor that this compositor is compositing | 272 // The device scale factor of the monitor that this compositor is compositing |
273 // layers on. | 273 // layers on. |
274 float device_scale_factor_; | 274 float device_scale_factor_; |
275 | 275 |
276 int last_started_frame_; | 276 int last_started_frame_; |
277 int last_ended_frame_; | 277 int last_ended_frame_; |
(...skipping 14 matching lines...) Expand all Loading... |
292 SwapState swap_state_; | 292 SwapState swap_state_; |
293 | 293 |
294 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 294 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
295 | 295 |
296 DISALLOW_COPY_AND_ASSIGN(Compositor); | 296 DISALLOW_COPY_AND_ASSIGN(Compositor); |
297 }; | 297 }; |
298 | 298 |
299 } // namespace ui | 299 } // namespace ui |
300 | 300 |
301 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 301 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |