Flutter Engine
vsync_waiter.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 FLUTTER_SHELL_PLATFORM_FUCHSIA_VSYNC_WAITER_H_
6 #define FLUTTER_SHELL_PLATFORM_FUCHSIA_VSYNC_WAITER_H_
7 
8 #include <lib/async/cpp/wait.h>
9 
10 #include "flutter/fml/macros.h"
11 #include "flutter/fml/memory/weak_ptr.h"
12 #include "flutter/fml/time/time_delta.h"
13 #include "flutter/fml/time/time_point.h"
14 #include "flutter/shell/common/vsync_waiter.h"
16 
17 namespace flutter_runner {
18 
19 class VsyncWaiter final : public flutter::VsyncWaiter {
20  public:
21  static constexpr zx_signals_t SessionPresentSignal = ZX_EVENT_SIGNALED;
22 
23  VsyncWaiter(std::string debug_label,
24  zx_handle_t session_present_handle,
25  flutter::TaskRunners task_runners,
26  fml::TimeDelta vsync_offset);
27 
28  ~VsyncWaiter() override;
29 
31  const fml::TimePoint now,
32  const fml::TimePoint last_frame_presentation_time,
33  const fml::TimeDelta presentation_interval);
34 
35  private:
36  const std::string debug_label_;
37  async::Wait session_wait_;
39 
40  // For accessing the VsyncWaiter via the UI thread, necessary for the callback
41  // for AwaitVSync()
42  std::unique_ptr<fml::WeakPtrFactory<VsyncWaiter>> weak_factory_ui_;
44 
45  // |flutter::VsyncWaiter|
46  void AwaitVSync() override;
47 
48  void FireCallbackWhenSessionAvailable();
49 
50  void FireCallbackNow();
51 
52  FML_DISALLOW_COPY_AND_ASSIGN(VsyncWaiter);
53 };
54 
55 } // namespace flutter_runner
56 
57 #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_VSYNC_WAITER_H_
static fml::TimePoint SnapToNextPhase(const fml::TimePoint now, const fml::TimePoint last_frame_presentation_time, const fml::TimeDelta presentation_interval)
VsyncWaiter(std::string debug_label, zx_handle_t session_present_handle, flutter::TaskRunners task_runners, fml::TimeDelta vsync_offset)
Definition: vsync_waiter.cc:22
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43
static constexpr zx_signals_t SessionPresentSignal
Definition: vsync_waiter.h:21