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