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