Flutter Engine
flutter::Window Class Referencefinal

#include <window.h>

Public Member Functions

 Window (int64_t window_id, ViewportMetrics metrics)
 
 ~Window ()
 
int window_id () const
 
const ViewportMetricsviewport_metrics () const
 
void DispatchPointerDataPacket (const PointerDataPacket &packet)
 
void UpdateWindowMetrics (const ViewportMetrics &metrics)
 

Detailed Description

Definition at line 19 of file window.h.

Constructor & Destructor Documentation

◆ Window()

flutter::Window::Window ( int64_t  window_id,
ViewportMetrics  metrics 
)

Definition at line 14 of file window.cc.

References tonic::DartState::Current(), tonic::DartPersistentValue::Set(), and tonic::ToDart().

15  : window_id_(window_id), viewport_metrics_(metrics) {
16  library_.Set(tonic::DartState::Current(),
17  Dart_LookupLibrary(tonic::ToDart("dart:ui")));
18 }
void Set(DartState *dart_state, Dart_Handle value)
static DartState * Current()
Definition: dart_state.cc:55
int window_id() const
Definition: window.h:25
Dart_Handle ToDart(const T &object)

◆ ~Window()

flutter::Window::~Window ( )

Definition at line 20 of file window.cc.

20 {}

Member Function Documentation

◆ DispatchPointerDataPacket()

void flutter::Window::DispatchPointerDataPacket ( const PointerDataPacket packet)

Definition at line 22 of file window.cc.

References tonic::DartByteData::Create(), tonic::DartPersistentValue::dart_state(), tonic::DartInvokeField(), flutter::PointerDataPacket::data(), tonic::LogIfError(), and tonic::DartPersistentValue::value().

Referenced by viewport_metrics().

22  {
23  std::shared_ptr<tonic::DartState> dart_state = library_.dart_state().lock();
24  if (!dart_state) {
25  return;
26  }
27  tonic::DartState::Scope scope(dart_state);
28 
29  const std::vector<uint8_t>& buffer = packet.data();
30  Dart_Handle data_handle =
31  tonic::DartByteData::Create(buffer.data(), buffer.size());
32  if (Dart_IsError(data_handle)) {
33  return;
34  }
36  library_.value(), "_dispatchPointerDataPacket", {data_handle}));
37 }
Dart_PersistentHandle value() const
Dart_Handle DartInvokeField(Dart_Handle target, const char *name, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:12
const std::weak_ptr< DartState > & dart_state() const
static Dart_Handle Create(const void *data, size_t length)
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ UpdateWindowMetrics()

void flutter::Window::UpdateWindowMetrics ( const ViewportMetrics metrics)

Definition at line 39 of file window.cc.

References tonic::DartPersistentValue::dart_state(), tonic::DartInvokeField(), flutter::ViewportMetrics::device_pixel_ratio, tonic::LogIfError(), flutter::ViewportMetrics::physical_height, flutter::ViewportMetrics::physical_padding_bottom, flutter::ViewportMetrics::physical_padding_left, flutter::ViewportMetrics::physical_padding_right, flutter::ViewportMetrics::physical_padding_top, flutter::ViewportMetrics::physical_system_gesture_inset_bottom, flutter::ViewportMetrics::physical_system_gesture_inset_left, flutter::ViewportMetrics::physical_system_gesture_inset_right, flutter::ViewportMetrics::physical_system_gesture_inset_top, flutter::ViewportMetrics::physical_view_inset_bottom, flutter::ViewportMetrics::physical_view_inset_left, flutter::ViewportMetrics::physical_view_inset_right, flutter::ViewportMetrics::physical_view_inset_top, flutter::ViewportMetrics::physical_width, tonic::ToDart(), and tonic::DartPersistentValue::value().

Referenced by flutter::testing::TEST_F(), and viewport_metrics().

39  {
40  viewport_metrics_ = metrics;
41 
42  std::shared_ptr<tonic::DartState> dart_state = library_.dart_state().lock();
43  if (!dart_state) {
44  return;
45  }
46  tonic::DartState::Scope scope(dart_state);
48  library_.value(), "_updateWindowMetrics",
49  {
50  tonic::ToDart(window_id_),
51  tonic::ToDart(metrics.device_pixel_ratio),
52  tonic::ToDart(metrics.physical_width),
53  tonic::ToDart(metrics.physical_height),
54  tonic::ToDart(metrics.physical_padding_top),
55  tonic::ToDart(metrics.physical_padding_right),
56  tonic::ToDart(metrics.physical_padding_bottom),
57  tonic::ToDart(metrics.physical_padding_left),
58  tonic::ToDart(metrics.physical_view_inset_top),
59  tonic::ToDart(metrics.physical_view_inset_right),
60  tonic::ToDart(metrics.physical_view_inset_bottom),
61  tonic::ToDart(metrics.physical_view_inset_left),
62  tonic::ToDart(metrics.physical_system_gesture_inset_top),
63  tonic::ToDart(metrics.physical_system_gesture_inset_right),
64  tonic::ToDart(metrics.physical_system_gesture_inset_bottom),
65  tonic::ToDart(metrics.physical_system_gesture_inset_left),
66  }));
67 }
Dart_PersistentHandle value() const
Dart_Handle DartInvokeField(Dart_Handle target, const char *name, std::initializer_list< Dart_Handle > args)
Definition: dart_invoke.cc:12
const std::weak_ptr< DartState > & dart_state() const
Dart_Handle ToDart(const T &object)
bool LogIfError(Dart_Handle handle)
Definition: dart_error.cc:15

◆ viewport_metrics()

const ViewportMetrics& flutter::Window::viewport_metrics ( ) const
inline

Definition at line 27 of file window.h.

References DispatchPointerDataPacket(), and UpdateWindowMetrics().

Referenced by flutter::Scene::create(), flutter::Canvas::drawShadow(), and flutter::testing::TEST_F().

27 { return viewport_metrics_; }

◆ window_id()

int flutter::Window::window_id ( ) const
inline

Definition at line 25 of file window.h.

25 { return window_id_; }

The documentation for this class was generated from the following files: