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