Flutter Engine
viewport_metrics.cc
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 #include "flutter/lib/ui/window/viewport_metrics.h"
6 
7 #include "flutter/fml/logging.h"
8 
9 namespace flutter {
10 
12 
13 ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio,
14  double p_physical_width,
15  double p_physical_height)
16  : device_pixel_ratio(p_device_pixel_ratio),
17  physical_width(p_physical_width),
18  physical_height(p_physical_height) {}
19 
20 ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio,
21  double p_physical_width,
22  double p_physical_height,
23  double p_physical_padding_top,
24  double p_physical_padding_right,
25  double p_physical_padding_bottom,
26  double p_physical_padding_left,
27  double p_physical_view_inset_top,
28  double p_physical_view_inset_right,
29  double p_physical_view_inset_bottom,
30  double p_physical_view_inset_left,
31  double p_physical_system_gesture_inset_top,
32  double p_physical_system_gesture_inset_right,
33  double p_physical_system_gesture_inset_bottom,
34  double p_physical_system_gesture_inset_left)
35  : device_pixel_ratio(p_device_pixel_ratio),
36  physical_width(p_physical_width),
37  physical_height(p_physical_height),
38  physical_padding_top(p_physical_padding_top),
39  physical_padding_right(p_physical_padding_right),
40  physical_padding_bottom(p_physical_padding_bottom),
41  physical_padding_left(p_physical_padding_left),
42  physical_view_inset_top(p_physical_view_inset_top),
43  physical_view_inset_right(p_physical_view_inset_right),
44  physical_view_inset_bottom(p_physical_view_inset_bottom),
45  physical_view_inset_left(p_physical_view_inset_left),
46  physical_system_gesture_inset_top(p_physical_system_gesture_inset_top),
48  p_physical_system_gesture_inset_right),
50  p_physical_system_gesture_inset_bottom),
51  physical_system_gesture_inset_left(p_physical_system_gesture_inset_left) {
52 }
53 
54 bool operator==(const ViewportMetrics& a, const ViewportMetrics& b) {
55  return a.device_pixel_ratio == b.device_pixel_ratio &&
74 }
75 
76 std::ostream& operator<<(std::ostream& os, const ViewportMetrics& a) {
77  os << "DPR: " << a.device_pixel_ratio << " "
78  << "Size: [" << a.physical_width << "W " << a.physical_height << "H] "
79  << "Padding: [" << a.physical_padding_top << "T "
80  << a.physical_padding_right << "R " << a.physical_padding_bottom << "B "
81  << a.physical_padding_left << "L] "
82  << "Insets: [" << a.physical_view_inset_top << "T "
84  << "B " << a.physical_view_inset_left << "L] "
85  << "Gesture Insets: [" << a.physical_system_gesture_inset_top << "T "
89  return os;
90 }
91 
92 } // namespace flutter
std::ostream & operator<<(std::ostream &os, const ViewportMetrics &a)
bool operator==(const ViewportMetrics &a, const ViewportMetrics &b)