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/animation_frame_task.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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 NON_EXPORTED_BASE(public AnimationFrameTaskProvider) { |
133 public: | 134 public: |
134 Compositor(gfx::AcceleratedWidget widget, | 135 Compositor(gfx::AcceleratedWidget widget, |
135 ui::ContextFactory* context_factory, | 136 ui::ContextFactory* context_factory, |
136 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 137 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
137 virtual ~Compositor(); | 138 virtual ~Compositor(); |
138 | 139 |
139 ui::ContextFactory* context_factory() { return context_factory_; } | 140 ui::ContextFactory* context_factory() { return context_factory_; } |
140 | 141 |
141 // Schedules a redraw of the layer tree associated with this compositor. | 142 // Schedules a redraw of the layer tree associated with this compositor. |
142 void ScheduleDraw(); | 143 void ScheduleDraw(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 virtual void DidCommit() OVERRIDE; | 229 virtual void DidCommit() OVERRIDE; |
229 virtual void DidCommitAndDrawFrame() OVERRIDE; | 230 virtual void DidCommitAndDrawFrame() OVERRIDE; |
230 virtual void DidCompleteSwapBuffers() OVERRIDE; | 231 virtual void DidCompleteSwapBuffers() OVERRIDE; |
231 | 232 |
232 // cc::LayerTreeHostSingleThreadClient implementation. | 233 // cc::LayerTreeHostSingleThreadClient implementation. |
233 virtual void ScheduleComposite() OVERRIDE; | 234 virtual void ScheduleComposite() OVERRIDE; |
234 virtual void ScheduleAnimation() OVERRIDE; | 235 virtual void ScheduleAnimation() OVERRIDE; |
235 virtual void DidPostSwapBuffers() OVERRIDE; | 236 virtual void DidPostSwapBuffers() OVERRIDE; |
236 virtual void DidAbortSwapBuffers() OVERRIDE; | 237 virtual void DidAbortSwapBuffers() OVERRIDE; |
237 | 238 |
238 // LayerAnimatorCollectionDelegate implementation. | 239 // AnimationFrameTaskProvider: |
239 virtual void ScheduleAnimationForLayerCollection() OVERRIDE; | 240 virtual scoped_ptr<ScopedAnimationFrameTask> RequestAnimationFrameTask( |
| 241 AnimationFrameTask* task) OVERRIDE; |
240 | 242 |
241 int last_started_frame() { return last_started_frame_; } | 243 int last_started_frame() { return last_started_frame_; } |
242 int last_ended_frame() { return last_ended_frame_; } | 244 int last_ended_frame() { return last_ended_frame_; } |
243 | 245 |
244 bool IsLocked() { return compositor_lock_ != NULL; } | 246 bool IsLocked() { return compositor_lock_ != NULL; } |
245 | 247 |
246 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 248 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
247 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 249 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
248 | 250 |
249 LayerAnimatorCollection* layer_animator_collection() { | 251 LayerAnimatorCollection* layer_animator_collection() { |
250 return &layer_animator_collection_; | 252 return &layer_animator_collection_; |
251 } | 253 } |
252 | 254 |
253 private: | 255 private: |
254 friend class base::RefCounted<Compositor>; | 256 friend class base::RefCounted<Compositor>; |
255 friend class CompositorLock; | 257 friend class CompositorLock; |
256 | 258 |
| 259 void RemoveAnimationFrameTask(AnimationFrameTask* task); |
| 260 |
| 261 std::set<AnimationFrameTask*> rafs_; |
| 262 |
257 // Called by CompositorLock. | 263 // Called by CompositorLock. |
258 void UnlockCompositor(); | 264 void UnlockCompositor(); |
259 | 265 |
260 // Called to release any pending CompositorLock | 266 // Called to release any pending CompositorLock |
261 void CancelCompositorLock(); | 267 void CancelCompositorLock(); |
262 | 268 |
263 // Notifies the compositor that compositing is complete. | 269 // Notifies the compositor that compositing is complete. |
264 void NotifyEnd(); | 270 void NotifyEnd(); |
265 | 271 |
266 gfx::Size size_; | 272 gfx::Size size_; |
(...skipping 29 matching lines...) Expand all Loading... |
296 bool defer_draw_scheduling_; | 302 bool defer_draw_scheduling_; |
297 | 303 |
298 // Used to prevent Draw()s while a composite is in progress. | 304 // Used to prevent Draw()s while a composite is in progress. |
299 bool waiting_on_compositing_end_; | 305 bool waiting_on_compositing_end_; |
300 bool draw_on_compositing_end_; | 306 bool draw_on_compositing_end_; |
301 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; | 307 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; |
302 SwapState swap_state_; | 308 SwapState swap_state_; |
303 | 309 |
304 LayerAnimatorCollection layer_animator_collection_; | 310 LayerAnimatorCollection layer_animator_collection_; |
305 | 311 |
306 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 312 base::WeakPtrFactory<Compositor> weak_ptr_factory_; |
307 | 313 |
308 DISALLOW_COPY_AND_ASSIGN(Compositor); | 314 DISALLOW_COPY_AND_ASSIGN(Compositor); |
309 }; | 315 }; |
310 | 316 |
311 } // namespace ui | 317 } // namespace ui |
312 | 318 |
313 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 319 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |