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" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "cc/trees/layer_tree_host_client.h" | 16 #include "cc/trees/layer_tree_host_client.h" |
17 #include "cc/trees/layer_tree_host_single_thread_client.h" | 17 #include "cc/trees/layer_tree_host_single_thread_client.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
| 19 #include "ui/compositor/compositor_animation_observer.h" |
19 #include "ui/compositor/compositor_export.h" | 20 #include "ui/compositor/compositor_export.h" |
20 #include "ui/compositor/compositor_observer.h" | 21 #include "ui/compositor/compositor_observer.h" |
21 #include "ui/compositor/layer_animator_collection.h" | 22 #include "ui/compositor/layer_animator_collection.h" |
22 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
23 #include "ui/gfx/size.h" | 24 #include "ui/gfx/size.h" |
24 #include "ui/gfx/vector2d.h" | 25 #include "ui/gfx/vector2d.h" |
25 | 26 |
26 class SkBitmap; | 27 class SkBitmap; |
27 | 28 |
28 namespace base { | 29 namespace base { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 DISALLOW_COPY_AND_ASSIGN(CompositorLock); | 122 DISALLOW_COPY_AND_ASSIGN(CompositorLock); |
122 }; | 123 }; |
123 | 124 |
124 // Compositor object to take care of GPU painting. | 125 // Compositor object to take care of GPU painting. |
125 // A Browser compositor object is responsible for generating the final | 126 // A Browser compositor object is responsible for generating the final |
126 // displayable form of pixels comprising a single widget's contents. It draws an | 127 // displayable form of pixels comprising a single widget's contents. It draws an |
127 // appropriately transformed texture for each transformed view in the widget's | 128 // appropriately transformed texture for each transformed view in the widget's |
128 // view hierarchy. | 129 // view hierarchy. |
129 class COMPOSITOR_EXPORT Compositor | 130 class COMPOSITOR_EXPORT Compositor |
130 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 131 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
131 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient), | 132 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { |
132 NON_EXPORTED_BASE(public LayerAnimatorCollectionDelegate) { | |
133 public: | 133 public: |
134 Compositor(gfx::AcceleratedWidget widget, | 134 Compositor(gfx::AcceleratedWidget widget, |
135 ui::ContextFactory* context_factory, | 135 ui::ContextFactory* context_factory, |
136 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 136 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
137 virtual ~Compositor(); | 137 virtual ~Compositor(); |
138 | 138 |
139 ui::ContextFactory* context_factory() { return context_factory_; } | 139 ui::ContextFactory* context_factory() { return context_factory_; } |
140 | 140 |
141 // Schedules a redraw of the layer tree associated with this compositor. | 141 // Schedules a redraw of the layer tree associated with this compositor. |
142 void ScheduleDraw(); | 142 void ScheduleDraw(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 // Returns the vsync manager for this compositor. | 192 // Returns the vsync manager for this compositor. |
193 scoped_refptr<CompositorVSyncManager> vsync_manager() const; | 193 scoped_refptr<CompositorVSyncManager> vsync_manager() const; |
194 | 194 |
195 // Compositor does not own observers. It is the responsibility of the | 195 // Compositor does not own observers. It is the responsibility of the |
196 // observer to remove itself when it is done observing. | 196 // observer to remove itself when it is done observing. |
197 void AddObserver(CompositorObserver* observer); | 197 void AddObserver(CompositorObserver* observer); |
198 void RemoveObserver(CompositorObserver* observer); | 198 void RemoveObserver(CompositorObserver* observer); |
199 bool HasObserver(CompositorObserver* observer); | 199 bool HasObserver(CompositorObserver* observer); |
200 | 200 |
| 201 void AddAnimationObserver(CompositorAnimationObserver* observer); |
| 202 void RemoveAnimationObserver(CompositorAnimationObserver* observer); |
| 203 bool HasAnimationObserver(CompositorAnimationObserver* observer); |
| 204 |
201 // Creates a compositor lock. Returns NULL if it is not possible to lock at | 205 // Creates a compositor lock. Returns NULL if it is not possible to lock at |
202 // this time (i.e. we're waiting to complete a previous unlock). | 206 // this time (i.e. we're waiting to complete a previous unlock). |
203 scoped_refptr<CompositorLock> GetCompositorLock(); | 207 scoped_refptr<CompositorLock> GetCompositorLock(); |
204 | 208 |
205 // Internal functions, called back by command-buffer contexts on swap buffer | 209 // Internal functions, called back by command-buffer contexts on swap buffer |
206 // events. | 210 // events. |
207 | 211 |
208 // Signals swap has been posted. | 212 // Signals swap has been posted. |
209 void OnSwapBuffersPosted(); | 213 void OnSwapBuffersPosted(); |
210 | 214 |
(...skipping 17 matching lines...) Expand all Loading... |
228 virtual void DidCommit() OVERRIDE; | 232 virtual void DidCommit() OVERRIDE; |
229 virtual void DidCommitAndDrawFrame() OVERRIDE; | 233 virtual void DidCommitAndDrawFrame() OVERRIDE; |
230 virtual void DidCompleteSwapBuffers() OVERRIDE; | 234 virtual void DidCompleteSwapBuffers() OVERRIDE; |
231 | 235 |
232 // cc::LayerTreeHostSingleThreadClient implementation. | 236 // cc::LayerTreeHostSingleThreadClient implementation. |
233 virtual void ScheduleComposite() OVERRIDE; | 237 virtual void ScheduleComposite() OVERRIDE; |
234 virtual void ScheduleAnimation() OVERRIDE; | 238 virtual void ScheduleAnimation() OVERRIDE; |
235 virtual void DidPostSwapBuffers() OVERRIDE; | 239 virtual void DidPostSwapBuffers() OVERRIDE; |
236 virtual void DidAbortSwapBuffers() OVERRIDE; | 240 virtual void DidAbortSwapBuffers() OVERRIDE; |
237 | 241 |
238 // LayerAnimatorCollectionDelegate implementation. | |
239 virtual void ScheduleAnimationForLayerCollection() OVERRIDE; | |
240 | |
241 int last_started_frame() { return last_started_frame_; } | 242 int last_started_frame() { return last_started_frame_; } |
242 int last_ended_frame() { return last_ended_frame_; } | 243 int last_ended_frame() { return last_ended_frame_; } |
243 | 244 |
244 bool IsLocked() { return compositor_lock_ != NULL; } | 245 bool IsLocked() { return compositor_lock_ != NULL; } |
245 | 246 |
246 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 247 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
247 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 248 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
248 | 249 |
249 LayerAnimatorCollection* layer_animator_collection() { | 250 LayerAnimatorCollection* layer_animator_collection() { |
250 return &layer_animator_collection_; | 251 return &layer_animator_collection_; |
(...skipping 13 matching lines...) Expand all Loading... |
264 void NotifyEnd(); | 265 void NotifyEnd(); |
265 | 266 |
266 gfx::Size size_; | 267 gfx::Size size_; |
267 | 268 |
268 ui::ContextFactory* context_factory_; | 269 ui::ContextFactory* context_factory_; |
269 | 270 |
270 // The root of the Layer tree drawn by this compositor. | 271 // The root of the Layer tree drawn by this compositor. |
271 Layer* root_layer_; | 272 Layer* root_layer_; |
272 | 273 |
273 ObserverList<CompositorObserver> observer_list_; | 274 ObserverList<CompositorObserver> observer_list_; |
| 275 ObserverList<CompositorAnimationObserver> animation_observer_list_; |
274 | 276 |
275 gfx::AcceleratedWidget widget_; | 277 gfx::AcceleratedWidget widget_; |
276 scoped_refptr<cc::Layer> root_web_layer_; | 278 scoped_refptr<cc::Layer> root_web_layer_; |
277 scoped_ptr<cc::LayerTreeHost> host_; | 279 scoped_ptr<cc::LayerTreeHost> host_; |
278 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; | 280 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; |
279 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 281 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
280 | 282 |
281 // The manager of vsync parameters for this compositor. | 283 // The manager of vsync parameters for this compositor. |
282 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 284 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
283 | 285 |
(...skipping 20 matching lines...) Expand all Loading... |
304 LayerAnimatorCollection layer_animator_collection_; | 306 LayerAnimatorCollection layer_animator_collection_; |
305 | 307 |
306 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 308 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
307 | 309 |
308 DISALLOW_COPY_AND_ASSIGN(Compositor); | 310 DISALLOW_COPY_AND_ASSIGN(Compositor); |
309 }; | 311 }; |
310 | 312 |
311 } // namespace ui | 313 } // namespace ui |
312 | 314 |
313 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 315 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |