37#define ABORT_TEST(r, cond, ...) \
40 REPORT_FAILURE(r, #cond, SkStringPrintf(__VA_ARGS__)); \
46static std::unique_ptr<SkCanvas> MakeDOMCanvas(
SkDOM*
dom, uint32_t
flags = 0) {
48 std::make_unique<SkXMLParserWriter>(
dom->beginParsing()),
50 return svgDevice ? std::make_unique<SkCanvas>(svgDevice)
61 unsigned scalarsPerPos,
63 const char* expected) {
64 if (
root ==
nullptr) {
70 if (textElem ==
nullptr) {
78 if (textNode !=
nullptr) {
83 int textLen =
SkToInt(strlen(expected));
85 const char*
x =
dom.findAttr(textElem,
"x");
88 int xposCount = textLen;
93 if (scalarsPerPos < 1) {
96 if (
txt[0] !=
' ' &&
txt[0] !=
'\t') {
100 for (
int i = 0;
i < xposCount; ++
i) {
106 const char*
y =
dom.findAttr(textElem,
"y");
109 int yposCount = (scalarsPerPos < 2) ? 1 : textLen;
114 if (scalarsPerPos < 2) {
117 for (
int i = 0;
i < yposCount; ++
i) {
126 const char* expected) {
147 MakeDOMCanvas(&
dom)->drawTextBlob(blob, 0, 0,
paint);
158 MakeDOMCanvas(&
dom)->drawTextBlob(blob, 0, 0,
paint);
166 static const struct {
171 {
"ab cd" ,
"ab cd" },
172 {
"ab \t\t cd",
"ab cd" },
173 {
" abcd" ,
"abcd" },
174 {
" abcd" ,
"abcd" },
175 {
" \t\t abcd",
"abcd" },
176 {
"abcd " ,
"abcd " },
177 {
"abcd " ,
"abcd " },
178 {
"abcd\t " ,
"abcd " },
179 {
"\t\t \t ab \t\t \t cd \t\t \t ",
"ab cd " },
200 if (
root ==
nullptr ||
dom ==
nullptr) {
207 if (
rect ==
nullptr) {
214 if (
defs ==
nullptr) {
220 if (pattern ==
nullptr) {
224 *patternOut = pattern;
227 if (
image ==
nullptr) {
239 auto svgCanvas = MakeDOMCanvas(
dom);
250 int rectWidth = 10, rectHeight = 10;
256 const SkDOM::Node *patternNode, *imageNode, *rectNode;
257 bool structureAppropriate =
258 FindImageShaderNodes(
reporter, &
dom,
root, &patternNode, &imageNode, &rectNode);
275 int rectWidth = 10, rectHeight = 10;
281 if (innerSvg ==
nullptr) {
286 const SkDOM::Node *patternNode, *imageNode, *rectNode;
287 bool structureAppropriate =
288 FindImageShaderNodes(
reporter, &
dom, innerSvg, &patternNode, &imageNode, &rectNode);
304 int imageNodeWidth = 3, imageNodeHeight = 3;
305 int rectNodeWidth = 10, rectNodeHeight = 10;
306 ImageShaderTestSetup(&
dom, &
paint, imageNodeWidth, imageNodeHeight, rectNodeWidth,
311 if (innerSvg ==
nullptr) {
316 const SkDOM::Node *patternNode, *imageNode, *rectNode;
317 bool structureAppropriate =
318 FindImageShaderNodes(
reporter, &
dom, innerSvg, &patternNode, &imageNode, &rectNode);
335 int rectWidth = 10, rectHeight = 10;
341 const SkDOM::Node *patternNode, *imageNode, *rectNode;
343 if (innerSvg ==
nullptr) {
347 bool structureAppropriate =
348 FindImageShaderNodes(
reporter, &
dom, innerSvg, &patternNode, &imageNode, &rectNode);
364 auto svgCanvas = MakeDOMCanvas(&
dom);
369 ABORT_TEST(
reporter, !rootElement,
"root element not found");
371 const SkDOM::Node* filterElement =
dom.getFirstChild(rootElement,
"filter");
372 ABORT_TEST(
reporter, !filterElement,
"filter element not found");
374 const SkDOM::Node* floodElement =
dom.getFirstChild(filterElement,
"feFlood");
375 ABORT_TEST(
reporter, !floodElement,
"feFlood element not found");
377 const SkDOM::Node* compositeElement =
dom.getFirstChild(filterElement,
"feComposite");
378 ABORT_TEST(
reporter, !compositeElement,
"feComposite element not found");
384 strcmp(
dom.findAttr(floodElement,
"flood-color"),
"red") == 0);
396 auto check_text = [&](uint32_t
flags,
bool expect_path) {
399 auto svgCanvas = MakeDOMCanvas(&
dom,
flags);
400 svgCanvas->drawString(
"foo", 100, 100,
font,
paint);
402 const auto* rootElement =
dom.finishParsing();
404 const auto* textElement =
dom.getFirstChild(rootElement,
"text");
406 const auto* pathElement =
dom.getFirstChild(rootElement,
"path");
411 check_text(0,
false);
426 const char* expected_fill;
427 const char* expected_stroke;
435 for (
const auto& tst :
gTests) {
437 p.setColor(tst.color);
438 p.setStyle(tst.style);
445 const auto*
root =
dom.finishParsing();
447 const auto*
rect =
dom.getFirstChild(
root,
"rect");
449 const auto* fill =
dom.findAttr(
rect,
"fill");
465 const char* expected_fill_opacity;
473 for (
const auto& tst :
gTests) {
475 p.setColor(tst.color);
480 auto svgCanvas = MakeDOMCanvas(&
dom);
482 svgCanvas->drawRect(
bounds,
p);
486 ABORT_TEST(
reporter, !rootElement,
"root element not found");
488 const SkDOM::Node* rectElement =
dom.getFirstChild(rootElement,
"rect");
489 ABORT_TEST(
reporter, !rectElement,
"rect element not found");
490 const auto* fill_opacity =
dom.findAttr(rectElement,
"fill-opacity");
503 auto svgCanvas = MakeDOMCanvas(&
dom);
508 ABORT_TEST(
reporter, !rootElement,
"root element not found");
510 const SkDOM::Node* rectElement =
dom.getFirstChild(rootElement,
"rect");
511 ABORT_TEST(
reporter, !rectElement,
"rect element not found");
519 paint.setColor(0xFFAABCDE);
520 auto svgCanvas = MakeDOMCanvas(&
dom);
523 paint.setColor(0xFFAABBCC);
525 paint.setColor(0xFFAA1123);
529 ABORT_TEST(
reporter, !rootElement,
"root element not found");
532 const SkDOM::Node* rectElement =
dom.getFirstChild(rootElement,
"rect");
533 ABORT_TEST(
reporter, !rectElement,
"rect element not found");
537 rectElement =
dom.getNextSibling(rectElement,
"rect");
538 ABORT_TEST(
reporter, !rectElement,
"rect element not found");
542 rectElement =
dom.getNextSibling(rectElement,
"rect");
543 ABORT_TEST(
reporter, !rectElement,
"rect element not found");
550 auto svgCanvas = MakeDOMCanvas(&
dom);
554 paint.setColor(0xFF00BBAC);
557 paint.setColor(0xFF123456);
558 paint.setStrokeWidth(1);
562 ABORT_TEST(
reporter, !rootElement,
"root element not found");
564 const SkDOM::Node* rectNode =
dom.getFirstChild(rootElement,
"rect");
565 ABORT_TEST(
reporter, !rectNode,
"rect element not found");
568 rectNode =
dom.getNextSibling(rectNode,
"rect");
569 ABORT_TEST(
reporter, !rectNode,
"rect element not found");
581 paint.setPathEffect(pathEffect);
584 auto svgCanvas = MakeDOMCanvas(&
dom);
588 const auto* rootElement =
dom.finishParsing();
590 const auto* pathElement =
dom.getFirstChild(rootElement,
"path");
601 paint.setPathEffect(pathEffect);
604 auto svgCanvas = MakeDOMCanvas(&
dom);
608 const auto* rootElement =
dom.finishParsing();
610 const auto* pathElement =
dom.getFirstChild(rootElement,
"path");
621 paint.setPathEffect(pathEffect);
624 auto svgCanvas = MakeDOMCanvas(&
dom);
628 const auto* rootElement =
dom.finishParsing();
630 const auto* pathElement =
dom.getFirstChild(rootElement,
"path");
641 paint.setStrokeWidth(10);
647 paint.setPathEffect(pathEffect);
650 auto svgCanvas = MakeDOMCanvas(&
dom);
653 const auto* rootElement =
dom.finishParsing();
655 const auto* pathElement =
dom.getFirstChild(rootElement,
"path");
664 const auto*
d =
dom.findAttr(pathElement,
"d");
668 mCount += (*
pos ==
'M') ? 1 : 0;
678 path.moveTo(100, 50);
679 path.lineTo(200, 50);
680 path.lineTo(200, 150);
686 const auto* rootElement =
dom.finishParsing();
688 const auto* pathElement =
dom.getFirstChild(rootElement,
"path");
690 const auto*
d =
dom.findAttr(pathElement,
"d");
697 auto svgCanvas = MakeDOMCanvas(&
dom);
702 svgCanvas->drawCircle(100, 100, 100,
paint);
705 const auto* rootElement =
dom.finishParsing();
707 const auto* ellipseElement =
dom.getFirstChild(rootElement,
"ellipse");
709 const auto* fill =
dom.findAttr(ellipseElement,
"fill");
715 auto check = [&](int64_t n,
bool expected) {
static const TestCase gTests[]
static const int points[]
#define check(reporter, ref, unref, make, kill)
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
constexpr SkColor SK_ColorBLACK
@ kUTF8
uses bytes to represent UTF-8 or ASCII
constexpr int SkToInt(S x)
static constexpr bool SkToBool(const T &x)
#define DEF_TEST(name, reporter)
#define REPORTER_ASSERT(r, cond,...)
@ kLines_PointMode
draw each pair of points as a line segment
static sk_sp< SkColorFilter > Blend(const SkColor4f &c, sk_sp< SkColorSpace >, SkBlendMode mode)
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
static const char * FindS32(const char str[], int32_t *value)
static int Count(const char str[])
static const char * FindScalars(const char str[], SkScalar value[], int count)
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
@ kRelativePathEncoding_Flag
@ kConvertTextToPaths_Flag
static sk_sp< SkDevice > Make(const SkISize &size, std::unique_ptr< SkXMLWriter >, uint32_t flags)
static sk_sp< SkTextBlob > MakeFromPosTextH(const void *text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
static sk_sp< SkTextBlob > MakeFromPosText(const void *text, size_t byteLength, const SkPoint pos[], const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
FlutterSemanticsFlag flags
static float max(float r, float g, float b)
static float min(float r, float g, float b)
Optional< SkRect > bounds
sk_sp< const SkImage > image
sk_sp< SkBlender > blender SkRect rect
SK_API sk_sp< SkShader > Color(SkColor)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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
it will be possible to load the file into Perfetto s trace viewer 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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
font
Font Metadata and Metrics.
static const int imageHeight
static const int imageWidth
static SkString to_string(int n)
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkPoint Make(float x, float y)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)