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_LIB_UI_WINDOW_VIEWPORT_METRICS_H_ 6 #define FLUTTER_LIB_UI_WINDOW_VIEWPORT_METRICS_H_ 7 8 #include <stdint.h> 9 10 namespace flutter { 11 12 // This is the value of double.maxFinite from dart:core. 13 // Platforms that do not explicitly set a depth will use this value, which 14 // avoids the need to special case logic that wants to check the max depth on 15 // the Dart side. 16 static const double kUnsetDepth = 1.7976931348623157e+308; 17 18 struct __attribute__((visibility("default"))) ViewportMetrics { 19 ViewportMetrics(); 20 21 // Create a 2D ViewportMetrics instance. 22 ViewportMetrics(double p_device_pixel_ratio, 23 double p_physical_width, 24 double p_physical_height, 25 double p_physical_padding_top, 26 double p_physical_padding_right, 27 double p_physical_padding_bottom, 28 double p_physical_padding_left, 29 double p_physical_view_inset_top, 30 double p_physical_view_inset_right, 31 double p_physical_view_inset_bottom, 32 double p_physical_view_inset_left, 33 double p_physical_system_gesture_inset_top, 34 double p_physical_system_gesture_inset_right, 35 double p_physical_system_gesture_inset_bottom, 36 double p_physical_system_gesture_inset_left); 37 38 // Create a ViewportMetrics instance that contains z information. 39 ViewportMetrics(double p_device_pixel_ratio, 40 double p_physical_width, 41 double p_physical_height, 42 double p_physical_depth, 43 double p_physical_padding_top, 44 double p_physical_padding_right, 45 double p_physical_padding_bottom, 46 double p_physical_padding_left, 47 double p_physical_view_inset_front, 48 double p_physical_view_inset_back, 49 double p_physical_view_inset_top, 50 double p_physical_view_inset_right, 51 double p_physical_view_inset_bottom, 52 double p_physical_view_inset_left); 53 54 ViewportMetrics(const ViewportMetrics& other); 55 56 double device_pixel_ratio = 1.0; 57 double physical_width = 0; 58 double physical_height = 0; 59 double physical_depth = kUnsetDepth; 60 double physical_padding_top = 0; 61 double physical_padding_right = 0; 62 double physical_padding_bottom = 0; 63 double physical_padding_left = 0; 64 double physical_view_inset_top = 0; 65 double physical_view_inset_right = 0; 66 double physical_view_inset_bottom = 0; 67 double physical_view_inset_left = 0; 68 double physical_view_inset_front = kUnsetDepth; 69 double physical_view_inset_back = kUnsetDepth; 70 double physical_system_gesture_inset_top = 0; 71 double physical_system_gesture_inset_right = 0; 72 double physical_system_gesture_inset_bottom = 0; 73 double physical_system_gesture_inset_left = 0; 74 }; 75 76 struct LogicalSize { 77 double width = 0.0; 78 double height = 0.0; 79 double depth = kUnsetDepth; 80 }; 81 82 struct LogicalInset { 83 double left = 0.0; 84 double top = 0.0; 85 double right = 0.0; 86 double bottom = 0.0; 87 double front = kUnsetDepth; 88 double back = kUnsetDepth; 89 }; 90 91 struct LogicalMetrics { 92 LogicalSize size; 93 double scale = 1.0; 94 double scale_z = 1.0; 95 LogicalInset padding; 96 LogicalInset view_inset; 97 }; 98 99 } // namespace flutter 100 101 #endif // FLUTTER_LIB_UI_WINDOW_VIEWPORT_METRICS_H_ 102