5#include "flutter/display_list/testing/dl_test_snippets.h"
6#include "flutter/display_list/dl_builder.h"
7#include "flutter/display_list/dl_op_receiver.h"
24 for (
int y = 10;
y <= 60;
y += 10) {
25 for (
int x = 10;
x <= 60;
x += 10) {
33 return outer_builder.
Build();
38 for (
int i = 0;
i <
ops;
i++) {
52 {0, 8, 0, [](
DlOpReceiver& r) { r.setAntiAlias(
true); }},
53 {0, 0, 0, [](
DlOpReceiver& r) { r.setAntiAlias(
false); }},
57 {0, 8, 0, [](
DlOpReceiver& r) { r.setInvertColors(
true); }},
58 {0, 0, 0, [](
DlOpReceiver& r) { r.setInvertColors(
false); }},
91 {0, 8, 0, [](
DlOpReceiver& r) { r.setStrokeWidth(1.0); }},
92 {0, 8, 0, [](
DlOpReceiver& r) { r.setStrokeWidth(5.0); }},
93 {0, 0, 0, [](
DlOpReceiver& r) { r.setStrokeWidth(0.0); }},
97 {0, 8, 0, [](
DlOpReceiver& r) { r.setStrokeMiter(0.0); }},
98 {0, 8, 0, [](
DlOpReceiver& r) { r.setStrokeMiter(5.0); }},
99 {0, 0, 0, [](
DlOpReceiver& r) { r.setStrokeMiter(4.0); }},
131 {0, 0, 0, [](
DlOpReceiver& r) { r.setColorSource(
nullptr); }},
189 {0, 0, 0, [](
DlOpReceiver& r) { r.setImageFilter(
nullptr); }},
222 {0, 0, 0, [](
DlOpReceiver& r) { r.setColorFilter(
nullptr); }},
241 {0, 0, 0, [](
DlOpReceiver& r) { r.setMaskFilter(
nullptr); }, 0u, 1u},
248 {
"Save(Layer)+Restore",
261 r.drawRect({5, 5, 15, 15});
262 r.drawRect({10, 10, 20, 20});
269 r.drawRect({5, 5, 15, 15});
270 r.drawRect({10, 10, 20, 20});
277 r.drawRect({5, 5, 15, 15});
278 r.drawRect({10, 10, 20, 20});
289 r.drawRect({10, 10, 20, 20});
297 r.drawRect({10, 10, 20, 20});
305 r.drawRect({5, 5, 15, 15});
306 r.drawRect({10, 10, 20, 20});
314 r.drawRect({5, 5, 15, 15});
315 r.drawRect({10, 10, 20, 20});
324 r.drawRect({10, 10, 20, 20});
333 r.drawRect({10, 10, 20, 20});
344 {1, 16, 0, [](
DlOpReceiver& r) { r.translate(10, 10); }},
345 {1, 16, 0, [](
DlOpReceiver& r) { r.translate(10, 15); }},
346 {1, 16, 0, [](
DlOpReceiver& r) { r.translate(15, 10); }},
370 {
"Transform2DAffine",
373 [](
DlOpReceiver& r) { r.transform2DAffine(0, 1, 12, 1, 0, 33); }},
376 [](
DlOpReceiver& r) { r.transform2DAffine(1, 0, 0, 0, 1, 0); }},
378 {
"TransformFullPerspective",
382 r.transformFullPerspective(0, 1, 0, 12, 1, 0, 0, 33, 3, 2, 5, 29,
388 r.transformFullPerspective(2, 1, 0, 4, 1, 3, 0, 5, 0, 0, 1, 0, 0,
394 r.transformFullPerspective(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
516 r.drawLine({0, 0}, {10, 10});
520 r.drawLine({1, 0}, {10, 10});
524 r.drawLine({0, 1}, {10, 10});
528 r.drawLine({0, 0}, {20, 10});
532 r.drawLine({0, 0}, {10, 20});
539 r.drawDashedLine({0, 0}, {10, 10}, 4.0f, 2.0f);
543 r.drawDashedLine({1, 0}, {10, 10}, 4.0f, 2.0f);
547 r.drawDashedLine({0, 1}, {10, 10}, 4.0f, 2.0f);
551 r.drawDashedLine({0, 0}, {20, 10}, 4.0f, 2.0f);
555 r.drawDashedLine({0, 0}, {10, 20}, 4.0f, 2.0f);
559 r.drawDashedLine({0, 0}, {10, 10}, 5.0f, 2.0f);
563 r.drawDashedLine({0, 0}, {10, 10}, 4.0f, 3.0f);
570 r.drawRect({0, 0, 10, 10});
574 r.drawRect({0, 1, 10, 10});
578 r.drawRect({0, 0, 20, 10});
582 r.drawRect({0, 0, 10, 20});
589 r.drawOval({0, 0, 10, 10});
593 r.drawOval({0, 1, 10, 10});
597 r.drawOval({0, 0, 20, 10});
601 r.drawOval({0, 0, 10, 20});
608 r.drawCircle({0, 0}, 10);
612 r.drawCircle({0, 5}, 10);
616 r.drawCircle({0, 0}, 20);
732 r.drawImageRect(
TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
738 r.drawImageRect(
TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
744 r.drawImageRect(
TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
750 r.drawImageRect(
TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
756 r.drawImageRect(
TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
762 r.drawImageRect(
TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
768 r.drawImageRect(
TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
775 r.drawImageRect(dl_image, {10, 10, 15, 15}, {10, 10, 80, 80},
784 r.drawImageNine(
TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
789 r.drawImageNine(
TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
794 r.drawImageNine(
TestImage1, {10, 10, 25, 20}, {10, 10, 80, 80},
799 r.drawImageNine(
TestImage1, {10, 10, 20, 20}, {10, 10, 85, 80},
804 r.drawImageNine(
TestImage1, {10, 10, 20, 20}, {10, 10, 80, 80},
809 r.drawImageNine(
TestImage2, {10, 10, 15, 15}, {10, 10, 80, 80},
815 r.drawImageNine(dl_image, {10, 10, 15, 15}, {10, 10, 80, 80},
824 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
832 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
839 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
847 static SkRect texs[] = {{10, 10, 20, 20}, {20, 25, 30, 30}};
855 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
862 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
870 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
871 static SkRect cull_rect = {0, 0, 200, 200};
876 {1, 48 + 32 + 8 + 8, 1,
879 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
885 {1, 64 + 32 + 8 + 8, 1,
888 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
890 static SkRect cull_rect = {0, 0, 200, 200};
899 static SkRect texs[] = {{10, 10, 20, 20}, {20, 20, 30, 30}};
900 r.drawAtlas(dl_image,
xforms,
texs,
nullptr, 2,
972 std::vector<DisplayListInvocationGroup>
result;
974 std::move(all_attribute_ops.begin(), all_attribute_ops.end(),
975 std::back_inserter(
result));
977 std::move(all_save_restore_ops.begin(), all_save_restore_ops.end(),
978 std::back_inserter(
result));
980 std::move(all_transform_ops.begin(), all_transform_ops.end(),
981 std::back_inserter(
result));
983 std::move(all_clip_ops.begin(), all_clip_ops.end(),
984 std::back_inserter(
result));
986 std::move(all_rendering_ops.begin(), all_rendering_ops.end(),
987 std::back_inserter(
result));
992 static constexpr const char* kTestFontFixture =
"Roboto-Regular.ttf";
999 static std::map<int, sk_sp<SkTextBlob>> text_blobs;
1000 auto it = text_blobs.find(index);
1001 if (it != text_blobs.end()) {
1008 text_blobs.insert(std::make_pair(index, blob));
constexpr SkColor SK_ColorCYAN
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
@ kUTF8
uses bytes to represent UTF-8 or ASCII
sk_sp< SkTypeface > makeFromData(sk_sp< SkData >, int ttcIndex=0) const
static SkMatrix Translate(SkScalar dx, SkScalar dy)
SkRRect makeOffset(SkScalar dx, SkScalar dy) const
static sk_sp< SkTextBlob > MakeFromText(const void *text, size_t byteLength, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
sk_sp< DisplayList > Build()
void DrawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1) override
@ 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
static sk_sp< DlImage > Make(const SkImage *image)
static const std::shared_ptr< DlLinearToSrgbGammaColorFilter > kInstance
Internal API for rendering recorded display lists to backends.
virtual void drawPoints(PointMode mode, uint32_t count, const SkPoint points[])=0
static const std::shared_ptr< DlSrgbToLinearGammaColorFilter > kInstance
static const SaveLayerOptions kNoAttributes
static const SaveLayerOptions kWithAttributes
#define FML_CHECK(condition)
PODArray< SkRSXform > xforms
PODArray< SkColor > colors
static const DlComposeImageFilter kTestComposeImageFilter2(kTestBlurImageFilter2, kTestMatrixImageFilter1)
std::vector< DisplayListInvocationGroup > CreateAllClipOps()
static const DlDilateImageFilter kTestDilateImageFilter2(6.0, 5.0)
std::vector< DisplayListInvocationGroup > CreateAllTransformOps()
static const std::shared_ptr< DlColorSource > kTestSource3
constexpr SkRect kTestBounds
static const DlMatrixImageFilter kTestMatrixImageFilter1(SkMatrix::RotateDeg(45), kNearestSampling)
SkFont CreateTestFontOfSize(SkScalar scalar)
static const DlBlurMaskFilter kTestMaskFilter1(DlBlurStyle::kNormal, 3.0)
std::vector< DisplayListInvocationGroup > CreateAllSaveRestoreOps()
static const std::shared_ptr< DlColorSource > kTestSource4
static const SkRRect kTestInnerRRect
static const DlBlurMaskFilter kTestMaskFilter4(DlBlurStyle::kInner, 3.0)
static const SkPath kTestPath1
static const DlComposeImageFilter kTestComposeImageFilter1(kTestBlurImageFilter1, kTestMatrixImageFilter1)
static std::shared_ptr< const DlVertices > TestVertices2
static const DlColorFilterImageFilter kTestCFImageFilter2(kTestBlendColorFilter2)
static const DlErodeImageFilter kTestErodeImageFilter2(4.0, 3.0)
static const DlMatrixColorFilter kTestMatrixColorFilter2(kInvertColorMatrix)
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 DlImageColorSource kTestSource1(TestImage1, DlTileMode::kClamp, DlTileMode::kMirror, kLinearSampling)
static const DlBlurImageFilter kTestBlurImageFilter4(5.0, 5.0, DlTileMode::kDecal)
static const DlErodeImageFilter kTestErodeImageFilter3(3.0, 4.0)
static const DlMatrixImageFilter kTestMatrixImageFilter3(SkMatrix::RotateDeg(45), kLinearSampling)
static const DlColorFilterImageFilter kTestCFImageFilter1(kTestBlendColorFilter1)
static constexpr SkPoint kTestPoints[2]
static const std::shared_ptr< DlColorSource > kTestSource5
std::vector< DisplayListInvocationGroup > CreateAllAttributesOps()
static const DlErodeImageFilter kTestErodeImageFilter1(4.0, 4.0)
static const SkRRect kTestRRect
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 DlBlendColorFilter kTestBlendColorFilter2(DlColor::kBlue(), DlBlendMode::kDstATop)
static const DlBlendColorFilter kTestBlendColorFilter1(DlColor::kRed(), DlBlendMode::kDstATop)
static const DlMatrixColorFilter kTestMatrixColorFilter1(kRotateColorMatrix)
static const DlBlendColorFilter kTestBlendColorFilter3(DlColor::kRed(), DlBlendMode::kDstIn)
static DlImageSampling kLinearSampling
static sk_sp< DisplayList > TestDisplayList2
static const DlMatrixImageFilter kTestMatrixImageFilter2(SkMatrix::RotateDeg(85), kNearestSampling)
static std::shared_ptr< const DlVertices > TestVertices1
static const SkPath kTestPath2
static const DlBlurImageFilter kTestBlurImageFilter3(5.0, 6.0, DlTileMode::kClamp)
std::vector< DisplayListInvocationGroup > CreateAllRenderingOps()
static const SkPath kTestPathRect
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)
static const SkPath kTestPathOval
std::vector< DisplayListInvocationGroup > CreateAllGroups()
static const DlComposeImageFilter kTestComposeImageFilter3(kTestBlurImageFilter1, kTestMatrixImageFilter2)
static const SkPath kTestPath3
static sk_sp< DisplayList > TestDisplayList1
@ kMiter
extends to miter limit
@ kBevel
connects outside edges
@ kButt
no stroke extension
@ kStrokeAndFill
both strokes and fills shapes
@ kStroke
strokes boundary of shapes
@ kFill
fills interior of shapes
@ kSrcOver
r = s + (1-sa)*d
const myers::Point & get(const myers::Segment &)
sk_sp< SkFontMgr > GetDefaultFontManager(uint32_t font_initialization_data)
static SkString to_string(int n)
constexpr SkRect makeOffset(float dx, float dy) const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)
static constexpr DlColor kBlue()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()