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
9namespace flutter {
10
11ViewportMetrics::ViewportMetrics() = default;
12
13ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio,
14 double p_physical_width,
15 double p_physical_height,
16 double p_physical_padding_top,
17 double p_physical_padding_right,
18 double p_physical_padding_bottom,
19 double p_physical_padding_left,
20 double p_physical_view_inset_top,
21 double p_physical_view_inset_right,
22 double p_physical_view_inset_bottom,
23 double p_physical_view_inset_left,
24 double p_physical_system_gesture_inset_top,
25 double p_physical_system_gesture_inset_right,
26 double p_physical_system_gesture_inset_bottom,
27 double p_physical_system_gesture_inset_left)
28 : device_pixel_ratio(p_device_pixel_ratio),
29 physical_width(p_physical_width),
30 physical_height(p_physical_height),
31 physical_padding_top(p_physical_padding_top),
32 physical_padding_right(p_physical_padding_right),
33 physical_padding_bottom(p_physical_padding_bottom),
34 physical_padding_left(p_physical_padding_left),
35 physical_view_inset_top(p_physical_view_inset_top),
36 physical_view_inset_right(p_physical_view_inset_right),
37 physical_view_inset_bottom(p_physical_view_inset_bottom),
38 physical_view_inset_left(p_physical_view_inset_left),
39 physical_system_gesture_inset_top(p_physical_system_gesture_inset_top),
40 physical_system_gesture_inset_right(
41 p_physical_system_gesture_inset_right),
42 physical_system_gesture_inset_bottom(
43 p_physical_system_gesture_inset_bottom),
44 physical_system_gesture_inset_left(p_physical_system_gesture_inset_left) {
45 // Ensure we don't have nonsensical dimensions.
46 FML_DCHECK(physical_width >= 0);
47 FML_DCHECK(physical_height >= 0);
48 FML_DCHECK(device_pixel_ratio > 0);
49}
50
51ViewportMetrics::ViewportMetrics(double p_device_pixel_ratio,
52 double p_physical_width,
53 double p_physical_height)
54 : device_pixel_ratio(p_device_pixel_ratio),
55 physical_width(p_physical_width),
56 physical_height(p_physical_height) {
57 // Ensure we don't have nonsensical dimensions.
58 FML_DCHECK(physical_width >= 0);
59 FML_DCHECK(physical_height >= 0);
60 FML_DCHECK(device_pixel_ratio > 0);
61}
62
63} // namespace flutter
64