10#if IMPELLER_SUPPORTS_RENDERING
14#include "third_party/skia/include/core/SkFontMgr.h"
15#include "third_party/skia/include/core/SkTypeface.h"
24 return builder.
Build();
30 for (
int y = 10;
y <= 60;
y += 10) {
31 for (
int x = 10;
x <= 60;
x += 10) {
39 return outer_builder.
Build();
44 for (
int i = 0;
i < ops;
i++) {
47 return builder.
Build();
52 SkSurfaces::Raster(SkImageInfo::MakeN32Premul(w,
h));
60 for (
int y = 0;
y < w;
y += checker_size) {
61 for (
int x = 0;
x <
h;
x += checker_size) {
62 DlPaint& cellp = ((
x +
y) & 1) == 0 ? p0 : p1;
73 surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(w,
h));
76 SkImageInfo::MakeN32(w,
h, SkAlphaType::kOpaque_SkAlphaType);
77 surface = SkSurfaces::Raster(info);
79 SkCanvas* canvas =
surface->getCanvas();
80 canvas->drawColor(color.
argb());
92 {0, 8, 0, [](
DlOpReceiver& r) { r.setAntiAlias(
true); }},
95 {0, 0, 0, [](
DlOpReceiver& r) { r.setAntiAlias(
false); }},
99 {0, 8, 0, [](
DlOpReceiver& r) { r.setInvertColors(
true); }},
102 {0, 0, 0, [](
DlOpReceiver& r) { r.setInvertColors(
false); }},
141 {0, 8, 0, [](
DlOpReceiver& r) { r.setStrokeWidth(1.0); }},
142 {0, 8, 0, [](
DlOpReceiver& r) { r.setStrokeWidth(5.0); }},
145 {0, 0, 0, [](
DlOpReceiver& r) { r.setStrokeWidth(0.0); }},
149 {0, 8, 0, [](
DlOpReceiver& r) { r.setStrokeMiter(0.0); }},
150 {0, 8, 0, [](
DlOpReceiver& r) { r.setStrokeMiter(5.0); }},
153 {0, 0, 0, [](
DlOpReceiver& r) { r.setStrokeMiter(4.0); }},
169 [](
DlOpReceiver& r) { r.setBlendMode(DlBlendMode::kSrcIn); }},
171 [](
DlOpReceiver& r) { r.setBlendMode(DlBlendMode::kDstIn); }},
175 [](
DlOpReceiver& r) { r.setBlendMode(DlBlendMode::kSrcOver); }},
191 {0, 0, 0, [](
DlOpReceiver& r) { r.setColorSource(
nullptr); }},
258 {0, 0, 0, [](
DlOpReceiver& r) { r.setImageFilter(
nullptr); }},
292 {0, 0, 0, [](
DlOpReceiver& r) { r.setColorFilter(
nullptr); }},
313 {0, 0, 0, [](
DlOpReceiver& r) { r.setMaskFilter(
nullptr); }, 0u, 1u},
320 {
"Save(Layer)+Restore",
425 {1, 16, 0, [](
DlOpReceiver& r) { r.translate(10, 10); }},
426 {1, 16, 0, [](
DlOpReceiver& r) { r.translate(10, 15); }},
427 {1, 16, 0, [](
DlOpReceiver& r) { r.translate(15, 10); }},
451 {
"Transform2DAffine",
454 [](
DlOpReceiver& r) { r.transform2DAffine(0, 1, 12, 1, 0, 33); }},
457 [](
DlOpReceiver& r) { r.transform2DAffine(1, 0, 0, 0, 1, 0); }},
459 {
"TransformFullPerspective",
463 r.transformFullPerspective(0, 1, 0, 12, 1, 0, 0, 33, 3, 2, 5, 29,
469 r.transformFullPerspective(2, 1, 0, 4, 1, 3, 0, 5, 0, 0, 1, 0, 0,
475 r.transformFullPerspective(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
554 {
"ClipRSuperellipse",
637 r.drawColor(
DlColor(SK_ColorBLUE), DlBlendMode::kSrcIn);
641 r.drawColor(
DlColor(SK_ColorBLUE), DlBlendMode::kDstOut);
645 r.drawColor(
DlColor(SK_ColorCYAN), DlBlendMode::kSrcIn);
650 {1, 24, 1, [](
DlOpReceiver& r) { r.drawLine({0, 0}, {10, 10}); }},
651 {1, 24, 1, [](
DlOpReceiver& r) { r.drawLine({1, 0}, {10, 10}); }},
652 {1, 24, 1, [](
DlOpReceiver& r) { r.drawLine({0, 1}, {10, 10}); }},
653 {1, 24, 1, [](
DlOpReceiver& r) { r.drawLine({0, 0}, {20, 10}); }},
654 {1, 24, 1, [](
DlOpReceiver& r) { r.drawLine({0, 0}, {10, 20}); }},
660 r.drawDashedLine({0, 0}, {10, 10}, 4.0f, 2.0f);
664 r.drawDashedLine({1, 0}, {10, 10}, 4.0f, 2.0f);
668 r.drawDashedLine({0, 1}, {10, 10}, 4.0f, 2.0f);
672 r.drawDashedLine({0, 0}, {20, 10}, 4.0f, 2.0f);
676 r.drawDashedLine({0, 0}, {10, 20}, 4.0f, 2.0f);
680 r.drawDashedLine({0, 0}, {10, 10}, 5.0f, 2.0f);
684 r.drawDashedLine({0, 0}, {10, 10}, 4.0f, 3.0f);
727 {1, 16, 1, [](
DlOpReceiver& r) { r.drawCircle({0, 0}, 10); }},
728 {1, 16, 1, [](
DlOpReceiver& r) { r.drawCircle({0, 5}, 10); }},
729 {1, 16, 1, [](
DlOpReceiver& r) { r.drawCircle({0, 0}, 20); }},
1006 r.drawAtlas(
kTestImage1, xforms, texs,
nullptr, 2,
1017 r.drawAtlas(
kTestImage1, xforms, texs,
nullptr, 2,
1030 r.drawAtlas(
kTestImage2, xforms, texs,
nullptr, 2,
1070 r.drawAtlas(dl_image, xforms, texs,
nullptr, 2,
1110#if IMPELLER_SUPPORTS_RENDERING
1160 std::vector<DisplayListInvocationGroup> result;
1162 std::move(all_attribute_ops.begin(), all_attribute_ops.end(),
1163 std::back_inserter(result));
1165 std::move(all_save_restore_ops.begin(), all_save_restore_ops.end(),
1166 std::back_inserter(result));
1168 std::move(all_transform_ops.begin(), all_transform_ops.end(),
1169 std::back_inserter(result));
1171 std::move(all_clip_ops.begin(), all_clip_ops.end(),
1172 std::back_inserter(result));
1174 std::move(all_rendering_ops.begin(), all_rendering_ops.end(),
1175 std::back_inserter(result));
1180 static constexpr const char* kTestFontFixture =
"Roboto-Regular.ttf";
1187 static std::map<int, sk_sp<SkTextBlob>> text_blobs;
1188 auto it = text_blobs.find(index);
1189 if (it != text_blobs.end()) {
1192 std::string
text =
"TestBlob" + std::to_string(index);
1194 text_blobs.insert(std::make_pair(index, blob));
1198#if IMPELLER_SUPPORTS_RENDERING
1199std::shared_ptr<impeller::TextFrame> GetTestTextFrame(
int index) {
1200 static std::map<int, std::shared_ptr<impeller::TextFrame>> text_frames;
1201 auto it = text_frames.find(index);
1202 if (it != text_frames.end()) {
1207 text_frames.insert(std::make_pair(index, frame));
1213 return SkTextBlob::MakeFromText(
text.c_str(),
text.size(),
1215 SkTextEncoding::kUTF8);
void DrawColor(DlColor color, DlBlendMode mode) override
void DrawDisplayList(const sk_sp< DisplayList > display_list, DlScalar opacity=SK_Scalar1) override
sk_sp< DisplayList > Build()
void DrawRect(const DlRect &rect, const DlPaint &paint) override
static std::shared_ptr< const DlColorFilter > MakeLinearToSrgbGamma()
static std::shared_ptr< const DlColorFilter > MakeSrgbToLinearGamma()
static sk_sp< DlImage > Make(const SkImage *image)
Internal API for rendering recorded display lists to backends.
virtual void drawPoints(DlPointMode mode, uint32_t count, const DlPoint points[])=0
virtual void setColor(DlColor color)=0
DlPaint & setColor(DlColor color)
DlPaint & setAlpha(uint8_t alpha)
DlPaint & setDrawStyle(DlDrawStyle style)
Backend implementation of |DlCanvas| for |SkCanvas|.
void DrawRect(const DlRect &rect, const DlPaint &paint) override
static std::shared_ptr< DlTextImpeller > Make(const std::shared_ptr< impeller::TextFrame > &frame)
static std::shared_ptr< DlTextSkia > Make(const sk_sp< SkTextBlob > &blob)
static const SaveLayerOptions kNoAttributes
static const SaveLayerOptions kWithAttributes
#define FML_CHECK(condition)
static const DlComposeImageFilter kTestComposeImageFilter2(kTestBlurImageFilter2, kTestMatrixImageFilter1)
static const DlPath kTestPathOval
std::vector< DisplayListInvocationGroup > CreateAllClipOps()
static const DlDilateImageFilter kTestDilateImageFilter2(6.0, 5.0)
std::vector< DisplayListInvocationGroup > CreateAllTransformOps()
static const std::shared_ptr< DlColorSource > kTestSource3
static const auto kTestMatrixColorFilter2
static const DlBlurMaskFilter kTestMaskFilter1(DlBlurStyle::kNormal, 3.0)
static const DlPath kTestPathRect
SkFont CreateTestFontOfSize(DlScalar scalar)
std::vector< DisplayListInvocationGroup > CreateAllSaveRestoreOps()
static const std::shared_ptr< DlColorSource > kTestSource4
static const DlBlurMaskFilter kTestMaskFilter4(DlBlurStyle::kInner, 3.0)
static const DlComposeImageFilter kTestComposeImageFilter1(kTestBlurImageFilter1, kTestMatrixImageFilter1)
static const std::shared_ptr< DlVertices > kTestVertices2
static const DlColorFilterImageFilter kTestCFImageFilter2(kTestBlendColorFilter2)
static const DlRoundRect kTestInnerRRect
constexpr DlPoint kTestPoints[]
static const DlErodeImageFilter kTestErodeImageFilter2(4.0, 3.0)
static const auto kTestBlendColorFilter2
sk_sp< SkData > OpenFixtureAsSkData(const std::string &fixture_name)
Opens a fixture of the given file name and returns a Skia SkData holding its contents.
static const DlBlurMaskFilter kTestMaskFilter3(DlBlurStyle::kSolid, 3.0)
static const DlMatrixImageFilter kTestMatrixImageFilter2(DlMatrix::MakeRotationZ(DlDegrees(85)), kNearestSampling)
static const DlPath kTestPath2
static const DlBlurImageFilter kTestBlurImageFilter4(5.0, 5.0, DlTileMode::kDecal)
static const DlErodeImageFilter kTestErodeImageFilter3(3.0, 4.0)
static const DlRoundSuperellipse kTestRSuperellipse
static const DlMatrixImageFilter kTestMatrixImageFilter1(DlMatrix::MakeRotationZ(DlDegrees(45)), kNearestSampling)
static const auto kTestMatrixColorFilter1
static const std::shared_ptr< DlColorSource > kTestSource1
constexpr DlRect kTestBounds
static const DlPath kTestPath1
static const DlColorFilterImageFilter kTestCFImageFilter1(kTestBlendColorFilter1)
static const DlPath kTestPath3
static const std::shared_ptr< DlColorSource > kTestSource5
std::vector< DisplayListInvocationGroup > CreateAllAttributesOps()
sk_sp< DlImage > MakeTestImage(int w, int h, int checker_size)
static const DlErodeImageFilter kTestErodeImageFilter1(4.0, 4.0)
sk_sp< DisplayList > GetSampleDisplayList()
static const std::shared_ptr< DlColorSource > kTestSource2
static const DlBlurMaskFilter kTestMaskFilter2(DlBlurStyle::kNormal, 5.0)
static const DlBlurImageFilter kTestBlurImageFilter2(6.0, 5.0, DlTileMode::kClamp)
static const auto kTestBlendColorFilter3
static const DlPath kTestPathRRect
static DlImageSampling kLinearSampling
static const auto kTestBlendColorFilter1
static sk_sp< DisplayList > TestDisplayList2
static const DlBlurImageFilter kTestBlurImageFilter3(5.0, 6.0, DlTileMode::kClamp)
std::vector< DisplayListInvocationGroup > CreateAllRenderingOps()
static const DlDilateImageFilter kTestDilateImageFilter1(5.0, 5.0)
sk_sp< DisplayList > GetSampleNestedDisplayList()
static DlImageSampling kNearestSampling
static const DlBlurMaskFilter kTestMaskFilter5(DlBlurStyle::kOuter, 3.0)
sk_sp< SkTextBlob > GetTestTextBlob(int index)
static const DlDilateImageFilter kTestDilateImageFilter3(5.0, 6.0)
static sk_sp< DisplayList > MakeTestDisplayList(int w, int h, SkColor color)
static const DlBlurImageFilter kTestBlurImageFilter1(5.0, 5.0, DlTileMode::kClamp)
std::vector< DisplayListInvocationGroup > CreateAllGroups()
static const DlComposeImageFilter kTestComposeImageFilter3(kTestBlurImageFilter1, kTestMatrixImageFilter2)
static const std::shared_ptr< DlVertices > kTestVertices1
static const DlRoundRect kTestRRect
static sk_sp< DisplayList > TestDisplayList1
static const DlMatrixImageFilter kTestMatrixImageFilter3(DlMatrix::MakeRotationZ(DlDegrees(45)), kLinearSampling)
impeller::Scalar DlScalar
@ kMiter
extends to miter limit
@ kBevel
connects outside edges
@ kButt
no stroke extension
impeller::Degrees DlDegrees
@ kLines
draw each separate pair of points as a line segment
@ kPolygon
draw each pair of overlapping points as a line segment
@ kPoints
draw each point separately
@ kStrokeAndFill
both strokes and fills shapes
@ kStroke
strokes boundary of shapes
@ kFill
fills interior of shapes
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder h
std::shared_ptr< TextFrame > MakeTextFrameFromTextBlobSkia(const sk_sp< SkTextBlob > &blob)
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)
static constexpr DlColor kBlue()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
constexpr bool isOpaque() const
static constexpr Matrix MakeTranslation(const Vector3 &t)
RoundRect Shift(Scalar dx, Scalar dy) const
Returns a new round rectangle translated by the given offset.
RoundSuperellipse Shift(Scalar dx, Scalar dy) const
Returns a new round rectangle translated by the given offset.
static constexpr TRect MakeWH(Type width, Type height)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
constexpr TRect< T > Shift(T dx, T dy) const
Returns a new rectangle translated by the given offset.
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)