| Flutter Impeller |

skia_conversions.h
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 #ifndef FLUTTER_IMPELLER_DISPLAY_LIST_SKIA_CONVERSIONS_H_
6 #define FLUTTER_IMPELLER_DISPLAY_LIST_SKIA_CONVERSIONS_H_
7
8 #include "display_list/dl_color.h"
9 #include "display_list/effects/dl_color_source.h"
10 #include "impeller/core/formats.h"
11 #include "impeller/geometry/color.h"
12 #include "impeller/geometry/path.h"
13 #include "impeller/geometry/path_builder.h"
14 #include "impeller/geometry/point.h"
15 #include "impeller/geometry/rect.h"
16 #include "third_party/skia/include/core/SkColor.h"
17 #include "third_party/skia/include/core/SkColorType.h"
18 #include "third_party/skia/include/core/SkPath.h"
19 #include "third_party/skia/include/core/SkPoint.h"
20 #include "third_party/skia/include/core/SkRRect.h"
21 #include "third_party/skia/include/core/SkRSXform.h"
22 #include "third_party/skia/include/core/SkTextBlob.h"
23
24 namespace impeller {
25 namespace skia_conversions {
26
27 Rect ToRect(const SkRect& rect);
28
29 std::optional<Rect> ToRect(const SkRect* rect);
30
31 std::vector<Rect> ToRects(const SkRect tex[], int count);
32
33 std::vector<Point> ToPoints(const SkPoint points[], int count);
34
35 Point ToPoint(const SkPoint& point);
36
37 Size ToSize(const SkPoint& point);
38
39 Color ToColor(const flutter::DlColor& color);
40
41 std::vector<Matrix> ToRSXForms(const SkRSXform xform[], int count);
42
43 PathBuilder::RoundingRadii ToRoundingRadii(const SkRRect& rrect);
44
45 Path ToPath(const SkPath& path, Point shift = Point(0, 0));
46
47 Path ToPath(const SkRRect& rrect);
48
49 Path PathDataFromTextBlob(const sk_sp<SkTextBlob>& blob,
50 Point shift = Point(0, 0));
51
52 std::optional<impeller::PixelFormat> ToPixelFormat(SkColorType type);
53
54 /// @brief Convert display list colors + stops into impeller colors and stops,
55 /// taking care to ensure that the stops monotonically increase from 0.0 to 1.0.
56 ///
57 /// The general process is:
58 /// * Ensure that the first gradient stop value is 0.0. If not, insert a new
59 /// stop with a value of 0.0 and use the first gradient color as this new
60 /// stops color.
61 /// * Ensure the last gradient stop value is 1.0. If not, insert a new stop
62 /// with a value of 1.0 and use the last gradient color as this stops color.
63 /// * Clamp all gradient values between the values of 0.0 and 1.0.
64 /// * For all stop values, ensure that the values are monotonically increasing
65 /// by clamping each value to a minimum of the previous stop value and itself.
66 /// For example, with stop values of 0.0, 0.5, 0.4, 1.0, we would clamp such
67 /// that the values were 0.0, 0.5, 0.5, 1.0.
68 void ConvertStops(const flutter::DlGradientColorSourceBase* gradient,
69 std::vector<Color>& colors,
70 std::vector<float>& stops);
71
72 } // namespace skia_conversions
73 } // namespace impeller
74
75 #endif // FLUTTER_IMPELLER_DISPLAY_LIST_SKIA_CONVERSIONS_H_
path.h
impeller::skia_conversions::PathDataFromTextBlob
Path PathDataFromTextBlob(const sk_sp< SkTextBlob > &blob, Point shift)
Definition: skia_conversions.cc:174
point.h
impeller::skia_conversions::ToPoints
std::vector< Point > ToPoints(const SkPoint points[], int count)
Definition: skia_conversions.cc:31
impeller::skia_conversions::ToPixelFormat
std::optional< impeller::PixelFormat > ToPixelFormat(SkColorType type)
Definition: skia_conversions.cc:182
impeller::skia_conversions::ConvertStops
void ConvertStops(const flutter::DlGradientColorSourceBase *gradient, std::vector< Color > &colors, std::vector< float > &stops)
Convert display list colors + stops into impeller colors and stops, taking care to ensure that the st...
Definition: skia_conversions.cc:198
impeller::skia_conversions::ToSize
Size ToSize(const SkPoint &point)
Definition: skia_conversions.cc:144
formats.h
impeller::skia_conversions::ToRects
std::vector< Rect > ToRects(const SkRect tex[], int count)
Definition: skia_conversions.cc:23
impeller::skia_conversions::ToColor
Color ToColor(const flutter::DlColor &color)
Definition: skia_conversions.cc:148
impeller::Size
TSize< Scalar > Size
Definition: size.h:137
path_builder.h
impeller::skia_conversions::ToRect
Rect ToRect(const SkRect &rect)
Definition: skia_conversions.cc:12
impeller::skia_conversions::ToRoundingRadii
PathBuilder::RoundingRadii ToRoundingRadii(const SkRRect &rrect)
Definition: skia_conversions.cc:39
impeller::Point
TPoint< Scalar > Point
Definition: point.h:316
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:661
impeller::skia_conversions::ToPoint
Point ToPoint(const SkPoint &point)
Definition: skia_conversions.cc:140
rect.h
impeller::skia_conversions::ToRSXForms
std::vector< Matrix > ToRSXForms(const SkRSXform xform[], int count)
Definition: skia_conversions.cc:157
color.h
impeller
Definition: aiks_blur_unittests.cc:20
impeller::skia_conversions::ToPath
Path ToPath(const SkPath &path, Point shift)
Definition: skia_conversions.cc:49