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 3 // found in the LICENSE file. 4 5 #ifndef UI_COMPOSITOR_COMPOSITOR_OBSERVER_H_ 6 #define UI_COMPOSITOR_COMPOSITOR_OBSERVER_H_ 7 8 #include "base/time/time.h" 9 #include "build/build_config.h" 10 #include "ui/compositor/compositor_export.h" 11 12 namespace gfx { 13 class Size; 14 struct PresentationFeedback; 15 } // namespace gfx 16 17 namespace ui { 18 19 class Compositor; 20 21 // A compositor observer is notified when compositing completes. 22 class COMPOSITOR_EXPORT CompositorObserver { 23 public: 24 virtual ~CompositorObserver() = default; 25 26 // A commit proxies information from the main thread to the compositor 27 // thread. It typically happens when some state changes that will require a 28 // composite. In the multi-threaded case, many commits may happen between 29 // two successive composites. In the single-threaded, a single commit 30 // between two composites (just before the composite as part of the 31 // composite cycle). If the compositor is locked, it will not send this 32 // this signal. OnCompositingDidCommit(Compositor * compositor)33 virtual void OnCompositingDidCommit(Compositor* compositor) {} 34 35 // Called when compositing started: it has taken all the layer changes into 36 // account and has issued the graphics commands. OnCompositingStarted(Compositor * compositor,base::TimeTicks start_time)37 virtual void OnCompositingStarted(Compositor* compositor, 38 base::TimeTicks start_time) {} 39 40 // Called when compositing completes: the present to screen has completed. OnCompositingEnded(Compositor * compositor)41 virtual void OnCompositingEnded(Compositor* compositor) {} 42 43 // Called when a child of the compositor is resizing. OnCompositingChildResizing(Compositor * compositor)44 virtual void OnCompositingChildResizing(Compositor* compositor) {} 45 46 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_BSD) 47 // Called when a swap with new size is completed. OnCompositingCompleteSwapWithNewSize(ui::Compositor * compositor,const gfx::Size & size)48 virtual void OnCompositingCompleteSwapWithNewSize(ui::Compositor* compositor, 49 const gfx::Size& size) {} 50 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_BSD) 51 52 // Called at the top of the compositor's destructor, to give observers a 53 // chance to remove themselves. OnCompositingShuttingDown(Compositor * compositor)54 virtual void OnCompositingShuttingDown(Compositor* compositor) {} 55 56 // Called when the presentation feedback was received from the viz. OnDidPresentCompositorFrame(uint32_t frame_token,const gfx::PresentationFeedback & feedback)57 virtual void OnDidPresentCompositorFrame( 58 uint32_t frame_token, 59 const gfx::PresentationFeedback& feedback) {} 60 }; 61 62 } // namespace ui 63 64 #endif // UI_COMPOSITOR_COMPOSITOR_OBSERVER_H_ 65