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