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 "mojo/skia/type_converters.h" | 5 #include "mojo/skia/type_converters.h" |
6 | 6 |
7 namespace mojo { | 7 namespace mojo { |
8 | 8 |
9 SkPoint TypeConverter<SkPoint, mojo::Point>::Convert(const mojo::Point& input) { | 9 SkIPoint TypeConverter<SkIPoint, mojo::Point>::Convert( |
10 return SkPoint::Make(input.x, input.y); | 10 const mojo::Point& input) { |
| 11 return SkIPoint::Make(input.x, input.y); |
11 } | 12 } |
12 | 13 |
13 mojo::Point TypeConverter<mojo::Point, SkPoint>::Convert(const SkPoint& input) { | 14 mojo::Point TypeConverter<mojo::Point, SkIPoint>::Convert( |
| 15 const SkIPoint& input) { |
14 mojo::Point output; | 16 mojo::Point output; |
15 output.x = input.x(); | 17 output.x = input.x(); |
16 output.y = input.y(); | 18 output.y = input.y(); |
17 return output; | 19 return output; |
18 } | 20 } |
19 | 21 |
20 SkRect TypeConverter<SkRect, mojo::Rect>::Convert(const mojo::Rect& input) { | 22 SkPoint TypeConverter<SkPoint, mojo::PointF>::Convert( |
21 return SkRect::MakeXYWH(input.x, input.y, input.width, input.height); | 23 const mojo::PointF& input) { |
| 24 return SkPoint::Make(input.x, input.y); |
22 } | 25 } |
23 | 26 |
24 mojo::Rect TypeConverter<mojo::Rect, SkRect>::Convert(const SkRect& input) { | 27 mojo::PointF TypeConverter<mojo::PointF, SkPoint>::Convert( |
| 28 const SkPoint& input) { |
| 29 mojo::PointF output; |
| 30 output.x = input.x(); |
| 31 output.y = input.y(); |
| 32 return output; |
| 33 } |
| 34 |
| 35 SkIRect TypeConverter<SkIRect, mojo::Rect>::Convert(const mojo::Rect& input) { |
| 36 return SkIRect::MakeXYWH(input.x, input.y, input.width, input.height); |
| 37 } |
| 38 |
| 39 mojo::Rect TypeConverter<mojo::Rect, SkIRect>::Convert(const SkIRect& input) { |
25 mojo::Rect output; | 40 mojo::Rect output; |
26 output.x = input.x(); | 41 output.x = input.x(); |
27 output.y = input.y(); | 42 output.y = input.y(); |
28 output.width = input.width(); | 43 output.width = input.width(); |
29 output.height = input.height(); | 44 output.height = input.height(); |
30 return output; | 45 return output; |
31 } | 46 } |
32 | 47 |
33 SkRRect TypeConverter<SkRRect, mojo::RRect>::Convert(const mojo::RRect& input) { | 48 SkRect TypeConverter<SkRect, mojo::RectF>::Convert(const mojo::RectF& input) { |
| 49 return SkRect::MakeXYWH(input.x, input.y, input.width, input.height); |
| 50 } |
| 51 |
| 52 mojo::RectF TypeConverter<mojo::RectF, SkRect>::Convert(const SkRect& input) { |
| 53 mojo::RectF output; |
| 54 output.x = input.x(); |
| 55 output.y = input.y(); |
| 56 output.width = input.width(); |
| 57 output.height = input.height(); |
| 58 return output; |
| 59 } |
| 60 |
| 61 SkRRect TypeConverter<SkRRect, mojo::RRectF>::Convert( |
| 62 const mojo::RRectF& input) { |
34 SkVector radii[4] = { | 63 SkVector radii[4] = { |
35 {input.top_left_radius_x, input.top_left_radius_y}, | 64 {input.top_left_radius_x, input.top_left_radius_y}, |
36 {input.top_right_radius_x, input.top_right_radius_y}, | 65 {input.top_right_radius_x, input.top_right_radius_y}, |
37 {input.bottom_left_radius_x, input.bottom_left_radius_y}, | 66 {input.bottom_left_radius_x, input.bottom_left_radius_y}, |
38 {input.bottom_right_radius_x, input.bottom_right_radius_y}}; | 67 {input.bottom_right_radius_x, input.bottom_right_radius_y}}; |
39 SkRRect output; | 68 SkRRect output; |
40 output.setRectRadii( | 69 output.setRectRadii( |
41 SkRect::MakeXYWH(input.x, input.y, input.width, input.height), radii); | 70 SkRect::MakeXYWH(input.x, input.y, input.width, input.height), radii); |
42 return output; | 71 return output; |
43 } | 72 } |
44 | 73 |
45 mojo::RRect TypeConverter<mojo::RRect, SkRRect>::Convert(const SkRRect& input) { | 74 mojo::RRectF TypeConverter<mojo::RRectF, SkRRect>::Convert( |
46 mojo::RRect output; | 75 const SkRRect& input) { |
| 76 mojo::RRectF output; |
47 output.x = input.rect().x(); | 77 output.x = input.rect().x(); |
48 output.y = input.rect().y(); | 78 output.y = input.rect().y(); |
49 output.width = input.rect().width(); | 79 output.width = input.rect().width(); |
50 output.height = input.rect().height(); | 80 output.height = input.rect().height(); |
51 output.top_left_radius_x = input.radii(SkRRect::kUpperLeft_Corner).x(); | 81 output.top_left_radius_x = input.radii(SkRRect::kUpperLeft_Corner).x(); |
52 output.top_left_radius_y = input.radii(SkRRect::kUpperLeft_Corner).y(); | 82 output.top_left_radius_y = input.radii(SkRRect::kUpperLeft_Corner).y(); |
53 output.top_right_radius_x = input.radii(SkRRect::kUpperRight_Corner).x(); | 83 output.top_right_radius_x = input.radii(SkRRect::kUpperRight_Corner).x(); |
54 output.top_right_radius_y = input.radii(SkRRect::kUpperRight_Corner).y(); | 84 output.top_right_radius_y = input.radii(SkRRect::kUpperRight_Corner).y(); |
55 output.bottom_left_radius_x = input.radii(SkRRect::kLowerLeft_Corner).x(); | 85 output.bottom_left_radius_x = input.radii(SkRRect::kLowerLeft_Corner).x(); |
56 output.bottom_left_radius_y = input.radii(SkRRect::kLowerLeft_Corner).y(); | 86 output.bottom_left_radius_y = input.radii(SkRRect::kLowerLeft_Corner).y(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 output->matrix[10] = 1.f; | 120 output->matrix[10] = 1.f; |
91 output->matrix[11] = 0.f; | 121 output->matrix[11] = 0.f; |
92 output->matrix[12] = input[6]; | 122 output->matrix[12] = input[6]; |
93 output->matrix[13] = input[7]; | 123 output->matrix[13] = input[7]; |
94 output->matrix[14] = 0.f; | 124 output->matrix[14] = 0.f; |
95 output->matrix[15] = input[8]; | 125 output->matrix[15] = input[8]; |
96 return output.Pass(); | 126 return output.Pass(); |
97 } | 127 } |
98 | 128 |
99 } // namespace mojo | 129 } // namespace mojo |
OLD | NEW |