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

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

Issue 775143003: cc: Implement unified BeginFrame on aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move common logic to DelegatedFrameHost Created 6 years 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
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/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/output/begin_frame_args.h"
16 #include "cc/surfaces/surface_sequence.h" 17 #include "cc/surfaces/surface_sequence.h"
17 #include "cc/trees/layer_tree_host_client.h" 18 #include "cc/trees/layer_tree_host_client.h"
18 #include "cc/trees/layer_tree_host_single_thread_client.h" 19 #include "cc/trees/layer_tree_host_single_thread_client.h"
19 #include "third_party/skia/include/core/SkColor.h" 20 #include "third_party/skia/include/core/SkColor.h"
21 #include "ui/base/compositor/compositor_begin_frame_observer.h"
20 #include "ui/compositor/compositor_animation_observer.h" 22 #include "ui/compositor/compositor_animation_observer.h"
21 #include "ui/compositor/compositor_export.h" 23 #include "ui/compositor/compositor_export.h"
22 #include "ui/compositor/compositor_observer.h" 24 #include "ui/compositor/compositor_observer.h"
23 #include "ui/compositor/layer_animator_collection.h" 25 #include "ui/compositor/layer_animator_collection.h"
24 #include "ui/gfx/native_widget_types.h" 26 #include "ui/gfx/native_widget_types.h"
25 #include "ui/gfx/size.h" 27 #include "ui/gfx/size.h"
26 #include "ui/gfx/vector2d.h" 28 #include "ui/gfx/vector2d.h"
27 29
28 namespace base { 30 namespace base {
29 class MessageLoopProxy; 31 class MessageLoopProxy;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Compositor does not own observers. It is the responsibility of the 218 // Compositor does not own observers. It is the responsibility of the
217 // observer to remove itself when it is done observing. 219 // observer to remove itself when it is done observing.
218 void AddObserver(CompositorObserver* observer); 220 void AddObserver(CompositorObserver* observer);
219 void RemoveObserver(CompositorObserver* observer); 221 void RemoveObserver(CompositorObserver* observer);
220 bool HasObserver(const CompositorObserver* observer) const; 222 bool HasObserver(const CompositorObserver* observer) const;
221 223
222 void AddAnimationObserver(CompositorAnimationObserver* observer); 224 void AddAnimationObserver(CompositorAnimationObserver* observer);
223 void RemoveAnimationObserver(CompositorAnimationObserver* observer); 225 void RemoveAnimationObserver(CompositorAnimationObserver* observer);
224 bool HasAnimationObserver(const CompositorAnimationObserver* observer) const; 226 bool HasAnimationObserver(const CompositorAnimationObserver* observer) const;
225 227
228 void AddBeginFrameObserver(
229 CompositorBeginFrameObserver* observer,
230 const cc::BeginFrameArgs& last_begin_frame_args_sent_to_observer);
231 void RemoveBeginFrameObserver(CompositorBeginFrameObserver* observer);
232 bool HasBeginFrameObserver(CompositorBeginFrameObserver* observer);
233
226 // Creates a compositor lock. Returns NULL if it is not possible to lock at 234 // Creates a compositor lock. Returns NULL if it is not possible to lock at
227 // this time (i.e. we're waiting to complete a previous unlock). 235 // this time (i.e. we're waiting to complete a previous unlock).
228 scoped_refptr<CompositorLock> GetCompositorLock(); 236 scoped_refptr<CompositorLock> GetCompositorLock();
229 237
230 // Internal functions, called back by command-buffer contexts on swap buffer 238 // Internal functions, called back by command-buffer contexts on swap buffer
231 // events. 239 // events.
232 240
233 // Signals swap has been posted. 241 // Signals swap has been posted.
234 void OnSwapBuffersPosted(); 242 void OnSwapBuffersPosted();
235 243
(...skipping 14 matching lines...) Expand all
250 float top_controls_delta) override {} 258 float top_controls_delta) override {}
251 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, 259 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta,
252 float page_scale, 260 float page_scale,
253 float top_controls_delta) override {} 261 float top_controls_delta) override {}
254 void RequestNewOutputSurface(bool fallback) override; 262 void RequestNewOutputSurface(bool fallback) override;
255 void DidInitializeOutputSurface() override {} 263 void DidInitializeOutputSurface() override {}
256 void WillCommit() override {} 264 void WillCommit() override {}
257 void DidCommit() override; 265 void DidCommit() override;
258 void DidCommitAndDrawFrame() override; 266 void DidCommitAndDrawFrame() override;
259 void DidCompleteSwapBuffers() override; 267 void DidCompleteSwapBuffers() override;
268 void SendBeginFramesToChildren(const cc::BeginFrameArgs& args) override;
260 269
261 // cc::LayerTreeHostSingleThreadClient implementation. 270 // cc::LayerTreeHostSingleThreadClient implementation.
262 void DidPostSwapBuffers() override; 271 void DidPostSwapBuffers() override;
263 void DidAbortSwapBuffers() override; 272 void DidAbortSwapBuffers() override;
264 273
265 bool IsLocked() { return compositor_lock_ != NULL; } 274 bool IsLocked() { return compositor_lock_ != NULL; }
266 275
267 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; 276 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const;
268 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); 277 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state);
269 const cc::RendererSettings& GetRendererSettings() const; 278 const cc::RendererSettings& GetRendererSettings() const;
270 279
271 LayerAnimatorCollection* layer_animator_collection() { 280 LayerAnimatorCollection* layer_animator_collection() {
272 return &layer_animator_collection_; 281 return &layer_animator_collection_;
273 } 282 }
274 283
275 cc::SurfaceIdAllocator* surface_id_allocator() { 284 cc::SurfaceIdAllocator* surface_id_allocator() {
276 return surface_id_allocator_.get(); 285 return surface_id_allocator_.get();
277 } 286 }
278 287
279 private: 288 private:
280 friend class base::RefCounted<Compositor>; 289 friend class base::RefCounted<Compositor>;
281 friend class CompositorLock; 290 friend class CompositorLock;
282 291
283 // Called by CompositorLock. 292 // Called by CompositorLock.
284 void UnlockCompositor(); 293 void UnlockCompositor();
285 294
286 // Called to release any pending CompositorLock 295 // Called to release any pending CompositorLock
287 void CancelCompositorLock(); 296 void CancelCompositorLock();
288 297
298 // Request scheduling of next BeginFrame to LayerTreeHost.
299 void SetChildrenNeedBeginFrames(bool need_begin_frame);
300
289 gfx::Size size_; 301 gfx::Size size_;
290 302
291 ui::ContextFactory* context_factory_; 303 ui::ContextFactory* context_factory_;
292 304
293 // The root of the Layer tree drawn by this compositor. 305 // The root of the Layer tree drawn by this compositor.
294 Layer* root_layer_; 306 Layer* root_layer_;
295 307
296 ObserverList<CompositorObserver> observer_list_; 308 ObserverList<CompositorObserver> observer_list_;
297 ObserverList<CompositorAnimationObserver> animation_observer_list_; 309 ObserverList<CompositorAnimationObserver> animation_observer_list_;
310 ObserverList<CompositorBeginFrameObserver> begin_frame_observer_list_;
298 311
299 gfx::AcceleratedWidget widget_; 312 gfx::AcceleratedWidget widget_;
300 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; 313 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_;
301 scoped_refptr<cc::Layer> root_web_layer_; 314 scoped_refptr<cc::Layer> root_web_layer_;
302 scoped_ptr<cc::LayerTreeHost> host_; 315 scoped_ptr<cc::LayerTreeHost> host_;
303 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_; 316 scoped_refptr<base::MessageLoopProxy> compositor_thread_loop_;
304 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 317 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
305 318
306 // The manager of vsync parameters for this compositor. 319 // The manager of vsync parameters for this compositor.
307 scoped_refptr<CompositorVSyncManager> vsync_manager_; 320 scoped_refptr<CompositorVSyncManager> vsync_manager_;
308 321
309 // The device scale factor of the monitor that this compositor is compositing 322 // The device scale factor of the monitor that this compositor is compositing
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
320 LayerAnimatorCollection layer_animator_collection_; 333 LayerAnimatorCollection layer_animator_collection_;
321 334
335 // Used to send to any new CompositorBeginFrameObserver immediately.
336 cc::BeginFrameArgs last_begin_frame_args_;
337
322 base::WeakPtrFactory<Compositor> weak_ptr_factory_; 338 base::WeakPtrFactory<Compositor> weak_ptr_factory_;
323 339
324 DISALLOW_COPY_AND_ASSIGN(Compositor); 340 DISALLOW_COPY_AND_ASSIGN(Compositor);
325 }; 341 };
326 342
327 } // namespace ui 343 } // namespace ui
328 344
329 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 345 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698