Flutter Engine
The Flutter Engine
DrawCommand.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
19#include "include/core/SkFont.h"
31#include "include/core/SkSize.h"
42#include "src/core/SkFontPriv.h"
45#include "src/core/SkRectPriv.h"
53
54#include <algorithm>
55#include <cstring>
56#include <utility>
57
58class GrDirectContext;
59
60#if defined(SK_GANESH)
62#endif
63
64#define DEBUGCANVAS_ATTRIBUTE_DUMP "dump"
65#define DEBUGCANVAS_ATTRIBUTE_COMMAND "command"
66#define DEBUGCANVAS_ATTRIBUTE_VISIBLE "visible"
67#define DEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
68#define DEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS "drawDepthTranslation"
69#define DEBUGCANVAS_ATTRIBUTE_COORDS "coords"
70#define DEBUGCANVAS_ATTRIBUTE_EDGING "edging"
71#define DEBUGCANVAS_ATTRIBUTE_HINTING "hinting"
72#define DEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
73#define DEBUGCANVAS_ATTRIBUTE_PAINT "paint"
74#define DEBUGCANVAS_ATTRIBUTE_OUTER "outer"
75#define DEBUGCANVAS_ATTRIBUTE_INNER "inner"
76#define DEBUGCANVAS_ATTRIBUTE_MODE "mode"
77#define DEBUGCANVAS_ATTRIBUTE_POINTS "points"
78#define DEBUGCANVAS_ATTRIBUTE_PATH "path"
79#define DEBUGCANVAS_ATTRIBUTE_CLUSTERS "clusters"
80#define DEBUGCANVAS_ATTRIBUTE_TEXT "text"
81#define DEBUGCANVAS_ATTRIBUTE_COLOR "color"
82#define DEBUGCANVAS_ATTRIBUTE_ALPHA "alpha"
83#define DEBUGCANVAS_ATTRIBUTE_BLENDMODE "blendMode"
84#define DEBUGCANVAS_ATTRIBUTE_SAMPLING "sampling"
85#define DEBUGCANVAS_ATTRIBUTE_STYLE "style"
86#define DEBUGCANVAS_ATTRIBUTE_STROKEWIDTH "strokeWidth"
87#define DEBUGCANVAS_ATTRIBUTE_STROKEMITER "strokeMiter"
88#define DEBUGCANVAS_ATTRIBUTE_STROKEJOIN "strokeJoin"
89#define DEBUGCANVAS_ATTRIBUTE_CAP "cap"
90#define DEBUGCANVAS_ATTRIBUTE_ANTIALIAS "antiAlias"
91#define DEBUGCANVAS_ATTRIBUTE_DITHER "dither"
92#define DEBUGCANVAS_ATTRIBUTE_FAKEBOLDTEXT "fakeBoldText"
93#define DEBUGCANVAS_ATTRIBUTE_LINEARTEXT "linearText"
94#define DEBUGCANVAS_ATTRIBUTE_SUBPIXELTEXT "subpixelText"
95#define DEBUGCANVAS_ATTRIBUTE_DEVKERNTEXT "devKernText"
96#define DEBUGCANVAS_ATTRIBUTE_LCDRENDERTEXT "lcdRenderText"
97#define DEBUGCANVAS_ATTRIBUTE_EMBEDDEDBITMAPTEXT "embeddedBitmapText"
98#define DEBUGCANVAS_ATTRIBUTE_AUTOHINTING "forceAutoHinting"
99#define DEBUGCANVAS_ATTRIBUTE_REGION "region"
100#define DEBUGCANVAS_ATTRIBUTE_REGIONOP "op"
101#define DEBUGCANVAS_ATTRIBUTE_EDGESTYLE "edgeStyle"
102#define DEBUGCANVAS_ATTRIBUTE_DEVICEREGION "deviceRegion"
103#define DEBUGCANVAS_ATTRIBUTE_BLUR "blur"
104#define DEBUGCANVAS_ATTRIBUTE_SIGMA "sigma"
105#define DEBUGCANVAS_ATTRIBUTE_QUALITY "quality"
106#define DEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize"
107#define DEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX"
108#define DEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX"
109#define DEBUGCANVAS_ATTRIBUTE_DASHING "dashing"
110#define DEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals"
111#define DEBUGCANVAS_ATTRIBUTE_PHASE "phase"
112#define DEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType"
113#define DEBUGCANVAS_ATTRIBUTE_VERBS "verbs"
114#define DEBUGCANVAS_ATTRIBUTE_NAME "name"
115#define DEBUGCANVAS_ATTRIBUTE_DATA "data"
116#define DEBUGCANVAS_ATTRIBUTE_VALUES "values"
117#define DEBUGCANVAS_ATTRIBUTE_SHADER "shader"
118#define DEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect"
119#define DEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter"
120#define DEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode"
121#define DEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop"
122#define DEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter"
123#define DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter"
124#define DEBUGCANVAS_ATTRIBUTE_IMAGE "image"
125#define DEBUGCANVAS_ATTRIBUTE_IMAGE_INDEX "imageIndex"
126#define DEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap"
127#define DEBUGCANVAS_ATTRIBUTE_SRC "src"
128#define DEBUGCANVAS_ATTRIBUTE_DST "dst"
129#define DEBUGCANVAS_ATTRIBUTE_CENTER "center"
130#define DEBUGCANVAS_ATTRIBUTE_STRICT "strict"
131#define DEBUGCANVAS_ATTRIBUTE_DESCRIPTION "description"
132#define DEBUGCANVAS_ATTRIBUTE_X "x"
133#define DEBUGCANVAS_ATTRIBUTE_Y "y"
134#define DEBUGCANVAS_ATTRIBUTE_RUNS "runs"
135#define DEBUGCANVAS_ATTRIBUTE_POSITIONS "positions"
136#define DEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs"
137#define DEBUGCANVAS_ATTRIBUTE_FONT "font"
138#define DEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface"
139#define DEBUGCANVAS_ATTRIBUTE_CUBICS "cubics"
140#define DEBUGCANVAS_ATTRIBUTE_COLORS "colors"
141#define DEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords"
142#define DEBUGCANVAS_ATTRIBUTE_STARTANGLE "startAngle"
143#define DEBUGCANVAS_ATTRIBUTE_SWEEPANGLE "sweepAngle"
144#define DEBUGCANVAS_ATTRIBUTE_USECENTER "useCenter"
145#define DEBUGCANVAS_ATTRIBUTE_SHORTDESC "shortDesc"
146#define DEBUGCANVAS_ATTRIBUTE_UNIQUE_ID "uniqueID"
147#define DEBUGCANVAS_ATTRIBUTE_WIDTH "width"
148#define DEBUGCANVAS_ATTRIBUTE_HEIGHT "height"
149#define DEBUGCANVAS_ATTRIBUTE_ALPHA "alpha"
150#define DEBUGCANVAS_ATTRIBUTE_LATTICE "lattice"
151#define DEBUGCANVAS_ATTRIBUTE_LATTICEXCOUNT "xCount"
152#define DEBUGCANVAS_ATTRIBUTE_LATTICEYCOUNT "yCount"
153#define DEBUGCANVAS_ATTRIBUTE_LATTICEXDIVS "xDivs"
154#define DEBUGCANVAS_ATTRIBUTE_LATTICEYDIVS "yDivs"
155#define DEBUGCANVAS_ATTRIBUTE_LATTICEFLAGS "flags"
156#define DEBUGCANVAS_ATTRIBUTE_ZPLANE "zPlane"
157#define DEBUGCANVAS_ATTRIBUTE_LIGHTPOSITION "lightPositions"
158#define DEBUGCANVAS_ATTRIBUTE_AMBIENTCOLOR "ambientColor"
159#define DEBUGCANVAS_ATTRIBUTE_SPOTCOLOR "spotColor"
160#define DEBUGCANVAS_ATTRIBUTE_LIGHTRADIUS "lightRadius"
161#define DEBUGCANVAS_ATTRIBUTE_LAYERNODEID "layerNodeId"
162
163#define DEBUGCANVAS_VERB_MOVE "move"
164#define DEBUGCANVAS_VERB_LINE "line"
165#define DEBUGCANVAS_VERB_QUAD "quad"
166#define DEBUGCANVAS_VERB_CUBIC "cubic"
167#define DEBUGCANVAS_VERB_CONIC "conic"
168#define DEBUGCANVAS_VERB_CLOSE "close"
169
170#define DEBUGCANVAS_STYLE_FILL "fill"
171#define DEBUGCANVAS_STYLE_STROKE "stroke"
172#define DEBUGCANVAS_STYLE_STROKEANDFILL "strokeAndFill"
173
174#define DEBUGCANVAS_POINTMODE_POINTS "points"
175#define DEBUGCANVAS_POINTMODE_LINES "lines"
176#define DEBUGCANVAS_POINTMODE_POLYGON "polygon"
177
178#define DEBUGCANVAS_CLIPOP_DIFFERENCE "difference"
179#define DEBUGCANVAS_CLIPOP_INTERSECT "intersect"
180
181#define DEBUGCANVAS_BLURSTYLE_NORMAL "normal"
182#define DEBUGCANVAS_BLURSTYLE_SOLID "solid"
183#define DEBUGCANVAS_BLURSTYLE_OUTER "outer"
184#define DEBUGCANVAS_BLURSTYLE_INNER "inner"
185
186#define DEBUGCANVAS_BLURQUALITY_LOW "low"
187#define DEBUGCANVAS_BLURQUALITY_HIGH "high"
188
189#define DEBUGCANVAS_FILLTYPE_WINDING "winding"
190#define DEBUGCANVAS_FILLTYPE_EVENODD "evenOdd"
191#define DEBUGCANVAS_FILLTYPE_INVERSEWINDING "inverseWinding"
192#define DEBUGCANVAS_FILLTYPE_INVERSEEVENODD "inverseEvenOdd"
193
194#define DEBUGCANVAS_CAP_BUTT "butt"
195#define DEBUGCANVAS_CAP_ROUND "round"
196#define DEBUGCANVAS_CAP_SQUARE "square"
197
198#define DEBUGCANVAS_MITER_JOIN "miter"
199#define DEBUGCANVAS_ROUND_JOIN "round"
200#define DEBUGCANVAS_BEVEL_JOIN "bevel"
201
202#define DEBUGCANVAS_COLORTYPE_ARGB4444 "ARGB4444"
203#define DEBUGCANVAS_COLORTYPE_RGBA8888 "RGBA8888"
204#define DEBUGCANVAS_COLORTYPE_BGRA8888 "BGRA8888"
205#define DEBUGCANVAS_COLORTYPE_565 "565"
206#define DEBUGCANVAS_COLORTYPE_GRAY8 "Gray8"
207#define DEBUGCANVAS_COLORTYPE_INDEX8 "Index8"
208#define DEBUGCANVAS_COLORTYPE_ALPHA8 "Alpha8"
209
210#define DEBUGCANVAS_ALPHATYPE_OPAQUE "opaque"
211#define DEBUGCANVAS_ALPHATYPE_PREMUL "premul"
212#define DEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul"
213#define DEBUGCANVAS_ALPHATYPE_UNKNOWN "unknown"
214
215#define DEBUGCANVAS_HINTING_NONE "none"
216#define DEBUGCANVAS_HINTING_SLIGHT "slight"
217#define DEBUGCANVAS_HINTING_NORMAL "normal"
218#define DEBUGCANVAS_HINTING_FULL "full"
219
220#define DEBUGCANVAS_EDGING_ALIAS "alias"
221#define DEBUGCANVAS_EDGING_ANTIALIAS "antialias"
222#define DEBUGCANVAS_EDGING_SUBPIXELANTIALIAS "subpixelantialias"
223
224#define DEBUGCANVAS_SHADOWFLAG_TRANSPARENT_OCC "transparentOccluder"
225#define DEBUGCANVAS_SHADOWFLAG_GEOMETRIC_ONLY "geometricOnly"
226
227static SkString* str_append(SkString* str, const SkRect& r) {
228 str->appendf(" [%g %g %g %g]", r.left(), r.top(), r.right(), r.bottom());
229 return str;
230}
231
233
235 switch (type) {
236 case kBeginDrawPicture_OpType: return "BeginDrawPicture";
237 case kClear_OpType: return "DrawClear";
238 case kClipPath_OpType: return "ClipPath";
239 case kClipRegion_OpType: return "ClipRegion";
240 case kClipRect_OpType: return "ClipRect";
241 case kClipRRect_OpType: return "ClipRRect";
242 case kResetClip_OpType: return "ResetClip";
243 case kConcat_OpType: return "Concat";
244 case kConcat44_OpType: return "Concat44";
245 case kDrawAnnotation_OpType: return "DrawAnnotation";
246 case kDrawBitmap_OpType: return "DrawBitmap";
247 case kDrawBitmapRect_OpType: return "DrawBitmapRect";
248 case kDrawDRRect_OpType: return "DrawDRRect";
249 case kDrawImage_OpType: return "DrawImage";
250 case kDrawImageLattice_OpType: return "DrawImageLattice";
251 case kDrawImageRect_OpType: return "DrawImageRect";
252 case kDrawImageRectLayer_OpType: return "DrawImageRectLayer";
253 case kDrawOval_OpType: return "DrawOval";
254 case kDrawPaint_OpType: return "DrawPaint";
255 case kDrawPatch_OpType: return "DrawPatch";
256 case kDrawPath_OpType: return "DrawPath";
257 case kDrawArc_OpType: return "DrawArc";
258 case kDrawPoints_OpType: return "DrawPoints";
259 case kDrawRect_OpType: return "DrawRect";
260 case kDrawRRect_OpType: return "DrawRRect";
261 case kDrawRegion_OpType: return "DrawRegion";
262 case kDrawShadow_OpType: return "DrawShadow";
263 case kDrawTextBlob_OpType: return "DrawTextBlob";
264 case kDrawVertices_OpType: return "DrawVertices";
265 case kDrawAtlas_OpType: return "DrawAtlas";
266 case kDrawDrawable_OpType: return "DrawDrawable";
267 case kDrawEdgeAAQuad_OpType: return "DrawEdgeAAQuad";
268 case kDrawEdgeAAImageSet_OpType: return "DrawEdgeAAImageSet";
269 case kEndDrawPicture_OpType: return "EndDrawPicture";
270 case kRestore_OpType: return "Restore";
271 case kSave_OpType: return "Save";
272 case kSaveLayer_OpType: return "SaveLayer";
273 case kSetMatrix_OpType: return "SetMatrix";
274 case kSetM44_OpType: return "SetM44";
275 default:
276 SkDebugf("OpType error 0x%08x\n", type);
277 SkASSERT(0);
278 break;
279 }
280 SkDEBUGFAIL("DrawType UNUSED\n");
281 return nullptr;
282}
283
284void DrawCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
287}
288
289namespace {
290
291void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) {
292 const SkISize& size = canvas->getBaseLayerSize();
293
294 static const SkScalar kInsetFrac = 0.9f; // Leave a border around object
295
296 canvas->translate(size.fWidth / 2.0f, size.fHeight / 2.0f);
297 if (bounds.width() > bounds.height()) {
298 canvas->scale(SkDoubleToScalar((kInsetFrac * size.fWidth) / bounds.width()),
299 SkDoubleToScalar((kInsetFrac * size.fHeight) / bounds.width()));
300 } else {
301 canvas->scale(SkDoubleToScalar((kInsetFrac * size.fWidth) / bounds.height()),
302 SkDoubleToScalar((kInsetFrac * size.fHeight) / bounds.height()));
303 }
304 canvas->translate(-bounds.centerX(), -bounds.centerY());
305}
306
307void render_path(SkCanvas* canvas, const SkPath& path) {
308 canvas->clear(0xFFFFFFFF);
309
310 const SkRect& bounds = path.getBounds();
311 if (bounds.isEmpty()) {
312 return;
313 }
314
315 SkAutoCanvasRestore acr(canvas, true);
316 xlate_and_scale_to_bounds(canvas, bounds);
317
318 SkPaint p;
319 p.setColor(SK_ColorBLACK);
320 p.setStyle(SkPaint::kStroke_Style);
321
322 canvas->drawPath(path, p);
323}
324
325void render_region(SkCanvas* canvas, const SkRegion& region) {
326 canvas->clear(0xFFFFFFFF);
327
328 const SkIRect& bounds = region.getBounds();
329 if (bounds.isEmpty()) {
330 return;
331 }
332
333 SkAutoCanvasRestore acr(canvas, true);
334 xlate_and_scale_to_bounds(canvas, SkRect::Make(bounds));
335
336 SkPaint p;
337 p.setColor(SK_ColorBLACK);
338 p.setStyle(SkPaint::kStroke_Style);
339
340 canvas->drawRegion(region, p);
341}
342
343void render_rrect(SkCanvas* canvas, const SkRRect& rrect) {
344 canvas->clear(0xFFFFFFFF);
345 canvas->save();
346
347 const SkRect& bounds = rrect.getBounds();
348
349 xlate_and_scale_to_bounds(canvas, bounds);
350
351 SkPaint p;
352 p.setColor(SK_ColorBLACK);
353 p.setStyle(SkPaint::kStroke_Style);
354
355 canvas->drawRRect(rrect, p);
356 canvas->restore();
357}
358
359void render_drrect(SkCanvas* canvas, const SkRRect& outer, const SkRRect& inner) {
360 canvas->clear(0xFFFFFFFF);
361 canvas->save();
362
363 const SkRect& bounds = outer.getBounds();
364
365 xlate_and_scale_to_bounds(canvas, bounds);
366
367 SkPaint p;
368 p.setColor(SK_ColorBLACK);
369 p.setStyle(SkPaint::kStroke_Style);
370
371 canvas->drawDRRect(outer, inner, p);
372 canvas->restore();
373}
374
375void render_shadow(SkCanvas* canvas, const SkPath& path, SkDrawShadowRec rec) {
376 canvas->clear(0xFFFFFFFF);
377
378 const SkRect& bounds = path.getBounds();
379 if (bounds.isEmpty()) {
380 return;
381 }
382
383 SkAutoCanvasRestore acr(canvas, true);
384 xlate_and_scale_to_bounds(canvas, bounds);
385
388 canvas->private_draw_shadow_rec(path, rec);
389}
390
391void apply_paint_blend_mode(const SkPaint& paint, SkJSONWriter& writer) {
392 const auto mode = paint.getBlendMode_or(SkBlendMode::kSrcOver);
395 }
396}
397
398} // namespace
399
401 writer.beginArray(nullptr, false);
402 writer.appendS32(SkColorGetA(color));
403 writer.appendS32(SkColorGetR(color));
404 writer.appendS32(SkColorGetG(color));
405 writer.appendS32(SkColorGetB(color));
406 writer.endArray();
407}
408
410 writer.beginArray(nullptr, false);
411 writer.appendFloat(color.fA);
412 writer.appendFloat(color.fR);
413 writer.appendFloat(color.fG);
414 writer.appendFloat(color.fB);
415 writer.endArray();
416}
417
419 writer.beginArray(nullptr, false);
420 writer.appendFloat(point.x());
421 writer.appendFloat(point.y());
422 writer.endArray();
423}
424
426 writer.beginArray(nullptr, false);
427 writer.appendFloat(x);
428 writer.appendFloat(y);
429 writer.endArray();
430}
431
433 writer.beginArray(nullptr, false);
434 writer.appendFloat(point.x());
435 writer.appendFloat(point.y());
436 writer.appendFloat(point.z());
437 writer.endArray();
438}
439
441 writer.beginArray(nullptr, false);
442 writer.appendFloat(rect.left());
443 writer.appendFloat(rect.top());
444 writer.appendFloat(rect.right());
445 writer.appendFloat(rect.bottom());
446 writer.endArray();
447}
448
450 writer.beginArray(nullptr, false);
451 writer.appendS32(rect.left());
452 writer.appendS32(rect.top());
453 writer.appendS32(rect.right());
454 writer.appendS32(rect.bottom());
455 writer.endArray();
456}
457
458static void make_json_rrect(SkJSONWriter& writer, const SkRRect& rrect) {
459 writer.beginArray(nullptr, false);
465 writer.endArray();
466}
467
469 writer.beginArray();
470 for (int r = 0; r < 3; ++r) {
471 writer.beginArray(nullptr, false);
472 for (int c = 0; c < 3; ++c) {
473 writer.appendFloat(matrix[r * 3 + c]);
474 }
475 writer.endArray();
476 }
477 writer.endArray();
478}
479
481 writer.beginArray();
482 for (int r = 0; r < 4; ++r) {
483 writer.beginArray(nullptr, false);
484 for (int c = 0; c < 4; ++c) {
485 writer.appendFloat(matrix.rc(r, c));
486 }
487 writer.endArray();
488 }
489 writer.endArray();
490}
491
493 writer.beginObject();
494
496 path.dump(&wstream, false);
497 auto data = wstream.detachAsData();
499 static_cast<const char*>(data->data()), data->size());
500
501 switch (path.getFillType()) {
504 break;
507 break;
511 break;
515 break;
516 }
518 SkPath::Iter iter(path, false);
519 SkPoint pts[4];
520 SkPath::Verb verb;
521 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
522 if (verb == SkPath::kClose_Verb) {
524 continue;
525 }
526 writer.beginObject(); // verb
527 switch (verb) {
528 case SkPath::kLine_Verb: {
530 MakeJsonPoint(writer, pts[1]);
531 break;
532 }
533 case SkPath::kQuad_Verb: {
535 MakeJsonPoint(writer, pts[1]);
536 MakeJsonPoint(writer, pts[2]);
537 writer.endArray(); // quad coords
538 break;
539 }
540 case SkPath::kCubic_Verb: {
542 MakeJsonPoint(writer, pts[1]);
543 MakeJsonPoint(writer, pts[2]);
544 MakeJsonPoint(writer, pts[3]);
545 writer.endArray(); // cubic coords
546 break;
547 }
548 case SkPath::kConic_Verb: {
550 MakeJsonPoint(writer, pts[1]);
551 MakeJsonPoint(writer, pts[2]);
552 writer.appendFloat(iter.conicWeight());
553 writer.endArray(); // conic coords
554 break;
555 }
556 case SkPath::kMove_Verb: {
558 MakeJsonPoint(writer, pts[0]);
559 break;
560 }
563 // Unreachable
564 break;
565 }
566 writer.endObject(); // verb
567 }
568 writer.endArray(); // verbs
569 writer.endObject(); // path
570}
571
573 // TODO: Actually serialize the rectangles, rather than just devolving to path
574 SkPath path;
576 MakeJsonPath(writer, path);
577}
578
580 writer.beginObject();
581 writer.appendS32("maxAniso", sampling.maxAniso);
582 writer.appendBool("useCubic", sampling.useCubic);
583 writer.appendS32("filter", (int)sampling.filter);
584 writer.appendS32("mipmap", (int)sampling.mipmap);
585 writer.appendFloat("cubic.B", sampling.cubic.B);
586 writer.appendFloat("cubic.C", sampling.cubic.C);
587 writer.endObject();
588}
589
590static const char* clipop_name(SkClipOp op) {
591 switch (op) {
594 default: SkASSERT(false); return "<invalid region op>";
595 }
596}
597
599 switch (mode) {
603 default: SkASSERT(false); return "<invalid point mode>";
604 }
605}
606
607static void store_scalar(SkJSONWriter& writer,
608 const char* key,
610 SkScalar defaultValue) {
611 if (value != defaultValue) {
612 writer.appendFloat(key, value);
613 }
614}
615
616static void store_bool(SkJSONWriter& writer, const char* key, bool value, bool defaultValue) {
617 if (value != defaultValue) {
618 writer.appendBool(key, value);
619 }
620}
621
622static SkString encode_data(const void* bytes,
623 size_t count,
624 const char* contentType,
625 UrlDataManager& urlDataManager) {
627 return urlDataManager.addData(data.get(), contentType);
628}
629
630void DrawCommand::flatten(const SkFlattenable* flattenable,
631 SkJSONWriter& writer,
632 UrlDataManager& urlDataManager) {
633 SkBinaryWriteBuffer buffer({}); // TODO(kjlubick, bungeman) feed SkSerialProcs through API
634 flattenable->flatten(buffer);
635 void* data = sk_malloc_throw(buffer.bytesWritten());
636 buffer.writeToMemory(data);
637 SkString url =
638 encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlDataManager);
641
643 JsonWriteBuffer jsonBuffer(&writer, &urlDataManager);
644 flattenable->flatten(jsonBuffer);
645 writer.endObject(); // values
646
647 sk_free(data);
648}
649
651 SkPixmap pm;
652 SkAssertResult(bitmap.peekPixels(&pm));
653
655 options.fZLibLevel = 1;
658}
659
660// flattens an image to a Json stream, also called from shader flatten
662 SkJSONWriter& writer,
663 UrlDataManager& urlDataManager) {
664 // For MSKP files, there is no need to encode the image,
665 // just report its id.
666 if (urlDataManager.hasImageIndex()) {
668 writer.appendU64(urlDataManager.lookupImage(&image));
669 return true;
670 }
671
673 size_t rowBytes = 4 * image.width();
674 SkAutoMalloc buffer(rowBytes * image.height());
675 SkImageInfo dstInfo =
676 SkImageInfo::Make(image.dimensions(), kN32_SkColorType, kPremul_SkAlphaType);
677 // "cheat" for this debug tool and use image's context
678 GrDirectContext* dContext = nullptr;
679#if defined(SK_GANESH)
680 dContext = GrAsDirectContext(as_IB(&image)->context());
681#endif
682 if (!image.readPixels(dContext, dstInfo, buffer.get(), rowBytes, 0, 0)) {
683 SkDebugf("DrawCommand::flatten SkImage: readPixels failed\n");
684 writer.endObject();
685 return false;
686 }
687
688 SkBitmap bm;
689 bm.installPixels(dstInfo, buffer.get(), rowBytes);
690
693 sk_sp<SkData> encoded = out.detachAsData();
694 if (encoded == nullptr) {
695 SkDebugf("DrawCommand::flatten SkImage: could not encode image as PNG\n");
696 writer.endObject();
697 return false;
698 }
699 auto dataPtr = encoded->data();
700 if (!dataPtr) {
701 SkDebugf("DrawCommand::flatten SkImage: encoding as PNG produced zero length data\n");
702 writer.endObject();
703 return false;
704 }
705 SkString url = encode_data(encoded->data(), encoded->size(), "image/png", urlDataManager);
707 writer.endObject();
708 return true;
709}
710
712 switch (colorType) {
719 default: SkASSERT(false); return DEBUGCANVAS_COLORTYPE_RGBA8888;
720 }
721}
722
723static const char* alpha_type_name(SkAlphaType alphaType) {
724 switch (alphaType) {
728 default: SkASSERT(false); return DEBUGCANVAS_ALPHATYPE_OPAQUE;
729 }
730}
731
733 SkJSONWriter& writer,
734 UrlDataManager& urlDataManager) {
735 sk_sp<SkImage> image(bitmap.asImage());
738 // Image will appear to have no uses, TODO(nifong): provide the user with a useful explanation
739 bool success = flatten(*image, writer, urlDataManager);
740 return success;
741}
742
743static void apply_font_hinting(const SkFont& font, SkJSONWriter& writer) {
744 SkFontHinting hinting = font.getHinting();
745 if (hinting != SkPaintDefaults_Hinting) {
746 switch (hinting) {
749 break;
752 break;
755 break;
758 break;
759 }
760 }
761}
762
763static void apply_font_edging(const SkFont& font, SkJSONWriter& writer) {
764 switch (font.getEdging()) {
767 break;
770 break;
774 break;
775 }
776}
777
778static void apply_paint_color(const SkPaint& paint, SkJSONWriter& writer) {
779 SkColor color = paint.getColor();
780 if (color != SK_ColorBLACK) {
783 }
784}
785
786static void apply_paint_style(const SkPaint& paint, SkJSONWriter& writer) {
787 SkPaint::Style style = paint.getStyle();
788 if (style != SkPaint::kFill_Style) {
789 switch (style) {
792 break;
793 }
796 break;
797 }
798 default: SkASSERT(false);
799 }
800 }
801}
802
803static void apply_paint_cap(const SkPaint& paint, SkJSONWriter& writer) {
804 SkPaint::Cap cap = paint.getStrokeCap();
805 if (cap != SkPaint::kDefault_Cap) {
806 switch (cap) {
809 break;
812 break;
815 break;
816 default: SkASSERT(false);
817 }
818 }
819}
820
821static void apply_paint_join(const SkPaint& paint, SkJSONWriter& writer) {
822 SkPaint::Join join = paint.getStrokeJoin();
824 switch (join) {
827 break;
830 break;
833 break;
834 default: SkASSERT(false);
835 }
836 }
837}
838
840 SkJSONWriter& writer,
841 UrlDataManager& urlDataManager) {
842 SkMaskFilter* maskFilter = paint.getMaskFilter();
843 if (maskFilter != nullptr) {
845 if (as_MFB(maskFilter)->asABlur(&blurRec)) {
848 switch (blurRec.fStyle) {
851 break;
854 break;
857 break;
860 break;
861 default: SkASSERT(false);
862 }
863 writer.endObject(); // blur
864 } else {
866 DrawCommand::flatten(maskFilter, writer, urlDataManager);
867 writer.endObject(); // maskFilter
868 }
869 }
870}
871
873 SkJSONWriter& writer,
874 UrlDataManager& urlDataManager) {
875 SkPathEffect* pathEffect = paint.getPathEffect();
876 if (pathEffect != nullptr) {
877 SkPathEffect::DashInfo dashInfo;
878 SkPathEffect::DashType dashType = pathEffect->asADash(&dashInfo);
879 if (dashType == SkPathEffect::kDash_DashType) {
880 dashInfo.fIntervals = (SkScalar*)sk_malloc_throw(dashInfo.fCount * sizeof(SkScalar));
881 pathEffect->asADash(&dashInfo);
884 for (int32_t i = 0; i < dashInfo.fCount; i++) {
885 writer.appendFloat(dashInfo.fIntervals[i]);
886 }
887 writer.endArray(); // intervals
888 sk_free(dashInfo.fIntervals);
890 writer.endObject(); // dashing
891 } else {
893 DrawCommand::flatten(pathEffect, writer, urlDataManager);
894 writer.endObject(); // pathEffect
895 }
896 }
897}
898
899static void apply_font_typeface(const SkFont& font,
900 SkJSONWriter& writer,
901 UrlDataManager& urlDataManager) {
902 SkTypeface* typeface = font.getTypeface();
903 if (typeface != nullptr) {
906 typeface->serialize(&buffer);
907 void* data = sk_malloc_throw(buffer.bytesWritten());
908 buffer.copyTo(data);
909 SkString url = encode_data(
910 data, buffer.bytesWritten(), "application/octet-stream", urlDataManager);
912 sk_free(data);
913 writer.endObject();
914 }
915}
916
917static void apply_flattenable(const char* key,
918 SkFlattenable* flattenable,
919 SkJSONWriter& writer,
920 UrlDataManager& urlDataManager) {
921 if (flattenable != nullptr) {
922 writer.beginObject(key);
923 DrawCommand::flatten(flattenable, writer, urlDataManager);
924 writer.endObject();
925 }
926}
927
929 const SkPaint& paint,
930 UrlDataManager& urlDataManager) {
931 writer.beginObject();
932 store_scalar(writer, DEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWidth(), 0.0f);
933 store_scalar(writer,
935 paint.getStrokeMiter(),
937 store_bool(writer, DEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(), false);
938 store_bool(writer, DEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false);
939
940 apply_paint_color(paint, writer);
941 apply_paint_style(paint, writer);
942 apply_paint_blend_mode(paint, writer);
943 apply_paint_cap(paint, writer);
944 apply_paint_join(paint, writer);
945 apply_paint_patheffect(paint, writer, urlDataManager);
946 apply_paint_maskfilter(paint, writer, urlDataManager);
947 apply_flattenable(DEBUGCANVAS_ATTRIBUTE_SHADER, paint.getShader(), writer, urlDataManager);
949 DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER, paint.getImageFilter(), writer, urlDataManager);
951 DEBUGCANVAS_ATTRIBUTE_COLORFILTER, paint.getColorFilter(), writer, urlDataManager);
952 writer.endObject(); // paint
953}
954
955static void MakeJsonFont(const SkFont& font, SkJSONWriter& writer, UrlDataManager& urlDataManager) {
956 writer.beginObject();
957 store_bool(writer, DEBUGCANVAS_ATTRIBUTE_FAKEBOLDTEXT, font.isEmbolden(), false);
958 store_bool(writer, DEBUGCANVAS_ATTRIBUTE_LINEARTEXT, font.isLinearMetrics(), false);
959 store_bool(writer, DEBUGCANVAS_ATTRIBUTE_SUBPIXELTEXT, font.isSubpixel(), false);
960 store_bool(writer, DEBUGCANVAS_ATTRIBUTE_EMBEDDEDBITMAPTEXT, font.isEmbeddedBitmaps(), false);
961 store_bool(writer, DEBUGCANVAS_ATTRIBUTE_AUTOHINTING, font.isForceAutoHinting(), false);
962
965 store_scalar(writer, DEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, font.getSkewX(), 0.0f);
966 apply_font_edging(font, writer);
967 apply_font_hinting(font, writer);
968 apply_font_typeface(font, writer, urlDataManager);
969 writer.endObject(); // font
970}
971
973 writer.beginObject();
976 if (nullptr != lattice.fBounds) {
978 MakeJsonIRect(writer, *lattice.fBounds);
979 }
981 for (int i = 0; i < lattice.fXCount; i++) {
982 writer.appendS32(lattice.fXDivs[i]);
983 }
984 writer.endArray(); // xdivs
986 for (int i = 0; i < lattice.fYCount; i++) {
987 writer.appendS32(lattice.fYDivs[i]);
988 }
989 writer.endArray(); // ydivs
990 if (nullptr != lattice.fRectTypes) {
992 int flagCount = 0;
993 for (int row = 0; row < lattice.fYCount + 1; row++) {
994 writer.beginArray();
995 for (int column = 0; column < lattice.fXCount + 1; column++) {
996 writer.appendS32(lattice.fRectTypes[flagCount++]);
997 }
998 writer.endArray(); // row
999 }
1000 writer.endArray();
1001 }
1002 writer.endObject();
1003}
1004
1006
1007void ClearCommand::execute(SkCanvas* canvas) const { canvas->clear(fColor); }
1008
1009void ClearCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1010 INHERITED::toJSON(writer, urlDataManager);
1012 MakeJsonColor(writer, fColor);
1013}
1014
1016 : INHERITED(kClipPath_OpType) {
1017 fPath = path;
1018 fOp = op;
1019 fDoAA = doAA;
1020}
1021
1022void ClipPathCommand::execute(SkCanvas* canvas) const { canvas->clipPath(fPath, fOp, fDoAA); }
1023
1025 render_path(canvas, fPath);
1026 return true;
1027}
1028
1029void ClipPathCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1030 INHERITED::toJSON(writer, urlDataManager);
1032 MakeJsonPath(writer, fPath);
1035}
1036
1038 : INHERITED(kClipRegion_OpType) {
1039 fRegion = region;
1040 fOp = op;
1041}
1042
1043void ClipRegionCommand::execute(SkCanvas* canvas) const { canvas->clipRegion(fRegion, fOp); }
1044
1045void ClipRegionCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1046 INHERITED::toJSON(writer, urlDataManager);
1048 MakeJsonRegion(writer, fRegion);
1050}
1051
1053 : INHERITED(kClipRect_OpType) {
1054 fRect = rect;
1055 fOp = op;
1056 fDoAA = doAA;
1057}
1058
1059void ClipRectCommand::execute(SkCanvas* canvas) const { canvas->clipRect(fRect, fOp, fDoAA); }
1060
1061void ClipRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1062 INHERITED::toJSON(writer, urlDataManager);
1064 MakeJsonRect(writer, fRect);
1067
1068 SkString desc;
1070}
1071
1073 : INHERITED(kClipRRect_OpType) {
1074 fRRect = rrect;
1075 fOp = op;
1076 fDoAA = doAA;
1077}
1078
1079void ClipRRectCommand::execute(SkCanvas* canvas) const { canvas->clipRRect(fRRect, fOp, fDoAA); }
1080
1082 render_rrect(canvas, fRRect);
1083 return true;
1084}
1085
1086void ClipRRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1087 INHERITED::toJSON(writer, urlDataManager);
1089 make_json_rrect(writer, fRRect);
1092}
1093
1095 : INHERITED(kClipShader_OpType) {
1096 fShader = std::move(cs);
1097 fOp = op;
1098}
1099
1100void ClipShaderCommand::execute(SkCanvas* canvas) const { canvas->clipShader(fShader, fOp); }
1101
1103 SkPaint paint;
1104 paint.setShader(fShader);
1105 canvas->drawPaint(paint);
1106 return true;
1107}
1108
1109void ClipShaderCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1110 INHERITED::toJSON(writer, urlDataManager);
1111 apply_flattenable(DEBUGCANVAS_ATTRIBUTE_SHADER, fShader.get(), writer, urlDataManager);
1113}
1114
1116
1118
1120 fMatrix = matrix;
1121}
1122
1123void ConcatCommand::execute(SkCanvas* canvas) const { canvas->concat(fMatrix); }
1124
1125namespace {
1126 void writeMatrixType(SkJSONWriter& writer, const SkMatrix& m) {
1127 switch (m.getType()) {
1129 writer.appendNString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, " (translate)");
1130 break;
1133 break;
1135 writer.appendNString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, " (rotation or skew)");
1136 break;
1138 writer.appendNString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, " (perspective)");
1139 break;
1140 default:
1141 break;
1142 }
1143 }
1144}
1145
1146void ConcatCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1147 INHERITED::toJSON(writer, urlDataManager);
1149 MakeJsonMatrix(writer, fMatrix);
1150 writeMatrixType(writer, fMatrix);
1151}
1152
1154 fMatrix = matrix;
1155}
1156
1157void Concat44Command::execute(SkCanvas* canvas) const { canvas->concat(fMatrix); }
1158
1159void Concat44Command::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1160 INHERITED::toJSON(writer, urlDataManager);
1162 MakeJsonMatrix44(writer, fMatrix);
1163}
1164
1165////
1166
1168 const char key[],
1170 : INHERITED(kDrawAnnotation_OpType), fRect(rect), fKey(key), fValue(std::move(value)) {}
1171
1173 canvas->drawAnnotation(fRect, fKey.c_str(), fValue);
1174}
1175
1176void DrawAnnotationCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1177 INHERITED::toJSON(writer, urlDataManager);
1178
1180 MakeJsonRect(writer, fRect);
1181 writer.appendString("key", fKey);
1182 if (fValue) {
1183 writer.appendString("value", static_cast<const char*>(fValue->data()), fValue->size());
1184 }
1185
1186 SkString desc;
1187 str_append(&desc, fRect)->appendf(" %s", fKey.c_str());
1189}
1190
1191////
1192
1194 SkScalar left,
1195 SkScalar top,
1197 const SkPaint* paint)
1198 : INHERITED(kDrawImage_OpType)
1199 , fImage(SkRef(image))
1200 , fLeft(left)
1201 , fTop(top)
1202 , fSampling(sampling)
1203 , fPaint(paint) {}
1204
1206 canvas->drawImage(fImage.get(), fLeft, fTop, fSampling, fPaint.getMaybeNull());
1207}
1208
1210 SkAutoCanvasRestore acr(canvas, true);
1211 canvas->clear(0xFFFFFFFF);
1212
1213 xlate_and_scale_to_bounds(
1214 canvas,
1216 fLeft, fTop, SkIntToScalar(fImage->width()), SkIntToScalar(fImage->height())));
1217 this->execute(canvas);
1218 return true;
1219}
1220
1222 return udm.lookupImage(fImage.get());
1223}
1224
1225void DrawImageCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1226 INHERITED::toJSON(writer, urlDataManager);
1227 flatten(*fImage, writer, urlDataManager);
1229 MakeJsonPoint(writer, fLeft, fTop);
1230 if (fPaint.isValid()) {
1232 MakeJsonPaint(writer, *fPaint, urlDataManager);
1233 }
1235 MakeJsonSampling(writer, fSampling);
1236
1238 writer.appendS32(DEBUGCANVAS_ATTRIBUTE_WIDTH, fImage->width());
1240 switch (fImage->alphaType()) {
1243 break;
1246 break;
1249 break;
1250 default:
1252 break;
1253 }
1254}
1255
1257 const SkCanvas::Lattice& lattice,
1258 const SkRect& dst,
1259 SkFilterMode filter,
1260 const SkPaint* paint)
1261 : INHERITED(kDrawImageLattice_OpType)
1262 , fImage(SkRef(image))
1263 , fLattice(lattice)
1264 , fDst(dst)
1265 , fFilter(filter)
1266 , fPaint(paint) {}
1267
1269 canvas->drawImageLattice(fImage.get(), fLattice, fDst, fFilter, fPaint.getMaybeNull());
1270}
1271
1273 SkAutoCanvasRestore acr(canvas, true);
1274 canvas->clear(0xFFFFFFFF);
1275
1276 xlate_and_scale_to_bounds(canvas, fDst);
1277
1278 this->execute(canvas);
1279 return true;
1280}
1281
1283 return udm.lookupImage(fImage.get());
1284}
1285
1287 INHERITED::toJSON(writer, urlDataManager);
1288 flatten(*fImage, writer, urlDataManager);
1290 MakeJsonLattice(writer, fLattice);
1292 MakeJsonRect(writer, fDst);
1293 if (fPaint.isValid()) {
1295 MakeJsonPaint(writer, *fPaint, urlDataManager);
1296 }
1297
1298 SkString desc;
1300}
1301
1303 const SkRect& src,
1304 const SkRect& dst,
1306 const SkPaint* paint,
1307 SkCanvas::SrcRectConstraint constraint)
1308 : INHERITED(kDrawImageRect_OpType)
1309 , fImage(SkRef(image))
1310 , fSrc(src)
1311 , fDst(dst)
1312 , fSampling(sampling)
1313 , fPaint(paint)
1314 , fConstraint(constraint) {}
1315
1317 canvas->drawImageRect(fImage.get(), fSrc, fDst, fSampling, fPaint.getMaybeNull(), fConstraint);
1318}
1319
1321 SkAutoCanvasRestore acr(canvas, true);
1322 canvas->clear(0xFFFFFFFF);
1323
1324 xlate_and_scale_to_bounds(canvas, fDst);
1325
1326 this->execute(canvas);
1327 return true;
1328}
1329
1331 return udm.lookupImage(fImage.get());
1332}
1333
1334void DrawImageRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1335 INHERITED::toJSON(writer, urlDataManager);
1336 flatten(*fImage, writer, urlDataManager);
1338 MakeJsonRect(writer, fSrc);
1340 MakeJsonRect(writer, fDst);
1342 MakeJsonSampling(writer, fSampling);
1343 if (fPaint.isValid()) {
1345 MakeJsonPaint(writer, *fPaint, urlDataManager);
1346 }
1347 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
1349 }
1350
1351 SkString desc;
1353}
1354
1356 const int nodeId,
1357 const int frame,
1358 const SkRect& src,
1359 const SkRect& dst,
1361 const SkPaint* paint,
1362 SkCanvas::SrcRectConstraint constraint)
1363 : INHERITED(kDrawImageRectLayer_OpType)
1364 , fLayerManager(layerManager)
1365 , fNodeId(nodeId)
1366 , fFrame(frame)
1367 , fSrc(src)
1368 , fDst(dst)
1369 , fSampling(sampling)
1370 , fPaint(paint)
1371 , fConstraint(constraint) {}
1372
1374 sk_sp<SkImage> snapshot = fLayerManager->getLayerAsImage(fNodeId, fFrame);
1375 canvas->drawImageRect(snapshot.get(), fSrc, fDst, SkSamplingOptions(), fPaint.getMaybeNull(), fConstraint);
1376}
1377
1379 SkAutoCanvasRestore acr(canvas, true);
1380 canvas->clear(0xFFFFFFFF);
1381
1382 xlate_and_scale_to_bounds(canvas, fDst);
1383
1384 this->execute(canvas);
1385 return true;
1386}
1387
1389 INHERITED::toJSON(writer, urlDataManager);
1390
1391 // Don't append an image attribute here, the image can be rendered in as many different ways
1392 // as there are commands in the layer, at least. the urlDataManager would save each one under
1393 // a different URL.
1394 // Append the node id, and the layer inspector of the debugger will know what to do with it.
1396
1398 MakeJsonRect(writer, fSrc);
1399
1401 MakeJsonRect(writer, fDst);
1403 MakeJsonSampling(writer, fSampling);
1404 if (fPaint.isValid()) {
1406 MakeJsonPaint(writer, *fPaint, urlDataManager);
1407 }
1408 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
1410 }
1411
1412 SkString desc;
1414}
1415
1417 : INHERITED(kDrawOval_OpType) {
1418 fOval = oval;
1419 fPaint = paint;
1420}
1421
1422void DrawOvalCommand::execute(SkCanvas* canvas) const { canvas->drawOval(fOval, fPaint); }
1423
1425 canvas->clear(0xFFFFFFFF);
1426 canvas->save();
1427
1428 xlate_and_scale_to_bounds(canvas, fOval);
1429
1430 SkPaint p;
1431 p.setColor(SK_ColorBLACK);
1432 p.setStyle(SkPaint::kStroke_Style);
1433
1434 canvas->drawOval(fOval, p);
1435 canvas->restore();
1436
1437 return true;
1438}
1439
1440void DrawOvalCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1441 INHERITED::toJSON(writer, urlDataManager);
1443 MakeJsonRect(writer, fOval);
1445 MakeJsonPaint(writer, fPaint, urlDataManager);
1446}
1447
1451 bool useCenter,
1452 const SkPaint& paint)
1453 : INHERITED(kDrawArc_OpType) {
1454 fOval = oval;
1455 fStartAngle = startAngle;
1456 fSweepAngle = sweepAngle;
1457 fUseCenter = useCenter;
1458 fPaint = paint;
1459}
1460
1462 canvas->drawArc(fOval, fStartAngle, fSweepAngle, fUseCenter, fPaint);
1463}
1464
1466 canvas->clear(0xFFFFFFFF);
1467 canvas->save();
1468
1469 xlate_and_scale_to_bounds(canvas, fOval);
1470
1471 SkPaint p;
1472 p.setColor(SK_ColorBLACK);
1473 p.setStyle(SkPaint::kStroke_Style);
1474
1475 canvas->drawArc(fOval, fStartAngle, fSweepAngle, fUseCenter, p);
1476 canvas->restore();
1477
1478 return true;
1479}
1480
1481void DrawArcCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1482 INHERITED::toJSON(writer, urlDataManager);
1484 MakeJsonRect(writer, fOval);
1485 writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_STARTANGLE, fStartAngle);
1486 writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_SWEEPANGLE, fSweepAngle);
1487 writer.appendBool(DEBUGCANVAS_ATTRIBUTE_USECENTER, fUseCenter);
1489 MakeJsonPaint(writer, fPaint, urlDataManager);
1490}
1491
1493 fPaint = paint;
1494}
1495
1496void DrawPaintCommand::execute(SkCanvas* canvas) const { canvas->drawPaint(fPaint); }
1497
1499 canvas->clear(0xFFFFFFFF);
1500 canvas->drawPaint(fPaint);
1501 return true;
1502}
1503
1504void DrawPaintCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1505 INHERITED::toJSON(writer, urlDataManager);
1507 MakeJsonPaint(writer, fPaint, urlDataManager);
1508}
1509
1511 fPaint = paint;
1512}
1513
1515 SkCanvasPriv::DrawBehind(canvas, fPaint);
1516}
1517
1519 canvas->clear(0xFFFFFFFF);
1520 SkCanvasPriv::DrawBehind(canvas, fPaint);
1521 return true;
1522}
1523
1524void DrawBehindCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1525 INHERITED::toJSON(writer, urlDataManager);
1527 MakeJsonPaint(writer, fPaint, urlDataManager);
1528}
1529
1531 : INHERITED(kDrawPath_OpType) {
1532 fPath = path;
1533 fPaint = paint;
1534}
1535
1536void DrawPathCommand::execute(SkCanvas* canvas) const { canvas->drawPath(fPath, fPaint); }
1537
1539 render_path(canvas, fPath);
1540 return true;
1541}
1542
1543void DrawPathCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1544 INHERITED::toJSON(writer, urlDataManager);
1546 MakeJsonPath(writer, fPath);
1548 MakeJsonPaint(writer, fPaint, urlDataManager);
1549}
1550
1552 : INHERITED(kDrawRegion_OpType) {
1553 fRegion = region;
1554 fPaint = paint;
1555}
1556
1557void DrawRegionCommand::execute(SkCanvas* canvas) const { canvas->drawRegion(fRegion, fPaint); }
1558
1560 render_region(canvas, fRegion);
1561 return true;
1562}
1563
1564void DrawRegionCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1565 INHERITED::toJSON(writer, urlDataManager);
1567 MakeJsonRegion(writer, fRegion);
1569 MakeJsonPaint(writer, fPaint, urlDataManager);
1570}
1571
1573 const SkMatrix* matrix,
1574 const SkPaint* paint)
1575 : INHERITED(kBeginDrawPicture_OpType)
1576 , fPicture(SkRef(picture))
1577 , fMatrix(matrix)
1578 , fPaint(paint) {}
1579
1581 if (fPaint.isValid()) {
1582 SkRect bounds = fPicture->cullRect();
1583 if (fMatrix.isValid()) {
1584 fMatrix->mapRect(&bounds);
1585 }
1586 canvas->saveLayer(&bounds, fPaint.get());
1587 }
1588
1589 if (fMatrix.isValid()) {
1590 if (!fPaint.isValid()) {
1591 canvas->save();
1592 }
1593 canvas->concat(*fMatrix);
1594 }
1595}
1596
1598 canvas->clear(0xFFFFFFFF);
1599 canvas->save();
1600
1601 xlate_and_scale_to_bounds(canvas, fPicture->cullRect());
1602
1603 canvas->drawPicture(fPicture.get());
1604
1605 canvas->restore();
1606
1607 return true;
1608}
1609
1611 : INHERITED(kEndDrawPicture_OpType), fRestore(restore) {}
1612
1614 if (fRestore) {
1615 canvas->restore();
1616 }
1617}
1618
1620 size_t count,
1621 const SkPoint pts[],
1622 const SkPaint& paint)
1623 : INHERITED(kDrawPoints_OpType), fMode(mode), fPts(pts, count), fPaint(paint) {}
1624
1626 canvas->drawPoints(fMode, fPts.size(), fPts.begin(), fPaint);
1627}
1628
1630 canvas->clear(0xFFFFFFFF);
1631 canvas->save();
1632
1633 SkRect bounds;
1634
1635 bounds.setEmpty();
1636 for (int i = 0; i < fPts.size(); ++i) {
1638 }
1639
1640 xlate_and_scale_to_bounds(canvas, bounds);
1641
1642 SkPaint p;
1643 p.setColor(SK_ColorBLACK);
1644 p.setStyle(SkPaint::kStroke_Style);
1645
1646 canvas->drawPoints(fMode, fPts.size(), fPts.begin(), p);
1647 canvas->restore();
1648
1649 return true;
1650}
1651
1652void DrawPointsCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1653 INHERITED::toJSON(writer, urlDataManager);
1656 for (int i = 0; i < fPts.size(); i++) {
1657 MakeJsonPoint(writer, fPts[i]);
1658 }
1659 writer.endArray(); // points
1661 MakeJsonPaint(writer, fPaint, urlDataManager);
1662}
1663
1665 SkScalar x,
1666 SkScalar y,
1667 const SkPaint& paint)
1668 : INHERITED(kDrawTextBlob_OpType)
1669 , fBlob(std::move(blob))
1670 , fXPos(x)
1671 , fYPos(y)
1672 , fPaint(paint) {}
1673
1675 canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
1676}
1677
1679 canvas->clear(SK_ColorWHITE);
1680 canvas->save();
1681
1682 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos);
1683 xlate_and_scale_to_bounds(canvas, bounds);
1684
1685 canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
1686
1687 canvas->restore();
1688
1689 return true;
1690}
1691
1692void DrawTextBlobCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1693 INHERITED::toJSON(writer, urlDataManager);
1694 writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_X, fXPos);
1695 writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_Y, fYPos);
1696 SkRect bounds = fBlob->bounds();
1698 MakeJsonRect(writer, bounds);
1700 MakeJsonPaint(writer, fPaint, urlDataManager);
1701
1703 SkTextBlobRunIterator iter(fBlob.get());
1704 while (!iter.done()) {
1705 writer.beginObject(); // run
1706 if (iter.textSize()) {
1707 writer.appendString(DEBUGCANVAS_ATTRIBUTE_TEXT, iter.text(), iter.textSize());
1708 }
1710 MakeJsonFont(iter.font(), writer, urlDataManager);
1712 MakeJsonPoint(writer, iter.offset());
1714 for (uint32_t i = 0; i < iter.glyphCount(); i++) {
1715 writer.appendU32(iter.glyphs()[i]);
1716 }
1717 writer.endArray(); // glyphs
1720 const SkScalar* iterPositions = iter.pos();
1721 for (uint32_t i = 0; i < iter.glyphCount(); i++) {
1722 switch (iter.positioning()) {
1724 MakeJsonPoint(writer, iterPositions[i * 2], iterPositions[i * 2 + 1]);
1725 break;
1727 writer.appendFloat(iterPositions[i]);
1728 break;
1731 // TODO_RSXFORM_BLOB
1732 break;
1733 }
1734 }
1735 writer.endArray(); // positions
1736 }
1737 if (iter.clusters()) {
1739 for (uint32_t i = 0; i < iter.glyphCount(); i++) {
1740 writer.appendU32(iter.clusters()[i]);
1741 }
1742 writer.endArray(); // clusters
1743 }
1744 writer.endObject(); // run
1745 iter.next();
1746 }
1747 writer.endArray(); // runs
1748
1749 SkString desc;
1750 // make the bounds local by applying the x,y
1751 bounds.offset(fXPos, fYPos);
1753}
1754
1756 const SkColor colors[4],
1757 const SkPoint texCoords[4],
1758 SkBlendMode bmode,
1759 const SkPaint& paint)
1760 : INHERITED(kDrawPatch_OpType), fBlendMode(bmode) {
1761 memcpy(fCubics, cubics, sizeof(fCubics));
1762 if (colors != nullptr) {
1763 memcpy(fColors, colors, sizeof(fColors));
1764 fColorsPtr = fColors;
1765 } else {
1766 fColorsPtr = nullptr;
1767 }
1768 if (texCoords != nullptr) {
1769 memcpy(fTexCoords, texCoords, sizeof(fTexCoords));
1770 fTexCoordsPtr = fTexCoords;
1771 } else {
1772 fTexCoordsPtr = nullptr;
1773 }
1774 fPaint = paint;
1775}
1776
1778 canvas->drawPatch(fCubics, fColorsPtr, fTexCoordsPtr, fBlendMode, fPaint);
1779}
1780
1781void DrawPatchCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1782 INHERITED::toJSON(writer, urlDataManager);
1784 for (int i = 0; i < 12; i++) {
1785 MakeJsonPoint(writer, fCubics[i]);
1786 }
1787 writer.endArray(); // cubics
1788 if (fColorsPtr != nullptr) {
1790 for (int i = 0; i < 4; i++) {
1791 MakeJsonColor(writer, fColorsPtr[i]);
1792 }
1793 writer.endArray(); // colors
1794 }
1795 if (fTexCoordsPtr != nullptr) {
1797 for (int i = 0; i < 4; i++) {
1798 MakeJsonPoint(writer, fTexCoords[i]);
1799 }
1800 writer.endArray(); // texCoords
1801 }
1802 // fBlendMode
1803}
1804
1806 : INHERITED(kDrawRect_OpType) {
1807 fRect = rect;
1808 fPaint = paint;
1809}
1810
1811void DrawRectCommand::execute(SkCanvas* canvas) const { canvas->drawRect(fRect, fPaint); }
1812
1813void DrawRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1814 INHERITED::toJSON(writer, urlDataManager);
1816 MakeJsonRect(writer, fRect);
1818 MakeJsonPaint(writer, fPaint, urlDataManager);
1819
1820 SkString desc;
1822}
1823
1825 : INHERITED(kDrawRRect_OpType) {
1826 fRRect = rrect;
1827 fPaint = paint;
1828}
1829
1830void DrawRRectCommand::execute(SkCanvas* canvas) const { canvas->drawRRect(fRRect, fPaint); }
1831
1833 render_rrect(canvas, fRRect);
1834 return true;
1835}
1836
1837void DrawRRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1838 INHERITED::toJSON(writer, urlDataManager);
1840 make_json_rrect(writer, fRRect);
1842 MakeJsonPaint(writer, fPaint, urlDataManager);
1843}
1844
1846 const SkRRect& inner,
1847 const SkPaint& paint)
1848 : INHERITED(kDrawDRRect_OpType) {
1849 fOuter = outer;
1850 fInner = inner;
1851 fPaint = paint;
1852}
1853
1855 canvas->drawDRRect(fOuter, fInner, fPaint);
1856}
1857
1859 render_drrect(canvas, fOuter, fInner);
1860 return true;
1861}
1862
1863void DrawDRRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1864 INHERITED::toJSON(writer, urlDataManager);
1866 make_json_rrect(writer, fOuter);
1868 make_json_rrect(writer, fInner);
1870 MakeJsonPaint(writer, fPaint, urlDataManager);
1871}
1872
1874 : INHERITED(kDrawShadow_OpType) {
1875 fPath = path;
1876 fShadowRec = rec;
1877}
1878
1880 canvas->private_draw_shadow_rec(fPath, fShadowRec);
1881}
1882
1884 render_shadow(canvas, fPath, fShadowRec);
1885 return true;
1886}
1887
1888void DrawShadowCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
1889 INHERITED::toJSON(writer, urlDataManager);
1890
1891 bool geometricOnly = SkToBool(fShadowRec.fFlags & SkShadowFlags::kGeometricOnly_ShadowFlag);
1892 bool transparentOccluder =
1894
1896 MakeJsonPath(writer, fPath);
1898 MakeJsonPoint3(writer, fShadowRec.fZPlaneParams);
1900 MakeJsonPoint3(writer, fShadowRec.fLightPos);
1903 MakeJsonColor(writer, fShadowRec.fAmbientColor);
1905 MakeJsonColor(writer, fShadowRec.fSpotColor);
1906 store_bool(writer, DEBUGCANVAS_SHADOWFLAG_TRANSPARENT_OCC, transparentOccluder, false);
1907 store_bool(writer, DEBUGCANVAS_SHADOWFLAG_GEOMETRIC_ONLY, geometricOnly, false);
1908}
1909
1910///////////////////////////////////////////////////////////////////////////////////////////////////
1911
1913 const SkPoint clip[4],
1915 const SkColor4f& color,
1917 : INHERITED(kDrawEdgeAAQuad_OpType)
1918 , fRect(rect)
1919 , fHasClip(clip != nullptr)
1920 , fAA(aa)
1921 , fColor(color)
1922 , fMode(mode) {
1923 if (clip) {
1924 for (int i = 0; i < 4; ++i) {
1925 fClip[i] = clip[i];
1926 }
1927 }
1928}
1929
1931 canvas->experimental_DrawEdgeAAQuad(fRect, fHasClip ? fClip : nullptr, fAA, fColor, fMode);
1932}
1933
1935 int count,
1936 const SkPoint dstClips[],
1937 const SkMatrix preViewMatrices[],
1939 const SkPaint* paint,
1940 SkCanvas::SrcRectConstraint constraint)
1941 : INHERITED(kDrawEdgeAAImageSet_OpType)
1942 , fSet(count)
1943 , fCount(count)
1944 , fSampling(sampling)
1945 , fPaint(paint)
1946 , fConstraint(constraint) {
1947 int totalDstClipCount, totalMatrixCount;
1948 SkCanvasPriv::GetDstClipAndMatrixCounts(set, count, &totalDstClipCount, &totalMatrixCount);
1949
1950 std::copy_n(set, count, fSet.get());
1951 fDstClips.reset(totalDstClipCount);
1952 std::copy_n(dstClips, totalDstClipCount, fDstClips.get());
1953 fPreViewMatrices.reset(totalMatrixCount);
1954 std::copy_n(preViewMatrices, totalMatrixCount, fPreViewMatrices.get());
1955}
1956
1958 canvas->experimental_DrawEdgeAAImageSet(fSet.get(),
1959 fCount,
1960 fDstClips.get(),
1961 fPreViewMatrices.get(),
1962 fSampling,
1963 fPaint.getMaybeNull(),
1964 fConstraint);
1965}
1966
1967///////////////////////////////////////////////////////////////////////////////////////////////////
1968
1970 : INHERITED(kDrawDrawable_OpType), fDrawable(SkRef(drawable)), fMatrix(matrix) {}
1971
1973 canvas->drawDrawable(fDrawable.get(), fMatrix.getMaybeNull());
1974}
1975
1976///////////////////////////////////////////////////////////////////////////////////////////////////
1977
1979 SkBlendMode bmode,
1980 const SkPaint& paint)
1981 : INHERITED(kDrawVertices_OpType)
1982 , fVertices(std::move(vertices))
1983 , fBlendMode(bmode)
1984 , fPaint(paint) {}
1985
1987 canvas->drawVertices(fVertices, fBlendMode, fPaint);
1988}
1989
1990///////////////////////////////////////////////////////////////////////////////////////////////////
1991
1993 const SkRSXform xform[],
1994 const SkRect tex[],
1995 const SkColor colors[],
1996 int count,
1997 SkBlendMode bmode,
1999 const SkRect* cull,
2000 const SkPaint* paint)
2001 : INHERITED(kDrawAtlas_OpType)
2002 , fImage(SkRef(image))
2003 , fXform(xform, count)
2004 , fTex(tex, count)
2005 , fColors(colors, colors ? count : 0)
2006 , fBlendMode(bmode)
2007 , fSampling(sampling)
2008 , fCull(cull)
2009 , fPaint(paint) {}
2010
2012 canvas->drawAtlas(fImage.get(),
2013 fXform.begin(),
2014 fTex.begin(),
2015 fColors.empty() ? nullptr : fColors.begin(),
2016 fXform.size(),
2017 fBlendMode,
2018 fSampling,
2019 fCull.getMaybeNull(),
2020 fPaint.getMaybeNull());
2021}
2022
2023///////////////////////////////////////////////////////////////////////////////////////////////////
2024
2026
2027void RestoreCommand::execute(SkCanvas* canvas) const { canvas->restore(); }
2028
2030
2031void SaveCommand::execute(SkCanvas* canvas) const { canvas->save(); }
2032
2034 : INHERITED(kSaveLayer_OpType)
2035 , fBounds(rec.fBounds)
2036 , fPaint(rec.fPaint)
2037 , fBackdrop(SkSafeRef(rec.fBackdrop))
2038 , fSaveLayerFlags(rec.fSaveLayerFlags)
2039 , fBackdropScale(SkCanvasPriv::GetBackdropScaleFactor(rec)) {}
2040
2042 // In the common case fBackdropScale == 1.f and then this is no different than a regular Rec
2044 fPaint.getMaybeNull(),
2045 fBackdrop.get(),
2046 fBackdropScale,
2047 fSaveLayerFlags));
2048}
2049
2050void SaveLayerCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
2051 INHERITED::toJSON(writer, urlDataManager);
2052 if (fBounds.isValid()) {
2054 MakeJsonRect(writer, *fBounds);
2055 }
2056 if (fPaint.isValid()) {
2058 MakeJsonPaint(writer, *fPaint, urlDataManager);
2059 }
2060 if (fBackdrop != nullptr) {
2062 flatten(fBackdrop.get(), writer, urlDataManager);
2063 writer.endObject(); // backdrop
2064 }
2065 if (fSaveLayerFlags != 0) {
2066 SkDebugf("unsupported: saveLayer flags\n");
2067 SkASSERT(false);
2068 }
2069}
2070
2072 fMatrix = matrix;
2073}
2074
2075void SetMatrixCommand::execute(SkCanvas* canvas) const { canvas->setMatrix(fMatrix); }
2076
2077void SetMatrixCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
2078 INHERITED::toJSON(writer, urlDataManager);
2080 MakeJsonMatrix(writer, fMatrix);
2081 writeMatrixType(writer, fMatrix);
2082}
2083
2085 fMatrix = matrix;
2086}
2087
2088void SetM44Command::execute(SkCanvas* canvas) const { canvas->setMatrix(fMatrix); }
2089
2090void SetM44Command::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
2091 INHERITED::toJSON(writer, urlDataManager);
2093 MakeJsonMatrix44(writer, fMatrix);
2094}
SkPoint fPts[2]
const char * options
#define DEBUGCANVAS_ATTRIBUTE_BLUR
#define DEBUGCANVAS_ATTRIBUTE_BLENDMODE
Definition: DrawCommand.cpp:83
static void make_json_rrect(SkJSONWriter &writer, const SkRRect &rrect)
static const char * clipop_name(SkClipOp op)
#define DEBUGCANVAS_ATTRIBUTE_FONT
#define DEBUGCANVAS_ALPHATYPE_OPAQUE
#define DEBUGCANVAS_POINTMODE_LINES
static void apply_paint_patheffect(const SkPaint &paint, SkJSONWriter &writer, UrlDataManager &urlDataManager)
#define DEBUGCANVAS_ATTRIBUTE_LATTICEFLAGS
#define DEBUGCANVAS_ATTRIBUTE_DATA
#define DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER
#define DEBUGCANVAS_ATTRIBUTE_SIGMA
#define DEBUGCANVAS_EDGING_ANTIALIAS
#define DEBUGCANVAS_ATTRIBUTE_CAP
Definition: DrawCommand.cpp:89
#define DEBUGCANVAS_ATTRIBUTE_CUBICS
#define DEBUGCANVAS_ATTRIBUTE_DASHING
#define DEBUGCANVAS_ATTRIBUTE_ALPHA
#define DEBUGCANVAS_ATTRIBUTE_SRC
#define DEBUGCANVAS_VERB_CUBIC
#define DEBUGCANVAS_ATTRIBUTE_MATRIX
Definition: DrawCommand.cpp:67
static const char * color_type_name(SkColorType colorType)
#define DEBUGCANVAS_CAP_SQUARE
#define DEBUGCANVAS_ATTRIBUTE_BOUNDS
Definition: DrawCommand.cpp:72
#define DEBUGCANVAS_ATTRIBUTE_AUTOHINTING
Definition: DrawCommand.cpp:98
#define DEBUGCANVAS_FILLTYPE_EVENODD
#define DEBUGCANVAS_ATTRIBUTE_PATHEFFECT
#define DEBUGCANVAS_ATTRIBUTE_FAKEBOLDTEXT
Definition: DrawCommand.cpp:92
#define DEBUGCANVAS_ATTRIBUTE_WIDTH
#define DEBUGCANVAS_POINTMODE_POINTS
#define DEBUGCANVAS_ATTRIBUTE_SUBPIXELTEXT
Definition: DrawCommand.cpp:94
#define DEBUGCANVAS_COLORTYPE_GRAY8
#define DEBUGCANVAS_ATTRIBUTE_SHADER
#define DEBUGCANVAS_ATTRIBUTE_IMAGE_INDEX
#define DEBUGCANVAS_CAP_BUTT
static void apply_font_edging(const SkFont &font, SkJSONWriter &writer)
#define DEBUGCANVAS_SHADOWFLAG_TRANSPARENT_OCC
static void store_bool(SkJSONWriter &writer, const char *key, bool value, bool defaultValue)
#define DEBUGCANVAS_COLORTYPE_565
#define DEBUGCANVAS_ATTRIBUTE_SHORTDESC
#define DEBUGCANVAS_HINTING_NORMAL
#define DEBUGCANVAS_ATTRIBUTE_LIGHTPOSITION
#define DEBUGCANVAS_ATTRIBUTE_VALUES
static void apply_font_typeface(const SkFont &font, SkJSONWriter &writer, UrlDataManager &urlDataManager)
#define DEBUGCANVAS_COLORTYPE_RGBA8888
#define DEBUGCANVAS_ATTRIBUTE_CLUSTERS
Definition: DrawCommand.cpp:79
#define DEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS
#define DEBUGCANVAS_ATTRIBUTE_STARTANGLE
#define DEBUGCANVAS_BLURSTYLE_SOLID
#define DEBUGCANVAS_ATTRIBUTE_LAYERNODEID
#define DEBUGCANVAS_STYLE_STROKE
#define DEBUGCANVAS_ATTRIBUTE_EDGING
Definition: DrawCommand.cpp:70
#define DEBUGCANVAS_ATTRIBUTE_SWEEPANGLE
#define DEBUGCANVAS_VERB_QUAD
#define DEBUGCANVAS_FILLTYPE_INVERSEWINDING
static void apply_paint_maskfilter(const SkPaint &paint, SkJSONWriter &writer, UrlDataManager &urlDataManager)
#define DEBUGCANVAS_CLIPOP_INTERSECT
#define DEBUGCANVAS_ATTRIBUTE_HINTING
Definition: DrawCommand.cpp:71
#define DEBUGCANVAS_FILLTYPE_INVERSEEVENODD
#define DEBUGCANVAS_ATTRIBUTE_LATTICE
static const char * pointmode_name(SkCanvas::PointMode mode)
#define DEBUGCANVAS_ATTRIBUTE_EMBEDDEDBITMAPTEXT
Definition: DrawCommand.cpp:97
#define DEBUGCANVAS_ATTRIBUTE_NAME
#define DEBUGCANVAS_ATTRIBUTE_LIGHTRADIUS
#define DEBUGCANVAS_ATTRIBUTE_DST
#define DEBUGCANVAS_VERB_CONIC
#define DEBUGCANVAS_COLORTYPE_ARGB4444
#define DEBUGCANVAS_ATTRIBUTE_DUMP
Definition: DrawCommand.cpp:64
#define DEBUGCANVAS_ATTRIBUTE_POSITIONS
#define DEBUGCANVAS_ATTRIBUTE_HEIGHT
#define DEBUGCANVAS_ATTRIBUTE_ZPLANE
#define DEBUGCANVAS_ATTRIBUTE_MASKFILTER
#define DEBUGCANVAS_ATTRIBUTE_STRICT
#define DEBUGCANVAS_STYLE_STROKEANDFILL
#define DEBUGCANVAS_ATTRIBUTE_INNER
Definition: DrawCommand.cpp:75
#define DEBUGCANVAS_ATTRIBUTE_OUTER
Definition: DrawCommand.cpp:74
#define DEBUGCANVAS_ATTRIBUTE_COMMAND
Definition: DrawCommand.cpp:65
#define DEBUGCANVAS_HINTING_FULL
#define DEBUGCANVAS_ATTRIBUTE_REGIONOP
#define DEBUGCANVAS_ALPHATYPE_UNPREMUL
#define DEBUGCANVAS_ATTRIBUTE_PAINT
Definition: DrawCommand.cpp:73
#define DEBUGCANVAS_ATTRIBUTE_COLOR
Definition: DrawCommand.cpp:81
#define DEBUGCANVAS_ATTRIBUTE_LATTICEXDIVS
#define DEBUGCANVAS_ALPHATYPE_UNKNOWN
#define DEBUGCANVAS_ATTRIBUTE_TEXTSCALEX
#define DEBUGCANVAS_BLURSTYLE_INNER
#define DEBUGCANVAS_ATTRIBUTE_LATTICEYDIVS
static void MakeJsonFont(const SkFont &font, SkJSONWriter &writer, UrlDataManager &urlDataManager)
#define DEBUGCANVAS_BLURSTYLE_OUTER
#define DEBUGCANVAS_VERB_MOVE
#define DEBUGCANVAS_ATTRIBUTE_UNIQUE_ID
#define DEBUGCANVAS_POINTMODE_POLYGON
#define DEBUGCANVAS_ALPHATYPE_PREMUL
#define DEBUGCANVAS_ATTRIBUTE_BACKDROP
#define DEBUGCANVAS_ATTRIBUTE_PATH
Definition: DrawCommand.cpp:78
#define DEBUGCANVAS_VERB_CLOSE
static void apply_font_hinting(const SkFont &font, SkJSONWriter &writer)
#define DEBUGCANVAS_ATTRIBUTE_SAMPLING
Definition: DrawCommand.cpp:84
#define DEBUGCANVAS_ATTRIBUTE_ANTIALIAS
Definition: DrawCommand.cpp:90
static SkString encode_data(const void *bytes, size_t count, const char *contentType, UrlDataManager &urlDataManager)
static void apply_paint_join(const SkPaint &paint, SkJSONWriter &writer)
static void store_scalar(SkJSONWriter &writer, const char *key, SkScalar value, SkScalar defaultValue)
#define DEBUGCANVAS_ATTRIBUTE_IMAGE
#define DEBUGCANVAS_CLIPOP_DIFFERENCE
#define DEBUGCANVAS_ATTRIBUTE_X
#define DEBUGCANVAS_MITER_JOIN
static SkString * str_append(SkString *str, const SkRect &r)
#define DEBUGCANVAS_ATTRIBUTE_SPOTCOLOR
#define DEBUGCANVAS_ATTRIBUTE_TEXT
Definition: DrawCommand.cpp:80
#define DEBUGCANVAS_BLURSTYLE_NORMAL
#define DEBUGCANVAS_SHADOWFLAG_GEOMETRIC_ONLY
#define DEBUGCANVAS_ATTRIBUTE_LATTICEYCOUNT
#define DEBUGCANVAS_ATTRIBUTE_COLORFILTER
#define DEBUGCANVAS_ATTRIBUTE_POINTS
Definition: DrawCommand.cpp:77
#define DEBUGCANVAS_ATTRIBUTE_STROKEMITER
Definition: DrawCommand.cpp:87
#define DEBUGCANVAS_ATTRIBUTE_GLYPHS
#define DEBUGCANVAS_BEVEL_JOIN
#define DEBUGCANVAS_ATTRIBUTE_PHASE
#define DEBUGCANVAS_ATTRIBUTE_TEXTSIZE
#define DEBUGCANVAS_FILLTYPE_WINDING
static const char * alpha_type_name(SkAlphaType alphaType)
#define DEBUGCANVAS_ATTRIBUTE_REGION
Definition: DrawCommand.cpp:99
#define DEBUGCANVAS_ATTRIBUTE_Y
#define DEBUGCANVAS_HINTING_NONE
#define DEBUGCANVAS_ROUND_JOIN
#define DEBUGCANVAS_ATTRIBUTE_LATTICEXCOUNT
static void apply_paint_style(const SkPaint &paint, SkJSONWriter &writer)
#define DEBUGCANVAS_ATTRIBUTE_VERBS
#define DEBUGCANVAS_ATTRIBUTE_STROKEWIDTH
Definition: DrawCommand.cpp:86
#define DEBUGCANVAS_ATTRIBUTE_VISIBLE
Definition: DrawCommand.cpp:66
#define DEBUGCANVAS_COLORTYPE_ALPHA8
static void apply_paint_cap(const SkPaint &paint, SkJSONWriter &writer)
#define DEBUGCANVAS_ATTRIBUTE_COLORS
#define DEBUGCANVAS_ATTRIBUTE_TYPEFACE
#define DEBUGCANVAS_ATTRIBUTE_STROKEJOIN
Definition: DrawCommand.cpp:88
#define DEBUGCANVAS_ATTRIBUTE_FILLTYPE
#define DEBUGCANVAS_ATTRIBUTE_DITHER
Definition: DrawCommand.cpp:91
#define DEBUGCANVAS_ATTRIBUTE_USECENTER
#define DEBUGCANVAS_ATTRIBUTE_COORDS
Definition: DrawCommand.cpp:69
#define DEBUGCANVAS_ATTRIBUTE_MODE
Definition: DrawCommand.cpp:76
#define DEBUGCANVAS_ATTRIBUTE_INTERVALS
#define DEBUGCANVAS_HINTING_SLIGHT
#define DEBUGCANVAS_ATTRIBUTE_RUNS
#define DEBUGCANVAS_EDGING_SUBPIXELANTIALIAS
static void apply_flattenable(const char *key, SkFlattenable *flattenable, SkJSONWriter &writer, UrlDataManager &urlDataManager)
#define DEBUGCANVAS_ATTRIBUTE_STYLE
Definition: DrawCommand.cpp:85
#define DEBUGCANVAS_EDGING_ALIAS
#define DEBUGCANVAS_COLORTYPE_BGRA8888
#define DEBUGCANVAS_ATTRIBUTE_AMBIENTCOLOR
#define DEBUGCANVAS_CAP_ROUND
static void apply_paint_color(const SkPaint &paint, SkJSONWriter &writer)
#define DEBUGCANVAS_VERB_LINE
#define DEBUGCANVAS_ATTRIBUTE_LINEARTEXT
Definition: DrawCommand.cpp:93
SkMatrix fMatrix
Definition: FillRRectOp.cpp:74
SkRect fRect
Definition: FillRRectOp.cpp:73
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
int count
Definition: FontMgrTest.cpp:50
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
SkRect fDst
Definition: LatticeOp.cpp:381
SkBlendMode fBlendMode
Definition: Layer.cpp:55
#define SkPaintDefaults_TextSize
#define SkPaintDefaults_Hinting
#define SkPaintDefaults_MiterLimit
const SkRect fBounds
kUnpremul_SkAlphaType
SkAlphaType
Definition: SkAlphaType.h:26
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
#define SkASSERT(cond)
Definition: SkAssert.h:116
SK_API const char * SkBlendMode_Name(SkBlendMode blendMode)
SkBlendMode
Definition: SkBlendMode.h:38
@ kSrcOver
r = s + (1-sa)*d
@ kOuter_SkBlurStyle
nothing inside, fuzzy outside
Definition: SkBlurTypes.h:14
@ kSolid_SkBlurStyle
solid inside, fuzzy outside
Definition: SkBlurTypes.h:13
@ kInner_SkBlurStyle
fuzzy inside, nothing outside
Definition: SkBlurTypes.h:15
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition: SkBlurTypes.h:12
SkClipOp
Definition: SkClipOp.h:13
SkColorType
Definition: SkColorType.h:19
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition: SkColorType.h:23
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition: SkColorType.h:26
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition: SkColorType.h:21
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition: SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition: SkColorType.h:22
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
#define SkColorGetR(color)
Definition: SkColor.h:65
#define SkColorGetG(color)
Definition: SkColor.h:69
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
#define SkColorGetA(color)
Definition: SkColor.h:61
#define SkColorGetB(color)
Definition: SkColor.h:73
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SkFontHinting
Definition: SkFontTypes.h:18
@ kNormal
glyph outlines modified to improve constrast
@ kNone
glyph outlines unchanged
@ kSlight
minimal modification to improve constrast
@ kFull
modifies glyph outlines for maximum constrast
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67
SkMaskFilterBase * as_MFB(SkMaskFilter *mf)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
static bool left(const SkPoint &p0, const SkPoint &p1)
static T * SkSafeRef(T *obj)
Definition: SkRefCnt.h:140
static T * SkRef(T *obj)
Definition: SkRefCnt.h:132
SkFilterMode
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkDoubleToScalar(x)
Definition: SkScalar.h:64
#define SkIntToScalar(x)
Definition: SkScalar.h:57
@ kGeometricOnly_ShadowFlag
Definition: SkShadowUtils.h:29
@ kTransparentOccluder_ShadowFlag
Definition: SkShadowUtils.h:27
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
GLenum type
bool render(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
BeginDrawPictureCommand(const SkPicture *picture, const SkMatrix *matrix, const SkPaint *paint)
void execute(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
ClearCommand(SkColor color)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void execute(SkCanvas *canvas) const override
ClipPathCommand(const SkPath &path, SkClipOp op, bool doAA)
bool render(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
ClipRRectCommand(const SkRRect &rrect, SkClipOp op, bool doAA)
void execute(SkCanvas *canvas) const override
bool render(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void execute(SkCanvas *canvas) const override
ClipRectCommand(const SkRect &rect, SkClipOp op, bool doAA)
void execute(SkCanvas *canvas) const override
ClipRegionCommand(const SkRegion &region, SkClipOp op)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
ClipShaderCommand(sk_sp< SkShader >, SkClipOp)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
bool render(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
Concat44Command(const SkM44 &matrix)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
ConcatCommand(const SkMatrix &matrix)
void execute(SkCanvas *canvas) const override
sk_sp< SkImage > getLayerAsImage(const int nodeId, const int frame)
void execute(SkCanvas *canvas) const override
DrawAnnotationCommand(const SkRect &, const char key[], sk_sp< SkData > value)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
DrawArcCommand(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
void execute(SkCanvas *canvas) const override
bool render(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
DrawAtlasCommand(const SkImage *, const SkRSXform[], const SkRect[], const SkColor[], int, SkBlendMode, const SkSamplingOptions &, const SkRect *, const SkPaint *)
bool render(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
DrawBehindCommand(const SkPaint &paint)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
static void MakeJsonMatrix44(SkJSONWriter &, const SkM44 &)
static void MakeJsonPoint3(SkJSONWriter &, const SkPoint3 &point)
static void MakeJsonPoint(SkJSONWriter &, const SkPoint &point)
static void MakeJsonColor(SkJSONWriter &, const SkColor color)
@ kDrawBitmapRect_OpType
Definition: DrawCommand.h:68
@ kDrawTextBlob_OpType
Definition: DrawCommand.h:84
@ kDrawPoints_OpType
Definition: DrawCommand.h:79
@ kDrawImageLattice_OpType
Definition: DrawCommand.h:71
@ kSaveLayer_OpType
Definition: DrawCommand.h:93
@ kDrawEdgeAAImageSet_OpType
Definition: DrawCommand.h:89
@ kDrawPath_OpType
Definition: DrawCommand.h:78
@ kDrawEdgeAAQuad_OpType
Definition: DrawCommand.h:88
@ kClipPath_OpType
Definition: DrawCommand.h:58
@ kDrawPaint_OpType
Definition: DrawCommand.h:76
@ kClipRegion_OpType
Definition: DrawCommand.h:59
@ kClipRRect_OpType
Definition: DrawCommand.h:61
@ kDrawImageRectLayer_OpType
Definition: DrawCommand.h:73
@ kDrawAnnotation_OpType
Definition: DrawCommand.h:66
@ kDrawRect_OpType
Definition: DrawCommand.h:80
@ kDrawRRect_OpType
Definition: DrawCommand.h:81
@ kDrawVertices_OpType
Definition: DrawCommand.h:85
@ kEndDrawPicture_OpType
Definition: DrawCommand.h:90
@ kSetMatrix_OpType
Definition: DrawCommand.h:94
@ kDrawOval_OpType
Definition: DrawCommand.h:74
@ kBeginDrawPicture_OpType
Definition: DrawCommand.h:56
@ kDrawImage_OpType
Definition: DrawCommand.h:70
@ kDrawImageRect_OpType
Definition: DrawCommand.h:72
@ kDrawPatch_OpType
Definition: DrawCommand.h:77
@ kResetClip_OpType
Definition: DrawCommand.h:63
@ kDrawBitmap_OpType
Definition: DrawCommand.h:67
@ kDrawAtlas_OpType
Definition: DrawCommand.h:86
@ kConcat44_OpType
Definition: DrawCommand.h:65
@ kDrawDRRect_OpType
Definition: DrawCommand.h:69
@ kDrawShadow_OpType
Definition: DrawCommand.h:83
@ kDrawDrawable_OpType
Definition: DrawCommand.h:87
@ kClipRect_OpType
Definition: DrawCommand.h:60
@ kDrawRegion_OpType
Definition: DrawCommand.h:82
DrawCommand(OpType opType)
static void MakeJsonPaint(SkJSONWriter &, const SkPaint &paint, UrlDataManager &urlDataManager)
virtual void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const
static void MakeJsonRect(SkJSONWriter &, const SkRect &rect)
static void flatten(const SkFlattenable *flattenable, SkJSONWriter &writer, UrlDataManager &urlDataManager)
static void MakeJsonSampling(SkJSONWriter &, const SkSamplingOptions &sampling)
static const char * GetCommandString(OpType type)
static void MakeJsonMatrix(SkJSONWriter &, const SkMatrix &)
static void MakeJsonIRect(SkJSONWriter &, const SkIRect &)
static void MakeJsonRegion(SkJSONWriter &, const SkRegion &region)
static void MakeJsonLattice(SkJSONWriter &, const SkCanvas::Lattice &lattice)
static void MakeJsonColor4f(SkJSONWriter &, const SkColor4f &color)
static void MakeJsonPath(SkJSONWriter &, const SkPath &path)
static void WritePNG(const SkBitmap &bitmap, SkWStream &out)
bool isVisible() const
Definition: DrawCommand.h:108
DrawDRRectCommand(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
void execute(SkCanvas *canvas) const override
bool render(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
DrawDrawableCommand(SkDrawable *, const SkMatrix *)
void execute(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
DrawEdgeAAImageSetCommand(const SkCanvas::ImageSetEntry[], int count, const SkPoint[], const SkMatrix[], const SkSamplingOptions &, const SkPaint *, SkCanvas::SrcRectConstraint)
DrawEdgeAAQuadCommand(const SkRect &rect, const SkPoint clip[4], SkCanvas::QuadAAFlags aa, const SkColor4f &color, SkBlendMode mode)
void execute(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
bool render(SkCanvas *canvas) const override
uint64_t imageId(UrlDataManager &udb) const
DrawImageCommand(const SkImage *image, SkScalar left, SkScalar top, const SkSamplingOptions &, const SkPaint *paint)
uint64_t imageId(UrlDataManager &udb) const
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
DrawImageLatticeCommand(const SkImage *image, const SkCanvas::Lattice &lattice, const SkRect &dst, SkFilterMode, const SkPaint *paint)
bool render(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
bool render(SkCanvas *canvas) const override
DrawImageRectCommand(const SkImage *image, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint, SkCanvas::SrcRectConstraint constraint)
uint64_t imageId(UrlDataManager &udm) const
void execute(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
bool render(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
DrawImageRectLayerCommand(DebugLayerManager *layerManager, const int nodeId, const int frame, const SkRect &src, const SkRect &dst, const SkSamplingOptions &sampling, const SkPaint *paint, SkCanvas::SrcRectConstraint constraint)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void execute(SkCanvas *canvas) const override
DrawOvalCommand(const SkRect &oval, const SkPaint &paint)
bool render(SkCanvas *canvas) const override
DrawPaintCommand(const SkPaint &paint)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
bool render(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
DrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode bmode, const SkPaint &paint)
void execute(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
bool render(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
DrawPathCommand(const SkPath &path, const SkPaint &paint)
bool render(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void execute(SkCanvas *canvas) const override
DrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
bool render(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
DrawRRectCommand(const SkRRect &rrect, const SkPaint &paint)
void execute(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
DrawRectCommand(const SkRect &rect, const SkPaint &paint)
bool render(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
DrawRegionCommand(const SkRegion &region, const SkPaint &paint)
bool render(SkCanvas *canvas) const override
DrawShadowCommand(const SkPath &path, const SkDrawShadowRec &rec)
void execute(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void execute(SkCanvas *canvas) const override
DrawTextBlobCommand(sk_sp< SkTextBlob > blob, SkScalar x, SkScalar y, const SkPaint &paint)
bool render(SkCanvas *canvas) const override
DrawVerticesCommand(sk_sp< SkVertices >, SkBlendMode, const SkPaint &)
void execute(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
EndDrawPictureCommand(bool restore)
void execute(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
void execute(SkCanvas *canvas) const override
SaveLayerCommand(const SkCanvas::SaveLayerRec &)
void execute(SkCanvas *canvas) const override
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void execute(SkCanvas *canvas) const override
SetM44Command(const SkM44 &matrix)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
SetMatrixCommand(const SkMatrix &matrix)
void toJSON(SkJSONWriter &writer, UrlDataManager &urlDataManager) const override
void execute(SkCanvas *canvas) const override
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
Definition: SkBitmap.cpp:323
static SkCanvas::SaveLayerRec ScaledBackdropLayer(const SkRect *bounds, const SkPaint *paint, const SkImageFilter *backdrop, SkScalar backdropScale, SkCanvas::SaveLayerFlags saveLayerFlags, SkCanvas::FilterSpan filters={})
Definition: SkCanvasPriv.h:75
static void ResetClip(SkCanvas *canvas)
Definition: SkCanvasPriv.h:61
static void DrawBehind(SkCanvas *canvas, const SkPaint &paint)
Definition: SkCanvasPriv.h:56
static void GetDstClipAndMatrixCounts(const SkCanvas::ImageSetEntry set[], int count, int *totalDstClipCount, int *totalMatrixCount)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint &paint)
Definition: SkCanvas.cpp:1710
void drawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode mode, const SkPaint &paint)
Definition: SkCanvas.cpp:2529
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
void private_draw_shadow_rec(const SkPath &, const SkDrawShadowRec &)
Definition: SkCanvas.cpp:1831
void drawDrawable(SkDrawable *drawable, const SkMatrix *matrix=nullptr)
Definition: SkCanvas.cpp:2574
void drawAnnotation(const SkRect &rect, const char key[], SkData *value)
Definition: SkCanvas.cpp:1824
virtual SkISize getBaseLayerSize() const
Definition: SkCanvas.cpp:369
SrcRectConstraint
Definition: SkCanvas.h:1541
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
Definition: SkCanvas.h:1542
void clipRegion(const SkRegion &deviceRgn, SkClipOp op=SkClipOp::kIntersect)
Definition: SkCanvas.cpp:1510
void experimental_DrawEdgeAAQuad(const SkRect &rect, const SkPoint clip[4], QuadAAFlags aaFlags, const SkColor4f &color, SkBlendMode mode)
Definition: SkCanvas.cpp:1845
void clear(SkColor color)
Definition: SkCanvas.h:1199
void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt, const SkPoint dstClips[], const SkMatrix preViewMatrices[], const SkSamplingOptions &, const SkPaint *paint=nullptr, SrcRectConstraint constraint=kStrict_SrcRectConstraint)
Definition: SkCanvas.cpp:1853
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705
void drawArc(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter, const SkPaint &paint)
Definition: SkCanvas.cpp:2728
void drawImageLattice(const SkImage *image, const Lattice &lattice, const SkRect &dst, SkFilterMode filter, const SkPaint *paint=nullptr)
Definition: SkCanvas.cpp:1786
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1456
void drawRegion(const SkRegion &region, const SkPaint &paint)
Definition: SkCanvas.cpp:1685
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void drawAtlas(const SkImage *atlas, const SkRSXform xform[], const SkRect tex[], const SkColor colors[], int count, SkBlendMode mode, const SkSamplingOptions &sampling, const SkRect *cullRect, const SkPaint *paint)
Definition: SkCanvas.cpp:1810
void setMatrix(const SkM44 &matrix)
Definition: SkCanvas.cpp:1349
void drawDRRect(const SkRRect &outer, const SkRRect &inner, const SkPaint &paint)
Definition: SkCanvas.cpp:1645
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
void drawPicture(const SkPicture *picture)
Definition: SkCanvas.h:1961
void clipShader(sk_sp< SkShader >, SkClipOp=SkClipOp::kIntersect)
Definition: SkCanvas.cpp:1488
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
Definition: SkCanvas.cpp:1720
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1242
@ kPolygon_PointMode
draw the array of points as a open polygon
Definition: SkCanvas.h:1243
@ kPoints_PointMode
draw each point separately
Definition: SkCanvas.h:1241
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1439
const void * data() const
Definition: SkData.h:37
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Definition: SkData.cpp:111
size_t size() const
Definition: SkData.h:30
sk_sp< SkData > detachAsData()
Definition: SkStream.cpp:707
virtual void flatten(SkWriteBuffer &) const
Definition: SkFlattenable.h:67
virtual const char * getTypeName() const =0
Definition: SkFont.h:35
@ kAntiAlias
may have transparent pixels on glyph edges
@ kAlias
no transparent pixels on glyph edges
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
uint32_t uniqueID() const
Definition: SkImage.h:311
SkAlphaType alphaType() const
Definition: SkImage.cpp:154
int width() const
Definition: SkImage.h:285
int height() const
Definition: SkImage.h:291
void appendS32(int32_t value)
Definition: SkJSONWriter.h:237
void appendNString(char const (&value)[N])
Definition: SkJSONWriter.h:220
void beginArray(const char *name=nullptr, bool multiline=true)
Definition: SkJSONWriter.h:146
void appendU32(uint32_t value)
Definition: SkJSONWriter.h:239
void beginObject(const char *name=nullptr, bool multiline=true)
Definition: SkJSONWriter.h:114
void appendU64(uint64_t value)
void appendFloat(float value)
Definition: SkJSONWriter.h:241
void appendS64(int64_t value)
void endObject()
Definition: SkJSONWriter.h:126
void appendBool(bool value)
Definition: SkJSONWriter.h:229
void appendName(const char *name)
Definition: SkJSONWriter.h:90
void appendCString(const char *value)
Definition: SkJSONWriter.h:224
void endArray()
Definition: SkJSONWriter.h:158
void appendString(const char *value, size_t size)
Definition: SkJSONWriter.h:176
Definition: SkM44.h:150
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkMatrix.cpp:1141
@ kPerspective_Mask
perspective SkMatrix
Definition: SkMatrix.h:196
@ kTranslate_Mask
translation SkMatrix
Definition: SkMatrix.h:193
@ kScale_Mask
scale SkMatrix
Definition: SkMatrix.h:194
@ kAffine_Mask
skew or rotate SkMatrix
Definition: SkMatrix.h:195
@ kDefault_Cap
equivalent to kButt_Cap
Definition: SkPaint.h:338
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
@ kSquare_Cap
adds square
Definition: SkPaint.h:336
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition: SkPaint.h:195
@ kDefault_Join
equivalent to kMiter_Join
Definition: SkPaint.h:363
@ kRound_Join
adds circle
Definition: SkPaint.h:360
@ kMiter_Join
extends to miter limit
Definition: SkPaint.h:359
@ kBevel_Join
connects outside edges
Definition: SkPaint.h:361
DashType asADash(DashInfo *info) const
@ kDash_DashType
fills in all of the info parameter
Definition: SkPathEffect.h:62
Verb next(SkPoint pts[4])
Definition: SkPath.cpp:1901
SkScalar conicWeight() const
Definition: SkPath.h:1535
Definition: SkPath.h:59
@ kClose_Verb
Definition: SkPath.h:1471
@ kMove_Verb
Definition: SkPath.h:1466
@ kConic_Verb
Definition: SkPath.h:1469
@ kDone_Verb
Definition: SkPath.h:1472
@ kCubic_Verb
Definition: SkPath.h:1470
@ kQuad_Verb
Definition: SkPath.h:1468
@ kLine_Verb
Definition: SkPath.h:1467
virtual SkRect cullRect() const =0
const SkRect & rect() const
Definition: SkRRect.h:264
SkVector radii(Corner corner) const
Definition: SkRRect.h:271
@ kUpperLeft_Corner
index of top-left corner radii
Definition: SkRRect.h:252
@ kLowerRight_Corner
index of bottom-right corner radii
Definition: SkRRect.h:254
@ kUpperRight_Corner
index of top-right corner radii
Definition: SkRRect.h:253
@ kLowerLeft_Corner
index of bottom-left corner radii
Definition: SkRRect.h:255
const SkRect & getBounds() const
Definition: SkRRect.h:279
static void GrowToInclude(SkRect *r, const SkPoint &pt)
Definition: SkRectPriv.h:47
bool getBoundaryPath(SkPath *path) const
const SkIRect & getBounds() const
Definition: SkRegion.h:165
const char * c_str() const
Definition: SkString.h:133
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:550
int size() const
Definition: SkTDArray.h:138
bool empty() const
Definition: SkTDArray.h:135
T * begin()
Definition: SkTDArray.h:150
T * get()
Definition: SkTLazy.h:83
bool isValid() const
Definition: SkTLazy.h:77
const T * getMaybeNull() const
Definition: SkTLazy.h:108
uint32_t * clusters() const
GlyphPositioning positioning() const
Definition: SkTextBlob.cpp:236
const SkPoint & offset() const
const SkScalar * pos() const
const uint16_t * glyphs() const
uint32_t glyphCount() const
uint32_t textSize() const
const SkFont & font() const
const SkRect & bounds() const
Definition: SkTextBlob.h:53
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
Definition: SkTypeface.cpp:202
bool hasImageIndex()
SkString addData(SkData *, const char *contentType)
int lookupImage(const SkImage *)
T * get() const
Definition: SkRefCnt.h:303
void reset(size_t count=0)
Definition: SkTemplates.h:123
const Paint & paint
Definition: color_source.cc:38
DlColor color
double frame
Definition: examples.cpp:31
float SkScalar
Definition: extension.cpp:12
uint8_t value
double y
double x
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
int flagCount
Definition: SkRecords.h:274
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Optional< SkRect > bounds
Definition: SkRecords.h:189
PODArray< SkPoint > dstClips
Definition: SkRecords.h:364
sk_sp< const SkImage > image
Definition: SkRecords.h:269
ClipOpAndAA opAA SkRegion region
Definition: SkRecords.h:238
sk_sp< const SkPicture > picture
Definition: SkRecords.h:299
SkRRect rrect
Definition: SkRecords.h:232
SkRect oval
Definition: SkRecords.h:249
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
PODArray< SkMatrix > preViewMatrices
Definition: SkRecords.h:365
SkScalar startAngle
Definition: SkRecords.h:250
SkScalar sweepAngle
Definition: SkRecords.h:251
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkSamplingOptions sampling
Definition: SkRecords.h:337
Definition: bitmap.py:1
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
Definition: switches.h:57
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 which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
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 mode
Definition: switches.h:228
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
Definition: switches.h:259
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 which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76
font
Font Metadata and Metrics.
dst
Definition: cp.py:12
Definition: ref_ptr.h:256
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741
int fYCount
number of y-coordinates
Definition: SkCanvas.h:1617
const SkIRect * fBounds
source bounds to draw from
Definition: SkCanvas.h:1618
const int * fYDivs
y-axis values dividing bitmap
Definition: SkCanvas.h:1614
int fXCount
number of x-coordinates
Definition: SkCanvas.h:1616
const RectType * fRectTypes
array of fill types
Definition: SkCanvas.h:1615
const int * fXDivs
x-axis values dividing bitmap
Definition: SkCanvas.h:1613
SkPoint3 fZPlaneParams
Definition: SkRect.h:32
Definition: SkSize.h:16
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
SkScalar fPhase
Offset into the dashed interval pattern.
Definition: SkPathEffect.h:73
int32_t fCount
Number of intervals in the dash. Should be even number.
Definition: SkPathEffect.h:72
SkScalar * fIntervals
Length of on/off intervals for dashed lines.
Definition: SkPathEffect.h:70
SkScalar x() const
Definition: SkPoint3.h:24
SkScalar y() const
Definition: SkPoint3.h:25
SkScalar z() const
Definition: SkPoint3.h:26
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
constexpr float left() const
Definition: SkRect.h:734
constexpr SkRect makeOffset(float dx, float dy) const
Definition: SkRect.h:965
constexpr float top() const
Definition: SkRect.h:741
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659
constexpr float right() const
Definition: SkRect.h:748
constexpr float bottom() const
Definition: SkRect.h:755
const SkCubicResampler cubic
const SkFilterMode filter
const SkMipmapMode mipmap
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
SkBlendMode fMode
Definition: xfermodes.cpp:52