| 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/surfaces/surface_sequence.h" |
| 17 #include "cc/trees/layer_tree_host_client.h" | 17 #include "cc/trees/layer_tree_host_client.h" |
| 18 #include "cc/trees/layer_tree_host_single_thread_client.h" | 18 #include "cc/trees/layer_tree_host_single_thread_client.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
| 20 #include "ui/compositor/compositor_animation_observer.h" | 20 #include "ui/compositor/compositor_animation_observer.h" |
| 21 #include "ui/compositor/compositor_export.h" | 21 #include "ui/compositor/compositor_export.h" |
| 22 #include "ui/compositor/compositor_observer.h" | 22 #include "ui/compositor/compositor_observer.h" |
| 23 #include "ui/compositor/layer_animator_collection.h" | 23 #include "ui/compositor/layer_animator_collection.h" |
| 24 #include "ui/gfx/native_widget_types.h" | 24 #include "ui/gfx/native_widget_types.h" |
| 25 #include "ui/gfx/size.h" | 25 #include "ui/gfx/size.h" |
| 26 #include "ui/gfx/vector2d.h" | 26 #include "ui/gfx/vector2d.h" |
| 27 | 27 |
| 28 class SkBitmap; |
| 29 |
| 28 namespace base { | 30 namespace base { |
| 29 class MessageLoopProxy; | 31 class MessageLoopProxy; |
| 30 class RunLoop; | 32 class RunLoop; |
| 31 } | 33 } |
| 32 | 34 |
| 33 namespace cc { | 35 namespace cc { |
| 34 class ContextProvider; | 36 class ContextProvider; |
| 35 class Layer; | 37 class Layer; |
| 36 class LayerTreeDebugState; | 38 class LayerTreeDebugState; |
| 37 class LayerTreeHost; | 39 class LayerTreeHost; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 168 |
| 167 // Called when we need the compositor to preserve the alpha channel in the | 169 // Called when we need the compositor to preserve the alpha channel in the |
| 168 // output for situations when we want to render transparently atop something | 170 // output for situations when we want to render transparently atop something |
| 169 // else, e.g. Aero glass. | 171 // else, e.g. Aero glass. |
| 170 void SetHostHasTransparentBackground(bool host_has_transparent_background); | 172 void SetHostHasTransparentBackground(bool host_has_transparent_background); |
| 171 | 173 |
| 172 // The scale factor of the device that this compositor is | 174 // The scale factor of the device that this compositor is |
| 173 // compositing layers on. | 175 // compositing layers on. |
| 174 float device_scale_factor() const { return device_scale_factor_; } | 176 float device_scale_factor() const { return device_scale_factor_; } |
| 175 | 177 |
| 178 // Draws the scene created by the layer tree and any visual effects. |
| 179 void Draw(); |
| 180 |
| 176 // Where possible, draws are scissored to a damage region calculated from | 181 // Where possible, draws are scissored to a damage region calculated from |
| 177 // changes to layer properties. This bypasses that and indicates that | 182 // changes to layer properties. This bypasses that and indicates that |
| 178 // the whole frame needs to be drawn. | 183 // the whole frame needs to be drawn. |
| 179 void ScheduleFullRedraw(); | 184 void ScheduleFullRedraw(); |
| 180 | 185 |
| 181 // Schedule redraw and append damage_rect to the damage region calculated | 186 // Schedule redraw and append damage_rect to the damage region calculated |
| 182 // from changes to layer properties. | 187 // from changes to layer properties. |
| 183 void ScheduleRedrawRect(const gfx::Rect& damage_rect); | 188 void ScheduleRedrawRect(const gfx::Rect& damage_rect); |
| 184 | 189 |
| 185 // Finishes all outstanding rendering and disables swapping on this surface | 190 // Finishes all outstanding rendering and disables swapping on this surface |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 float page_scale, | 257 float page_scale, |
| 253 float top_controls_delta) override {} | 258 float top_controls_delta) override {} |
| 254 void RequestNewOutputSurface(bool fallback) override; | 259 void RequestNewOutputSurface(bool fallback) override; |
| 255 void DidInitializeOutputSurface() override {} | 260 void DidInitializeOutputSurface() override {} |
| 256 void WillCommit() override {} | 261 void WillCommit() override {} |
| 257 void DidCommit() override; | 262 void DidCommit() override; |
| 258 void DidCommitAndDrawFrame() override; | 263 void DidCommitAndDrawFrame() override; |
| 259 void DidCompleteSwapBuffers() override; | 264 void DidCompleteSwapBuffers() override; |
| 260 | 265 |
| 261 // cc::LayerTreeHostSingleThreadClient implementation. | 266 // cc::LayerTreeHostSingleThreadClient implementation. |
| 267 void ScheduleComposite() override; |
| 268 void ScheduleAnimation() override; |
| 262 void DidPostSwapBuffers() override; | 269 void DidPostSwapBuffers() override; |
| 263 void DidAbortSwapBuffers() override; | 270 void DidAbortSwapBuffers() override; |
| 264 | 271 |
| 272 int last_started_frame() { return last_started_frame_; } |
| 273 int last_ended_frame() { return last_ended_frame_; } |
| 274 |
| 265 bool IsLocked() { return compositor_lock_ != NULL; } | 275 bool IsLocked() { return compositor_lock_ != NULL; } |
| 266 | 276 |
| 267 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 277 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
| 268 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 278 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
| 269 const cc::RendererSettings& GetRendererSettings() const; | 279 const cc::RendererSettings& GetRendererSettings() const; |
| 270 | 280 |
| 271 LayerAnimatorCollection* layer_animator_collection() { | 281 LayerAnimatorCollection* layer_animator_collection() { |
| 272 return &layer_animator_collection_; | 282 return &layer_animator_collection_; |
| 273 } | 283 } |
| 274 | 284 |
| 275 cc::SurfaceIdAllocator* surface_id_allocator() { | 285 cc::SurfaceIdAllocator* surface_id_allocator() { |
| 276 return surface_id_allocator_.get(); | 286 return surface_id_allocator_.get(); |
| 277 } | 287 } |
| 278 | 288 |
| 279 private: | 289 private: |
| 280 friend class base::RefCounted<Compositor>; | 290 friend class base::RefCounted<Compositor>; |
| 281 friend class CompositorLock; | 291 friend class CompositorLock; |
| 282 | 292 |
| 283 // Called by CompositorLock. | 293 // Called by CompositorLock. |
| 284 void UnlockCompositor(); | 294 void UnlockCompositor(); |
| 285 | 295 |
| 286 // Called to release any pending CompositorLock | 296 // Called to release any pending CompositorLock |
| 287 void CancelCompositorLock(); | 297 void CancelCompositorLock(); |
| 288 | 298 |
| 299 // Notifies the compositor that compositing is complete. |
| 300 void NotifyEnd(); |
| 301 |
| 289 gfx::Size size_; | 302 gfx::Size size_; |
| 290 | 303 |
| 291 ui::ContextFactory* context_factory_; | 304 ui::ContextFactory* context_factory_; |
| 292 | 305 |
| 293 // The root of the Layer tree drawn by this compositor. | 306 // The root of the Layer tree drawn by this compositor. |
| 294 Layer* root_layer_; | 307 Layer* root_layer_; |
| 295 | 308 |
| 296 ObserverList<CompositorObserver> observer_list_; | 309 ObserverList<CompositorObserver> observer_list_; |
| 297 ObserverList<CompositorAnimationObserver> animation_observer_list_; | 310 ObserverList<CompositorAnimationObserver> animation_observer_list_; |
| 298 | 311 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 310 // layers on. | 323 // layers on. |
| 311 float device_scale_factor_; | 324 float device_scale_factor_; |
| 312 | 325 |
| 313 int last_started_frame_; | 326 int last_started_frame_; |
| 314 int last_ended_frame_; | 327 int last_ended_frame_; |
| 315 | 328 |
| 316 bool disable_schedule_composite_; | 329 bool disable_schedule_composite_; |
| 317 | 330 |
| 318 CompositorLock* compositor_lock_; | 331 CompositorLock* compositor_lock_; |
| 319 | 332 |
| 333 // Prevent more than one draw from being scheduled. |
| 334 bool defer_draw_scheduling_; |
| 335 |
| 336 // Used to prevent Draw()s while a composite is in progress. |
| 337 bool waiting_on_compositing_end_; |
| 338 bool draw_on_compositing_end_; |
| 339 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; |
| 340 SwapState swap_state_; |
| 341 |
| 320 LayerAnimatorCollection layer_animator_collection_; | 342 LayerAnimatorCollection layer_animator_collection_; |
| 321 | 343 |
| 322 base::WeakPtrFactory<Compositor> weak_ptr_factory_; | 344 base::WeakPtrFactory<Compositor> weak_ptr_factory_; |
| 323 | 345 |
| 324 DISALLOW_COPY_AND_ASSIGN(Compositor); | 346 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 325 }; | 347 }; |
| 326 | 348 |
| 327 } // namespace ui | 349 } // namespace ui |
| 328 | 350 |
| 329 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 351 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |