| 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 "flutter/display_list/dl_blend_mode.h"
9 #include "flutter/display_list/dl_color.h"
10 #include "flutter/display_list/effects/dl_color_sources.h"
11 #include "impeller/core/formats.h"
12 #include "impeller/core/sampler_descriptor.h"
13 #include "impeller/geometry/color.h"
14 #include "impeller/geometry/path.h"
15 #include "impeller/geometry/path_builder.h"
16 #include "impeller/geometry/point.h"
17 #include "impeller/geometry/rect.h"
18 #include "third_party/skia/include/core/SkColorType.h"
19 #include "third_party/skia/include/core/SkPath.h"
20 #include "third_party/skia/include/core/SkPoint.h"
21 #include "third_party/skia/include/core/SkRRect.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 std::optional<impeller::PixelFormat> ToPixelFormat(SkColorType type);
52
53 impeller::SamplerDescriptor ToSamplerDescriptor(
54 const flutter::DlImageSampling options);
55
56 Matrix ToMatrix(const SkMatrix& m);
57
58 BlendMode ToBlendMode(flutter::DlBlendMode mode);
59
60 /// @brief Convert display list colors + stops into impeller colors and stops,
61 /// taking care to ensure that the stops monotonically increase from 0.0 to 1.0.
62 ///
63 /// The general process is:
64 /// * Ensure that the first gradient stop value is 0.0. If not, insert a new
65 /// stop with a value of 0.0 and use the first gradient color as this new
66 /// stops color.
67 /// * Ensure the last gradient stop value is 1.0. If not, insert a new stop
68 /// with a value of 1.0 and use the last gradient color as this stops color.
69 /// * Clamp all gradient values between the values of 0.0 and 1.0.
70 /// * For all stop values, ensure that the values are monotonically increasing
71 /// by clamping each value to a minimum of the previous stop value and itself.
72 /// For example, with stop values of 0.0, 0.5, 0.4, 1.0, we would clamp such
73 /// that the values were 0.0, 0.5, 0.5, 1.0.
74 void ConvertStops(const flutter::DlGradientColorSourceBase* gradient,
75 std::vector<Color>& colors,
76 std::vector<float>& stops);
77
78 } // namespace skia_conversions
79 } // namespace impeller
80
81 #endif // FLUTTER_IMPELLER_DISPLAY_LIST_SKIA_CONVERSIONS_H_
type
GLenum type
Definition: blit_command_gles.cc:151
color.h
formats.h
path.h
path_builder.h
impeller::skia_conversions::ToMatrix
Matrix ToMatrix(const SkMatrix &m)
Definition: skia_conversions.cc:165
impeller::skia_conversions::ToBlendMode
BlendMode ToBlendMode(flutter::DlBlendMode mode)
Definition: skia_conversions.cc:176
impeller::skia_conversions::ToPixelFormat
std::optional< impeller::PixelFormat > ToPixelFormat(SkColorType type)
Definition: skia_conversions.cc:100
impeller::skia_conversions::ToPoints
std::vector< Point > ToPoints(const SkPoint points[], int count)
Definition: skia_conversions.cc:65
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:116
impeller::skia_conversions::ToPoint
Point ToPoint(const SkPoint &point)
Definition: skia_conversions.cc:81
impeller::skia_conversions::ToSize
Size ToSize(const SkPoint &point)
Definition: skia_conversions.cc:85
impeller::skia_conversions::ToRects
std::vector< Rect > ToRects(const SkRect tex[], int count)
Definition: skia_conversions.cc:49
impeller::skia_conversions::ToSamplerDescriptor
impeller::SamplerDescriptor ToSamplerDescriptor(const flutter::DlImageSampling options)
Definition: skia_conversions.cc:141
impeller::skia_conversions::IsNearlySimpleRRect
bool IsNearlySimpleRRect(const SkRRect &rr)
Like SkRRect.isSimple, but allows the corners to differ by kEhCloseEnough.
Definition: skia_conversions.cc:22
impeller::skia_conversions::ToRect
Rect ToRect(const SkRect &rect)
Definition: skia_conversions.cc:31
impeller::skia_conversions::ToColor
Color ToColor(const flutter::DlColor &color)
Definition: skia_conversions.cc:89
impeller
Definition: allocation.cc:12
impeller::DlRect
flutter::DlRect DlRect
Definition: dl_dispatcher.h:25
impeller::Rect
TRect< Scalar > Rect
Definition: rect.h:792
impeller::Point
TPoint< Scalar > Point
Definition: point.h:327
impeller::DlPoint
flutter::DlPoint DlPoint
Definition: dl_dispatcher.h:24
impeller::BlendMode
BlendMode
Definition: color.h:58
impeller::Size
TSize< Scalar > Size
Definition: size.h:171
point.h
rect.h
sampler_descriptor.h
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:14