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 MOJO_SERVICES_GFX_COMPOSITION_CPP_SCHEDULING_H_ |
| 6 #define MOJO_SERVICES_GFX_COMPOSITION_CPP_SCHEDULING_H_ |
| 7 |
| 8 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h" |
| 9 |
| 10 namespace mojo { |
| 11 namespace gfx { |
| 12 namespace composition { |
| 13 |
| 14 // Tracks frame scheduling information. |
| 15 class FrameTracker { |
| 16 public: |
| 17 FrameTracker(); |
| 18 ~FrameTracker(); |
| 19 |
| 20 // Returns the number of frames that have been tracked. |
| 21 uint64_t frame_count() const { return frame_count_; } |
| 22 |
| 23 // Returns the current frame info. |
| 24 // This value is not meaningful when |frame_count()| is zero. |
| 25 const mojo::gfx::composition::FrameInfo& frame_info() const { |
| 26 return frame_info_; |
| 27 } |
| 28 |
| 29 // Clears the frame tracker's state such that the next update will be |
| 30 // treated as if it were the first. |
| 31 void Clear(); |
| 32 |
| 33 // Updates |frame_info()| with new frame scheduling information |
| 34 // from |raw_frame_info| and applies compensation for lag. |
| 35 // |
| 36 // |now| should come from a recent call to |mojo::GetTimeTicksNow()|. |
| 37 // |
| 38 // Whenever an application receives new frame scheduling information from the |
| 39 // system, it should call this function before using it. |
| 40 // |
| 41 // Returns the time delta between the previous frame and the current frame |
| 42 // in microseconds, or 0 if this is the first frame. |
| 43 uint64_t Update(const mojo::gfx::composition::FrameInfo& raw_frame_info, |
| 44 MojoTimeTicks now); |
| 45 |
| 46 private: |
| 47 uint64_t frame_count_ = 0u; |
| 48 mojo::gfx::composition::FrameInfo frame_info_; |
| 49 |
| 50 MOJO_DISALLOW_COPY_AND_ASSIGN(FrameTracker); |
| 51 }; |
| 52 |
| 53 } // namespace composition |
| 54 } // namespace gfx |
| 55 } // namespace mojo |
| 56 |
| 57 #endif // MOJO_SERVICES_GFX_COMPOSITION_CPP_SCHEDULING_H_ |
OLD | NEW |