OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/display/mojo/display_type_converters.h" | 5 #include "ui/display/mojo/display_type_converters.h" |
6 | 6 |
7 #include "ui/display/display.h" | 7 #include "ui/display/display.h" |
8 #include "ui/gfx/geometry/mojo/geometry_type_converters.h" | |
9 | 8 |
10 namespace mojo { | 9 namespace mojo { |
11 | 10 |
12 // static | 11 // static |
13 display::Display | 12 display::Display |
14 TypeConverter<display::Display, mus::mojom::DisplayPtr>::Convert( | 13 TypeConverter<display::Display, mus::mojom::DisplayPtr>::Convert( |
15 const mus::mojom::DisplayPtr& input) { | 14 const mus::mojom::DisplayPtr& input) { |
16 if (input.is_null()) | 15 if (input.is_null()) |
17 return display::Display(); | 16 return display::Display(); |
18 | 17 |
19 display::Display result(input->id); | 18 display::Display result(input->id); |
20 gfx::Rect pixel_bounds = input->bounds.To<gfx::Rect>(); | 19 gfx::Rect pixel_bounds = input->bounds; |
21 gfx::Rect pixel_work_area = input->work_area.To<gfx::Rect>(); | 20 gfx::Rect pixel_work_area = input->work_area; |
22 float pixel_ratio = input->device_pixel_ratio; | 21 float pixel_ratio = input->device_pixel_ratio; |
23 | 22 |
24 gfx::Rect dip_bounds = | 23 gfx::Rect dip_bounds = |
25 gfx::ScaleToEnclosingRect(pixel_bounds, 1.f / pixel_ratio); | 24 gfx::ScaleToEnclosingRect(pixel_bounds, 1.f / pixel_ratio); |
26 gfx::Rect dip_work_area = | 25 gfx::Rect dip_work_area = |
27 gfx::ScaleToEnclosingRect(pixel_work_area, 1.f / pixel_ratio); | 26 gfx::ScaleToEnclosingRect(pixel_work_area, 1.f / pixel_ratio); |
28 result.set_bounds(dip_bounds); | 27 result.set_bounds(dip_bounds); |
29 result.set_work_area(dip_work_area); | 28 result.set_work_area(dip_work_area); |
30 result.set_device_scale_factor(input->device_pixel_ratio); | 29 result.set_device_scale_factor(input->device_pixel_ratio); |
31 | 30 |
(...skipping 19 matching lines...) Expand all Loading... |
51 result.set_touch_support(display::Display::TOUCH_SUPPORT_AVAILABLE); | 50 result.set_touch_support(display::Display::TOUCH_SUPPORT_AVAILABLE); |
52 break; | 51 break; |
53 case mus::mojom::TouchSupport::UNAVAILABLE: | 52 case mus::mojom::TouchSupport::UNAVAILABLE: |
54 result.set_touch_support(display::Display::TOUCH_SUPPORT_UNAVAILABLE); | 53 result.set_touch_support(display::Display::TOUCH_SUPPORT_UNAVAILABLE); |
55 break; | 54 break; |
56 } | 55 } |
57 return result; | 56 return result; |
58 } | 57 } |
59 | 58 |
60 } // namespace mojo | 59 } // namespace mojo |
OLD | NEW |