Flutter Engine
 
Loading...
Searching...
No Matches
dl_sk_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_DISPLAY_LIST_SKIA_DL_SK_CONVERSIONS_H_
6#define FLUTTER_DISPLAY_LIST_SKIA_DL_SK_CONVERSIONS_H_
7
10
11namespace flutter {
12
13SkPaint ToSk(const DlPaint& paint);
14SkPaint ToStrokedSk(const DlPaint& paint);
15SkPaint ToNonShaderSk(const DlPaint& paint);
16
17inline SkBlendMode ToSk(DlBlendMode mode) {
18 return static_cast<SkBlendMode>(mode);
19}
20
21// Returns an SkColor4f representing this color in the sRGB color space.
22inline SkColor4f ToSkColor4f(DlColor color) {
23 if (color.getColorSpace() == DlColorSpace::kSRGB ||
25 return SkColor4f{color.getRedF(), color.getGreenF(), color.getBlueF(),
26 color.getAlphaF()};
27 } else {
29 }
30}
31
32inline SkColor ToSkColor(DlColor color) {
33 return color.argb();
34}
35
36inline SkPaint::Style ToSk(DlDrawStyle style) {
37 return static_cast<SkPaint::Style>(style);
38}
39
40inline SkPaint::Cap ToSk(DlStrokeCap cap) {
41 return static_cast<SkPaint::Cap>(cap);
42}
43
44inline SkPaint::Join ToSk(DlStrokeJoin join) {
45 return static_cast<SkPaint::Join>(join);
46}
47
48inline SkTileMode ToSk(DlTileMode dl_mode) {
49 return static_cast<SkTileMode>(dl_mode);
50}
51
52inline SkBlurStyle ToSk(const DlBlurStyle blur_style) {
53 return static_cast<SkBlurStyle>(blur_style);
54}
55
56inline SkFilterMode ToSk(const DlFilterMode filter_mode) {
57 return static_cast<SkFilterMode>(filter_mode);
58}
59
60inline SkVertices::VertexMode ToSk(DlVertexMode dl_mode) {
61 return static_cast<SkVertices::VertexMode>(dl_mode);
62}
63
64inline SkSamplingOptions ToSk(DlImageSampling sampling) {
65 switch (sampling) {
67 return SkSamplingOptions(SkCubicResampler{1 / 3.0f, 1 / 3.0f});
69 return SkSamplingOptions(SkFilterMode::kLinear);
71 return SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear);
73 return SkSamplingOptions(SkFilterMode::kNearest);
74 }
75}
76
77inline SkCanvas::SrcRectConstraint ToSk(DlSrcRectConstraint constraint) {
78 return static_cast<SkCanvas::SrcRectConstraint>(constraint);
79}
80
81inline SkClipOp ToSk(DlClipOp op) {
82 return static_cast<SkClipOp>(op);
83}
84
85inline SkCanvas::PointMode ToSk(DlPointMode mode) {
86 return static_cast<SkCanvas::PointMode>(mode);
87}
88
89extern sk_sp<SkShader> ToSk(const DlColorSource* source);
90inline sk_sp<SkShader> ToSk(
91 const std::shared_ptr<const DlColorSource>& source) {
92 return ToSk(source.get());
93}
94inline sk_sp<SkShader> ToSk(const DlColorSource& source) {
95 return ToSk(&source);
96}
97
98extern sk_sp<SkImageFilter> ToSk(const DlImageFilter* filter);
99inline sk_sp<SkImageFilter> ToSk(const std::shared_ptr<DlImageFilter>& filter) {
100 return ToSk(filter.get());
101}
102inline sk_sp<SkImageFilter> ToSk(const DlImageFilter& filter) {
103 return ToSk(&filter);
104}
105
106extern sk_sp<SkColorFilter> ToSk(const DlColorFilter* filter);
107inline sk_sp<SkColorFilter> ToSk(
108 const std::shared_ptr<const DlColorFilter>& filter) {
109 return ToSk(filter.get());
110}
111inline sk_sp<SkColorFilter> ToSk(const DlColorFilter& filter) {
112 return ToSk(&filter);
113}
114
115extern sk_sp<SkMaskFilter> ToSk(const DlMaskFilter* filter);
116inline sk_sp<SkMaskFilter> ToSk(
117 const std::shared_ptr<const DlMaskFilter>& filter) {
118 return ToSk(filter.get());
119}
120inline sk_sp<SkMaskFilter> ToSk(const DlMaskFilter& filter) {
121 return ToSk(&filter);
122}
123
124inline SkMatrix* ToSk(const DlMatrix* matrix, SkMatrix& scratch) {
125 return matrix ? &scratch.setAll(matrix->m[0], matrix->m[4], matrix->m[12], //
126 matrix->m[1], matrix->m[5], matrix->m[13], //
127 matrix->m[3], matrix->m[7], matrix->m[15])
128 : nullptr;
129}
130
131extern sk_sp<SkVertices> ToSk(const std::shared_ptr<DlVertices>& vertices);
132
133inline const SkRSXform* ToSk(const DlRSTransform* transforms) {
134 return reinterpret_cast<const SkRSXform*>(transforms);
135}
136
137} // namespace flutter
138
139#endif // FLUTTER_DISPLAY_LIST_SKIA_DL_SK_CONVERSIONS_H_
SkPaint ToSk(const DlPaint &paint)
DlStrokeJoin
Definition dl_paint.h:37
DlStrokeCap
Definition dl_paint.h:28
SkColor ToSkColor(DlColor color)
SkPaint ToStrokedSk(const DlPaint &paint)
DlPointMode
Definition dl_types.h:15
SkColor4f ToSkColor4f(DlColor color)
DlVertexMode
Defines the way in which the vertices of a DlVertices object are separated into triangles into which ...
Definition dl_vertices.h:18
SkPaint ToNonShaderSk(const DlPaint &paint)
DlDrawStyle
Definition dl_paint.h:19
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
DlSrcRectConstraint
Definition dl_types.h:21
BlendMode
Definition color.h:58
constexpr DlColorSpace getColorSpace() const
Definition dl_color.h:118
constexpr DlScalar getRedF() const
Definition dl_color.h:114
constexpr DlScalar getAlphaF() const
Definition dl_color.h:113
DlColor withColorSpace(DlColorSpace color_space) const
Definition dl_color.cc:40
constexpr DlScalar getBlueF() const
Definition dl_color.h:116
constexpr DlScalar getGreenF() const
Definition dl_color.h:115
uint32_t argb() const
Definition dl_color.h:158
A 4x4 matrix using column-major storage.
Definition matrix.h:37
Scalar m[16]
Definition matrix.h:39