| 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/compositor/layer_animator_collection.h" |
| 20 #include "ui/gfx/native_widget_types.h" | 21 #include "ui/gfx/native_widget_types.h" |
| 21 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 22 #include "ui/gfx/vector2d.h" | 23 #include "ui/gfx/vector2d.h" |
| 23 | 24 |
| 24 class SkBitmap; | 25 class SkBitmap; |
| 25 | 26 |
| 26 namespace base { | 27 namespace base { |
| 27 class MessageLoopProxy; | 28 class MessageLoopProxy; |
| 28 class RunLoop; | 29 class RunLoop; |
| 29 } | 30 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 DISALLOW_COPY_AND_ASSIGN(CompositorLock); | 120 DISALLOW_COPY_AND_ASSIGN(CompositorLock); |
| 120 }; | 121 }; |
| 121 | 122 |
| 122 // Compositor object to take care of GPU painting. | 123 // Compositor object to take care of GPU painting. |
| 123 // A Browser compositor object is responsible for generating the final | 124 // A Browser compositor object is responsible for generating the final |
| 124 // displayable form of pixels comprising a single widget's contents. It draws an | 125 // displayable form of pixels comprising a single widget's contents. It draws an |
| 125 // appropriately transformed texture for each transformed view in the widget's | 126 // appropriately transformed texture for each transformed view in the widget's |
| 126 // view hierarchy. | 127 // view hierarchy. |
| 127 class COMPOSITOR_EXPORT Compositor | 128 class COMPOSITOR_EXPORT Compositor |
| 128 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 129 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
| 129 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { | 130 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient), |
| 131 NON_EXPORTED_BASE(public LayerAnimatorCollectionDelegate) { |
| 130 public: | 132 public: |
| 131 Compositor(gfx::AcceleratedWidget widget, | 133 Compositor(gfx::AcceleratedWidget widget, |
| 132 ui::ContextFactory* context_factory); | 134 ui::ContextFactory* context_factory); |
| 133 virtual ~Compositor(); | 135 virtual ~Compositor(); |
| 134 | 136 |
| 135 ui::ContextFactory* context_factory() { return context_factory_; } | 137 ui::ContextFactory* context_factory() { return context_factory_; } |
| 136 | 138 |
| 137 // Schedules a redraw of the layer tree associated with this compositor. | 139 // Schedules a redraw of the layer tree associated with this compositor. |
| 138 void ScheduleDraw(); | 140 void ScheduleDraw(); |
| 139 | 141 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 208 |
| 207 // Signals swap has completed. | 209 // Signals swap has completed. |
| 208 void OnSwapBuffersComplete(); | 210 void OnSwapBuffersComplete(); |
| 209 | 211 |
| 210 // Signals swap has aborted (e.g. lost context). | 212 // Signals swap has aborted (e.g. lost context). |
| 211 void OnSwapBuffersAborted(); | 213 void OnSwapBuffersAborted(); |
| 212 | 214 |
| 213 // LayerTreeHostClient implementation. | 215 // LayerTreeHostClient implementation. |
| 214 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} | 216 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} |
| 215 virtual void DidBeginMainFrame() OVERRIDE {} | 217 virtual void DidBeginMainFrame() OVERRIDE {} |
| 216 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} | 218 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE; |
| 217 virtual void Layout() OVERRIDE; | 219 virtual void Layout() OVERRIDE; |
| 218 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, | 220 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, |
| 219 float page_scale) OVERRIDE {} | 221 float page_scale) OVERRIDE {} |
| 220 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 222 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
| 221 OVERRIDE; | 223 OVERRIDE; |
| 222 virtual void DidInitializeOutputSurface() OVERRIDE {} | 224 virtual void DidInitializeOutputSurface() OVERRIDE {} |
| 223 virtual void WillCommit() OVERRIDE {} | 225 virtual void WillCommit() OVERRIDE {} |
| 224 virtual void DidCommit() OVERRIDE; | 226 virtual void DidCommit() OVERRIDE; |
| 225 virtual void DidCommitAndDrawFrame() OVERRIDE; | 227 virtual void DidCommitAndDrawFrame() OVERRIDE; |
| 226 virtual void DidCompleteSwapBuffers() OVERRIDE; | 228 virtual void DidCompleteSwapBuffers() OVERRIDE; |
| 227 | 229 |
| 228 // cc::LayerTreeHostSingleThreadClient implementation. | 230 // cc::LayerTreeHostSingleThreadClient implementation. |
| 229 virtual void ScheduleComposite() OVERRIDE; | 231 virtual void ScheduleComposite() OVERRIDE; |
| 230 virtual void ScheduleAnimation() OVERRIDE; | 232 virtual void ScheduleAnimation() OVERRIDE; |
| 231 virtual void DidPostSwapBuffers() OVERRIDE; | 233 virtual void DidPostSwapBuffers() OVERRIDE; |
| 232 virtual void DidAbortSwapBuffers() OVERRIDE; | 234 virtual void DidAbortSwapBuffers() OVERRIDE; |
| 233 | 235 |
| 236 // LayerAnimatorCollectionDelegate implementation. |
| 237 virtual void ScheduleAnimationForLayerCollection() OVERRIDE; |
| 238 |
| 234 int last_started_frame() { return last_started_frame_; } | 239 int last_started_frame() { return last_started_frame_; } |
| 235 int last_ended_frame() { return last_ended_frame_; } | 240 int last_ended_frame() { return last_ended_frame_; } |
| 236 | 241 |
| 237 bool IsLocked() { return compositor_lock_ != NULL; } | 242 bool IsLocked() { return compositor_lock_ != NULL; } |
| 238 | 243 |
| 239 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 244 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
| 240 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 245 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
| 241 | 246 |
| 247 LayerAnimatorCollection* layer_animator_collection() { |
| 248 return &layer_animator_collection_; |
| 249 } |
| 250 |
| 242 private: | 251 private: |
| 243 friend class base::RefCounted<Compositor>; | 252 friend class base::RefCounted<Compositor>; |
| 244 friend class CompositorLock; | 253 friend class CompositorLock; |
| 245 | 254 |
| 246 // Called by CompositorLock. | 255 // Called by CompositorLock. |
| 247 void UnlockCompositor(); | 256 void UnlockCompositor(); |
| 248 | 257 |
| 249 // Called to release any pending CompositorLock | 258 // Called to release any pending CompositorLock |
| 250 void CancelCompositorLock(); | 259 void CancelCompositorLock(); |
| 251 | 260 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 282 | 291 |
| 283 // Prevent more than one draw from being scheduled. | 292 // Prevent more than one draw from being scheduled. |
| 284 bool defer_draw_scheduling_; | 293 bool defer_draw_scheduling_; |
| 285 | 294 |
| 286 // Used to prevent Draw()s while a composite is in progress. | 295 // Used to prevent Draw()s while a composite is in progress. |
| 287 bool waiting_on_compositing_end_; | 296 bool waiting_on_compositing_end_; |
| 288 bool draw_on_compositing_end_; | 297 bool draw_on_compositing_end_; |
| 289 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; | 298 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; |
| 290 SwapState swap_state_; | 299 SwapState swap_state_; |
| 291 | 300 |
| 301 LayerAnimatorCollection layer_animator_collection_; |
| 302 |
| 292 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 303 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
| 293 | 304 |
| 294 DISALLOW_COPY_AND_ASSIGN(Compositor); | 305 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 295 }; | 306 }; |
| 296 | 307 |
| 297 } // namespace ui | 308 } // namespace ui |
| 298 | 309 |
| 299 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 310 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |