Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1204)

Side by Side Diff: ui/compositor/compositor.h

Issue 291843012: compositor: Tick the UI animations from cc, instead of from timer callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 DISALLOW_COPY_AND_ASSIGN(CompositorLock); 128 DISALLOW_COPY_AND_ASSIGN(CompositorLock);
128 }; 129 };
129 130
130 // Compositor object to take care of GPU painting. 131 // Compositor object to take care of GPU painting.
131 // A Browser compositor object is responsible for generating the final 132 // A Browser compositor object is responsible for generating the final
132 // displayable form of pixels comprising a single widget's contents. It draws an 133 // displayable form of pixels comprising a single widget's contents. It draws an
133 // appropriately transformed texture for each transformed view in the widget's 134 // appropriately transformed texture for each transformed view in the widget's
134 // view hierarchy. 135 // view hierarchy.
135 class COMPOSITOR_EXPORT Compositor 136 class COMPOSITOR_EXPORT Compositor
136 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), 137 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient),
137 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient) { 138 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient),
139 NON_EXPORTED_BASE(public LayerAnimatorCollectionDelegate) {
138 public: 140 public:
139 // This is deprecated, and will be removed shortly. 141 // This is deprecated, and will be removed shortly.
140 // TODO(sky): remove this. 142 // TODO(sky): remove this.
141 explicit Compositor(gfx::AcceleratedWidget widget); 143 explicit Compositor(gfx::AcceleratedWidget widget);
142 Compositor(gfx::AcceleratedWidget widget, 144 Compositor(gfx::AcceleratedWidget widget,
143 ui::ContextFactory* context_factory); 145 ui::ContextFactory* context_factory);
144 virtual ~Compositor(); 146 virtual ~Compositor();
145 147
146 ui::ContextFactory* context_factory() { return context_factory_; } 148 ui::ContextFactory* context_factory() { return context_factory_; }
147 149
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 219
218 // Signals swap has completed. 220 // Signals swap has completed.
219 void OnSwapBuffersComplete(); 221 void OnSwapBuffersComplete();
220 222
221 // Signals swap has aborted (e.g. lost context). 223 // Signals swap has aborted (e.g. lost context).
222 void OnSwapBuffersAborted(); 224 void OnSwapBuffersAborted();
223 225
224 // LayerTreeHostClient implementation. 226 // LayerTreeHostClient implementation.
225 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} 227 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {}
226 virtual void DidBeginMainFrame() OVERRIDE {} 228 virtual void DidBeginMainFrame() OVERRIDE {}
227 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} 229 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE;
228 virtual void Layout() OVERRIDE; 230 virtual void Layout() OVERRIDE;
229 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, 231 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
230 float page_scale) OVERRIDE {} 232 float page_scale) OVERRIDE {}
231 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) 233 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback)
232 OVERRIDE; 234 OVERRIDE;
233 virtual void DidInitializeOutputSurface() OVERRIDE {} 235 virtual void DidInitializeOutputSurface() OVERRIDE {}
234 virtual void WillCommit() OVERRIDE {} 236 virtual void WillCommit() OVERRIDE {}
235 virtual void DidCommit() OVERRIDE; 237 virtual void DidCommit() OVERRIDE;
236 virtual void DidCommitAndDrawFrame() OVERRIDE; 238 virtual void DidCommitAndDrawFrame() OVERRIDE;
237 virtual void DidCompleteSwapBuffers() OVERRIDE; 239 virtual void DidCompleteSwapBuffers() OVERRIDE;
238 240
239 // cc::LayerTreeHostSingleThreadClient implementation. 241 // cc::LayerTreeHostSingleThreadClient implementation.
240 virtual void ScheduleComposite() OVERRIDE; 242 virtual void ScheduleComposite() OVERRIDE;
241 virtual void ScheduleAnimation() OVERRIDE; 243 virtual void ScheduleAnimation() OVERRIDE;
242 virtual void DidPostSwapBuffers() OVERRIDE; 244 virtual void DidPostSwapBuffers() OVERRIDE;
243 virtual void DidAbortSwapBuffers() OVERRIDE; 245 virtual void DidAbortSwapBuffers() OVERRIDE;
244 246
247 // LayerAnimatorCollectionDelegate implementation.
248 virtual void ScheduleAnimationForLayerCollection() OVERRIDE;
249
245 int last_started_frame() { return last_started_frame_; } 250 int last_started_frame() { return last_started_frame_; }
246 int last_ended_frame() { return last_ended_frame_; } 251 int last_ended_frame() { return last_ended_frame_; }
247 252
248 bool IsLocked() { return compositor_lock_ != NULL; } 253 bool IsLocked() { return compositor_lock_ != NULL; }
249 254
250 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; 255 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const;
251 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); 256 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state);
252 257
258 LayerAnimatorCollection* layer_animator_collection() {
259 return &layer_animator_collection_;
260 }
261
253 private: 262 private:
254 friend class base::RefCounted<Compositor>; 263 friend class base::RefCounted<Compositor>;
255 friend class CompositorLock; 264 friend class CompositorLock;
256 265
257 // Called from both constructors. It's temporary while we have both 266 // Called from both constructors. It's temporary while we have both
258 // constructors. 267 // constructors.
259 // TODO(sky): nuke this. 268 // TODO(sky): nuke this.
260 void Init(); 269 void Init();
261 270
262 // Called by CompositorLock. 271 // Called by CompositorLock.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 307
299 // Prevent more than one draw from being scheduled. 308 // Prevent more than one draw from being scheduled.
300 bool defer_draw_scheduling_; 309 bool defer_draw_scheduling_;
301 310
302 // Used to prevent Draw()s while a composite is in progress. 311 // Used to prevent Draw()s while a composite is in progress.
303 bool waiting_on_compositing_end_; 312 bool waiting_on_compositing_end_;
304 bool draw_on_compositing_end_; 313 bool draw_on_compositing_end_;
305 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED }; 314 enum SwapState { SWAP_NONE, SWAP_POSTED, SWAP_COMPLETED };
306 SwapState swap_state_; 315 SwapState swap_state_;
307 316
317 LayerAnimatorCollection layer_animator_collection_;
318
308 base::WeakPtrFactory<Compositor> schedule_draw_factory_; 319 base::WeakPtrFactory<Compositor> schedule_draw_factory_;
309 320
310 DISALLOW_COPY_AND_ASSIGN(Compositor); 321 DISALLOW_COPY_AND_ASSIGN(Compositor);
311 }; 322 };
312 323
313 } // namespace ui 324 } // namespace ui
314 325
315 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 326 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698