OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 SERVICES_GFX_COMPOSITOR_FRAME_DISPATCHER_H_ |
| 6 #define SERVICES_GFX_COMPOSITOR_FRAME_DISPATCHER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
| 12 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h" |
| 13 |
| 14 namespace compositor { |
| 15 |
| 16 using FrameCallback = |
| 17 base::Callback<void(mojo::gfx::composition::FrameInfoPtr)>; |
| 18 |
| 19 // Maintains a list of pending frame callbacks to be dispatched. |
| 20 class FrameDispatcher { |
| 21 public: |
| 22 FrameDispatcher(); |
| 23 ~FrameDispatcher(); |
| 24 |
| 25 // Adds a callback, returns true if it was the first pending callback. |
| 26 bool AddCallback(const FrameCallback& callback); |
| 27 |
| 28 // Dispatches all pending callbacks then clears the list. |
| 29 void DispatchCallbacks(const mojo::gfx::composition::FrameInfo& frame_info); |
| 30 |
| 31 private: |
| 32 std::vector<FrameCallback> pending_callbacks_; |
| 33 |
| 34 DISALLOW_COPY_AND_ASSIGN(FrameDispatcher); |
| 35 }; |
| 36 |
| 37 } // namespace compositor |
| 38 |
| 39 #endif // SERVICES_GFX_COMPOSITOR_FRAME_DISPATCHER_H_ |
OLD | NEW |