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 virtual scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator() = 0; | |
danakj
2014/10/02 01:53:45
add whitespace and a comment for this
| |
98 }; | 101 }; |
99 | 102 |
100 // This class represents a lock on the compositor, that can be used to prevent | 103 // 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 | 104 // 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 | 105 // 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 | 106 // at the right size. The caller keeps a reference on this object, and drops the |
104 // reference once it desires to release the lock. | 107 // reference once it desires to release the lock. |
105 // Note however that the lock is cancelled after a short timeout to ensure | 108 // 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 | 109 // responsiveness of the UI, so the compositor tree should be kept in a |
107 // "reasonable" state while the lock is held. | 110 // "reasonable" state while the lock is held. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 | 257 |
255 bool IsLocked() { return compositor_lock_ != NULL; } | 258 bool IsLocked() { return compositor_lock_ != NULL; } |
256 | 259 |
257 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 260 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
258 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 261 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
259 | 262 |
260 LayerAnimatorCollection* layer_animator_collection() { | 263 LayerAnimatorCollection* layer_animator_collection() { |
261 return &layer_animator_collection_; | 264 return &layer_animator_collection_; |
262 } | 265 } |
263 | 266 |
267 cc::SurfaceSequence CreateSurfaceSequence(); | |
268 cc::SurfaceIdAllocator* surface_id_allocator() { | |
269 return surface_id_allocator_.get(); | |
270 } | |
271 | |
264 private: | 272 private: |
265 friend class base::RefCounted<Compositor>; | 273 friend class base::RefCounted<Compositor>; |
266 friend class CompositorLock; | 274 friend class CompositorLock; |
267 | 275 |
268 // Called by CompositorLock. | 276 // Called by CompositorLock. |
269 void UnlockCompositor(); | 277 void UnlockCompositor(); |
270 | 278 |
271 // Called to release any pending CompositorLock | 279 // Called to release any pending CompositorLock |
272 void CancelCompositorLock(); | 280 void CancelCompositorLock(); |
273 | 281 |
274 // Notifies the compositor that compositing is complete. | 282 // Notifies the compositor that compositing is complete. |
275 void NotifyEnd(); | 283 void NotifyEnd(); |
276 | 284 |
277 gfx::Size size_; | 285 gfx::Size size_; |
278 | 286 |
279 ui::ContextFactory* context_factory_; | 287 ui::ContextFactory* context_factory_; |
280 | 288 |
281 // The root of the Layer tree drawn by this compositor. | 289 // The root of the Layer tree drawn by this compositor. |
282 Layer* root_layer_; | 290 Layer* root_layer_; |
283 | 291 |
284 ObserverList<CompositorObserver> observer_list_; | 292 ObserverList<CompositorObserver> observer_list_; |
285 ObserverList<CompositorAnimationObserver> animation_observer_list_; | 293 ObserverList<CompositorAnimationObserver> animation_observer_list_; |
286 | 294 |
287 gfx::AcceleratedWidget widget_; | 295 gfx::AcceleratedWidget widget_; |
296 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | |
297 uint32_t surface_sequence_number_; | |
288 scoped_refptr<cc::Layer> root_web_layer_; | 298 scoped_refptr<cc::Layer> root_web_layer_; |
289 scoped_ptr<cc::LayerTreeHost> host_; | 299 scoped_ptr<cc::LayerTreeHost> host_; |
290 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; | 300 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; |
291 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 301 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
292 | 302 |
293 // The manager of vsync parameters for this compositor. | 303 // The manager of vsync parameters for this compositor. |
294 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 304 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
295 | 305 |
296 // The device scale factor of the monitor that this compositor is compositing | 306 // The device scale factor of the monitor that this compositor is compositing |
297 // layers on. | 307 // layers on. |
(...skipping 18 matching lines...) Expand all Loading... | |
316 LayerAnimatorCollection layer_animator_collection_; | 326 LayerAnimatorCollection layer_animator_collection_; |
317 | 327 |
318 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 328 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
319 | 329 |
320 DISALLOW_COPY_AND_ASSIGN(Compositor); | 330 DISALLOW_COPY_AND_ASSIGN(Compositor); |
321 }; | 331 }; |
322 | 332 |
323 } // namespace ui | 333 } // namespace ui |
324 | 334 |
325 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 335 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |