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; | |
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 | 258 |
256 bool IsLocked() { return compositor_lock_ != NULL; } | 259 bool IsLocked() { return compositor_lock_ != NULL; } |
257 | 260 |
258 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 261 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
259 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 262 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
260 | 263 |
261 LayerAnimatorCollection* layer_animator_collection() { | 264 LayerAnimatorCollection* layer_animator_collection() { |
262 return &layer_animator_collection_; | 265 return &layer_animator_collection_; |
263 } | 266 } |
264 | 267 |
268 cc::SurfaceSequence CreateSurfaceSequence(); | |
269 cc::SurfaceIdAllocator* surface_id_allocator() { | |
270 return surface_id_allocator_.get(); | |
271 } | |
272 | |
265 private: | 273 private: |
266 friend class base::RefCounted<Compositor>; | 274 friend class base::RefCounted<Compositor>; |
267 friend class CompositorLock; | 275 friend class CompositorLock; |
268 | 276 |
269 // Called by CompositorLock. | 277 // Called by CompositorLock. |
270 void UnlockCompositor(); | 278 void UnlockCompositor(); |
271 | 279 |
272 // Called to release any pending CompositorLock | 280 // Called to release any pending CompositorLock |
273 void CancelCompositorLock(); | 281 void CancelCompositorLock(); |
274 | 282 |
275 // Notifies the compositor that compositing is complete. | 283 // Notifies the compositor that compositing is complete. |
276 void NotifyEnd(); | 284 void NotifyEnd(); |
277 | 285 |
278 gfx::Size size_; | 286 gfx::Size size_; |
279 | 287 |
280 ui::ContextFactory* context_factory_; | 288 ui::ContextFactory* context_factory_; |
281 | 289 |
282 // The root of the Layer tree drawn by this compositor. | 290 // The root of the Layer tree drawn by this compositor. |
283 Layer* root_layer_; | 291 Layer* root_layer_; |
284 | 292 |
285 ObserverList<CompositorObserver> observer_list_; | 293 ObserverList<CompositorObserver> observer_list_; |
286 ObserverList<CompositorAnimationObserver> animation_observer_list_; | 294 ObserverList<CompositorAnimationObserver> animation_observer_list_; |
287 | 295 |
288 gfx::AcceleratedWidget widget_; | 296 gfx::AcceleratedWidget widget_; |
297 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | |
298 int surface_sequence_number_; | |
jamesr
2014/09/24 04:51:01
uint32_t ?
| |
289 scoped_refptr<cc::Layer> root_web_layer_; | 299 scoped_refptr<cc::Layer> root_web_layer_; |
290 scoped_ptr<cc::LayerTreeHost> host_; | 300 scoped_ptr<cc::LayerTreeHost> host_; |
291 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; | 301 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; |
292 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 302 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
293 | 303 |
294 // The manager of vsync parameters for this compositor. | 304 // The manager of vsync parameters for this compositor. |
295 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 305 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
296 | 306 |
297 // The device scale factor of the monitor that this compositor is compositing | 307 // The device scale factor of the monitor that this compositor is compositing |
298 // layers on. | 308 // layers on. |
(...skipping 18 matching lines...) Expand all Loading... | |
317 LayerAnimatorCollection layer_animator_collection_; | 327 LayerAnimatorCollection layer_animator_collection_; |
318 | 328 |
319 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 329 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
320 | 330 |
321 DISALLOW_COPY_AND_ASSIGN(Compositor); | 331 DISALLOW_COPY_AND_ASSIGN(Compositor); |
322 }; | 332 }; |
323 | 333 |
324 } // namespace ui | 334 } // namespace ui |
325 | 335 |
326 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 336 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |