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/surfaces/surface_sequence.h" |
16 #include "cc/trees/layer_tree_host_client.h" | 17 #include "cc/trees/layer_tree_host_client.h" |
17 #include "cc/trees/layer_tree_host_single_thread_client.h" | 18 #include "cc/trees/layer_tree_host_single_thread_client.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
19 #include "ui/compositor/compositor_animation_observer.h" | 20 #include "ui/compositor/compositor_animation_observer.h" |
20 #include "ui/compositor/compositor_export.h" | 21 #include "ui/compositor/compositor_export.h" |
21 #include "ui/compositor/compositor_observer.h" | 22 #include "ui/compositor/compositor_observer.h" |
22 #include "ui/compositor/layer_animator_collection.h" | 23 #include "ui/compositor/layer_animator_collection.h" |
23 #include "ui/gfx/native_widget_types.h" | 24 #include "ui/gfx/native_widget_types.h" |
24 #include "ui/gfx/size.h" | 25 #include "ui/gfx/size.h" |
25 #include "ui/gfx/vector2d.h" | 26 #include "ui/gfx/vector2d.h" |
26 | 27 |
27 class SkBitmap; | 28 class SkBitmap; |
28 | 29 |
29 namespace base { | 30 namespace base { |
30 class MessageLoopProxy; | 31 class MessageLoopProxy; |
31 class RunLoop; | 32 class RunLoop; |
32 } | 33 } |
33 | 34 |
34 namespace cc { | 35 namespace cc { |
35 class ContextProvider; | 36 class ContextProvider; |
36 class Layer; | 37 class Layer; |
37 class LayerTreeDebugState; | 38 class LayerTreeDebugState; |
38 class LayerTreeHost; | 39 class LayerTreeHost; |
39 class SharedBitmapManager; | 40 class SharedBitmapManager; |
| 41 class SurfaceIdAllocator; |
40 } | 42 } |
41 | 43 |
42 namespace gfx { | 44 namespace gfx { |
43 class Rect; | 45 class Rect; |
44 class Size; | 46 class Size; |
45 } | 47 } |
46 | 48 |
47 namespace gpu { | 49 namespace gpu { |
48 struct Mailbox; | 50 struct Mailbox; |
49 } | 51 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // When true, the factory uses test contexts that do not do real GL | 90 // When true, the factory uses test contexts that do not do real GL |
89 // operations. | 91 // operations. |
90 virtual bool DoesCreateTestContexts() = 0; | 92 virtual bool DoesCreateTestContexts() = 0; |
91 | 93 |
92 // Gets the shared bitmap manager for software mode. | 94 // Gets the shared bitmap manager for software mode. |
93 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; | 95 virtual cc::SharedBitmapManager* GetSharedBitmapManager() = 0; |
94 | 96 |
95 // Gets the compositor message loop, or NULL if not using threaded | 97 // Gets the compositor message loop, or NULL if not using threaded |
96 // compositing. | 98 // compositing. |
97 virtual base::MessageLoopProxy* GetCompositorMessageLoop() = 0; | 99 virtual base::MessageLoopProxy* GetCompositorMessageLoop() = 0; |
| 100 |
| 101 // Creates a Surface ID allocator with a new namespace. |
| 102 virtual scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() = 0; |
98 }; | 103 }; |
99 | 104 |
100 // 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 |
101 // 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 |
102 // 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 |
103 // 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 |
104 // reference once it desires to release the lock. | 109 // reference once it desires to release the lock. |
105 // 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 |
106 // 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 |
107 // "reasonable" state while the lock is held. | 112 // "reasonable" state while the lock is held. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 264 |
260 bool IsLocked() { return compositor_lock_ != NULL; } | 265 bool IsLocked() { return compositor_lock_ != NULL; } |
261 | 266 |
262 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 267 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
263 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 268 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
264 | 269 |
265 LayerAnimatorCollection* layer_animator_collection() { | 270 LayerAnimatorCollection* layer_animator_collection() { |
266 return &layer_animator_collection_; | 271 return &layer_animator_collection_; |
267 } | 272 } |
268 | 273 |
| 274 // Creates a SurfaceSequence that will be satisfied on the next frame this |
| 275 // compositor commits and swaps. |
| 276 cc::SurfaceSequence CreateSurfaceSequenceForNextFrame(); |
| 277 |
| 278 cc::SurfaceIdAllocator* surface_id_allocator() { |
| 279 return surface_id_allocator_.get(); |
| 280 } |
| 281 |
269 private: | 282 private: |
270 friend class base::RefCounted<Compositor>; | 283 friend class base::RefCounted<Compositor>; |
271 friend class CompositorLock; | 284 friend class CompositorLock; |
272 | 285 |
273 // Called by CompositorLock. | 286 // Called by CompositorLock. |
274 void UnlockCompositor(); | 287 void UnlockCompositor(); |
275 | 288 |
276 // Called to release any pending CompositorLock | 289 // Called to release any pending CompositorLock |
277 void CancelCompositorLock(); | 290 void CancelCompositorLock(); |
278 | 291 |
279 // Notifies the compositor that compositing is complete. | 292 // Notifies the compositor that compositing is complete. |
280 void NotifyEnd(); | 293 void NotifyEnd(); |
281 | 294 |
282 gfx::Size size_; | 295 gfx::Size size_; |
283 | 296 |
284 ui::ContextFactory* context_factory_; | 297 ui::ContextFactory* context_factory_; |
285 | 298 |
286 // The root of the Layer tree drawn by this compositor. | 299 // The root of the Layer tree drawn by this compositor. |
287 Layer* root_layer_; | 300 Layer* root_layer_; |
288 | 301 |
289 ObserverList<CompositorObserver> observer_list_; | 302 ObserverList<CompositorObserver> observer_list_; |
290 ObserverList<CompositorAnimationObserver> animation_observer_list_; | 303 ObserverList<CompositorAnimationObserver> animation_observer_list_; |
291 | 304 |
292 gfx::AcceleratedWidget widget_; | 305 gfx::AcceleratedWidget widget_; |
| 306 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
| 307 uint32_t surface_sequence_number_; |
293 scoped_refptr<cc::Layer> root_web_layer_; | 308 scoped_refptr<cc::Layer> root_web_layer_; |
294 scoped_ptr<cc::LayerTreeHost> host_; | 309 scoped_ptr<cc::LayerTreeHost> host_; |
295 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; | 310 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; |
296 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 311 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
297 | 312 |
298 // The manager of vsync parameters for this compositor. | 313 // The manager of vsync parameters for this compositor. |
299 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 314 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
300 | 315 |
301 // The device scale factor of the monitor that this compositor is compositing | 316 // The device scale factor of the monitor that this compositor is compositing |
302 // layers on. | 317 // layers on. |
(...skipping 18 matching lines...) Expand all Loading... |
321 LayerAnimatorCollection layer_animator_collection_; | 336 LayerAnimatorCollection layer_animator_collection_; |
322 | 337 |
323 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 338 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
324 | 339 |
325 DISALLOW_COPY_AND_ASSIGN(Compositor); | 340 DISALLOW_COPY_AND_ASSIGN(Compositor); |
326 }; | 341 }; |
327 | 342 |
328 } // namespace ui | 343 } // namespace ui |
329 | 344 |
330 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 345 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |