5 #ifndef FLUTTER_IMPELLER_TOOLKIT_INTEROP_FORMATS_H_
6 #define FLUTTER_IMPELLER_TOOLKIT_INTEROP_FORMATS_H_
10 #include "flutter/display_list/dl_builder.h"
11 #include "flutter/display_list/dl_color.h"
12 #include "flutter/display_list/geometry/dl_path_builder.h"
13 #include "flutter/txt/src/txt/font_style.h"
14 #include "flutter/txt/src/txt/font_weight.h"
15 #include "flutter/txt/src/txt/paragraph_style.h"
24 #include "flutter/third_party/skia/include/core/SkM44.h"
25 #include "flutter/third_party/skia/include/core/SkPath.h"
26 #include "flutter/third_party/skia/include/core/SkRRect.h"
34 return SkRect::MakeXYWH(rect->
x, rect->
y, rect->
width, rect->
height);
38 return SkPoint::Make(point.
x, point.
y);
42 return SkColorSetARGB(color.
alpha * 255,
54 return SkRect::MakeXYWH(rect.
GetX(),
64 return SkPathFillType::kWinding;
66 return SkPathFillType::kEvenOdd;
68 return SkPathFillType::kWinding;
72 return SkIRect::MakeXYWH(rect.
GetX(),
79 template <
class SkiaType,
class OtherType>
80 std::vector<SkiaType>
ToSkiaType(
const std::vector<OtherType>& other_vec) {
81 std::vector<SkiaType> skia_vec;
82 skia_vec.reserve(other_vec.size());
83 for (
const auto& other : other_vec) {
90 return flutter::DlColor::RGBA(color.
red,
98 return SkM44::ColMajor(matrix.
m).asM33();
101 template <
class DlType,
class OtherType>
103 std::vector<DlType> dl_vec;
104 dl_vec.reserve(other_vec.size());
105 for (
const auto& other : other_vec) {
115 return flutter::DlImageSampling::kNearestNeighbor;
117 return flutter::DlImageSampling::kLinear;
119 return flutter::DlImageSampling::kLinear;
125 return flutter::DlBlurStyle::kNormal;
127 return flutter::DlBlurStyle::kSolid;
129 return flutter::DlBlurStyle::kOuter;
131 return flutter::DlBlurStyle::kInner;
133 return flutter::DlBlurStyle::kNormal;
137 using Mode = flutter::DlBlendMode;
146 return Mode::kSrcOver;
148 return Mode::kDstOver;
154 return Mode::kSrcOut;
156 return Mode::kDstOut;
158 return Mode::kSrcATop;
160 return Mode::kDstATop;
166 return Mode::kModulate;
168 return Mode::kScreen;
170 return Mode::kOverlay;
172 return Mode::kDarken;
174 return Mode::kLighten;
176 return Mode::kColorDodge;
178 return Mode::kColorBurn;
180 return Mode::kHardLight;
182 return Mode::kSoftLight;
184 return Mode::kDifference;
186 return Mode::kExclusion;
188 return Mode::kMultiply;
192 return Mode::kSaturation;
196 return Mode::kLuminosity;
198 return Mode::kSrcOver;
202 using Corner = SkRRect::Corner;
203 SkVector sk_radii[4];
209 result.setRectRadii(
ToSkiaType(rect), sk_radii);
215 m.
m[4], m.
m[5], m.
m[6], m.
m[7],
216 m.
m[8], m.
m[9], m.
m[10], m.
m[11],
217 m.
m[12], m.
m[13], m.
m[14], m.
m[15]
232 to.
m[10] = from.
m[10];
233 to.
m[11] = from.
m[11];
234 to.
m[12] = from.
m[12];
235 to.
m[13] = from.
m[13];
236 to.
m[14] = from.
m[14];
237 to.
m[15] = from.
m[15];
245 return Point{point.
x, point.
y};
249 return Size{point.
x, point.
y};
259 return flutter::DlTileMode::kClamp;
261 return flutter::DlTileMode::kRepeat;
263 return flutter::DlTileMode::kMirror;
265 return flutter::DlTileMode::kDecal;
267 return flutter::DlTileMode::kClamp;
292 return flutter::DlClipOp::kDifference;
294 return flutter::DlClipOp::kIntersect;
296 return flutter::DlClipOp::kDifference;
375 return flutter::DlDrawStyle::kFill;
377 return flutter::DlDrawStyle::kStroke;
379 return flutter::DlDrawStyle::kStrokeAndFill;
381 return flutter::DlDrawStyle::kFill;
387 return flutter::DlStrokeCap::kButt;
389 return flutter::DlStrokeCap::kRound;
391 return flutter::DlStrokeCap::kSquare;
393 return flutter::DlStrokeCap::kButt;
399 return flutter::DlStrokeJoin::kMiter;
401 return flutter::DlStrokeJoin::kRound;
403 return flutter::DlStrokeJoin::kBevel;
405 return flutter::DlStrokeJoin::kMiter;
422 switch (color_space) {
424 return flutter::DlColorSpace::kSRGB;
426 return flutter::DlColorSpace::kExtendedSRGB;
428 return flutter::DlColorSpace::kDisplayP3;
430 return flutter::DlColorSpace::kSRGB;
434 return flutter::DlColor(color.
alpha,
446 return txt::TextDecorationStyle::kSolid;
448 return txt::TextDecorationStyle::kDouble;
450 return txt::TextDecorationStyle::kDotted;
452 return txt::TextDecorationStyle::kDashed;
454 return txt::TextDecorationStyle::kWavy;
456 return txt::TextDecorationStyle::kSolid;
462 return txt::FontWeight::w100;
464 return txt::FontWeight::w200;
466 return txt::FontWeight::w300;
468 return txt::FontWeight::w400;
470 return txt::FontWeight::w500;
472 return txt::FontWeight::w600;
474 return txt::FontWeight::w700;
476 return txt::FontWeight::w800;
478 return txt::FontWeight::w900;
480 return txt::FontWeight::w400;
486 return txt::FontStyle::normal;
488 return txt::FontStyle::italic;
490 return txt::FontStyle::normal;
496 return txt::TextAlign::left;
498 return txt::TextAlign::right;
500 return txt::TextAlign::center;
502 return txt::TextAlign::justify;
508 return txt::TextAlign::left;
514 return txt::TextDirection::rtl;
516 return txt::TextDirection::ltr;
518 return txt::TextDirection::ltr;
@ kImpellerFillTypeNonZero
@ kImpellerTextDirectionLTR
@ kImpellerTextDirectionRTL
@ kImpellerTextureSamplingNearestNeighbor
@ kImpellerTextureSamplingLinear
ImpellerTextDecorationStyle
@ kImpellerTextDecorationStyleSolid
@ kImpellerTextDecorationStyleWavy
@ kImpellerTextDecorationStyleDouble
@ kImpellerTextDecorationStyleDotted
@ kImpellerTextDecorationStyleDashed
@ kImpellerStrokeJoinRound
@ kImpellerStrokeJoinBevel
@ kImpellerStrokeJoinMiter
@ kImpellerBlendModeSaturation
@ kImpellerBlendModeSoftLight
@ kImpellerBlendModeHardLight
@ kImpellerBlendModeLuminosity
@ kImpellerBlendModeLighten
@ kImpellerBlendModeModulate
@ kImpellerBlendModeSourceIn
@ kImpellerBlendModeDifference
@ kImpellerBlendModeClear
@ kImpellerBlendModeColor
@ kImpellerBlendModeMultiply
@ kImpellerBlendModeSourceATop
@ kImpellerBlendModeDestinationOut
@ kImpellerBlendModeScreen
@ kImpellerBlendModeExclusion
@ kImpellerBlendModeColorBurn
@ kImpellerBlendModeDarken
@ kImpellerBlendModeOverlay
@ kImpellerBlendModeDestinationIn
@ kImpellerBlendModeDestinationATop
@ kImpellerBlendModeDestination
@ kImpellerBlendModeSourceOver
@ kImpellerBlendModeColorDodge
@ kImpellerBlendModeDestinationOver
@ kImpellerBlendModeSource
@ kImpellerBlendModeSourceOut
@ kImpellerStrokeCapRound
@ kImpellerStrokeCapSquare
@ kImpellerDrawStyleStroke
@ kImpellerDrawStyleStrokeAndFill
@ kImpellerColorSpaceExtendedSRGB
@ kImpellerColorSpaceSRGB
@ kImpellerColorSpaceDisplayP3
@ kImpellerTileModeMirror
@ kImpellerTileModeRepeat
@ kImpellerTextAlignmentJustify
@ kImpellerTextAlignmentLeft
@ kImpellerTextAlignmentCenter
@ kImpellerTextAlignmentRight
@ kImpellerTextAlignmentStart
@ kImpellerTextAlignmentEnd
@ kImpellerFontStyleItalic
@ kImpellerFontStyleNormal
@ kImpellerClipOperationIntersect
@ kImpellerClipOperationDifference
@ kImpellerBlurStyleNormal
@ kImpellerBlurStyleOuter
@ kImpellerBlurStyleInner
@ kImpellerBlurStyleSolid
@ kImpellerPixelFormatRGBA8888
constexpr SkVector ToSkiaVector(const Size &point)
constexpr txt::TextDecorationStyle ToTxtType(ImpellerTextDecorationStyle style)
SkMatrix ToSkMatrix(const Matrix &matrix)
constexpr Matrix ToImpellerType(const ImpellerMatrix &m)
constexpr Size ToImpellerSize(const ImpellerPoint &point)
constexpr void FromImpellerType(const Matrix &from, ImpellerMatrix &to)
constexpr flutter::DlColor ToDisplayListType(Color color)
constexpr std::optional< SkRect > ToSkiaType(const ImpellerRect *rect)
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
ImpellerColorSpace color_space
ImpellerPoint bottom_left
ImpellerPoint bottom_right
A 4x4 matrix using column-major storage.
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
constexpr static TRect MakeXYWH(Type x, Type y, Type width, Type height)
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
static constexpr TSize MakeWH(Type width, Type height)