| 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/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "cc/trees/layer_tree_host_client.h" | 15 #include "cc/trees/layer_tree_host_client.h" |
| 16 #include "cc/trees/layer_tree_host_single_thread_client.h" | 16 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 17 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
| 18 #include "ui/compositor/compositor_export.h" | 18 #include "ui/compositor/compositor_export.h" |
| 19 #include "ui/compositor/compositor_observer.h" | 19 #include "ui/compositor/compositor_observer.h" |
| 20 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
| 21 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 22 #include "ui/gfx/vector2d.h" | 22 #include "ui/gfx/vector2d.h" |
| 23 | 23 |
| 24 class SkBitmap; | |
| 25 | |
| 26 namespace base { | 24 namespace base { |
| 27 class MessageLoopProxy; | 25 class MessageLoopProxy; |
| 28 class RunLoop; | 26 class RunLoop; |
| 29 } | 27 } |
| 30 | 28 |
| 31 namespace cc { | 29 namespace cc { |
| 32 class ContextProvider; | 30 class ContextProvider; |
| 33 class Layer; | 31 class Layer; |
| 34 class LayerTreeDebugState; | 32 class LayerTreeDebugState; |
| 35 class LayerTreeHost; | 33 class LayerTreeHost; |
| 36 } | 34 } |
| 37 | 35 |
| 38 namespace gfx { | 36 namespace gfx { |
| 39 class Rect; | 37 class Rect; |
| 40 class Size; | 38 class Size; |
| 41 } | 39 } |
| 42 | 40 |
| 43 namespace gpu { | 41 namespace gpu { |
| 44 struct Mailbox; | 42 struct Mailbox; |
| 45 } | 43 } |
| 46 | 44 |
| 47 namespace ui { | 45 namespace ui { |
| 48 | 46 |
| 49 class Compositor; | 47 class Compositor; |
| 50 class CompositorVSyncManager; | 48 class CompositorVSyncManager; |
| 51 class Layer; | 49 class Layer; |
| 52 class PostedSwapQueue; | |
| 53 class Reflector; | 50 class Reflector; |
| 54 class Texture; | 51 class Texture; |
| 55 struct LatencyInfo; | 52 struct LatencyInfo; |
| 56 | 53 |
| 57 // This class abstracts the creation of the 3D context for the compositor. It is | 54 // This class abstracts the creation of the 3D context for the compositor. It is |
| 58 // a global object. | 55 // a global object. |
| 59 class COMPOSITOR_EXPORT ContextFactory { | 56 class COMPOSITOR_EXPORT ContextFactory { |
| 60 public: | 57 public: |
| 61 virtual ~ContextFactory() {} | 58 virtual ~ContextFactory() {} |
| 62 | 59 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 189 |
| 193 // Called when we need the compositor to preserve the alpha channel in the | 190 // Called when we need the compositor to preserve the alpha channel in the |
| 194 // output for situations when we want to render transparently atop something | 191 // output for situations when we want to render transparently atop something |
| 195 // else, e.g. Aero glass. | 192 // else, e.g. Aero glass. |
| 196 void SetHostHasTransparentBackground(bool host_has_transparent_background); | 193 void SetHostHasTransparentBackground(bool host_has_transparent_background); |
| 197 | 194 |
| 198 // The scale factor of the device that this compositor is | 195 // The scale factor of the device that this compositor is |
| 199 // compositing layers on. | 196 // compositing layers on. |
| 200 float device_scale_factor() const { return device_scale_factor_; } | 197 float device_scale_factor() const { return device_scale_factor_; } |
| 201 | 198 |
| 202 // Draws the scene created by the layer tree and any visual effects. | |
| 203 void Draw(); | |
| 204 | |
| 205 // Where possible, draws are scissored to a damage region calculated from | 199 // Where possible, draws are scissored to a damage region calculated from |
| 206 // changes to layer properties. This bypasses that and indicates that | 200 // changes to layer properties. This bypasses that and indicates that |
| 207 // the whole frame needs to be drawn. | 201 // the whole frame needs to be drawn. |
| 208 void ScheduleFullRedraw(); | 202 void ScheduleFullRedraw(); |
| 209 | 203 |
| 210 // Schedule redraw and append damage_rect to the damage region calculated | 204 // Schedule redraw and append damage_rect to the damage region calculated |
| 211 // from changes to layer properties. | 205 // from changes to layer properties. |
| 212 void ScheduleRedrawRect(const gfx::Rect& damage_rect); | 206 void ScheduleRedrawRect(const gfx::Rect& damage_rect); |
| 213 | 207 |
| 214 void SetLatencyInfo(const LatencyInfo& latency_info); | 208 void SetLatencyInfo(const LatencyInfo& latency_info); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 296 |
| 303 ObserverList<CompositorObserver> observer_list_; | 297 ObserverList<CompositorObserver> observer_list_; |
| 304 | 298 |
| 305 gfx::AcceleratedWidget widget_; | 299 gfx::AcceleratedWidget widget_; |
| 306 scoped_refptr<cc::Layer> root_web_layer_; | 300 scoped_refptr<cc::Layer> root_web_layer_; |
| 307 scoped_ptr<cc::LayerTreeHost> host_; | 301 scoped_ptr<cc::LayerTreeHost> host_; |
| 308 | 302 |
| 309 // The manager of vsync parameters for this compositor. | 303 // The manager of vsync parameters for this compositor. |
| 310 scoped_refptr<CompositorVSyncManager> vsync_manager_; | 304 scoped_refptr<CompositorVSyncManager> vsync_manager_; |
| 311 | 305 |
| 312 // Used to verify that we have at most one draw swap in flight. | |
| 313 scoped_ptr<PostedSwapQueue> posted_swaps_; | |
| 314 | |
| 315 // 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 |
| 316 // layers on. | 307 // layers on. |
| 317 float device_scale_factor_; | 308 float device_scale_factor_; |
| 318 | 309 |
| 319 int last_started_frame_; | 310 int last_started_frame_; |
| 320 int last_ended_frame_; | 311 int last_ended_frame_; |
| 321 | 312 |
| 322 bool next_draw_is_resize_; | |
| 323 | |
| 324 bool disable_schedule_composite_; | 313 bool disable_schedule_composite_; |
| 325 | 314 |
| 326 CompositorLock* compositor_lock_; | 315 CompositorLock* compositor_lock_; |
| 327 | 316 |
| 328 // Prevent more than one draw from being scheduled. | |
| 329 bool defer_draw_scheduling_; | |
| 330 | |
| 331 // Used to prevent Draw()s while a composite is in progress. | |
| 332 bool waiting_on_compositing_end_; | |
| 333 bool draw_on_compositing_end_; | |
| 334 | |
| 335 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 317 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
| 336 | 318 |
| 337 DISALLOW_COPY_AND_ASSIGN(Compositor); | 319 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 338 }; | 320 }; |
| 339 | 321 |
| 340 } // namespace ui | 322 } // namespace ui |
| 341 | 323 |
| 342 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 324 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |