2012-06-29 14:21:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/debugger/DrawCommand.h"
|
2016-02-17 19:20:26 +00:00
|
|
|
|
2018-10-12 15:42:02 +00:00
|
|
|
#include <algorithm>
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkColorFilter.h"
|
|
|
|
#include "include/core/SkDrawable.h"
|
|
|
|
#include "include/core/SkImageFilter.h"
|
|
|
|
#include "include/core/SkPathEffect.h"
|
|
|
|
#include "include/core/SkPicture.h"
|
|
|
|
#include "include/core/SkTypeface.h"
|
|
|
|
#include "include/effects/SkDashPathEffect.h"
|
|
|
|
#include "include/encode/SkPngEncoder.h"
|
|
|
|
#include "include/private/SkShadowFlags.h"
|
|
|
|
#include "include/private/SkTHash.h"
|
|
|
|
#include "src/core/SkAutoMalloc.h"
|
|
|
|
#include "src/core/SkCanvasPriv.h"
|
|
|
|
#include "src/core/SkClipOpPriv.h"
|
|
|
|
#include "src/core/SkLatticeIter.h"
|
|
|
|
#include "src/core/SkMaskFilterBase.h"
|
|
|
|
#include "src/core/SkPaintDefaults.h"
|
|
|
|
#include "src/core/SkReadBuffer.h"
|
|
|
|
#include "src/core/SkRectPriv.h"
|
|
|
|
#include "src/core/SkTextBlobPriv.h"
|
|
|
|
#include "src/core/SkWriteBuffer.h"
|
2019-12-12 16:05:10 +00:00
|
|
|
#include "tools/debugger/DebugLayerManager.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/debugger/JsonWriteBuffer.h"
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_COMMAND "command"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_VISIBLE "visible"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS "drawDepthTranslation"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_COORDS "coords"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_EDGING "edging"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_HINTING "hinting"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_PAINT "paint"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_OUTER "outer"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_INNER "inner"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_MODE "mode"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_POINTS "points"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_PATH "path"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_TEXT "text"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_COLOR "color"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_ALPHA "alpha"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_BLENDMODE "blendMode"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_STYLE "style"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_STROKEWIDTH "strokeWidth"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_STROKEMITER "strokeMiter"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_STROKEJOIN "strokeJoin"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_CAP "cap"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_ANTIALIAS "antiAlias"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_DITHER "dither"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_FAKEBOLDTEXT "fakeBoldText"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LINEARTEXT "linearText"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_SUBPIXELTEXT "subpixelText"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_DEVKERNTEXT "devKernText"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LCDRENDERTEXT "lcdRenderText"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_EMBEDDEDBITMAPTEXT "embeddedBitmapText"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_AUTOHINTING "forceAutoHinting"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_REGION "region"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_REGIONOP "op"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_EDGESTYLE "edgeStyle"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_DEVICEREGION "deviceRegion"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_BLUR "blur"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_SIGMA "sigma"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_QUALITY "quality"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_DASHING "dashing"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_PHASE "phase"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_VERBS "verbs"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_NAME "name"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_DATA "data"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_VALUES "values"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_SHADER "shader"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_IMAGE "image"
|
2020-01-03 15:29:13 +00:00
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_IMAGE_INDEX "imageIndex"
|
2019-03-20 18:02:32 +00:00
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_SRC "src"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_DST "dst"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_CENTER "center"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_STRICT "strict"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_DESCRIPTION "description"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_X "x"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_Y "y"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_RUNS "runs"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_POSITIONS "positions"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_FONT "font"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_CUBICS "cubics"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_COLORS "colors"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_STARTANGLE "startAngle"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_SWEEPANGLE "sweepAngle"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_USECENTER "useCenter"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_SHORTDESC "shortDesc"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_UNIQUE_ID "uniqueID"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_WIDTH "width"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_HEIGHT "height"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_ALPHA "alpha"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LATTICE "lattice"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LATTICEXCOUNT "xCount"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LATTICEYCOUNT "yCount"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LATTICEXDIVS "xDivs"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LATTICEYDIVS "yDivs"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LATTICEFLAGS "flags"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_ZPLANE "zPlane"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LIGHTPOSITION "lightPositions"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_AMBIENTCOLOR "ambientColor"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_SPOTCOLOR "spotColor"
|
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LIGHTRADIUS "lightRadius"
|
2019-12-12 16:05:10 +00:00
|
|
|
#define DEBUGCANVAS_ATTRIBUTE_LAYERNODEID "layerNodeId"
|
2019-03-20 18:02:32 +00:00
|
|
|
|
|
|
|
#define DEBUGCANVAS_VERB_MOVE "move"
|
|
|
|
#define DEBUGCANVAS_VERB_LINE "line"
|
|
|
|
#define DEBUGCANVAS_VERB_QUAD "quad"
|
|
|
|
#define DEBUGCANVAS_VERB_CUBIC "cubic"
|
|
|
|
#define DEBUGCANVAS_VERB_CONIC "conic"
|
|
|
|
#define DEBUGCANVAS_VERB_CLOSE "close"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_STYLE_FILL "fill"
|
|
|
|
#define DEBUGCANVAS_STYLE_STROKE "stroke"
|
|
|
|
#define DEBUGCANVAS_STYLE_STROKEANDFILL "strokeAndFill"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_POINTMODE_POINTS "points"
|
|
|
|
#define DEBUGCANVAS_POINTMODE_LINES "lines"
|
|
|
|
#define DEBUGCANVAS_POINTMODE_POLYGON "polygon"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_REGIONOP_DIFFERENCE "difference"
|
|
|
|
#define DEBUGCANVAS_REGIONOP_INTERSECT "intersect"
|
|
|
|
#define DEBUGCANVAS_REGIONOP_UNION "union"
|
|
|
|
#define DEBUGCANVAS_REGIONOP_XOR "xor"
|
|
|
|
#define DEBUGCANVAS_REGIONOP_REVERSE_DIFFERENCE "reverseDifference"
|
|
|
|
#define DEBUGCANVAS_REGIONOP_REPLACE "replace"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_BLURSTYLE_NORMAL "normal"
|
|
|
|
#define DEBUGCANVAS_BLURSTYLE_SOLID "solid"
|
|
|
|
#define DEBUGCANVAS_BLURSTYLE_OUTER "outer"
|
|
|
|
#define DEBUGCANVAS_BLURSTYLE_INNER "inner"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_BLURQUALITY_LOW "low"
|
|
|
|
#define DEBUGCANVAS_BLURQUALITY_HIGH "high"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_FILLTYPE_WINDING "winding"
|
|
|
|
#define DEBUGCANVAS_FILLTYPE_EVENODD "evenOdd"
|
|
|
|
#define DEBUGCANVAS_FILLTYPE_INVERSEWINDING "inverseWinding"
|
|
|
|
#define DEBUGCANVAS_FILLTYPE_INVERSEEVENODD "inverseEvenOdd"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_CAP_BUTT "butt"
|
|
|
|
#define DEBUGCANVAS_CAP_ROUND "round"
|
|
|
|
#define DEBUGCANVAS_CAP_SQUARE "square"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_MITER_JOIN "miter"
|
|
|
|
#define DEBUGCANVAS_ROUND_JOIN "round"
|
|
|
|
#define DEBUGCANVAS_BEVEL_JOIN "bevel"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_COLORTYPE_ARGB4444 "ARGB4444"
|
|
|
|
#define DEBUGCANVAS_COLORTYPE_RGBA8888 "RGBA8888"
|
|
|
|
#define DEBUGCANVAS_COLORTYPE_BGRA8888 "BGRA8888"
|
|
|
|
#define DEBUGCANVAS_COLORTYPE_565 "565"
|
|
|
|
#define DEBUGCANVAS_COLORTYPE_GRAY8 "Gray8"
|
|
|
|
#define DEBUGCANVAS_COLORTYPE_INDEX8 "Index8"
|
|
|
|
#define DEBUGCANVAS_COLORTYPE_ALPHA8 "Alpha8"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_ALPHATYPE_OPAQUE "opaque"
|
|
|
|
#define DEBUGCANVAS_ALPHATYPE_PREMUL "premul"
|
|
|
|
#define DEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul"
|
|
|
|
#define DEBUGCANVAS_ALPHATYPE_UNKNOWN "unknown"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_FILTERQUALITY_NONE "none"
|
|
|
|
#define DEBUGCANVAS_FILTERQUALITY_LOW "low"
|
|
|
|
#define DEBUGCANVAS_FILTERQUALITY_MEDIUM "medium"
|
|
|
|
#define DEBUGCANVAS_FILTERQUALITY_HIGH "high"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_HINTING_NONE "none"
|
|
|
|
#define DEBUGCANVAS_HINTING_SLIGHT "slight"
|
|
|
|
#define DEBUGCANVAS_HINTING_NORMAL "normal"
|
|
|
|
#define DEBUGCANVAS_HINTING_FULL "full"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_EDGING_ALIAS "alias"
|
|
|
|
#define DEBUGCANVAS_EDGING_ANTIALIAS "antialias"
|
|
|
|
#define DEBUGCANVAS_EDGING_SUBPIXELANTIALIAS "subpixelantialias"
|
|
|
|
|
|
|
|
#define DEBUGCANVAS_SHADOWFLAG_TRANSPARENT_OCC "transparentOccluder"
|
|
|
|
#define DEBUGCANVAS_SHADOWFLAG_GEOMETRIC_ONLY "geometricOnly"
|
2018-04-12 16:45:58 +00:00
|
|
|
|
2016-06-29 18:36:34 +00:00
|
|
|
static SkString* str_append(SkString* str, const SkRect& r) {
|
|
|
|
str->appendf(" [%g %g %g %g]", r.left(), r.top(), r.right(), r.bottom());
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
DrawCommand::DrawCommand(OpType type) : fOpType(type), fVisible(true) {}
|
2013-05-29 13:24:23 +00:00
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
const char* DrawCommand::GetCommandString(OpType type) {
|
2012-06-29 14:21:22 +00:00
|
|
|
switch (type) {
|
2015-04-02 03:58:37 +00:00
|
|
|
case kBeginDrawPicture_OpType: return "BeginDrawPicture";
|
2018-03-12 14:57:28 +00:00
|
|
|
case kClear_OpType: return "DrawClear";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kClipPath_OpType: return "ClipPath";
|
|
|
|
case kClipRegion_OpType: return "ClipRegion";
|
|
|
|
case kClipRect_OpType: return "ClipRect";
|
|
|
|
case kClipRRect_OpType: return "ClipRRect";
|
|
|
|
case kConcat_OpType: return "Concat";
|
2016-06-29 17:28:11 +00:00
|
|
|
case kDrawAnnotation_OpType: return "DrawAnnotation";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kDrawBitmap_OpType: return "DrawBitmap";
|
2018-05-18 20:59:13 +00:00
|
|
|
case kDrawBitmapLattice_OpType: return "DrawBitmapLattice";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kDrawBitmapNine_OpType: return "DrawBitmapNine";
|
|
|
|
case kDrawBitmapRect_OpType: return "DrawBitmapRect";
|
|
|
|
case kDrawDRRect_OpType: return "DrawDRRect";
|
2015-07-22 17:23:01 +00:00
|
|
|
case kDrawImage_OpType: return "DrawImage";
|
2017-01-12 21:20:50 +00:00
|
|
|
case kDrawImageLattice_OpType: return "DrawImageLattice";
|
2018-03-12 14:57:28 +00:00
|
|
|
case kDrawImageNine_OpType: return "DrawImageNine";
|
2015-07-22 17:23:01 +00:00
|
|
|
case kDrawImageRect_OpType: return "DrawImageRect";
|
2019-12-12 16:05:10 +00:00
|
|
|
case kDrawImageRectLayer_OpType: return "DrawImageRectLayer";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kDrawOval_OpType: return "DrawOval";
|
|
|
|
case kDrawPaint_OpType: return "DrawPaint";
|
|
|
|
case kDrawPatch_OpType: return "DrawPatch";
|
|
|
|
case kDrawPath_OpType: return "DrawPath";
|
2018-03-12 14:57:28 +00:00
|
|
|
case kDrawArc_OpType: return "DrawArc";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kDrawPoints_OpType: return "DrawPoints";
|
|
|
|
case kDrawRect_OpType: return "DrawRect";
|
|
|
|
case kDrawRRect_OpType: return "DrawRRect";
|
2018-03-12 14:57:28 +00:00
|
|
|
case kDrawRegion_OpType: return "DrawRegion";
|
2018-04-12 16:45:58 +00:00
|
|
|
case kDrawShadow_OpType: return "DrawShadow";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kDrawTextBlob_OpType: return "DrawTextBlob";
|
|
|
|
case kDrawVertices_OpType: return "DrawVertices";
|
2018-05-29 15:23:35 +00:00
|
|
|
case kDrawAtlas_OpType: return "DrawAtlas";
|
2018-05-29 18:55:50 +00:00
|
|
|
case kDrawDrawable_OpType: return "DrawDrawable";
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
case kDrawEdgeAAQuad_OpType: return "DrawEdgeAAQuad";
|
|
|
|
case kDrawEdgeAAImageSet_OpType: return "DrawEdgeAAImageSet";
|
2015-04-02 03:58:37 +00:00
|
|
|
case kEndDrawPicture_OpType: return "EndDrawPicture";
|
2015-02-13 19:13:00 +00:00
|
|
|
case kRestore_OpType: return "Restore";
|
|
|
|
case kSave_OpType: return "Save";
|
|
|
|
case kSaveLayer_OpType: return "SaveLayer";
|
|
|
|
case kSetMatrix_OpType: return "SetMatrix";
|
2012-06-29 14:21:22 +00:00
|
|
|
default:
|
2015-02-13 19:13:00 +00:00
|
|
|
SkDebugf("OpType error 0x%08x\n", type);
|
2012-06-29 14:21:22 +00:00
|
|
|
SkASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
SkDEBUGFAIL("DrawType UNUSED\n");
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_COMMAND, this->GetCommandString(fOpType));
|
|
|
|
writer.appendBool(DEBUGCANVAS_ATTRIBUTE_VISIBLE, this->isVisible());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) {
|
2017-02-22 18:21:42 +00:00
|
|
|
const SkISize& size = canvas->getBaseLayerSize();
|
2013-06-06 23:59:28 +00:00
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
static const SkScalar kInsetFrac = 0.9f; // Leave a border around object
|
2013-06-06 23:59:28 +00:00
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
canvas->translate(size.fWidth / 2.0f, size.fHeight / 2.0f);
|
2013-06-06 23:59:28 +00:00
|
|
|
if (bounds.width() > bounds.height()) {
|
2019-03-20 16:59:00 +00:00
|
|
|
canvas->scale(SkDoubleToScalar((kInsetFrac * size.fWidth) / bounds.width()),
|
|
|
|
SkDoubleToScalar((kInsetFrac * size.fHeight) / bounds.width()));
|
2013-06-06 23:59:28 +00:00
|
|
|
} else {
|
2019-03-20 16:59:00 +00:00
|
|
|
canvas->scale(SkDoubleToScalar((kInsetFrac * size.fWidth) / bounds.height()),
|
|
|
|
SkDoubleToScalar((kInsetFrac * size.fHeight) / bounds.height()));
|
2013-06-06 23:59:28 +00:00
|
|
|
}
|
|
|
|
canvas->translate(-bounds.centerX(), -bounds.centerY());
|
|
|
|
}
|
2013-06-07 07:01:06 +00:00
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
void render_path(SkCanvas* canvas, const SkPath& path) {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
const SkRect& bounds = path.getBounds();
|
2015-10-06 14:24:03 +00:00
|
|
|
if (bounds.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-06-06 23:59:28 +00:00
|
|
|
|
2015-10-06 14:24:03 +00:00
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
2013-06-06 23:59:28 +00:00
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawPath(path, p);
|
|
|
|
}
|
|
|
|
|
2018-03-12 14:57:28 +00:00
|
|
|
void render_region(SkCanvas* canvas, const SkRegion& region) {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
const SkIRect& bounds = region.getBounds();
|
|
|
|
if (bounds.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
2018-03-13 14:19:27 +00:00
|
|
|
xlate_and_scale_to_bounds(canvas, SkRect::Make(bounds));
|
2018-03-12 14:57:28 +00:00
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawRegion(region, p);
|
|
|
|
}
|
|
|
|
|
2015-08-27 14:41:13 +00:00
|
|
|
void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRect = nullptr) {
|
2017-02-22 18:21:42 +00:00
|
|
|
const SkISize& size = canvas->getBaseLayerSize();
|
2013-06-06 23:59:28 +00:00
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
SkScalar xScale = SkIntToScalar(size.fWidth - 2) / input.width();
|
|
|
|
SkScalar yScale = SkIntToScalar(size.fHeight - 2) / input.height();
|
2013-06-06 23:59:28 +00:00
|
|
|
|
|
|
|
if (input.width() > input.height()) {
|
2019-03-20 16:59:00 +00:00
|
|
|
yScale *= input.height() / (float)input.width();
|
2013-06-06 23:59:28 +00:00
|
|
|
} else {
|
2019-03-20 16:59:00 +00:00
|
|
|
xScale *= input.width() / (float)input.height();
|
2013-06-06 23:59:28 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
SkRect dst = SkRect::MakeXYWH(
|
|
|
|
SK_Scalar1, SK_Scalar1, xScale * input.width(), yScale * input.height());
|
2013-06-07 07:01:06 +00:00
|
|
|
|
2015-09-24 13:56:27 +00:00
|
|
|
static const int kNumBlocks = 8;
|
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
2019-03-20 16:59:00 +00:00
|
|
|
SkISize block = {canvas->imageInfo().width() / kNumBlocks,
|
|
|
|
canvas->imageInfo().height() / kNumBlocks};
|
2015-09-24 13:56:27 +00:00
|
|
|
for (int y = 0; y < kNumBlocks; ++y) {
|
|
|
|
for (int x = 0; x < kNumBlocks; ++x) {
|
|
|
|
SkPaint paint;
|
2019-03-20 16:59:00 +00:00
|
|
|
paint.setColor((x + y) % 2 ? SK_ColorLTGRAY : SK_ColorDKGRAY);
|
|
|
|
SkRect r = SkRect::MakeXYWH(SkIntToScalar(x * block.width()),
|
|
|
|
SkIntToScalar(y * block.height()),
|
2015-09-24 13:56:27 +00:00
|
|
|
SkIntToScalar(block.width()),
|
|
|
|
SkIntToScalar(block.height()));
|
|
|
|
canvas->drawRect(r, paint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-06 17:02:53 +00:00
|
|
|
canvas->drawBitmapRect(input, dst, nullptr);
|
2013-06-06 23:59:28 +00:00
|
|
|
|
2014-09-05 20:34:00 +00:00
|
|
|
if (srcRect) {
|
2019-03-20 16:59:00 +00:00
|
|
|
SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1,
|
2013-06-06 23:59:28 +00:00
|
|
|
srcRect->fTop * yScale + SK_Scalar1,
|
|
|
|
srcRect->fRight * xScale + SK_Scalar1,
|
|
|
|
srcRect->fBottom * yScale + SK_Scalar1);
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorRED);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawRect(r, p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void render_rrect(SkCanvas* canvas, const SkRRect& rrect) {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
const SkRect& bounds = rrect.getBounds();
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawRRect(rrect, p);
|
|
|
|
canvas->restore();
|
|
|
|
}
|
2013-06-07 07:01:06 +00:00
|
|
|
|
2014-02-24 17:28:55 +00:00
|
|
|
void render_drrect(SkCanvas* canvas, const SkRRect& outer, const SkRRect& inner) {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
const SkRect& bounds = outer.getBounds();
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawDRRect(outer, inner, p);
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
2018-04-12 16:45:58 +00:00
|
|
|
void render_shadow(SkCanvas* canvas, const SkPath& path, SkDrawShadowRec rec) {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
const SkRect& bounds = path.getBounds();
|
|
|
|
if (bounds.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
rec.fAmbientColor = SK_ColorBLACK;
|
2019-03-20 16:59:00 +00:00
|
|
|
rec.fSpotColor = SK_ColorBLACK;
|
2018-04-12 16:45:58 +00:00
|
|
|
canvas->private_draw_shadow_rec(path, rec);
|
|
|
|
}
|
|
|
|
|
2017-06-06 20:58:40 +00:00
|
|
|
static const char* const gBlendModeMap[] = {
|
2019-03-20 16:59:00 +00:00
|
|
|
"clear", "src", "dst", "srcOver", "dstOver", "srcIn", "dstIn",
|
|
|
|
"srcOut", "dstOut", "srcATop", "dstATop", "xor", "plus", "modulate",
|
|
|
|
|
|
|
|
"screen",
|
|
|
|
|
|
|
|
"overlay", "darken", "lighten", "colorDodge", "colorBurn", "hardLight", "softLight",
|
|
|
|
"difference", "exclusion", "multiply",
|
|
|
|
|
|
|
|
"hue", "saturation", "color", "luminosity",
|
2017-06-06 20:58:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static_assert(SK_ARRAY_COUNT(gBlendModeMap) == static_cast<size_t>(SkBlendMode::kLastMode) + 1,
|
|
|
|
"blendMode mismatch");
|
|
|
|
static_assert(SK_ARRAY_COUNT(gBlendModeMap) == static_cast<size_t>(SkBlendMode::kLuminosity) + 1,
|
|
|
|
"blendMode mismatch");
|
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
void apply_paint_blend_mode(const SkPaint& paint, SkJSONWriter& writer) {
|
2017-06-06 20:58:40 +00:00
|
|
|
const auto mode = paint.getBlendMode();
|
|
|
|
if (mode != SkBlendMode::kSrcOver) {
|
|
|
|
SkASSERT(static_cast<size_t>(mode) < SK_ARRAY_COUNT(gBlendModeMap));
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_BLENDMODE,
|
2019-01-28 18:41:19 +00:00
|
|
|
gBlendModeMap[static_cast<size_t>(mode)]);
|
2017-06-06 20:58:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
}; // namespace
|
2013-06-06 23:59:28 +00:00
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonColor(SkJSONWriter& writer, const SkColor color) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginArray(nullptr, false);
|
|
|
|
writer.appendS32(SkColorGetA(color));
|
|
|
|
writer.appendS32(SkColorGetR(color));
|
|
|
|
writer.appendS32(SkColorGetG(color));
|
|
|
|
writer.appendS32(SkColorGetB(color));
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonColor4f(SkJSONWriter& writer, const SkColor4f& color) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginArray(nullptr, false);
|
|
|
|
writer.appendFloat(color.fA);
|
|
|
|
writer.appendFloat(color.fR);
|
|
|
|
writer.appendFloat(color.fG);
|
|
|
|
writer.appendFloat(color.fB);
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonPoint(SkJSONWriter& writer, const SkPoint& point) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginArray(nullptr, false);
|
|
|
|
writer.appendFloat(point.x());
|
|
|
|
writer.appendFloat(point.y());
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonPoint(SkJSONWriter& writer, SkScalar x, SkScalar y) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginArray(nullptr, false);
|
|
|
|
writer.appendFloat(x);
|
|
|
|
writer.appendFloat(y);
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonPoint3(SkJSONWriter& writer, const SkPoint3& point) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginArray(nullptr, false);
|
|
|
|
writer.appendFloat(point.x());
|
|
|
|
writer.appendFloat(point.y());
|
|
|
|
writer.appendFloat(point.z());
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonRect(SkJSONWriter& writer, const SkRect& rect) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginArray(nullptr, false);
|
|
|
|
writer.appendFloat(rect.left());
|
|
|
|
writer.appendFloat(rect.top());
|
|
|
|
writer.appendFloat(rect.right());
|
|
|
|
writer.appendFloat(rect.bottom());
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonIRect(SkJSONWriter& writer, const SkIRect& rect) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginArray(nullptr, false);
|
|
|
|
writer.appendS32(rect.left());
|
|
|
|
writer.appendS32(rect.top());
|
|
|
|
writer.appendS32(rect.right());
|
|
|
|
writer.appendS32(rect.bottom());
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void make_json_rrect(SkJSONWriter& writer, const SkRRect& rrect) {
|
|
|
|
writer.beginArray(nullptr, false);
|
2019-03-20 16:59:00 +00:00
|
|
|
DrawCommand::MakeJsonRect(writer, rrect.rect());
|
|
|
|
DrawCommand::MakeJsonPoint(writer, rrect.radii(SkRRect::kUpperLeft_Corner));
|
|
|
|
DrawCommand::MakeJsonPoint(writer, rrect.radii(SkRRect::kUpperRight_Corner));
|
|
|
|
DrawCommand::MakeJsonPoint(writer, rrect.radii(SkRRect::kLowerRight_Corner));
|
|
|
|
DrawCommand::MakeJsonPoint(writer, rrect.radii(SkRRect::kLowerLeft_Corner));
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonMatrix(SkJSONWriter& writer, const SkMatrix& matrix) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginArray();
|
|
|
|
for (int r = 0; r < 3; ++r) {
|
|
|
|
writer.beginArray(nullptr, false);
|
|
|
|
for (int c = 0; c < 3; ++c) {
|
|
|
|
writer.appendFloat(matrix[r * 3 + c]);
|
|
|
|
}
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
writer.endArray();
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonPath(SkJSONWriter& writer, const SkPath& path) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginObject();
|
2019-12-03 21:26:15 +00:00
|
|
|
switch (path.getFillType()) {
|
2019-11-26 17:17:17 +00:00
|
|
|
case SkPathFillType::kWinding:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_FILLTYPE, DEBUGCANVAS_FILLTYPE_WINDING);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
2019-11-26 17:17:17 +00:00
|
|
|
case SkPathFillType::kEvenOdd:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_FILLTYPE, DEBUGCANVAS_FILLTYPE_EVENODD);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
2019-11-26 17:17:17 +00:00
|
|
|
case SkPathFillType::kInverseWinding:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_FILLTYPE,
|
|
|
|
DEBUGCANVAS_FILLTYPE_INVERSEWINDING);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
2019-11-26 17:17:17 +00:00
|
|
|
case SkPathFillType::kInverseEvenOdd:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_FILLTYPE,
|
|
|
|
DEBUGCANVAS_FILLTYPE_INVERSEEVENODD);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
2016-03-29 16:03:52 +00:00
|
|
|
}
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_VERBS);
|
2016-02-10 13:40:46 +00:00
|
|
|
SkPath::Iter iter(path, false);
|
2019-03-20 16:59:00 +00:00
|
|
|
SkPoint pts[4];
|
2016-02-10 13:40:46 +00:00
|
|
|
SkPath::Verb verb;
|
|
|
|
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
|
2019-01-28 18:41:19 +00:00
|
|
|
if (verb == SkPath::kClose_Verb) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_VERB_CLOSE);
|
2019-01-28 18:41:19 +00:00
|
|
|
continue;
|
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.beginObject(); // verb
|
2016-02-10 13:40:46 +00:00
|
|
|
switch (verb) {
|
|
|
|
case SkPath::kLine_Verb: {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_VERB_LINE);
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonPoint(writer, pts[1]);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kQuad_Verb: {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_VERB_QUAD);
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonPoint(writer, pts[1]);
|
|
|
|
MakeJsonPoint(writer, pts[2]);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // quad coords
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kCubic_Verb: {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_VERB_CUBIC);
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonPoint(writer, pts[1]);
|
|
|
|
MakeJsonPoint(writer, pts[2]);
|
|
|
|
MakeJsonPoint(writer, pts[3]);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // cubic coords
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kConic_Verb: {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_VERB_CONIC);
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonPoint(writer, pts[1]);
|
|
|
|
MakeJsonPoint(writer, pts[2]);
|
|
|
|
writer.appendFloat(iter.conicWeight());
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // conic coords
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kMove_Verb: {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_VERB_MOVE);
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonPoint(writer, pts[0]);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kClose_Verb:
|
|
|
|
case SkPath::kDone_Verb:
|
2019-01-28 18:41:19 +00:00
|
|
|
// Unreachable
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // verb
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // verbs
|
|
|
|
writer.endObject(); // path
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonRegion(SkJSONWriter& writer, const SkRegion& region) {
|
2018-03-12 14:57:28 +00:00
|
|
|
// TODO: Actually serialize the rectangles, rather than just devolving to path
|
|
|
|
SkPath path;
|
|
|
|
region.getBoundaryPath(&path);
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonPath(writer, path);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
static const char* regionop_name(SkClipOp op) {
|
2016-02-10 13:40:46 +00:00
|
|
|
switch (op) {
|
2019-03-20 18:02:32 +00:00
|
|
|
case kDifference_SkClipOp: return DEBUGCANVAS_REGIONOP_DIFFERENCE;
|
|
|
|
case kIntersect_SkClipOp: return DEBUGCANVAS_REGIONOP_INTERSECT;
|
|
|
|
case kUnion_SkClipOp: return DEBUGCANVAS_REGIONOP_UNION;
|
|
|
|
case kXOR_SkClipOp: return DEBUGCANVAS_REGIONOP_XOR;
|
|
|
|
case kReverseDifference_SkClipOp: return DEBUGCANVAS_REGIONOP_REVERSE_DIFFERENCE;
|
|
|
|
case kReplace_SkClipOp: return DEBUGCANVAS_REGIONOP_REPLACE;
|
2019-03-20 16:59:00 +00:00
|
|
|
default: SkASSERT(false); return "<invalid region op>";
|
2018-11-30 20:33:19 +00:00
|
|
|
}
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
static const char* pointmode_name(SkCanvas::PointMode mode) {
|
2016-02-10 13:40:46 +00:00
|
|
|
switch (mode) {
|
2019-03-20 18:02:32 +00:00
|
|
|
case SkCanvas::kPoints_PointMode: return DEBUGCANVAS_POINTMODE_POINTS;
|
|
|
|
case SkCanvas::kLines_PointMode: return DEBUGCANVAS_POINTMODE_LINES;
|
|
|
|
case SkCanvas::kPolygon_PointMode: return DEBUGCANVAS_POINTMODE_POLYGON;
|
2019-03-20 16:59:00 +00:00
|
|
|
default: SkASSERT(false); return "<invalid point mode>";
|
2018-11-30 20:33:19 +00:00
|
|
|
}
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
static void store_scalar(SkJSONWriter& writer,
|
|
|
|
const char* key,
|
|
|
|
SkScalar value,
|
|
|
|
SkScalar defaultValue) {
|
2016-02-10 13:40:46 +00:00
|
|
|
if (value != defaultValue) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.appendFloat(key, value);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
static void store_bool(SkJSONWriter& writer, const char* key, bool value, bool defaultValue) {
|
2016-02-10 13:40:46 +00:00
|
|
|
if (value != defaultValue) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.appendBool(key, value);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
static SkString encode_data(const void* bytes,
|
|
|
|
size_t count,
|
|
|
|
const char* contentType,
|
2019-01-28 18:41:19 +00:00
|
|
|
UrlDataManager& urlDataManager) {
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> data(SkData::MakeWithCopy(bytes, count));
|
2019-01-28 18:41:19 +00:00
|
|
|
return urlDataManager.addData(data.get(), contentType);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::flatten(const SkFlattenable* flattenable,
|
|
|
|
SkJSONWriter& writer,
|
|
|
|
UrlDataManager& urlDataManager) {
|
2016-05-04 18:06:28 +00:00
|
|
|
SkBinaryWriteBuffer buffer;
|
2016-02-11 18:35:21 +00:00
|
|
|
flattenable->flatten(buffer);
|
|
|
|
void* data = sk_malloc_throw(buffer.bytesWritten());
|
|
|
|
buffer.writeToMemory(data);
|
2019-03-20 16:59:00 +00:00
|
|
|
SkString url =
|
|
|
|
encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_NAME, flattenable->getTypeName());
|
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_DATA, url.c_str());
|
2016-05-04 18:06:28 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_VALUES);
|
2019-03-20 16:59:00 +00:00
|
|
|
JsonWriteBuffer jsonBuffer(&writer, &urlDataManager);
|
2016-05-04 18:06:28 +00:00
|
|
|
flattenable->flatten(jsonBuffer);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // values
|
2016-05-04 18:06:28 +00:00
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
sk_free(data);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::WritePNG(SkBitmap bitmap, SkWStream& out) {
|
2018-08-08 21:03:39 +00:00
|
|
|
SkPixmap pm;
|
|
|
|
SkAssertResult(bitmap.peekPixels(&pm));
|
2016-03-21 17:19:39 +00:00
|
|
|
|
2018-08-08 21:03:39 +00:00
|
|
|
SkPngEncoder::Options options;
|
2019-03-20 16:59:00 +00:00
|
|
|
options.fZLibLevel = 1;
|
2018-08-08 21:03:39 +00:00
|
|
|
options.fFilterFlags = SkPngEncoder::FilterFlag::kNone;
|
|
|
|
SkPngEncoder::Encode(&out, pm, options);
|
2016-03-21 17:19:39 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
bool DrawCommand::flatten(const SkImage& image,
|
|
|
|
SkJSONWriter& writer,
|
|
|
|
UrlDataManager& urlDataManager) {
|
|
|
|
size_t rowBytes = 4 * image.width();
|
2017-01-11 17:44:43 +00:00
|
|
|
SkAutoMalloc buffer(rowBytes * image.height());
|
2019-03-20 16:59:00 +00:00
|
|
|
SkImageInfo dstInfo =
|
2019-09-30 19:12:27 +00:00
|
|
|
SkImageInfo::Make(image.dimensions(), kN32_SkColorType, kPremul_SkAlphaType);
|
2016-03-21 17:19:39 +00:00
|
|
|
if (!image.readPixels(dstInfo, buffer.get(), rowBytes, 0, 0)) {
|
|
|
|
SkDebugf("readPixels failed\n");
|
|
|
|
return false;
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2016-06-30 17:06:51 +00:00
|
|
|
|
|
|
|
SkBitmap bm;
|
|
|
|
bm.installPixels(dstInfo, buffer.get(), rowBytes);
|
|
|
|
|
2016-03-21 17:19:39 +00:00
|
|
|
SkDynamicMemoryWStream out;
|
2019-03-20 16:59:00 +00:00
|
|
|
DrawCommand::WritePNG(bm, out);
|
2016-09-12 19:01:44 +00:00
|
|
|
sk_sp<SkData> encoded = out.detachAsData();
|
2019-03-20 16:59:00 +00:00
|
|
|
SkString url = encode_data(encoded->data(), encoded->size(), "image/png", urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_DATA, url.c_str());
|
2016-02-10 13:40:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* color_type_name(SkColorType colorType) {
|
|
|
|
switch (colorType) {
|
2019-03-20 18:02:32 +00:00
|
|
|
case kARGB_4444_SkColorType: return DEBUGCANVAS_COLORTYPE_ARGB4444;
|
|
|
|
case kRGBA_8888_SkColorType: return DEBUGCANVAS_COLORTYPE_RGBA8888;
|
|
|
|
case kBGRA_8888_SkColorType: return DEBUGCANVAS_COLORTYPE_BGRA8888;
|
|
|
|
case kRGB_565_SkColorType: return DEBUGCANVAS_COLORTYPE_565;
|
|
|
|
case kGray_8_SkColorType: return DEBUGCANVAS_COLORTYPE_GRAY8;
|
|
|
|
case kAlpha_8_SkColorType: return DEBUGCANVAS_COLORTYPE_ALPHA8;
|
|
|
|
default: SkASSERT(false); return DEBUGCANVAS_COLORTYPE_RGBA8888;
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* alpha_type_name(SkAlphaType alphaType) {
|
|
|
|
switch (alphaType) {
|
2019-03-20 18:02:32 +00:00
|
|
|
case kOpaque_SkAlphaType: return DEBUGCANVAS_ALPHATYPE_OPAQUE;
|
|
|
|
case kPremul_SkAlphaType: return DEBUGCANVAS_ALPHATYPE_PREMUL;
|
|
|
|
case kUnpremul_SkAlphaType: return DEBUGCANVAS_ALPHATYPE_UNPREMUL;
|
|
|
|
default: SkASSERT(false); return DEBUGCANVAS_ALPHATYPE_OPAQUE;
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
bool DrawCommand::flatten(const SkBitmap& bitmap,
|
|
|
|
SkJSONWriter& writer,
|
|
|
|
UrlDataManager& urlDataManager) {
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image(SkImage::MakeFromBitmap(bitmap));
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_COLOR, color_type_name(bitmap.colorType()));
|
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_ALPHA, alpha_type_name(bitmap.alphaType()));
|
2019-01-28 18:41:19 +00:00
|
|
|
bool success = flatten(*image, writer, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
static void apply_font_hinting(const SkFont& font, SkJSONWriter& writer) {
|
2019-01-04 14:41:49 +00:00
|
|
|
SkFontHinting hinting = font.getHinting();
|
2016-08-25 18:10:41 +00:00
|
|
|
if (hinting != SkPaintDefaults_Hinting) {
|
|
|
|
switch (hinting) {
|
2019-05-07 20:50:29 +00:00
|
|
|
case SkFontHinting::kNone:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_HINTING, DEBUGCANVAS_HINTING_NONE);
|
2016-08-25 18:10:41 +00:00
|
|
|
break;
|
2019-05-07 20:50:29 +00:00
|
|
|
case SkFontHinting::kSlight:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_HINTING, DEBUGCANVAS_HINTING_SLIGHT);
|
2016-08-25 18:10:41 +00:00
|
|
|
break;
|
2019-05-07 20:50:29 +00:00
|
|
|
case SkFontHinting::kNormal:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_HINTING, DEBUGCANVAS_HINTING_NORMAL);
|
2016-08-25 18:10:41 +00:00
|
|
|
break;
|
2019-05-07 20:50:29 +00:00
|
|
|
case SkFontHinting::kFull:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_HINTING, DEBUGCANVAS_HINTING_FULL);
|
2016-08-25 18:10:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
static void apply_font_edging(const SkFont& font, SkJSONWriter& writer) {
|
2019-01-04 14:41:49 +00:00
|
|
|
switch (font.getEdging()) {
|
|
|
|
case SkFont::Edging::kAlias:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_EDGING, DEBUGCANVAS_EDGING_ALIAS);
|
2019-01-04 14:41:49 +00:00
|
|
|
break;
|
|
|
|
case SkFont::Edging::kAntiAlias:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_EDGING, DEBUGCANVAS_EDGING_ANTIALIAS);
|
2019-01-04 14:41:49 +00:00
|
|
|
break;
|
|
|
|
case SkFont::Edging::kSubpixelAntiAlias:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_EDGING, DEBUGCANVAS_EDGING_SUBPIXELANTIALIAS);
|
2019-01-04 14:41:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
static void apply_paint_color(const SkPaint& paint, SkJSONWriter& writer) {
|
2016-02-10 13:40:46 +00:00
|
|
|
SkColor color = paint.getColor();
|
|
|
|
if (color != SK_ColorBLACK) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COLOR);
|
2019-03-20 16:59:00 +00:00
|
|
|
DrawCommand::MakeJsonColor(writer, color);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
static void apply_paint_style(const SkPaint& paint, SkJSONWriter& writer) {
|
2016-02-10 13:40:46 +00:00
|
|
|
SkPaint::Style style = paint.getStyle();
|
|
|
|
if (style != SkPaint::kFill_Style) {
|
|
|
|
switch (style) {
|
|
|
|
case SkPaint::kStroke_Style: {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_STYLE, DEBUGCANVAS_STYLE_STROKE);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPaint::kStrokeAndFill_Style: {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_STYLE, DEBUGCANVAS_STYLE_STROKEANDFILL);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: SkASSERT(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
static void apply_paint_cap(const SkPaint& paint, SkJSONWriter& writer) {
|
2016-02-10 13:40:46 +00:00
|
|
|
SkPaint::Cap cap = paint.getStrokeCap();
|
|
|
|
if (cap != SkPaint::kDefault_Cap) {
|
|
|
|
switch (cap) {
|
2016-02-10 22:05:02 +00:00
|
|
|
case SkPaint::kButt_Cap:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_CAP, DEBUGCANVAS_CAP_BUTT);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
2016-02-10 22:05:02 +00:00
|
|
|
case SkPaint::kRound_Cap:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_CAP, DEBUGCANVAS_CAP_ROUND);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
2016-02-10 22:05:02 +00:00
|
|
|
case SkPaint::kSquare_Cap:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_CAP, DEBUGCANVAS_CAP_SQUARE);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
default: SkASSERT(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-10 22:05:02 +00:00
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
static void apply_paint_join(const SkPaint& paint, SkJSONWriter& writer) {
|
2016-02-10 22:05:02 +00:00
|
|
|
SkPaint::Join join = paint.getStrokeJoin();
|
|
|
|
if (join != SkPaint::kDefault_Join) {
|
|
|
|
switch (join) {
|
|
|
|
case SkPaint::kMiter_Join:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_STROKEJOIN, DEBUGCANVAS_MITER_JOIN);
|
2016-02-10 22:05:02 +00:00
|
|
|
break;
|
|
|
|
case SkPaint::kRound_Join:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_STROKEJOIN, DEBUGCANVAS_ROUND_JOIN);
|
2016-02-10 22:05:02 +00:00
|
|
|
break;
|
|
|
|
case SkPaint::kBevel_Join:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_STROKEJOIN, DEBUGCANVAS_BEVEL_JOIN);
|
2016-02-10 22:05:02 +00:00
|
|
|
break;
|
|
|
|
default: SkASSERT(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
static void apply_paint_filterquality(const SkPaint& paint, SkJSONWriter& writer) {
|
2016-02-10 22:05:02 +00:00
|
|
|
SkFilterQuality quality = paint.getFilterQuality();
|
|
|
|
switch (quality) {
|
2019-03-20 16:59:00 +00:00
|
|
|
case kNone_SkFilterQuality: break;
|
2016-02-10 22:05:02 +00:00
|
|
|
case kLow_SkFilterQuality:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_FILTERQUALITY, DEBUGCANVAS_FILTERQUALITY_LOW);
|
2016-02-10 22:05:02 +00:00
|
|
|
break;
|
|
|
|
case kMedium_SkFilterQuality:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_FILTERQUALITY,
|
|
|
|
DEBUGCANVAS_FILTERQUALITY_MEDIUM);
|
2016-02-10 22:05:02 +00:00
|
|
|
break;
|
|
|
|
case kHigh_SkFilterQuality:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_FILTERQUALITY,
|
|
|
|
DEBUGCANVAS_FILTERQUALITY_HIGH);
|
2016-02-10 22:05:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
static void apply_paint_maskfilter(const SkPaint& paint,
|
|
|
|
SkJSONWriter& writer,
|
2016-02-11 18:35:21 +00:00
|
|
|
UrlDataManager& urlDataManager) {
|
2016-02-10 13:40:46 +00:00
|
|
|
SkMaskFilter* maskFilter = paint.getMaskFilter();
|
|
|
|
if (maskFilter != nullptr) {
|
2018-01-23 20:29:32 +00:00
|
|
|
SkMaskFilterBase::BlurRec blurRec;
|
|
|
|
if (as_MFB(maskFilter)->asABlur(&blurRec)) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_BLUR);
|
|
|
|
writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_SIGMA, blurRec.fSigma);
|
2016-02-10 13:40:46 +00:00
|
|
|
switch (blurRec.fStyle) {
|
|
|
|
case SkBlurStyle::kNormal_SkBlurStyle:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_STYLE, DEBUGCANVAS_BLURSTYLE_NORMAL);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
case SkBlurStyle::kSolid_SkBlurStyle:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_STYLE, DEBUGCANVAS_BLURSTYLE_SOLID);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
case SkBlurStyle::kOuter_SkBlurStyle:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_STYLE, DEBUGCANVAS_BLURSTYLE_OUTER);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
case SkBlurStyle::kInner_SkBlurStyle:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_STYLE, DEBUGCANVAS_BLURSTYLE_INNER);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
2019-03-20 16:59:00 +00:00
|
|
|
default: SkASSERT(false);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // blur
|
2016-02-10 13:40:46 +00:00
|
|
|
} else {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_MASKFILTER);
|
2019-03-20 16:59:00 +00:00
|
|
|
DrawCommand::flatten(maskFilter, writer, urlDataManager);
|
|
|
|
writer.endObject(); // maskFilter
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
static void apply_paint_patheffect(const SkPaint& paint,
|
|
|
|
SkJSONWriter& writer,
|
2016-02-11 18:35:21 +00:00
|
|
|
UrlDataManager& urlDataManager) {
|
2016-02-10 13:40:46 +00:00
|
|
|
SkPathEffect* pathEffect = paint.getPathEffect();
|
|
|
|
if (pathEffect != nullptr) {
|
|
|
|
SkPathEffect::DashInfo dashInfo;
|
|
|
|
SkPathEffect::DashType dashType = pathEffect->asADash(&dashInfo);
|
|
|
|
if (dashType == SkPathEffect::kDash_DashType) {
|
2019-03-20 16:59:00 +00:00
|
|
|
dashInfo.fIntervals = (SkScalar*)sk_malloc_throw(dashInfo.fCount * sizeof(SkScalar));
|
2016-02-10 13:40:46 +00:00
|
|
|
pathEffect->asADash(&dashInfo);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_DASHING);
|
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_INTERVALS, false);
|
2016-02-10 13:40:46 +00:00
|
|
|
for (int32_t i = 0; i < dashInfo.fCount; i++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.appendFloat(dashInfo.fIntervals[i]);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // intervals
|
2016-02-10 13:40:46 +00:00
|
|
|
sk_free(dashInfo.fIntervals);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_PHASE, dashInfo.fPhase);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // dashing
|
2016-02-10 13:40:46 +00:00
|
|
|
} else {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_PATHEFFECT);
|
2019-03-20 16:59:00 +00:00
|
|
|
DrawCommand::flatten(pathEffect, writer, urlDataManager);
|
|
|
|
writer.endObject(); // pathEffect
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-29 16:03:52 +00:00
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
static void apply_font_typeface(const SkFont& font,
|
|
|
|
SkJSONWriter& writer,
|
|
|
|
UrlDataManager& urlDataManager) {
|
2019-01-22 19:45:16 +00:00
|
|
|
SkTypeface* typeface = font.getTypefaceOrDefault();
|
2016-02-10 13:40:46 +00:00
|
|
|
if (typeface != nullptr) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_TYPEFACE);
|
2016-02-11 18:35:21 +00:00
|
|
|
SkDynamicMemoryWStream buffer;
|
|
|
|
typeface->serialize(&buffer);
|
|
|
|
void* data = sk_malloc_throw(buffer.bytesWritten());
|
|
|
|
buffer.copyTo(data);
|
2019-03-20 16:59:00 +00:00
|
|
|
SkString url = encode_data(
|
|
|
|
data, buffer.bytesWritten(), "application/octet-stream", urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_DATA, url.c_str());
|
2016-02-11 18:35:21 +00:00
|
|
|
sk_free(data);
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.endObject();
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
static void apply_flattenable(const char* key,
|
|
|
|
SkFlattenable* flattenable,
|
|
|
|
SkJSONWriter& writer,
|
2019-01-28 18:41:19 +00:00
|
|
|
UrlDataManager& urlDataManager) {
|
|
|
|
if (flattenable != nullptr) {
|
|
|
|
writer.beginObject(key);
|
2019-03-20 16:59:00 +00:00
|
|
|
DrawCommand::flatten(flattenable, writer, urlDataManager);
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.endObject();
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonPaint(SkJSONWriter& writer,
|
|
|
|
const SkPaint& paint,
|
|
|
|
UrlDataManager& urlDataManager) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginObject();
|
2019-03-20 18:02:32 +00:00
|
|
|
store_scalar(writer, DEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWidth(), 0.0f);
|
2019-03-20 16:59:00 +00:00
|
|
|
store_scalar(writer,
|
2019-03-20 18:02:32 +00:00
|
|
|
DEBUGCANVAS_ATTRIBUTE_STROKEMITER,
|
2019-03-20 16:59:00 +00:00
|
|
|
paint.getStrokeMiter(),
|
2016-02-10 13:40:46 +00:00
|
|
|
SkPaintDefaults_MiterLimit);
|
2019-03-20 18:02:32 +00:00
|
|
|
store_bool(writer, DEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(), false);
|
|
|
|
store_bool(writer, DEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false);
|
2019-01-28 18:41:19 +00:00
|
|
|
|
|
|
|
apply_paint_color(paint, writer);
|
|
|
|
apply_paint_style(paint, writer);
|
|
|
|
apply_paint_blend_mode(paint, writer);
|
|
|
|
apply_paint_cap(paint, writer);
|
|
|
|
apply_paint_join(paint, writer);
|
|
|
|
apply_paint_filterquality(paint, writer);
|
|
|
|
apply_paint_patheffect(paint, writer, urlDataManager);
|
|
|
|
apply_paint_maskfilter(paint, writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
apply_flattenable(DEBUGCANVAS_ATTRIBUTE_SHADER, paint.getShader(), writer, urlDataManager);
|
2019-03-20 16:59:00 +00:00
|
|
|
apply_flattenable(
|
2019-03-20 18:02:32 +00:00
|
|
|
DEBUGCANVAS_ATTRIBUTE_IMAGEFILTER, paint.getImageFilter(), writer, urlDataManager);
|
2019-03-20 16:59:00 +00:00
|
|
|
apply_flattenable(
|
2019-03-20 18:02:32 +00:00
|
|
|
DEBUGCANVAS_ATTRIBUTE_COLORFILTER, paint.getColorFilter(), writer, urlDataManager);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // paint
|
2019-01-28 18:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void MakeJsonFont(const SkFont& font, SkJSONWriter& writer, UrlDataManager& urlDataManager) {
|
|
|
|
writer.beginObject();
|
2019-03-20 18:02:32 +00:00
|
|
|
store_bool(writer, DEBUGCANVAS_ATTRIBUTE_FAKEBOLDTEXT, font.isEmbolden(), false);
|
|
|
|
store_bool(writer, DEBUGCANVAS_ATTRIBUTE_LINEARTEXT, font.isLinearMetrics(), false);
|
|
|
|
store_bool(writer, DEBUGCANVAS_ATTRIBUTE_SUBPIXELTEXT, font.isSubpixel(), false);
|
|
|
|
store_bool(writer, DEBUGCANVAS_ATTRIBUTE_EMBEDDEDBITMAPTEXT, font.isEmbeddedBitmaps(), false);
|
|
|
|
store_bool(writer, DEBUGCANVAS_ATTRIBUTE_AUTOHINTING, font.isForceAutoHinting(), false);
|
|
|
|
|
|
|
|
store_scalar(writer, DEBUGCANVAS_ATTRIBUTE_TEXTSIZE, font.getSize(), SkPaintDefaults_TextSize);
|
|
|
|
store_scalar(writer, DEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, font.getScaleX(), SK_Scalar1);
|
|
|
|
store_scalar(writer, DEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, font.getSkewX(), 0.0f);
|
2019-01-28 18:41:19 +00:00
|
|
|
apply_font_edging(font, writer);
|
|
|
|
apply_font_hinting(font, writer);
|
|
|
|
apply_font_typeface(font, writer, urlDataManager);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // font
|
2019-01-28 18:41:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
void DrawCommand::MakeJsonLattice(SkJSONWriter& writer, const SkCanvas::Lattice& lattice) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginObject();
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendS32(DEBUGCANVAS_ATTRIBUTE_LATTICEXCOUNT, lattice.fXCount);
|
|
|
|
writer.appendS32(DEBUGCANVAS_ATTRIBUTE_LATTICEYCOUNT, lattice.fYCount);
|
2017-01-12 21:20:50 +00:00
|
|
|
if (nullptr != lattice.fBounds) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_BOUNDS);
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonIRect(writer, *lattice.fBounds);
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_LATTICEXDIVS);
|
2017-01-12 21:20:50 +00:00
|
|
|
for (int i = 0; i < lattice.fXCount; i++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.appendS32(lattice.fXDivs[i]);
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // xdivs
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_LATTICEYDIVS);
|
2017-01-12 21:20:50 +00:00
|
|
|
for (int i = 0; i < lattice.fYCount; i++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.appendS32(lattice.fYDivs[i]);
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // ydivs
|
2017-12-11 18:01:58 +00:00
|
|
|
if (nullptr != lattice.fRectTypes) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_LATTICEFLAGS);
|
2017-01-12 21:20:50 +00:00
|
|
|
int flagCount = 0;
|
2019-03-20 16:59:00 +00:00
|
|
|
for (int row = 0; row < lattice.fYCount + 1; row++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.beginArray();
|
2019-03-20 16:59:00 +00:00
|
|
|
for (int column = 0; column < lattice.fXCount + 1; column++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.appendS32(lattice.fRectTypes[flagCount++]);
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // row
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.endArray();
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.endObject();
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
ClearCommand::ClearCommand(SkColor color) : INHERITED(kClear_OpType) { fColor = color; }
|
2016-02-10 22:05:02 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClearCommand::execute(SkCanvas* canvas) const { canvas->clear(fColor); }
|
2016-02-10 22:05:02 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClearCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COLOR);
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonColor(writer, fColor);
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
ClipPathCommand::ClipPathCommand(const SkPath& path, SkClipOp op, bool doAA)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kClipPath_OpType) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPath = path;
|
2019-03-20 16:59:00 +00:00
|
|
|
fOp = op;
|
2013-03-17 18:33:46 +00:00
|
|
|
fDoAA = doAA;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClipPathCommand::execute(SkCanvas* canvas) const { canvas->clipPath(fPath, fOp, fDoAA); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool ClipPathCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_path(canvas, fPath);
|
|
|
|
return true;
|
2012-11-21 17:11:02 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClipPathCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PATH);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPath(writer, fPath);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_REGIONOP, regionop_name(fOp));
|
|
|
|
writer.appendBool(DEBUGCANVAS_ATTRIBUTE_ANTIALIAS, fDoAA);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
ClipRegionCommand::ClipRegionCommand(const SkRegion& region, SkClipOp op)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kClipRegion_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fRegion = region;
|
2019-03-20 16:59:00 +00:00
|
|
|
fOp = op;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClipRegionCommand::execute(SkCanvas* canvas) const { canvas->clipRegion(fRegion, fOp); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClipRegionCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_REGION);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRegion(writer, fRegion);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_REGIONOP, regionop_name(fOp));
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
ClipRectCommand::ClipRectCommand(const SkRect& rect, SkClipOp op, bool doAA)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kClipRect_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fRect = rect;
|
2019-03-20 16:59:00 +00:00
|
|
|
fOp = op;
|
2013-03-22 12:25:30 +00:00
|
|
|
fDoAA = doAA;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClipRectCommand::execute(SkCanvas* canvas) const { canvas->clipRect(fRect, fOp, fDoAA); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClipRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fRect);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_REGIONOP, regionop_name(fOp));
|
|
|
|
writer.appendBool(DEBUGCANVAS_ATTRIBUTE_ANTIALIAS, fDoAA);
|
2016-06-29 18:36:34 +00:00
|
|
|
|
|
|
|
SkString desc;
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, str_append(&desc, fRect)->c_str());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
ClipRRectCommand::ClipRRectCommand(const SkRRect& rrect, SkClipOp op, bool doAA)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kClipRRect_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fRRect = rrect;
|
2019-03-20 16:59:00 +00:00
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClipRRectCommand::execute(SkCanvas* canvas) const { canvas->clipRRect(fRRect, fOp, fDoAA); }
|
2013-01-02 20:20:31 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool ClipRRectCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_rrect(canvas, fRRect);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ClipRRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
make_json_rrect(writer, fRRect);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_REGIONOP, regionop_name(fOp));
|
|
|
|
writer.appendBool(DEBUGCANVAS_ATTRIBUTE_ANTIALIAS, fDoAA);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
ConcatCommand::ConcatCommand(const SkMatrix& matrix) : INHERITED(kConcat_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fMatrix = matrix;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ConcatCommand::execute(SkCanvas* canvas) const { canvas->concat(fMatrix); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void ConcatCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_MATRIX);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonMatrix(writer, fMatrix);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2016-06-29 01:54:19 +00:00
|
|
|
////
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawAnnotationCommand::DrawAnnotationCommand(const SkRect& rect,
|
|
|
|
const char key[],
|
|
|
|
sk_sp<SkData> value)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawAnnotation_OpType), fRect(rect), fKey(key), fValue(std::move(value)) {}
|
2016-06-29 01:54:19 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawAnnotationCommand::execute(SkCanvas* canvas) const {
|
2016-06-29 01:54:19 +00:00
|
|
|
canvas->drawAnnotation(fRect, fKey.c_str(), fValue);
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawAnnotationCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2016-06-29 01:54:19 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fRect);
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.appendString("key", fKey.c_str());
|
2016-06-29 01:54:19 +00:00
|
|
|
if (fValue.get()) {
|
|
|
|
// TODO: dump out the "value"
|
|
|
|
}
|
2016-06-29 18:36:34 +00:00
|
|
|
|
|
|
|
SkString desc;
|
|
|
|
str_append(&desc, fRect)->appendf(" %s", fKey.c_str());
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, desc.c_str());
|
2016-06-29 01:54:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawBitmapCommand::DrawBitmapCommand(const SkBitmap& bitmap,
|
|
|
|
SkScalar left,
|
|
|
|
SkScalar top,
|
|
|
|
const SkPaint* paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawBitmap_OpType), fBitmap(bitmap), fLeft(left), fTop(top), fPaint(paint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawBitmapCommand::execute(SkCanvas* canvas) const {
|
2018-05-29 17:38:07 +00:00
|
|
|
canvas->drawBitmap(fBitmap, fLeft, fTop, fPaint.getMaybeNull());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawBitmapCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_bitmap(canvas, fBitmap);
|
|
|
|
return true;
|
2012-11-26 13:09:17 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawBitmapCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_BITMAP);
|
2019-01-28 18:41:19 +00:00
|
|
|
flatten(fBitmap, writer, urlDataManager);
|
|
|
|
writer.endObject();
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPoint(writer, fLeft, fTop);
|
2019-01-28 18:41:19 +00:00
|
|
|
if (fPaint.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-01-28 19:31:18 +00:00
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawBitmapLatticeCommand::DrawBitmapLatticeCommand(const SkBitmap& bitmap,
|
|
|
|
const SkCanvas::Lattice& lattice,
|
|
|
|
const SkRect& dst,
|
|
|
|
const SkPaint* paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawBitmapLattice_OpType)
|
|
|
|
, fBitmap(bitmap)
|
|
|
|
, fLattice(lattice)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint) {}
|
2018-05-18 20:59:13 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawBitmapLatticeCommand::execute(SkCanvas* canvas) const {
|
2018-05-18 20:59:13 +00:00
|
|
|
canvas->drawBitmapLattice(fBitmap, fLattice, fDst, fPaint.getMaybeNull());
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawBitmapLatticeCommand::render(SkCanvas* canvas) const {
|
2018-05-18 20:59:13 +00:00
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawBitmapLatticeCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_BITMAP);
|
2019-01-28 18:41:19 +00:00
|
|
|
flatten(fBitmap, writer, urlDataManager);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // bitmap
|
2019-01-28 18:41:19 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_LATTICE);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonLattice(writer, fLattice);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fDst);
|
2019-01-28 18:41:19 +00:00
|
|
|
if (fPaint.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-01-28 19:31:18 +00:00
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
2018-05-18 20:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SkString desc;
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, str_append(&desc, fDst)->c_str());
|
2018-05-18 20:59:13 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawBitmapNineCommand::DrawBitmapNineCommand(const SkBitmap& bitmap,
|
|
|
|
const SkIRect& center,
|
|
|
|
const SkRect& dst,
|
|
|
|
const SkPaint* paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawBitmapNine_OpType)
|
|
|
|
, fBitmap(bitmap)
|
|
|
|
, fCenter(center)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawBitmapNineCommand::execute(SkCanvas* canvas) const {
|
2018-05-29 17:38:07 +00:00
|
|
|
canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaint.getMaybeNull());
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawBitmapNineCommand::render(SkCanvas* canvas) const {
|
2015-11-18 20:59:42 +00:00
|
|
|
SkRect tmp = SkRect::Make(fCenter);
|
|
|
|
render_bitmap(canvas, fBitmap, &tmp);
|
2013-06-06 23:59:28 +00:00
|
|
|
return true;
|
2012-11-26 13:09:17 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawBitmapNineCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_BITMAP);
|
2019-01-28 18:41:19 +00:00
|
|
|
flatten(fBitmap, writer, urlDataManager);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // bitmap
|
2019-01-28 18:41:19 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_CENTER);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonIRect(writer, fCenter);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fDst);
|
2019-01-28 18:41:19 +00:00
|
|
|
if (fPaint.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-01-28 19:31:18 +00:00
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawBitmapRectCommand::DrawBitmapRectCommand(const SkBitmap& bitmap,
|
|
|
|
const SkRect* src,
|
|
|
|
const SkRect& dst,
|
|
|
|
const SkPaint* paint,
|
|
|
|
SkCanvas::SrcRectConstraint constraint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawBitmapRect_OpType)
|
|
|
|
, fBitmap(bitmap)
|
|
|
|
, fSrc(src)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint)
|
|
|
|
, fConstraint(constraint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawBitmapRectCommand::execute(SkCanvas* canvas) const {
|
2019-03-20 16:59:00 +00:00
|
|
|
canvas->legacy_drawBitmapRect(
|
|
|
|
fBitmap, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), fConstraint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawBitmapRectCommand::render(SkCanvas* canvas) const {
|
2018-05-29 17:38:07 +00:00
|
|
|
render_bitmap(canvas, fBitmap, fSrc.getMaybeNull());
|
2013-06-06 23:59:28 +00:00
|
|
|
return true;
|
2012-11-26 13:09:17 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawBitmapRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_BITMAP);
|
2019-01-28 18:41:19 +00:00
|
|
|
flatten(fBitmap, writer, urlDataManager);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // bitmap
|
2019-01-28 18:41:19 +00:00
|
|
|
|
|
|
|
if (fSrc.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_SRC);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, *fSrc);
|
2019-01-28 18:41:19 +00:00
|
|
|
}
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fDst);
|
2019-01-28 18:41:19 +00:00
|
|
|
if (fPaint.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-01-28 19:31:18 +00:00
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
2019-01-28 18:41:19 +00:00
|
|
|
}
|
|
|
|
if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendBool(DEBUGCANVAS_ATTRIBUTE_STRICT, true);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2016-06-29 18:36:34 +00:00
|
|
|
|
|
|
|
SkString desc;
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, str_append(&desc, fDst)->c_str());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawImageCommand::DrawImageCommand(const SkImage* image,
|
|
|
|
SkScalar left,
|
|
|
|
SkScalar top,
|
|
|
|
const SkPaint* paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawImage_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fLeft(left)
|
|
|
|
, fTop(top)
|
|
|
|
, fPaint(paint) {}
|
2015-07-22 17:23:01 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawImageCommand::execute(SkCanvas* canvas) const {
|
2016-11-03 20:26:13 +00:00
|
|
|
canvas->drawImage(fImage.get(), fLeft, fTop, fPaint.getMaybeNull());
|
2015-07-22 17:23:01 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawImageCommand::render(SkCanvas* canvas) const {
|
2015-07-22 17:23:01 +00:00
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
xlate_and_scale_to_bounds(
|
|
|
|
canvas,
|
|
|
|
SkRect::MakeXYWH(
|
|
|
|
fLeft, fTop, SkIntToScalar(fImage->width()), SkIntToScalar(fImage->height())));
|
2015-07-22 17:23:01 +00:00
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawImageCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2016-08-29 16:15:33 +00:00
|
|
|
|
2020-01-03 15:29:13 +00:00
|
|
|
|
|
|
|
if (urlDataManager.hasImageIndex()) {
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_IMAGE_INDEX);
|
|
|
|
writer.appendU64((uint64_t)urlDataManager.lookupImage(fImage.get()));
|
|
|
|
} else {
|
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_IMAGE);
|
|
|
|
flatten(*fImage, writer, urlDataManager);
|
|
|
|
writer.endObject(); // image
|
|
|
|
}
|
2019-12-09 15:05:42 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPoint(writer, fLeft, fTop);
|
2019-01-28 18:41:19 +00:00
|
|
|
if (fPaint.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-01-28 19:31:18 +00:00
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
2019-01-28 18:41:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendU32(DEBUGCANVAS_ATTRIBUTE_UNIQUE_ID, fImage->uniqueID());
|
|
|
|
writer.appendS32(DEBUGCANVAS_ATTRIBUTE_WIDTH, fImage->width());
|
|
|
|
writer.appendS32(DEBUGCANVAS_ATTRIBUTE_HEIGHT, fImage->height());
|
2019-01-28 18:41:19 +00:00
|
|
|
switch (fImage->alphaType()) {
|
|
|
|
case kOpaque_SkAlphaType:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_ALPHA, DEBUGCANVAS_ALPHATYPE_OPAQUE);
|
2019-01-28 18:41:19 +00:00
|
|
|
break;
|
|
|
|
case kPremul_SkAlphaType:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_ALPHA, DEBUGCANVAS_ALPHATYPE_PREMUL);
|
2019-01-28 18:41:19 +00:00
|
|
|
break;
|
|
|
|
case kUnpremul_SkAlphaType:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_ALPHA, DEBUGCANVAS_ALPHATYPE_UNPREMUL);
|
2019-01-28 18:41:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_ALPHA, DEBUGCANVAS_ALPHATYPE_UNKNOWN);
|
2019-01-28 18:41:19 +00:00
|
|
|
break;
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawImageLatticeCommand::DrawImageLatticeCommand(const SkImage* image,
|
|
|
|
const SkCanvas::Lattice& lattice,
|
|
|
|
const SkRect& dst,
|
|
|
|
const SkPaint* paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawImageLattice_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fLattice(lattice)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint) {}
|
2017-01-12 21:20:50 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawImageLatticeCommand::execute(SkCanvas* canvas) const {
|
2018-05-18 20:59:13 +00:00
|
|
|
canvas->drawImageLattice(fImage.get(), fLattice, fDst, fPaint.getMaybeNull());
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawImageLatticeCommand::render(SkCanvas* canvas) const {
|
2017-01-12 21:20:50 +00:00
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawImageLatticeCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2020-01-03 15:29:13 +00:00
|
|
|
if (urlDataManager.hasImageIndex()) {
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_IMAGE_INDEX);
|
|
|
|
writer.appendU64((uint64_t)urlDataManager.lookupImage(fImage.get()));
|
|
|
|
} else {
|
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_IMAGE);
|
|
|
|
flatten(*fImage, writer, urlDataManager);
|
|
|
|
writer.endObject(); // image
|
|
|
|
}
|
2019-12-09 15:05:42 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_LATTICE);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonLattice(writer, fLattice);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fDst);
|
2019-01-28 18:41:19 +00:00
|
|
|
if (fPaint.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-01-28 19:31:18 +00:00
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SkString desc;
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, str_append(&desc, fDst)->c_str());
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawImageRectCommand::DrawImageRectCommand(const SkImage* image,
|
|
|
|
const SkRect* src,
|
|
|
|
const SkRect& dst,
|
|
|
|
const SkPaint* paint,
|
|
|
|
SkCanvas::SrcRectConstraint constraint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawImageRect_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fSrc(src)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint)
|
|
|
|
, fConstraint(constraint) {}
|
2015-07-22 17:23:01 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawImageRectCommand::execute(SkCanvas* canvas) const {
|
2019-03-20 16:59:00 +00:00
|
|
|
canvas->legacy_drawImageRect(
|
|
|
|
fImage.get(), fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), fConstraint);
|
2015-07-22 17:23:01 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawImageRectCommand::render(SkCanvas* canvas) const {
|
2015-07-22 17:23:01 +00:00
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawImageRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2020-01-03 15:29:13 +00:00
|
|
|
if (urlDataManager.hasImageIndex()) {
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_IMAGE_INDEX);
|
|
|
|
writer.appendU64((uint64_t)urlDataManager.lookupImage(fImage.get()));
|
|
|
|
} else {
|
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_IMAGE);
|
|
|
|
flatten(*fImage, writer, urlDataManager);
|
|
|
|
writer.endObject(); // image
|
|
|
|
}
|
2019-12-09 15:05:42 +00:00
|
|
|
|
2019-01-28 18:41:19 +00:00
|
|
|
if (fSrc.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_SRC);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, *fSrc);
|
2019-01-28 18:41:19 +00:00
|
|
|
}
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fDst);
|
2019-01-28 18:41:19 +00:00
|
|
|
if (fPaint.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-01-28 19:31:18 +00:00
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
2019-01-28 18:41:19 +00:00
|
|
|
}
|
|
|
|
if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendBool(DEBUGCANVAS_ATTRIBUTE_STRICT, true);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2016-06-29 18:36:34 +00:00
|
|
|
|
|
|
|
SkString desc;
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, str_append(&desc, fDst)->c_str());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-12-12 16:05:10 +00:00
|
|
|
DrawImageRectLayerCommand::DrawImageRectLayerCommand(DebugLayerManager* layerManager,
|
|
|
|
const int nodeId,
|
|
|
|
const int frame,
|
|
|
|
const SkRect* src,
|
|
|
|
const SkRect& dst,
|
|
|
|
const SkPaint* paint,
|
|
|
|
SkCanvas::SrcRectConstraint constraint)
|
|
|
|
: INHERITED(kDrawImageRectLayer_OpType)
|
|
|
|
, fLayerManager(layerManager)
|
|
|
|
, fNodeId(nodeId)
|
|
|
|
, fFrame(frame)
|
|
|
|
, fSrc(src)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint)
|
|
|
|
, fConstraint(constraint) {}
|
|
|
|
|
|
|
|
void DrawImageRectLayerCommand::execute(SkCanvas* canvas) const {
|
|
|
|
sk_sp<SkImage> snapshot = fLayerManager->getLayerAsImage(fNodeId, fFrame);
|
|
|
|
canvas->legacy_drawImageRect(
|
|
|
|
snapshot.get(), fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), fConstraint);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DrawImageRectLayerCommand::render(SkCanvas* canvas) const {
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawImageRectLayerCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
|
|
|
|
|
|
|
// Don't append an image attribute here, the image can be rendered in as many different ways
|
|
|
|
// as there are commands in the layer, at least. the urlDataManager would save each one under
|
|
|
|
// a different URL.
|
|
|
|
// Append the node id, and the layer inspector of the debugger will know what to do with it.
|
|
|
|
writer.appendS64(DEBUGCANVAS_ATTRIBUTE_LAYERNODEID, fNodeId);
|
|
|
|
|
|
|
|
if (fSrc.isValid()) {
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_SRC);
|
|
|
|
MakeJsonRect(writer, *fSrc);
|
|
|
|
}
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
|
|
|
|
MakeJsonRect(writer, fDst);
|
|
|
|
if (fPaint.isValid()) {
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
|
|
|
}
|
|
|
|
if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
|
|
|
|
writer.appendBool(DEBUGCANVAS_ATTRIBUTE_STRICT, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
SkString desc;
|
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, str_append(&desc, fDst)->c_str());
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawImageNineCommand::DrawImageNineCommand(const SkImage* image,
|
|
|
|
const SkIRect& center,
|
|
|
|
const SkRect& dst,
|
|
|
|
const SkPaint* paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawImageNine_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fCenter(center)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint) {}
|
2018-03-12 14:57:28 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawImageNineCommand::execute(SkCanvas* canvas) const {
|
2018-05-29 17:38:07 +00:00
|
|
|
canvas->drawImageNine(fImage.get(), fCenter, fDst, fPaint.getMaybeNull());
|
2018-03-12 14:57:28 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawImageNineCommand::render(SkCanvas* canvas) const {
|
2018-03-12 14:57:28 +00:00
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawImageNineCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2020-01-03 15:29:13 +00:00
|
|
|
if (urlDataManager.hasImageIndex()) {
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_IMAGE_INDEX);
|
|
|
|
writer.appendU64((uint64_t)urlDataManager.lookupImage(fImage.get()));
|
|
|
|
} else {
|
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_IMAGE);
|
|
|
|
flatten(*fImage, writer, urlDataManager);
|
|
|
|
writer.endObject(); // image
|
|
|
|
}
|
2019-12-09 15:05:42 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_CENTER);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonIRect(writer, fCenter);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_DST);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fDst);
|
2019-01-28 18:41:19 +00:00
|
|
|
if (fPaint.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-01-28 19:31:18 +00:00
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
2018-03-12 14:57:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawOvalCommand::DrawOvalCommand(const SkRect& oval, const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawOval_OpType) {
|
|
|
|
fOval = oval;
|
2013-03-22 12:25:30 +00:00
|
|
|
fPaint = paint;
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawOvalCommand::execute(SkCanvas* canvas) const { canvas->drawOval(fOval, fPaint); }
|
2013-01-02 20:20:31 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawOvalCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fOval);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawOval(fOval, p);
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawOvalCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fOval);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawArcCommand::DrawArcCommand(const SkRect& oval,
|
|
|
|
SkScalar startAngle,
|
|
|
|
SkScalar sweepAngle,
|
|
|
|
bool useCenter,
|
|
|
|
const SkPaint& paint)
|
2018-03-12 14:57:28 +00:00
|
|
|
: INHERITED(kDrawArc_OpType) {
|
2019-03-20 16:59:00 +00:00
|
|
|
fOval = oval;
|
2016-08-19 18:25:19 +00:00
|
|
|
fStartAngle = startAngle;
|
|
|
|
fSweepAngle = sweepAngle;
|
2019-03-20 16:59:00 +00:00
|
|
|
fUseCenter = useCenter;
|
|
|
|
fPaint = paint;
|
2016-08-19 18:25:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawArcCommand::execute(SkCanvas* canvas) const {
|
2016-08-19 18:25:19 +00:00
|
|
|
canvas->drawArc(fOval, fStartAngle, fSweepAngle, fUseCenter, fPaint);
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawArcCommand::render(SkCanvas* canvas) const {
|
2016-08-19 18:25:19 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fOval);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
|
|
|
canvas->drawArc(fOval, fStartAngle, fSweepAngle, fUseCenter, p);
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawArcCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fOval);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_STARTANGLE, fStartAngle);
|
|
|
|
writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_SWEEPANGLE, fSweepAngle);
|
|
|
|
writer.appendBool(DEBUGCANVAS_ATTRIBUTE_USECENTER, fUseCenter);
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2016-08-19 18:25:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawPaintCommand::DrawPaintCommand(const SkPaint& paint) : INHERITED(kDrawPaint_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fPaint = paint;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawPaintCommand::execute(SkCanvas* canvas) const { canvas->drawPaint(fPaint); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawPaintCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->drawPaint(fPaint);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawPaintCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-04-19 19:00:47 +00:00
|
|
|
DrawBehindCommand::DrawBehindCommand(const SkPaint& paint) : INHERITED(kDrawPaint_OpType) {
|
|
|
|
fPaint = paint;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawBehindCommand::execute(SkCanvas* canvas) const {
|
|
|
|
SkCanvasPriv::DrawBehind(canvas, fPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DrawBehindCommand::render(SkCanvas* canvas) const {
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
SkCanvasPriv::DrawBehind(canvas, fPaint);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawBehindCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawPathCommand::DrawPathCommand(const SkPath& path, const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawPath_OpType) {
|
|
|
|
fPath = path;
|
2013-03-17 18:33:46 +00:00
|
|
|
fPaint = paint;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawPathCommand::execute(SkCanvas* canvas) const { canvas->drawPath(fPath, fPaint); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawPathCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_path(canvas, fPath);
|
|
|
|
return true;
|
2012-11-21 17:11:02 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawPathCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PATH);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPath(writer, fPath);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawRegionCommand::DrawRegionCommand(const SkRegion& region, const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawRegion_OpType) {
|
2018-03-12 14:57:28 +00:00
|
|
|
fRegion = region;
|
2019-03-20 16:59:00 +00:00
|
|
|
fPaint = paint;
|
2018-03-12 14:57:28 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawRegionCommand::execute(SkCanvas* canvas) const { canvas->drawRegion(fRegion, fPaint); }
|
2018-03-12 14:57:28 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawRegionCommand::render(SkCanvas* canvas) const {
|
2018-03-12 14:57:28 +00:00
|
|
|
render_region(canvas, fRegion);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawRegionCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_REGION);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRegion(writer, fRegion);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2018-03-12 14:57:28 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
BeginDrawPictureCommand::BeginDrawPictureCommand(const SkPicture* picture,
|
|
|
|
const SkMatrix* matrix,
|
|
|
|
const SkPaint* paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kBeginDrawPicture_OpType)
|
|
|
|
, fPicture(SkRef(picture))
|
|
|
|
, fMatrix(matrix)
|
|
|
|
, fPaint(paint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void BeginDrawPictureCommand::execute(SkCanvas* canvas) const {
|
2015-04-02 03:58:37 +00:00
|
|
|
if (fPaint.isValid()) {
|
|
|
|
SkRect bounds = fPicture->cullRect();
|
|
|
|
if (fMatrix.isValid()) {
|
2019-01-28 19:31:18 +00:00
|
|
|
fMatrix->mapRect(&bounds);
|
2015-04-02 03:58:37 +00:00
|
|
|
}
|
|
|
|
canvas->saveLayer(&bounds, fPaint.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fMatrix.isValid()) {
|
|
|
|
if (!fPaint.isValid()) {
|
|
|
|
canvas->save();
|
|
|
|
}
|
2019-01-28 19:31:18 +00:00
|
|
|
canvas->concat(*fMatrix);
|
2015-04-02 03:58:37 +00:00
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool BeginDrawPictureCommand::render(SkCanvas* canvas) const {
|
2013-11-21 17:08:12 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
2014-08-29 15:03:56 +00:00
|
|
|
xlate_and_scale_to_bounds(canvas, fPicture->cullRect());
|
2013-11-21 17:08:12 +00:00
|
|
|
|
2014-06-04 12:40:44 +00:00
|
|
|
canvas->drawPicture(fPicture.get());
|
2013-11-21 17:08:12 +00:00
|
|
|
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
EndDrawPictureCommand::EndDrawPictureCommand(bool restore)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kEndDrawPicture_OpType), fRestore(restore) {}
|
2015-04-02 03:58:37 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void EndDrawPictureCommand::execute(SkCanvas* canvas) const {
|
2015-04-02 03:58:37 +00:00
|
|
|
if (fRestore) {
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawPointsCommand::DrawPointsCommand(SkCanvas::PointMode mode,
|
|
|
|
size_t count,
|
|
|
|
const SkPoint pts[],
|
|
|
|
const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawPoints_OpType), fMode(mode), fPts(pts, count), fPaint(paint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawPointsCommand::execute(SkCanvas* canvas) const {
|
2018-05-29 17:38:07 +00:00
|
|
|
canvas->drawPoints(fMode, fPts.count(), fPts.begin(), fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawPointsCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
SkRect bounds;
|
|
|
|
|
|
|
|
bounds.setEmpty();
|
2018-05-29 17:38:07 +00:00
|
|
|
for (int i = 0; i < fPts.count(); ++i) {
|
2018-01-08 22:09:54 +00:00
|
|
|
SkRectPriv::GrowToInclude(&bounds, fPts[i]);
|
2013-06-06 23:59:28 +00:00
|
|
|
}
|
2013-06-07 07:01:06 +00:00
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
|
|
|
SkPaint p;
|
|
|
|
p.setColor(SK_ColorBLACK);
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
|
2018-05-29 17:38:07 +00:00
|
|
|
canvas->drawPoints(fMode, fPts.count(), fPts.begin(), p);
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawPointsCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_MODE, pointmode_name(fMode));
|
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_POINTS);
|
2018-05-29 17:38:07 +00:00
|
|
|
for (int i = 0; i < fPts.count(); i++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonPoint(writer, fPts[i]);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // points
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawTextBlobCommand::DrawTextBlobCommand(sk_sp<SkTextBlob> blob,
|
|
|
|
SkScalar x,
|
|
|
|
SkScalar y,
|
|
|
|
const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawTextBlob_OpType)
|
|
|
|
, fBlob(std::move(blob))
|
|
|
|
, fXPos(x)
|
|
|
|
, fYPos(y)
|
|
|
|
, fPaint(paint) {}
|
2014-08-26 14:56:44 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawTextBlobCommand::execute(SkCanvas* canvas) const {
|
2014-08-26 14:56:44 +00:00
|
|
|
canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawTextBlobCommand::render(SkCanvas* canvas) const {
|
2014-08-29 22:08:20 +00:00
|
|
|
canvas->clear(SK_ColorWHITE);
|
|
|
|
canvas->save();
|
|
|
|
|
|
|
|
SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos);
|
|
|
|
xlate_and_scale_to_bounds(canvas, bounds);
|
|
|
|
|
2016-09-13 17:00:23 +00:00
|
|
|
canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
|
2014-08-29 22:08:20 +00:00
|
|
|
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawTextBlobCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_RUNS);
|
2016-02-10 13:40:46 +00:00
|
|
|
SkTextBlobRunIterator iter(fBlob.get());
|
|
|
|
while (!iter.done()) {
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.beginObject(); // run
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_GLYPHS);
|
2016-02-10 13:40:46 +00:00
|
|
|
for (uint32_t i = 0; i < iter.glyphCount(); i++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
writer.appendU32(iter.glyphs()[i]);
|
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // glyphs
|
2019-01-28 18:41:19 +00:00
|
|
|
if (iter.positioning() != SkTextBlobRunIterator::kDefault_Positioning) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_POSITIONS);
|
2019-01-28 18:41:19 +00:00
|
|
|
const SkScalar* iterPositions = iter.pos();
|
|
|
|
for (uint32_t i = 0; i < iter.glyphCount(); i++) {
|
|
|
|
switch (iter.positioning()) {
|
2019-03-20 16:59:00 +00:00
|
|
|
case SkTextBlobRunIterator::kFull_Positioning:
|
|
|
|
MakeJsonPoint(writer, iterPositions[i * 2], iterPositions[i * 2 + 1]);
|
|
|
|
break;
|
|
|
|
case SkTextBlobRunIterator::kHorizontal_Positioning:
|
|
|
|
writer.appendFloat(iterPositions[i]);
|
|
|
|
break;
|
|
|
|
case SkTextBlobRunIterator::kDefault_Positioning: break;
|
|
|
|
case SkTextBlobRunIterator::kRSXform_Positioning:
|
|
|
|
// TODO_RSXFORM_BLOB
|
|
|
|
break;
|
2019-01-28 18:41:19 +00:00
|
|
|
}
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // positions
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_FONT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonFont(iter.font(), writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPoint(writer, iter.offset());
|
2019-01-28 18:41:19 +00:00
|
|
|
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // run
|
2016-02-10 13:40:46 +00:00
|
|
|
iter.next();
|
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // runs
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_X, fXPos);
|
|
|
|
writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_Y, fYPos);
|
2016-07-07 21:10:14 +00:00
|
|
|
SkRect bounds = fBlob->bounds();
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, bounds);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2016-07-07 21:10:14 +00:00
|
|
|
|
|
|
|
SkString desc;
|
|
|
|
// make the bounds local by applying the x,y
|
|
|
|
bounds.offset(fXPos, fYPos);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, str_append(&desc, bounds)->c_str());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawPatchCommand::DrawPatchCommand(const SkPoint cubics[12],
|
|
|
|
const SkColor colors[4],
|
|
|
|
const SkPoint texCoords[4],
|
|
|
|
SkBlendMode bmode,
|
|
|
|
const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawPatch_OpType), fBlendMode(bmode) {
|
2015-02-13 19:13:00 +00:00
|
|
|
memcpy(fCubics, cubics, sizeof(fCubics));
|
2016-02-10 22:05:02 +00:00
|
|
|
if (colors != nullptr) {
|
|
|
|
memcpy(fColors, colors, sizeof(fColors));
|
|
|
|
fColorsPtr = fColors;
|
|
|
|
} else {
|
|
|
|
fColorsPtr = nullptr;
|
|
|
|
}
|
|
|
|
if (texCoords != nullptr) {
|
|
|
|
memcpy(fTexCoords, texCoords, sizeof(fTexCoords));
|
|
|
|
fTexCoordsPtr = fTexCoords;
|
|
|
|
} else {
|
|
|
|
fTexCoordsPtr = nullptr;
|
|
|
|
}
|
2015-02-13 19:13:00 +00:00
|
|
|
fPaint = paint;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawPatchCommand::execute(SkCanvas* canvas) const {
|
2016-10-28 19:42:34 +00:00
|
|
|
canvas->drawPatch(fCubics, fColorsPtr, fTexCoordsPtr, fBlendMode, fPaint);
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawPatchCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_CUBICS);
|
2016-02-10 22:05:02 +00:00
|
|
|
for (int i = 0; i < 12; i++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonPoint(writer, fCubics[i]);
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // cubics
|
2016-02-10 22:05:02 +00:00
|
|
|
if (fColorsPtr != nullptr) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_COLORS);
|
2016-02-10 22:05:02 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonColor(writer, fColorsPtr[i]);
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // colors
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
|
|
|
if (fTexCoordsPtr != nullptr) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginArray(DEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS);
|
2016-02-10 22:05:02 +00:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2019-01-28 18:41:19 +00:00
|
|
|
MakeJsonPoint(writer, fTexCoords[i]);
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endArray(); // texCoords
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
2016-10-28 19:42:34 +00:00
|
|
|
// fBlendMode
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawRectCommand::DrawRectCommand(const SkRect& rect, const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawRect_OpType) {
|
|
|
|
fRect = rect;
|
2013-03-17 18:33:46 +00:00
|
|
|
fPaint = paint;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawRectCommand::execute(SkCanvas* canvas) const { canvas->drawRect(fRect, fPaint); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, fRect);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2016-06-29 18:36:34 +00:00
|
|
|
|
|
|
|
SkString desc;
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendString(DEBUGCANVAS_ATTRIBUTE_SHORTDESC, str_append(&desc, fRect)->c_str());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawRRectCommand::DrawRRectCommand(const SkRRect& rrect, const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawRRect_OpType) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fRRect = rrect;
|
|
|
|
fPaint = paint;
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawRRectCommand::execute(SkCanvas* canvas) const { canvas->drawRRect(fRRect, fPaint); }
|
2013-01-02 20:20:31 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawRRectCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_rrect(canvas, fRRect);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawRRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_COORDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
make_json_rrect(writer, fRRect);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawDRRectCommand::DrawDRRectCommand(const SkRRect& outer,
|
|
|
|
const SkRRect& inner,
|
|
|
|
const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawDRRect_OpType) {
|
2014-02-24 17:28:55 +00:00
|
|
|
fOuter = outer;
|
|
|
|
fInner = inner;
|
|
|
|
fPaint = paint;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawDRRectCommand::execute(SkCanvas* canvas) const {
|
2014-02-24 17:28:55 +00:00
|
|
|
canvas->drawDRRect(fOuter, fInner, fPaint);
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawDRRectCommand::render(SkCanvas* canvas) const {
|
2014-02-24 17:28:55 +00:00
|
|
|
render_drrect(canvas, fOuter, fInner);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawDRRectCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_OUTER);
|
2019-03-20 16:59:00 +00:00
|
|
|
make_json_rrect(writer, fOuter);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_INNER);
|
2019-03-20 16:59:00 +00:00
|
|
|
make_json_rrect(writer, fInner);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPaint(writer, fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawShadowCommand::DrawShadowCommand(const SkPath& path, const SkDrawShadowRec& rec)
|
2018-04-12 16:45:58 +00:00
|
|
|
: INHERITED(kDrawShadow_OpType) {
|
2019-03-20 16:59:00 +00:00
|
|
|
fPath = path;
|
2018-04-12 16:45:58 +00:00
|
|
|
fShadowRec = rec;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawShadowCommand::execute(SkCanvas* canvas) const {
|
2018-04-12 16:45:58 +00:00
|
|
|
canvas->private_draw_shadow_rec(fPath, fShadowRec);
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
bool DrawShadowCommand::render(SkCanvas* canvas) const {
|
2018-04-12 16:45:58 +00:00
|
|
|
render_shadow(canvas, fPath, fShadowRec);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawShadowCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2018-04-12 16:45:58 +00:00
|
|
|
|
|
|
|
bool geometricOnly = SkToBool(fShadowRec.fFlags & SkShadowFlags::kGeometricOnly_ShadowFlag);
|
|
|
|
bool transparentOccluder =
|
|
|
|
SkToBool(fShadowRec.fFlags & SkShadowFlags::kTransparentOccluder_ShadowFlag);
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PATH);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPath(writer, fPath);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_ZPLANE);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPoint3(writer, fShadowRec.fZPlaneParams);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_LIGHTPOSITION);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonPoint3(writer, fShadowRec.fLightPos);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendFloat(DEBUGCANVAS_ATTRIBUTE_LIGHTRADIUS, fShadowRec.fLightRadius);
|
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_AMBIENTCOLOR);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonColor(writer, fShadowRec.fAmbientColor);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_SPOTCOLOR);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonColor(writer, fShadowRec.fSpotColor);
|
2019-03-20 18:02:32 +00:00
|
|
|
store_bool(writer, DEBUGCANVAS_SHADOWFLAG_TRANSPARENT_OCC, transparentOccluder, false);
|
|
|
|
store_bool(writer, DEBUGCANVAS_SHADOWFLAG_GEOMETRIC_ONLY, geometricOnly, false);
|
2018-04-12 16:45:58 +00:00
|
|
|
}
|
|
|
|
|
2018-05-29 18:55:50 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawEdgeAAQuadCommand::DrawEdgeAAQuadCommand(const SkRect& rect,
|
|
|
|
const SkPoint clip[],
|
|
|
|
SkCanvas::QuadAAFlags aa,
|
2019-08-27 19:25:49 +00:00
|
|
|
const SkColor4f& color,
|
2019-03-20 18:02:32 +00:00
|
|
|
SkBlendMode mode)
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
: INHERITED(kDrawEdgeAAQuad_OpType)
|
|
|
|
, fRect(rect)
|
|
|
|
, fHasClip(clip != nullptr)
|
|
|
|
, fAA(aa)
|
|
|
|
, fColor(color)
|
|
|
|
, fMode(mode) {
|
|
|
|
if (clip) {
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
|
|
|
fClip[i] = clip[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawEdgeAAQuadCommand::execute(SkCanvas* canvas) const {
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
canvas->experimental_DrawEdgeAAQuad(fRect, fHasClip ? fClip : nullptr, fAA, fColor, fMode);
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawEdgeAAImageSetCommand::DrawEdgeAAImageSetCommand(const SkCanvas::ImageSetEntry set[],
|
|
|
|
int count,
|
|
|
|
const SkPoint dstClips[],
|
|
|
|
const SkMatrix preViewMatrices[],
|
|
|
|
const SkPaint* paint,
|
|
|
|
SkCanvas::SrcRectConstraint constraint)
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
: INHERITED(kDrawEdgeAAImageSet_OpType)
|
|
|
|
, fSet(count)
|
|
|
|
, fCount(count)
|
|
|
|
, fPaint(paint)
|
|
|
|
, fConstraint(constraint) {
|
|
|
|
int totalDstClipCount, totalMatrixCount;
|
|
|
|
SkCanvasPriv::GetDstClipAndMatrixCounts(set, count, &totalDstClipCount, &totalMatrixCount);
|
|
|
|
|
|
|
|
std::copy_n(set, count, fSet.get());
|
|
|
|
fDstClips.reset(totalDstClipCount);
|
|
|
|
std::copy_n(dstClips, totalDstClipCount, fDstClips.get());
|
|
|
|
fPreViewMatrices.reset(totalMatrixCount);
|
|
|
|
std::copy_n(preViewMatrices, totalMatrixCount, fPreViewMatrices.get());
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawEdgeAAImageSetCommand::execute(SkCanvas* canvas) const {
|
2019-03-20 16:59:00 +00:00
|
|
|
canvas->experimental_DrawEdgeAAImageSet(fSet.get(),
|
|
|
|
fCount,
|
|
|
|
fDstClips.get(),
|
|
|
|
fPreViewMatrices.get(),
|
|
|
|
fPaint.getMaybeNull(),
|
|
|
|
fConstraint);
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawDrawableCommand::DrawDrawableCommand(SkDrawable* drawable, const SkMatrix* matrix)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawDrawable_OpType), fDrawable(SkRef(drawable)), fMatrix(matrix) {}
|
2018-05-29 18:55:50 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawDrawableCommand::execute(SkCanvas* canvas) const {
|
2018-05-29 18:55:50 +00:00
|
|
|
canvas->drawDrawable(fDrawable.get(), fMatrix.getMaybeNull());
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawVerticesCommand::DrawVerticesCommand(sk_sp<SkVertices> vertices,
|
|
|
|
SkBlendMode bmode,
|
|
|
|
const SkPaint& paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawVertices_OpType)
|
|
|
|
, fVertices(std::move(vertices))
|
|
|
|
, fBlendMode(bmode)
|
|
|
|
, fPaint(paint) {}
|
2013-03-25 11:50:42 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawVerticesCommand::execute(SkCanvas* canvas) const {
|
2017-03-17 16:09:04 +00:00
|
|
|
canvas->drawVertices(fVertices, fBlendMode, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2018-05-29 15:23:35 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
DrawAtlasCommand::DrawAtlasCommand(const SkImage* image,
|
|
|
|
const SkRSXform xform[],
|
|
|
|
const SkRect tex[],
|
|
|
|
const SkColor colors[],
|
|
|
|
int count,
|
|
|
|
SkBlendMode bmode,
|
|
|
|
const SkRect* cull,
|
|
|
|
const SkPaint* paint)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kDrawAtlas_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fXform(xform, count)
|
|
|
|
, fTex(tex, count)
|
|
|
|
, fColors(colors, colors ? count : 0)
|
|
|
|
, fBlendMode(bmode)
|
|
|
|
, fCull(cull)
|
|
|
|
, fPaint(paint) {}
|
2018-05-29 15:23:35 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void DrawAtlasCommand::execute(SkCanvas* canvas) const {
|
2019-03-20 16:59:00 +00:00
|
|
|
canvas->drawAtlas(fImage.get(),
|
|
|
|
fXform.begin(),
|
|
|
|
fTex.begin(),
|
|
|
|
fColors.isEmpty() ? nullptr : fColors.begin(),
|
|
|
|
fXform.count(),
|
|
|
|
fBlendMode,
|
|
|
|
fCull.getMaybeNull(),
|
|
|
|
fPaint.getMaybeNull());
|
2018-05-29 15:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
RestoreCommand::RestoreCommand() : INHERITED(kRestore_OpType) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void RestoreCommand::execute(SkCanvas* canvas) const { canvas->restore(); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
SaveCommand::SaveCommand() : INHERITED(kSave_OpType) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void SaveCommand::execute(SkCanvas* canvas) const { canvas->save(); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
SaveLayerCommand::SaveLayerCommand(const SkCanvas::SaveLayerRec& rec)
|
2019-03-20 16:59:00 +00:00
|
|
|
: INHERITED(kSaveLayer_OpType)
|
|
|
|
, fBounds(rec.fBounds)
|
|
|
|
, fPaint(rec.fPaint)
|
|
|
|
, fBackdrop(SkSafeRef(rec.fBackdrop))
|
|
|
|
, fSaveLayerFlags(rec.fSaveLayerFlags) {}
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void SaveLayerCommand::execute(SkCanvas* canvas) const {
|
2019-03-20 16:59:00 +00:00
|
|
|
canvas->saveLayer(
|
|
|
|
SkCanvas::SaveLayerRec(fBounds.getMaybeNull(), fPaint.getMaybeNull(), fSaveLayerFlags));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void SaveLayerCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2018-05-29 17:38:07 +00:00
|
|
|
if (fBounds.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_BOUNDS);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonRect(writer, *fBounds);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2018-05-29 17:38:07 +00:00
|
|
|
if (fPaint.isValid()) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_PAINT);
|
2019-01-28 19:31:18 +00:00
|
|
|
MakeJsonPaint(writer, *fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
if (fBackdrop != nullptr) {
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.beginObject(DEBUGCANVAS_ATTRIBUTE_BACKDROP);
|
2019-01-28 18:41:19 +00:00
|
|
|
flatten(fBackdrop.get(), writer, urlDataManager);
|
2019-03-20 16:59:00 +00:00
|
|
|
writer.endObject(); // backdrop
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
if (fSaveLayerFlags != 0) {
|
|
|
|
SkDebugf("unsupported: saveLayer flags\n");
|
|
|
|
SkASSERT(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
SetMatrixCommand::SetMatrixCommand(const SkMatrix& matrix) : INHERITED(kSetMatrix_OpType) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fMatrix = matrix;
|
2014-10-16 21:28:28 +00:00
|
|
|
}
|
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void SetMatrixCommand::execute(SkCanvas* canvas) const { canvas->setMatrix(fMatrix); }
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2019-03-20 18:02:32 +00:00
|
|
|
void SetMatrixCommand::toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const {
|
2019-01-28 18:41:19 +00:00
|
|
|
INHERITED::toJSON(writer, urlDataManager);
|
2019-03-20 18:02:32 +00:00
|
|
|
writer.appendName(DEBUGCANVAS_ATTRIBUTE_MATRIX);
|
2019-03-20 16:59:00 +00:00
|
|
|
MakeJsonMatrix(writer, fMatrix);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|