| 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/core/sampler_descriptor.h"
12 #include "impeller/geometry/color.h"
13 #include "impeller/geometry/path.h"
14 #include "impeller/geometry/path_builder.h"
15 #include "impeller/geometry/point.h"
16 #include "impeller/geometry/rect.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 /// @brief Like SkRRect.isSimple, but allows the corners to differ by
28 /// kEhCloseEnough.
29 ///
30 /// An RRect is simple if all corner radii are approximately
31 /// equal.
32 bool IsNearlySimpleRRect(const SkRRect& rr);
33
34 Rect ToRect(const SkRect& rect);
35
36 std::optional<Rect> ToRect(const SkRect* rect);
37 std::optional<const Rect> ToRect(const flutter::DlRect* rect);
38
39 std::vector<Rect> ToRects(const SkRect tex[], int count);
40 std::vector<Rect> ToRects(const flutter::DlRect tex[], int count);
41
42 std::vector<Point> ToPoints(const SkPoint points[], int count);
43 std::vector<Point> ToPoints(const flutter::DlPoint points[], int count);
44
45 Point ToPoint(const SkPoint& point);
46
47 Size ToSize(const SkPoint& point);
48
49 Color ToColor(const flutter::DlColor& color);
50
51 Matrix ToRSXForm(const SkRSXform& form);
52
53 PathBuilder::RoundingRadii ToRoundingRadii(const SkRRect& rrect);
54
55 Path ToPath(const SkRRect& rrect);
56
57 std::optional<impeller::PixelFormat> ToPixelFormat(SkColorType type);
58
59 impeller::SamplerDescriptor ToSamplerDescriptor(
60 const flutter::DlImageSampling options);
61
62 Matrix ToMatrix(const SkMatrix& m);
63
64 BlendMode ToBlendMode(flutter::DlBlendMode mode);
65
66 /// @brief Convert display list colors + stops into impeller colors and stops,
67 /// taking care to ensure that the stops monotonically increase from 0.0 to 1.0.
68 ///
69 /// The general process is:
70 /// * Ensure that the first gradient stop value is 0.0. If not, insert a new
71 /// stop with a value of 0.0 and use the first gradient color as this new
72 /// stops color.
73 /// * Ensure the last gradient stop value is 1.0. If not, insert a new stop
74 /// with a value of 1.0 and use the last gradient color as this stops color.
75 /// * Clamp all gradient values between the values of 0.0 and 1.0.
76 /// * For all stop values, ensure that the values are monotonically increasing
77 /// by clamping each value to a minimum of the previous stop value and itself.
78 /// For example, with stop values of 0.0, 0.5, 0.4, 1.0, we would clamp such
79 /// that the values were 0.0, 0.5, 0.5, 1.0.
80 void ConvertStops(const flutter::DlGradientColorSourceBase* gradient,
81 std::vector<Color>& colors,
82 std::vector<float>& stops);
83
84 } // namespace skia_conversions
85 } // namespace impeller
86
87 #endif // FLUTTER_IMPELLER_DISPLAY_LIST_SKIA_CONVERSIONS_H_
point.h
impeller::skia_conversions::ToPoints
std::vector< Point > ToPoints(const SkPoint points[], int count)
Definition: skia_conversions.cc:64
impeller::skia_conversions::IsNearlySimpleRRect
bool IsNearlySimpleRRect(const SkRRect &rr)
Like SkRRect.isSimple, but allows the corners to differ by kEhCloseEnough.
Definition: skia_conversions.cc:21
impeller::skia_conversions::ToPixelFormat
std::optional< impeller::PixelFormat > ToPixelFormat(SkColorType type)
Definition: skia_conversions.cc:128
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:144
impeller::skia_conversions::ToSize
Size ToSize(const SkPoint &point)
Definition: skia_conversions.cc:102
impeller::BlendMode
BlendMode
Definition: color.h:58
impeller::skia_conversions::ToSamplerDescriptor
impeller::SamplerDescriptor ToSamplerDescriptor(const flutter::DlImageSampling options)
Definition: skia_conversions.cc:169
impeller::skia_conversions::ToMatrix
Matrix ToMatrix(const SkMatrix &m)
Definition: skia_conversions.cc:193
path_builder.h
impeller::skia_conversions::ToRects
std::vector< Rect > ToRects(const SkRect tex[], int count)
Definition: skia_conversions.cc:48
formats.h
impeller::skia_conversions::ToColor
Color ToColor(const flutter::DlColor &color)
Definition: skia_conversions.cc:106
impeller::Size
TSize< Scalar > Size
Definition: size.h:137
impeller::skia_conversions::ToBlendMode
BlendMode ToBlendMode(flutter::DlBlendMode mode)
Definition: skia_conversions.cc:204
impeller::skia_conversions::ToRSXForm
Matrix ToRSXForm(const SkRSXform &form)
Definition: skia_conversions.cc:117
impeller::skia_conversions::ToRect
Rect ToRect(const SkRect &rect)
Definition: skia_conversions.cc:30
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:15
impeller::skia_conversions::ToRoundingRadii
PathBuilder::RoundingRadii ToRoundingRadii(const SkRRect &rrect)
Definition: skia_conversions.cc:80
impeller::Point
TPoint< Scalar > Point
Definition: point.h:327
impeller::DlRect
flutter::DlRect DlRect
Definition: dl_dispatcher.h:23
type
GLenum type
Definition: blit_command_gles.cc:127
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:776
impeller::skia_conversions::ToPoint
Point ToPoint(const SkPoint &point)
Definition: skia_conversions.cc:98
sampler_descriptor.h
impeller::DlPoint
flutter::DlPoint DlPoint
Definition: dl_dispatcher.h:22
rect.h
color.h
color
DlColor color
Definition: dl_golden_blur_unittests.cc:24
impeller::skia_conversions::ToPath
Path ToPath(const SkRRect &rrect)
Definition: skia_conversions.cc:90
path.h
impeller
Definition: allocation.cc:12