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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkDrawCommand.h"
|
2016-02-17 19:20:26 +00:00
|
|
|
|
2018-10-12 15:42:02 +00:00
|
|
|
#include <algorithm>
|
2017-01-11 17:44:43 +00:00
|
|
|
#include "SkAutoMalloc.h"
|
2018-10-12 15:42:02 +00:00
|
|
|
#include "SkClipOpPriv.h"
|
2016-02-10 13:40:46 +00:00
|
|
|
#include "SkColorFilter.h"
|
|
|
|
#include "SkDashPathEffect.h"
|
2018-05-29 18:55:50 +00:00
|
|
|
#include "SkDrawable.h"
|
2016-02-10 13:40:46 +00:00
|
|
|
#include "SkImageFilter.h"
|
2016-05-04 18:06:28 +00:00
|
|
|
#include "SkJsonWriteBuffer.h"
|
2018-10-12 15:42:02 +00:00
|
|
|
#include "SkLatticeIter.h"
|
2018-01-23 20:29:32 +00:00
|
|
|
#include "SkMaskFilterBase.h"
|
2016-02-10 13:40:46 +00:00
|
|
|
#include "SkPaintDefaults.h"
|
|
|
|
#include "SkPathEffect.h"
|
2015-02-13 19:13:00 +00:00
|
|
|
#include "SkPicture.h"
|
2018-08-08 21:03:39 +00:00
|
|
|
#include "SkPngEncoder.h"
|
2017-12-06 21:09:20 +00:00
|
|
|
#include "SkReadBuffer.h"
|
2018-01-08 22:09:54 +00:00
|
|
|
#include "SkRectPriv.h"
|
2018-10-12 15:42:02 +00:00
|
|
|
#include "SkShadowFlags.h"
|
2018-10-12 14:22:49 +00:00
|
|
|
#include "SkTHash.h"
|
2018-10-12 15:42:02 +00:00
|
|
|
#include "SkTextBlobPriv.h"
|
2016-02-10 13:40:46 +00:00
|
|
|
#include "SkTypeface.h"
|
|
|
|
#include "SkWriteBuffer.h"
|
|
|
|
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command"
|
2016-02-23 14:53:37 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_VISIBLE "visible"
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
|
2016-07-13 21:05:28 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS "drawDepthTranslation"
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords"
|
2016-08-25 18:10:41 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_HINTING "hinting"
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_PATH "path"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_TEXT "text"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_COLOR "color"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_ALPHA "alpha"
|
2017-06-06 20:58:40 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_BLENDMODE "blendMode"
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_STYLE "style"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH "strokeWidth"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER "strokeMiter"
|
2016-02-10 22:05:02 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN "strokeJoin"
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_CAP "cap"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS "antiAlias"
|
2016-02-10 22:05:02 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_DITHER "dither"
|
2017-06-23 18:35:07 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_FAKEBOLDTEXT "fakeBoldText"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LINEARTEXT "linearText"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_SUBPIXELTEXT "subpixelText"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_DEVKERNTEXT "devKernText"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LCDRENDERTEXT "lcdRenderText"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_EMBEDDEDBITMAPTEXT "embeddedBitmapText"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_AUTOHINTING "forceAutoHinting"
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_REGION "region"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_REGIONOP "op"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_EDGESTYLE "edgeStyle"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_DEVICEREGION "deviceRegion"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_BLUR "blur"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_SIGMA "sigma"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_QUALITY "quality"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_DASHING "dashing"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_PHASE "phase"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_VERBS "verbs"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_NAME "name"
|
2016-02-11 18:35:21 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_DATA "data"
|
2016-05-04 18:06:28 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_VALUES "values"
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_SHADER "shader"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode"
|
2016-02-10 22:05:02 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LOOPER "looper"
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_IMAGE "image"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_SRC "src"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_DST "dst"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_CENTER "center"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_STRICT "strict"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_DESCRIPTION "description"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_X "x"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_Y "y"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_RUNS "runs"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_POSITIONS "positions"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_FONT "font"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface"
|
2016-02-10 22:05:02 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality"
|
2016-08-19 18:25:19 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE "startAngle"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE "sweepAngle"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_USECENTER "useCenter"
|
2016-06-30 16:18:27 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC "shortDesc"
|
2016-08-29 16:15:33 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_UNIQUE_ID "uniqueID"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_WIDTH "width"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_HEIGHT "height"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_ALPHA "alpha"
|
2017-01-12 21:20:50 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LATTICE "lattice"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LATTICEXCOUNT "xCount"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LATTICEYCOUNT "yCount"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LATTICEXDIVS "xDivs"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LATTICEYDIVS "yDivs"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LATTICEFLAGS "flags"
|
2018-04-12 16:45:58 +00:00
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_ZPLANE "zPlane"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LIGHTPOSITION "lightPositions"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_AMBIENTCOLOR "ambientColor"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_SPOTCOLOR "spotColor"
|
|
|
|
#define SKDEBUGCANVAS_ATTRIBUTE_LIGHTRADIUS "lightRadius"
|
2016-06-29 18:36:34 +00:00
|
|
|
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_VERB_MOVE "move"
|
|
|
|
#define SKDEBUGCANVAS_VERB_LINE "line"
|
|
|
|
#define SKDEBUGCANVAS_VERB_QUAD "quad"
|
|
|
|
#define SKDEBUGCANVAS_VERB_CUBIC "cubic"
|
|
|
|
#define SKDEBUGCANVAS_VERB_CONIC "conic"
|
|
|
|
#define SKDEBUGCANVAS_VERB_CLOSE "close"
|
|
|
|
|
|
|
|
#define SKDEBUGCANVAS_STYLE_FILL "fill"
|
|
|
|
#define SKDEBUGCANVAS_STYLE_STROKE "stroke"
|
|
|
|
#define SKDEBUGCANVAS_STYLE_STROKEANDFILL "strokeAndFill"
|
|
|
|
|
|
|
|
#define SKDEBUGCANVAS_POINTMODE_POINTS "points"
|
|
|
|
#define SKDEBUGCANVAS_POINTMODE_LINES "lines"
|
|
|
|
#define SKDEBUGCANVAS_POINTMODE_POLYGON "polygon"
|
|
|
|
|
|
|
|
#define SKDEBUGCANVAS_REGIONOP_DIFFERENCE "difference"
|
|
|
|
#define SKDEBUGCANVAS_REGIONOP_INTERSECT "intersect"
|
|
|
|
#define SKDEBUGCANVAS_REGIONOP_UNION "union"
|
|
|
|
#define SKDEBUGCANVAS_REGIONOP_XOR "xor"
|
|
|
|
#define SKDEBUGCANVAS_REGIONOP_REVERSE_DIFFERENCE "reverseDifference"
|
|
|
|
#define SKDEBUGCANVAS_REGIONOP_REPLACE "replace"
|
|
|
|
|
|
|
|
#define SKDEBUGCANVAS_BLURSTYLE_NORMAL "normal"
|
|
|
|
#define SKDEBUGCANVAS_BLURSTYLE_SOLID "solid"
|
|
|
|
#define SKDEBUGCANVAS_BLURSTYLE_OUTER "outer"
|
|
|
|
#define SKDEBUGCANVAS_BLURSTYLE_INNER "inner"
|
|
|
|
|
|
|
|
#define SKDEBUGCANVAS_BLURQUALITY_LOW "low"
|
|
|
|
#define SKDEBUGCANVAS_BLURQUALITY_HIGH "high"
|
|
|
|
|
|
|
|
#define SKDEBUGCANVAS_FILLTYPE_WINDING "winding"
|
|
|
|
#define SKDEBUGCANVAS_FILLTYPE_EVENODD "evenOdd"
|
|
|
|
#define SKDEBUGCANVAS_FILLTYPE_INVERSEWINDING "inverseWinding"
|
|
|
|
#define SKDEBUGCANVAS_FILLTYPE_INVERSEEVENODD "inverseEvenOdd"
|
|
|
|
|
|
|
|
#define SKDEBUGCANVAS_CAP_BUTT "butt"
|
|
|
|
#define SKDEBUGCANVAS_CAP_ROUND "round"
|
|
|
|
#define SKDEBUGCANVAS_CAP_SQUARE "square"
|
|
|
|
|
2016-02-10 22:05:02 +00:00
|
|
|
#define SKDEBUGCANVAS_MITER_JOIN "miter"
|
|
|
|
#define SKDEBUGCANVAS_ROUND_JOIN "round"
|
|
|
|
#define SKDEBUGCANVAS_BEVEL_JOIN "bevel"
|
|
|
|
|
2016-02-10 13:40:46 +00:00
|
|
|
#define SKDEBUGCANVAS_COLORTYPE_ARGB4444 "ARGB4444"
|
|
|
|
#define SKDEBUGCANVAS_COLORTYPE_RGBA8888 "RGBA8888"
|
|
|
|
#define SKDEBUGCANVAS_COLORTYPE_BGRA8888 "BGRA8888"
|
|
|
|
#define SKDEBUGCANVAS_COLORTYPE_565 "565"
|
|
|
|
#define SKDEBUGCANVAS_COLORTYPE_GRAY8 "Gray8"
|
|
|
|
#define SKDEBUGCANVAS_COLORTYPE_INDEX8 "Index8"
|
|
|
|
#define SKDEBUGCANVAS_COLORTYPE_ALPHA8 "Alpha8"
|
|
|
|
|
|
|
|
#define SKDEBUGCANVAS_ALPHATYPE_OPAQUE "opaque"
|
|
|
|
#define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul"
|
|
|
|
#define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul"
|
2016-08-29 16:15:33 +00:00
|
|
|
#define SKDEBUGCANVAS_ALPHATYPE_UNKNOWN "unknown"
|
2016-02-10 13:40:46 +00:00
|
|
|
|
2016-02-10 22:05:02 +00:00
|
|
|
#define SKDEBUGCANVAS_FILTERQUALITY_NONE "none"
|
|
|
|
#define SKDEBUGCANVAS_FILTERQUALITY_LOW "low"
|
|
|
|
#define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium"
|
|
|
|
#define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high"
|
|
|
|
|
2016-08-25 18:10:41 +00:00
|
|
|
#define SKDEBUGCANVAS_HINTING_NONE "none"
|
|
|
|
#define SKDEBUGCANVAS_HINTING_SLIGHT "slight"
|
|
|
|
#define SKDEBUGCANVAS_HINTING_NORMAL "normal"
|
|
|
|
#define SKDEBUGCANVAS_HINTING_FULL "full"
|
|
|
|
|
2018-04-12 16:45:58 +00:00
|
|
|
#define SKDEBUGCANVAS_SHADOWFLAG_TRANSPARENT_OCC "transparentOccluder"
|
|
|
|
#define SKDEBUGCANVAS_SHADOWFLAG_GEOMETRIC_ONLY "geometricOnly"
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
SkDrawCommand::SkDrawCommand(OpType type)
|
|
|
|
: fOpType(type)
|
2013-05-29 13:24:23 +00:00
|
|
|
, fVisible(true) {
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
const char* SkDrawCommand::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";
|
2018-10-12 15:42:02 +00:00
|
|
|
case kDrawImageSet_OpType: return "DrawImageSet";
|
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";
|
2016-07-07 23:32:51 +00:00
|
|
|
case kDrawTextRSXform_OpType: return "DrawTextRSXform";
|
2015-02-13 19:13:00 +00:00
|
|
|
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";
|
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
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value result;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType);
|
2016-02-23 14:53:37 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_VISIBLE] = Json::Value(this->isVisible());
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
static const SkScalar kInsetFrac = 0.9f; // Leave a border around object
|
|
|
|
|
|
|
|
canvas->translate(size.fWidth/2.0f, size.fHeight/2.0f);
|
|
|
|
if (bounds.width() > bounds.height()) {
|
|
|
|
canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.width()),
|
|
|
|
SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.width()));
|
|
|
|
} else {
|
|
|
|
canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.height()),
|
|
|
|
SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.height()));
|
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width();
|
|
|
|
SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height();
|
|
|
|
|
|
|
|
if (input.width() > input.height()) {
|
|
|
|
yScale *= input.height() / (float) input.width();
|
|
|
|
} else {
|
|
|
|
xScale *= input.width() / (float) input.height();
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2015-09-24 13:56:27 +00:00
|
|
|
SkISize block = {
|
|
|
|
canvas->imageInfo().width()/kNumBlocks,
|
|
|
|
canvas->imageInfo().height()/kNumBlocks
|
|
|
|
};
|
|
|
|
for (int y = 0; y < kNumBlocks; ++y) {
|
|
|
|
for (int x = 0; x < kNumBlocks; ++x) {
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setColor((x+y)%2 ? SK_ColorLTGRAY : SK_ColorDKGRAY);
|
|
|
|
SkRect r = SkRect::MakeXYWH(SkIntToScalar(x*block.width()),
|
|
|
|
SkIntToScalar(y*block.height()),
|
|
|
|
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) {
|
2013-06-06 23:59:28 +00:00
|
|
|
SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1,
|
|
|
|
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;
|
|
|
|
rec.fSpotColor = SK_ColorBLACK;
|
|
|
|
canvas->private_draw_shadow_rec(path, rec);
|
|
|
|
}
|
|
|
|
|
2017-06-06 20:58:40 +00:00
|
|
|
static const char* const gBlendModeMap[] = {
|
|
|
|
"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",
|
|
|
|
};
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
void apply_paint_blend_mode(const SkPaint& paint, Json::Value* target) {
|
|
|
|
const auto mode = paint.getBlendMode();
|
|
|
|
if (mode != SkBlendMode::kSrcOver) {
|
|
|
|
SkASSERT(static_cast<size_t>(mode) < SK_ARRAY_COUNT(gBlendModeMap));
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_BLENDMODE] =
|
|
|
|
Json::Value(gBlendModeMap[static_cast<size_t>(mode)]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-06 23:59:28 +00:00
|
|
|
};
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonColor(const SkColor color) {
|
2016-02-10 22:05:02 +00:00
|
|
|
Json::Value result(Json::arrayValue);
|
|
|
|
result.append(Json::Value(SkColorGetA(color)));
|
|
|
|
result.append(Json::Value(SkColorGetR(color)));
|
|
|
|
result.append(Json::Value(SkColorGetG(color)));
|
|
|
|
result.append(Json::Value(SkColorGetB(color)));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-09-25 20:15:58 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonColor4f(const SkColor4f& color) {
|
|
|
|
Json::Value result(Json::arrayValue);
|
|
|
|
result.append(Json::Value(color.fA));
|
|
|
|
result.append(Json::Value(color.fR));
|
|
|
|
result.append(Json::Value(color.fG));
|
|
|
|
result.append(Json::Value(color.fB));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonPoint(const SkPoint& point) {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value result(Json::arrayValue);
|
|
|
|
result.append(Json::Value(point.x()));
|
|
|
|
result.append(Json::Value(point.y()));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonPoint(SkScalar x, SkScalar y) {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value result(Json::arrayValue);
|
|
|
|
result.append(Json::Value(x));
|
|
|
|
result.append(Json::Value(y));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-04-12 16:45:58 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonPoint3(const SkPoint3& point) {
|
|
|
|
Json::Value result(Json::arrayValue);
|
|
|
|
result.append(Json::Value(point.x()));
|
|
|
|
result.append(Json::Value(point.y()));
|
|
|
|
result.append(Json::Value(point.z()));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonRect(const SkRect& rect) {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value result(Json::arrayValue);
|
|
|
|
result.append(Json::Value(rect.left()));
|
|
|
|
result.append(Json::Value(rect.top()));
|
|
|
|
result.append(Json::Value(rect.right()));
|
|
|
|
result.append(Json::Value(rect.bottom()));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-03-03 19:39:38 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonIRect(const SkIRect& rect) {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value result(Json::arrayValue);
|
|
|
|
result.append(Json::Value(rect.left()));
|
|
|
|
result.append(Json::Value(rect.top()));
|
|
|
|
result.append(Json::Value(rect.right()));
|
|
|
|
result.append(Json::Value(rect.bottom()));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Json::Value make_json_rrect(const SkRRect& rrect) {
|
|
|
|
Json::Value result(Json::arrayValue);
|
2016-05-04 18:06:28 +00:00
|
|
|
result.append(SkDrawCommand::MakeJsonRect(rrect.rect()));
|
|
|
|
result.append(SkDrawCommand::MakeJsonPoint(rrect.radii(SkRRect::kUpperLeft_Corner)));
|
|
|
|
result.append(SkDrawCommand::MakeJsonPoint(rrect.radii(SkRRect::kUpperRight_Corner)));
|
|
|
|
result.append(SkDrawCommand::MakeJsonPoint(rrect.radii(SkRRect::kLowerRight_Corner)));
|
|
|
|
result.append(SkDrawCommand::MakeJsonPoint(rrect.radii(SkRRect::kLowerLeft_Corner)));
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-03-03 19:39:38 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonMatrix(const SkMatrix& matrix) {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value result(Json::arrayValue);
|
|
|
|
Json::Value row1(Json::arrayValue);
|
|
|
|
row1.append(Json::Value(matrix[0]));
|
|
|
|
row1.append(Json::Value(matrix[1]));
|
|
|
|
row1.append(Json::Value(matrix[2]));
|
|
|
|
result.append(row1);
|
|
|
|
Json::Value row2(Json::arrayValue);
|
|
|
|
row2.append(Json::Value(matrix[3]));
|
|
|
|
row2.append(Json::Value(matrix[4]));
|
|
|
|
row2.append(Json::Value(matrix[5]));
|
|
|
|
result.append(row2);
|
|
|
|
Json::Value row3(Json::arrayValue);
|
|
|
|
row3.append(Json::Value(matrix[6]));
|
|
|
|
row3.append(Json::Value(matrix[7]));
|
|
|
|
row3.append(Json::Value(matrix[8]));
|
|
|
|
result.append(row3);
|
|
|
|
return result;
|
|
|
|
}
|
2016-02-10 22:05:02 +00:00
|
|
|
|
2016-07-13 21:05:28 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonScalar(SkScalar z) {
|
|
|
|
Json::Value result(z);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonPath(const SkPath& path) {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value result(Json::objectValue);
|
|
|
|
switch (path.getFillType()) {
|
|
|
|
case SkPath::kWinding_FillType:
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_WINDING;
|
|
|
|
break;
|
|
|
|
case SkPath::kEvenOdd_FillType:
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_EVENODD;
|
|
|
|
break;
|
|
|
|
case SkPath::kInverseWinding_FillType:
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_INVERSEWINDING;
|
|
|
|
break;
|
|
|
|
case SkPath::kInverseEvenOdd_FillType:
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_INVERSEEVENODD;
|
|
|
|
break;
|
2016-03-29 16:03:52 +00:00
|
|
|
}
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value verbs(Json::arrayValue);
|
|
|
|
SkPath::Iter iter(path, false);
|
|
|
|
SkPoint pts[4];
|
|
|
|
SkPath::Verb verb;
|
|
|
|
while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
|
|
|
|
switch (verb) {
|
|
|
|
case SkPath::kLine_Verb: {
|
|
|
|
Json::Value line(Json::objectValue);
|
2016-05-04 18:06:28 +00:00
|
|
|
line[SKDEBUGCANVAS_VERB_LINE] = MakeJsonPoint(pts[1]);
|
2016-02-10 13:40:46 +00:00
|
|
|
verbs.append(line);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kQuad_Verb: {
|
|
|
|
Json::Value quad(Json::objectValue);
|
|
|
|
Json::Value coords(Json::arrayValue);
|
2016-05-04 18:06:28 +00:00
|
|
|
coords.append(MakeJsonPoint(pts[1]));
|
|
|
|
coords.append(MakeJsonPoint(pts[2]));
|
2016-02-10 13:40:46 +00:00
|
|
|
quad[SKDEBUGCANVAS_VERB_QUAD] = coords;
|
|
|
|
verbs.append(quad);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kCubic_Verb: {
|
|
|
|
Json::Value cubic(Json::objectValue);
|
|
|
|
Json::Value coords(Json::arrayValue);
|
2016-05-04 18:06:28 +00:00
|
|
|
coords.append(MakeJsonPoint(pts[1]));
|
|
|
|
coords.append(MakeJsonPoint(pts[2]));
|
|
|
|
coords.append(MakeJsonPoint(pts[3]));
|
2016-02-10 13:40:46 +00:00
|
|
|
cubic[SKDEBUGCANVAS_VERB_CUBIC] = coords;
|
|
|
|
verbs.append(cubic);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kConic_Verb: {
|
|
|
|
Json::Value conic(Json::objectValue);
|
|
|
|
Json::Value coords(Json::arrayValue);
|
2016-05-04 18:06:28 +00:00
|
|
|
coords.append(MakeJsonPoint(pts[1]));
|
|
|
|
coords.append(MakeJsonPoint(pts[2]));
|
2016-02-10 13:40:46 +00:00
|
|
|
coords.append(Json::Value(iter.conicWeight()));
|
|
|
|
conic[SKDEBUGCANVAS_VERB_CONIC] = coords;
|
|
|
|
verbs.append(conic);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kMove_Verb: {
|
|
|
|
Json::Value move(Json::objectValue);
|
2016-05-04 18:06:28 +00:00
|
|
|
move[SKDEBUGCANVAS_VERB_MOVE] = MakeJsonPoint(pts[0]);
|
2016-02-10 13:40:46 +00:00
|
|
|
verbs.append(move);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPath::kClose_Verb:
|
|
|
|
verbs.append(Json::Value(SKDEBUGCANVAS_VERB_CLOSE));
|
|
|
|
break;
|
|
|
|
case SkPath::kDone_Verb:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_VERBS] = verbs;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonRegion(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);
|
|
|
|
return MakeJsonPath(path);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 14:00:50 +00:00
|
|
|
static Json::Value make_json_regionop(SkClipOp op) {
|
2016-02-10 13:40:46 +00:00
|
|
|
switch (op) {
|
2016-12-09 14:00:50 +00:00
|
|
|
case kDifference_SkClipOp:
|
2016-02-10 13:40:46 +00:00
|
|
|
return Json::Value(SKDEBUGCANVAS_REGIONOP_DIFFERENCE);
|
2016-12-09 14:00:50 +00:00
|
|
|
case kIntersect_SkClipOp:
|
2016-02-10 13:40:46 +00:00
|
|
|
return Json::Value(SKDEBUGCANVAS_REGIONOP_INTERSECT);
|
2016-12-09 14:00:50 +00:00
|
|
|
case kUnion_SkClipOp:
|
2016-02-10 13:40:46 +00:00
|
|
|
return Json::Value(SKDEBUGCANVAS_REGIONOP_UNION);
|
2016-12-09 14:00:50 +00:00
|
|
|
case kXOR_SkClipOp:
|
2016-02-10 13:40:46 +00:00
|
|
|
return Json::Value(SKDEBUGCANVAS_REGIONOP_XOR);
|
2016-12-09 14:00:50 +00:00
|
|
|
case kReverseDifference_SkClipOp:
|
2016-02-10 13:40:46 +00:00
|
|
|
return Json::Value(SKDEBUGCANVAS_REGIONOP_REVERSE_DIFFERENCE);
|
2016-12-09 14:00:50 +00:00
|
|
|
case kReplace_SkClipOp:
|
2016-02-10 13:40:46 +00:00
|
|
|
return Json::Value(SKDEBUGCANVAS_REGIONOP_REPLACE);
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
|
|
|
return Json::Value("<invalid region op>");
|
2018-11-30 20:33:19 +00:00
|
|
|
}
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Json::Value make_json_pointmode(SkCanvas::PointMode mode) {
|
|
|
|
switch (mode) {
|
|
|
|
case SkCanvas::kPoints_PointMode:
|
|
|
|
return Json::Value(SKDEBUGCANVAS_POINTMODE_POINTS);
|
|
|
|
case SkCanvas::kLines_PointMode:
|
|
|
|
return Json::Value(SKDEBUGCANVAS_POINTMODE_LINES);
|
2016-03-29 16:03:52 +00:00
|
|
|
case SkCanvas::kPolygon_PointMode:
|
2016-02-10 13:40:46 +00:00
|
|
|
return Json::Value(SKDEBUGCANVAS_POINTMODE_POLYGON);
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
|
|
|
return Json::Value("<invalid point mode>");
|
2018-11-30 20:33:19 +00:00
|
|
|
}
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2016-03-29 16:03:52 +00:00
|
|
|
static void store_scalar(Json::Value* target, const char* key, SkScalar value,
|
2016-02-10 20:10:00 +00:00
|
|
|
SkScalar defaultValue) {
|
2016-02-10 13:40:46 +00:00
|
|
|
if (value != defaultValue) {
|
|
|
|
(*target)[key] = Json::Value(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-10 20:10:00 +00:00
|
|
|
static void store_bool(Json::Value* target, const char* key, bool value, bool defaultValue) {
|
2016-02-10 13:40:46 +00:00
|
|
|
if (value != defaultValue) {
|
|
|
|
(*target)[key] = Json::Value(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 16:03:52 +00:00
|
|
|
static void encode_data(const void* bytes, size_t count, const char* contentType,
|
2016-02-11 18:35:21 +00:00
|
|
|
UrlDataManager& urlDataManager, Json::Value* target) {
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> data(SkData::MakeWithCopy(bytes, count));
|
|
|
|
SkString url = urlDataManager.addData(data.get(), contentType);
|
2016-02-11 18:35:21 +00:00
|
|
|
*target = Json::Value(url.c_str());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
void SkDrawCommand::flatten(const SkFlattenable* flattenable, Json::Value* target,
|
|
|
|
UrlDataManager& urlDataManager) {
|
|
|
|
SkBinaryWriteBuffer buffer;
|
2016-02-11 18:35:21 +00:00
|
|
|
flattenable->flatten(buffer);
|
|
|
|
void* data = sk_malloc_throw(buffer.bytesWritten());
|
|
|
|
buffer.writeToMemory(data);
|
|
|
|
Json::Value jsonData;
|
|
|
|
encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlDataManager, &jsonData);
|
|
|
|
Json::Value jsonFlattenable;
|
|
|
|
jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME] = Json::Value(flattenable->getTypeName());
|
|
|
|
jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData;
|
2016-05-04 18:06:28 +00:00
|
|
|
|
|
|
|
SkJsonWriteBuffer jsonBuffer(&urlDataManager);
|
|
|
|
flattenable->flatten(jsonBuffer);
|
|
|
|
jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_VALUES] = jsonBuffer.getValue();
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
(*target) = jsonFlattenable;
|
|
|
|
sk_free(data);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
|
2018-08-08 21:03:39 +00:00
|
|
|
void SkDrawCommand::WritePNG(SkBitmap bitmap, SkWStream& out) {
|
|
|
|
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;
|
|
|
|
options.fZLibLevel = 1;
|
|
|
|
options.fFilterFlags = SkPngEncoder::FilterFlag::kNone;
|
|
|
|
SkPngEncoder::Encode(&out, pm, options);
|
2016-03-21 17:19:39 +00:00
|
|
|
}
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
bool SkDrawCommand::flatten(const SkImage& image, Json::Value* target,
|
|
|
|
UrlDataManager& urlDataManager) {
|
2016-03-21 17:19:39 +00:00
|
|
|
size_t rowBytes = 4 * image.width();
|
2017-01-11 17:44:43 +00:00
|
|
|
SkAutoMalloc buffer(rowBytes * image.height());
|
2016-03-29 16:03:52 +00:00
|
|
|
SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(),
|
2016-03-21 17:19:39 +00:00
|
|
|
kN32_SkColorType, kPremul_SkAlphaType);
|
|
|
|
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;
|
2018-08-08 21:03:39 +00:00
|
|
|
SkDrawCommand::WritePNG(bm, out);
|
2016-09-12 19:01:44 +00:00
|
|
|
sk_sp<SkData> encoded = out.detachAsData();
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value jsonData;
|
|
|
|
encode_data(encoded->data(), encoded->size(), "image/png", urlDataManager, &jsonData);
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData;
|
2016-02-10 13:40:46 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* color_type_name(SkColorType colorType) {
|
|
|
|
switch (colorType) {
|
|
|
|
case kARGB_4444_SkColorType:
|
|
|
|
return SKDEBUGCANVAS_COLORTYPE_ARGB4444;
|
|
|
|
case kRGBA_8888_SkColorType:
|
|
|
|
return SKDEBUGCANVAS_COLORTYPE_RGBA8888;
|
|
|
|
case kBGRA_8888_SkColorType:
|
|
|
|
return SKDEBUGCANVAS_COLORTYPE_BGRA8888;
|
|
|
|
case kRGB_565_SkColorType:
|
|
|
|
return SKDEBUGCANVAS_COLORTYPE_565;
|
|
|
|
case kGray_8_SkColorType:
|
|
|
|
return SKDEBUGCANVAS_COLORTYPE_GRAY8;
|
|
|
|
case kAlpha_8_SkColorType:
|
|
|
|
return SKDEBUGCANVAS_COLORTYPE_ALPHA8;
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
|
|
|
return SKDEBUGCANVAS_COLORTYPE_RGBA8888;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* alpha_type_name(SkAlphaType alphaType) {
|
|
|
|
switch (alphaType) {
|
|
|
|
case kOpaque_SkAlphaType:
|
|
|
|
return SKDEBUGCANVAS_ALPHATYPE_OPAQUE;
|
|
|
|
case kPremul_SkAlphaType:
|
|
|
|
return SKDEBUGCANVAS_ALPHATYPE_PREMUL;
|
|
|
|
case kUnpremul_SkAlphaType:
|
|
|
|
return SKDEBUGCANVAS_ALPHATYPE_UNPREMUL;
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
|
|
|
return SKDEBUGCANVAS_ALPHATYPE_OPAQUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
bool SkDrawCommand::flatten(const SkBitmap& bitmap, Json::Value* target,
|
|
|
|
UrlDataManager& urlDataManager) {
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image(SkImage::MakeFromBitmap(bitmap));
|
2016-02-10 13:40:46 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = Json::Value(color_type_name(bitmap.colorType()));
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = Json::Value(alpha_type_name(bitmap.alphaType()));
|
2016-02-11 18:35:21 +00:00
|
|
|
bool success = flatten(*image, target, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:10:41 +00:00
|
|
|
static void apply_paint_hinting(const SkPaint& paint, Json::Value* target) {
|
2018-11-08 00:54:33 +00:00
|
|
|
SkFontHinting hinting = (SkFontHinting)paint.getHinting();
|
2016-08-25 18:10:41 +00:00
|
|
|
if (hinting != SkPaintDefaults_Hinting) {
|
|
|
|
switch (hinting) {
|
2018-11-08 00:54:33 +00:00
|
|
|
case kNo_SkFontHinting:
|
2016-08-25 18:10:41 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_HINTING] = SKDEBUGCANVAS_HINTING_NONE;
|
|
|
|
break;
|
2018-11-08 00:54:33 +00:00
|
|
|
case kSlight_SkFontHinting:
|
2016-08-25 18:10:41 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_HINTING] = SKDEBUGCANVAS_HINTING_SLIGHT;
|
|
|
|
break;
|
2018-11-08 00:54:33 +00:00
|
|
|
case kNormal_SkFontHinting:
|
2016-08-25 18:10:41 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_HINTING] = SKDEBUGCANVAS_HINTING_NORMAL;
|
|
|
|
break;
|
2018-11-08 00:54:33 +00:00
|
|
|
case kFull_SkFontHinting:
|
2016-08-25 18:10:41 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_HINTING] = SKDEBUGCANVAS_HINTING_FULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-10 13:40:46 +00:00
|
|
|
static void apply_paint_color(const SkPaint& paint, Json::Value* target) {
|
|
|
|
SkColor color = paint.getColor();
|
|
|
|
if (color != SK_ColorBLACK) {
|
|
|
|
Json::Value colorValue(Json::arrayValue);
|
|
|
|
colorValue.append(Json::Value(SkColorGetA(color)));
|
|
|
|
colorValue.append(Json::Value(SkColorGetR(color)));
|
|
|
|
colorValue.append(Json::Value(SkColorGetG(color)));
|
|
|
|
colorValue.append(Json::Value(SkColorGetB(color)));
|
2018-11-30 20:33:19 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = colorValue;
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void apply_paint_style(const SkPaint& paint, Json::Value* target) {
|
|
|
|
SkPaint::Style style = paint.getStyle();
|
|
|
|
if (style != SkPaint::kFill_Style) {
|
|
|
|
switch (style) {
|
|
|
|
case SkPaint::kStroke_Style: {
|
|
|
|
Json::Value stroke(SKDEBUGCANVAS_STYLE_STROKE);
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = stroke;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SkPaint::kStrokeAndFill_Style: {
|
|
|
|
Json::Value strokeAndFill(SKDEBUGCANVAS_STYLE_STROKEANDFILL);
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = strokeAndFill;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: SkASSERT(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void apply_paint_cap(const SkPaint& paint, Json::Value* target) {
|
|
|
|
SkPaint::Cap cap = paint.getStrokeCap();
|
|
|
|
if (cap != SkPaint::kDefault_Cap) {
|
|
|
|
switch (cap) {
|
2016-02-10 22:05:02 +00:00
|
|
|
case SkPaint::kButt_Cap:
|
2016-02-10 13:40:46 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_CAP] = Json::Value(SKDEBUGCANVAS_CAP_BUTT);
|
|
|
|
break;
|
2016-02-10 22:05:02 +00:00
|
|
|
case SkPaint::kRound_Cap:
|
2016-02-10 13:40:46 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_CAP] = Json::Value(SKDEBUGCANVAS_CAP_ROUND);
|
|
|
|
break;
|
2016-02-10 22:05:02 +00:00
|
|
|
case SkPaint::kSquare_Cap:
|
2016-02-10 13:40:46 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_CAP] = Json::Value(SKDEBUGCANVAS_CAP_SQUARE);
|
|
|
|
break;
|
|
|
|
default: SkASSERT(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-10 22:05:02 +00:00
|
|
|
|
|
|
|
static void apply_paint_join(const SkPaint& paint, Json::Value* target) {
|
|
|
|
SkPaint::Join join = paint.getStrokeJoin();
|
|
|
|
if (join != SkPaint::kDefault_Join) {
|
|
|
|
switch (join) {
|
|
|
|
case SkPaint::kMiter_Join:
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_MITER_JOIN);
|
|
|
|
break;
|
|
|
|
case SkPaint::kRound_Join:
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_ROUND_JOIN);
|
|
|
|
break;
|
|
|
|
case SkPaint::kBevel_Join:
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_BEVEL_JOIN);
|
|
|
|
break;
|
|
|
|
default: SkASSERT(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void apply_paint_filterquality(const SkPaint& paint, Json::Value* target) {
|
|
|
|
SkFilterQuality quality = paint.getFilterQuality();
|
|
|
|
switch (quality) {
|
|
|
|
case kNone_SkFilterQuality:
|
|
|
|
break;
|
|
|
|
case kLow_SkFilterQuality:
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_FILTERQUALITY_LOW);
|
|
|
|
break;
|
|
|
|
case kMedium_SkFilterQuality:
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_FILTERQUALITY_MEDIUM);
|
|
|
|
break;
|
|
|
|
case kHigh_SkFilterQuality:
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_FILTERQUALITY_HIGH);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 16:03:52 +00:00
|
|
|
static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target,
|
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)) {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value blur(Json::objectValue);
|
|
|
|
blur[SKDEBUGCANVAS_ATTRIBUTE_SIGMA] = Json::Value(blurRec.fSigma);
|
|
|
|
switch (blurRec.fStyle) {
|
|
|
|
case SkBlurStyle::kNormal_SkBlurStyle:
|
2016-02-10 22:05:02 +00:00
|
|
|
blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_BLURSTYLE_NORMAL);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
case SkBlurStyle::kSolid_SkBlurStyle:
|
2016-02-10 22:05:02 +00:00
|
|
|
blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_BLURSTYLE_SOLID);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
case SkBlurStyle::kOuter_SkBlurStyle:
|
2016-02-10 22:05:02 +00:00
|
|
|
blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_BLURSTYLE_OUTER);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
case SkBlurStyle::kInner_SkBlurStyle:
|
2016-02-10 22:05:02 +00:00
|
|
|
blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value(
|
|
|
|
SKDEBUGCANVAS_BLURSTYLE_INNER);
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
SkASSERT(false);
|
|
|
|
}
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur;
|
|
|
|
} else {
|
|
|
|
Json::Value jsonMaskFilter;
|
2016-05-04 18:06:28 +00:00
|
|
|
SkDrawCommand::flatten(maskFilter, &jsonMaskFilter, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER] = jsonMaskFilter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 16:03:52 +00:00
|
|
|
static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target,
|
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) {
|
|
|
|
dashInfo.fIntervals = (SkScalar*) sk_malloc_throw(dashInfo.fCount * sizeof(SkScalar));
|
|
|
|
pathEffect->asADash(&dashInfo);
|
|
|
|
Json::Value dashing(Json::objectValue);
|
|
|
|
Json::Value intervals(Json::arrayValue);
|
|
|
|
for (int32_t i = 0; i < dashInfo.fCount; i++) {
|
|
|
|
intervals.append(Json::Value(dashInfo.fIntervals[i]));
|
|
|
|
}
|
|
|
|
sk_free(dashInfo.fIntervals);
|
|
|
|
dashing[SKDEBUGCANVAS_ATTRIBUTE_INTERVALS] = intervals;
|
|
|
|
dashing[SKDEBUGCANVAS_ATTRIBUTE_PHASE] = dashInfo.fPhase;
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_DASHING] = dashing;
|
|
|
|
} else {
|
|
|
|
Json::Value jsonPathEffect;
|
2016-05-04 18:06:28 +00:00
|
|
|
SkDrawCommand::flatten(pathEffect, &jsonPathEffect, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT] = jsonPathEffect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-29 16:03:52 +00:00
|
|
|
|
|
|
|
static void apply_paint_typeface(const SkPaint& paint, Json::Value* target,
|
2016-02-11 18:35:21 +00:00
|
|
|
UrlDataManager& urlDataManager) {
|
2016-02-10 13:40:46 +00:00
|
|
|
SkTypeface* typeface = paint.getTypeface();
|
|
|
|
if (typeface != nullptr) {
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value jsonTypeface;
|
|
|
|
SkDynamicMemoryWStream buffer;
|
|
|
|
typeface->serialize(&buffer);
|
|
|
|
void* data = sk_malloc_throw(buffer.bytesWritten());
|
|
|
|
buffer.copyTo(data);
|
|
|
|
Json::Value jsonData;
|
2016-03-29 16:03:52 +00:00
|
|
|
encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlDataManager,
|
2016-02-11 18:35:21 +00:00
|
|
|
&jsonData);
|
|
|
|
jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData;
|
|
|
|
sk_free(data);
|
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE] = jsonTypeface;
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 16:03:52 +00:00
|
|
|
static void apply_paint_shader(const SkPaint& paint, Json::Value* target,
|
2016-02-11 18:35:21 +00:00
|
|
|
UrlDataManager& urlDataManager) {
|
2016-02-10 13:40:46 +00:00
|
|
|
SkFlattenable* shader = paint.getShader();
|
|
|
|
if (shader != nullptr) {
|
|
|
|
Json::Value jsonShader;
|
2016-05-04 18:06:28 +00:00
|
|
|
SkDrawCommand::flatten(shader, &jsonShader, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_SHADER] = jsonShader;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
static void apply_paint_imagefilter(const SkPaint& paint, Json::Value* target,
|
|
|
|
UrlDataManager& urlDataManager) {
|
2016-02-10 13:40:46 +00:00
|
|
|
SkFlattenable* imageFilter = paint.getImageFilter();
|
|
|
|
if (imageFilter != nullptr) {
|
|
|
|
Json::Value jsonImageFilter;
|
2016-05-04 18:06:28 +00:00
|
|
|
SkDrawCommand::flatten(imageFilter, &jsonImageFilter, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER] = jsonImageFilter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 16:03:52 +00:00
|
|
|
static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target,
|
2016-02-11 18:35:21 +00:00
|
|
|
UrlDataManager& urlDataManager) {
|
2016-02-10 13:40:46 +00:00
|
|
|
SkFlattenable* colorFilter = paint.getColorFilter();
|
|
|
|
if (colorFilter != nullptr) {
|
|
|
|
Json::Value jsonColorFilter;
|
2016-05-04 18:06:28 +00:00
|
|
|
SkDrawCommand::flatten(colorFilter, &jsonColorFilter, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-29 16:03:52 +00:00
|
|
|
static void apply_paint_looper(const SkPaint& paint, Json::Value* target,
|
2016-02-11 18:35:21 +00:00
|
|
|
UrlDataManager& urlDataManager) {
|
2016-02-10 22:05:02 +00:00
|
|
|
SkFlattenable* looper = paint.getLooper();
|
|
|
|
if (looper != nullptr) {
|
|
|
|
Json::Value jsonLooper;
|
2016-05-04 18:06:28 +00:00
|
|
|
SkDrawCommand::flatten(looper, &jsonLooper, urlDataManager);
|
2016-02-10 22:05:02 +00:00
|
|
|
(*target)[SKDEBUGCANVAS_ATTRIBUTE_LOOPER] = jsonLooper;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-04 18:06:28 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonPaint(const SkPaint& paint, UrlDataManager& urlDataManager) {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value result(Json::objectValue);
|
|
|
|
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWidth(), 0.0f);
|
2016-03-29 16:03:52 +00:00
|
|
|
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMiter(),
|
2016-02-10 13:40:46 +00:00
|
|
|
SkPaintDefaults_MiterLimit);
|
|
|
|
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(), false);
|
2016-02-10 22:05:02 +00:00
|
|
|
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false);
|
2017-06-23 18:35:07 +00:00
|
|
|
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_FAKEBOLDTEXT, paint.isFakeBoldText(), false);
|
|
|
|
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_LINEARTEXT, paint.isLinearText(), false);
|
|
|
|
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_SUBPIXELTEXT, paint.isSubpixelText(), false);
|
|
|
|
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_LCDRENDERTEXT, paint.isLCDRenderText(), false);
|
|
|
|
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_EMBEDDEDBITMAPTEXT, paint.isEmbeddedBitmapText(), false);
|
|
|
|
store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_AUTOHINTING, paint.isAutohinted(), false);
|
|
|
|
//kGenA8FromLCD_Flag
|
|
|
|
|
2016-03-29 16:03:52 +00:00
|
|
|
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(),
|
2016-02-10 13:40:46 +00:00
|
|
|
SkPaintDefaults_TextSize);
|
|
|
|
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScaleX(), SK_Scalar1);
|
|
|
|
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX(), 0.0f);
|
2016-08-25 18:10:41 +00:00
|
|
|
apply_paint_hinting(paint, &result);
|
2016-02-10 13:40:46 +00:00
|
|
|
apply_paint_color(paint, &result);
|
|
|
|
apply_paint_style(paint, &result);
|
2017-06-06 20:58:40 +00:00
|
|
|
apply_paint_blend_mode(paint, &result);
|
2016-02-10 13:40:46 +00:00
|
|
|
apply_paint_cap(paint, &result);
|
2016-02-10 22:05:02 +00:00
|
|
|
apply_paint_join(paint, &result);
|
|
|
|
apply_paint_filterquality(paint, &result);
|
2016-02-11 18:35:21 +00:00
|
|
|
apply_paint_patheffect(paint, &result, urlDataManager);
|
|
|
|
apply_paint_maskfilter(paint, &result, urlDataManager);
|
|
|
|
apply_paint_shader(paint, &result, urlDataManager);
|
|
|
|
apply_paint_looper(paint, &result, urlDataManager);
|
|
|
|
apply_paint_imagefilter(paint, &result, urlDataManager);
|
|
|
|
apply_paint_colorfilter(paint, &result, urlDataManager);
|
|
|
|
apply_paint_typeface(paint, &result, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-01-12 21:20:50 +00:00
|
|
|
Json::Value SkDrawCommand::MakeJsonLattice(const SkCanvas::Lattice& lattice) {
|
|
|
|
Json::Value result(Json::objectValue);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_LATTICEXCOUNT] = Json::Value(lattice.fXCount);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_LATTICEYCOUNT] = Json::Value(lattice.fYCount);
|
|
|
|
if (nullptr != lattice.fBounds) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS] = MakeJsonIRect(*lattice.fBounds);
|
|
|
|
}
|
|
|
|
Json::Value XDivs(Json::arrayValue);
|
|
|
|
for (int i = 0; i < lattice.fXCount; i++) {
|
|
|
|
XDivs.append(Json::Value(lattice.fXDivs[i]));
|
|
|
|
}
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_LATTICEXDIVS] = XDivs;
|
|
|
|
Json::Value YDivs(Json::arrayValue);
|
|
|
|
for (int i = 0; i < lattice.fYCount; i++) {
|
|
|
|
YDivs.append(Json::Value(lattice.fYDivs[i]));
|
|
|
|
}
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_LATTICEYDIVS] = YDivs;
|
2017-12-11 18:01:58 +00:00
|
|
|
if (nullptr != lattice.fRectTypes) {
|
2017-01-12 21:20:50 +00:00
|
|
|
Json::Value flags(Json::arrayValue);
|
|
|
|
int flagCount = 0;
|
|
|
|
for (int row = 0; row < lattice.fYCount+1; row++) {
|
|
|
|
Json::Value flagsRow(Json::arrayValue);
|
|
|
|
for (int column = 0; column < lattice.fXCount+1; column++) {
|
2017-12-11 18:01:58 +00:00
|
|
|
flagsRow.append(Json::Value(lattice.fRectTypes[flagCount++]));
|
2017-01-12 21:20:50 +00:00
|
|
|
}
|
|
|
|
flags.append(flagsRow);
|
|
|
|
}
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_LATTICEFLAGS] = flags;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-03-12 14:57:28 +00:00
|
|
|
SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kClear_OpType) {
|
2016-02-10 22:05:02 +00:00
|
|
|
fColor = color;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkClearCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->clear(fColor);
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkClearCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = MakeJsonColor(fColor);
|
2016-02-10 22:05:02 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkClipOp op, bool doAA)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kClipPath_OpType) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPath = path;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkClipPathCommand::execute(SkCanvas* canvas) const {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->clipPath(fPath, fOp, fDoAA);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkClipPathCommand::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
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkClipPathCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = MakeJsonPath(fPath);
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = fDoAA;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkClipOp op)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kClipRegion_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fRegion = region;
|
|
|
|
fOp = op;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkClipRegionCommand::execute(SkCanvas* canvas) const {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->clipRegion(fRegion, fOp);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkClipRegionCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_REGION] = MakeJsonRegion(fRegion);
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkClipOp op, bool doAA)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kClipRect_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fRect = rect;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkClipRectCommand::execute(SkCanvas* canvas) const {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->clipRect(fRect, fOp, fDoAA);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA);
|
2016-06-29 18:36:34 +00:00
|
|
|
|
|
|
|
SkString desc;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fRect)->c_str());
|
|
|
|
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-12-09 14:00:50 +00:00
|
|
|
SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkClipOp op, bool doAA)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kClipRRect_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fRRect = rrect;
|
|
|
|
fOp = op;
|
|
|
|
fDoAA = doAA;
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkClipRRectCommand::execute(SkCanvas* canvas) const {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->clipRRect(fRRect, fOp, fDoAA);
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkClipRRectCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_rrect(canvas, fRRect);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkClipRRectCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkConcatCommand::SkConcatCommand(const SkMatrix& matrix)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kConcat_OpType) {
|
2013-03-22 16:33:31 +00:00
|
|
|
fMatrix = matrix;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkConcatCommand::execute(SkCanvas* canvas) const {
|
2013-03-22 16:33:31 +00:00
|
|
|
canvas->concat(fMatrix);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkConcatCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-03-03 19:39:38 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix);
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-06-29 01:54:19 +00:00
|
|
|
////
|
|
|
|
|
|
|
|
SkDrawAnnotationCommand::SkDrawAnnotationCommand(const SkRect& rect, const char key[],
|
|
|
|
sk_sp<SkData> value)
|
|
|
|
: INHERITED(kDrawAnnotation_OpType)
|
|
|
|
, fRect(rect)
|
|
|
|
, fKey(key)
|
|
|
|
, fValue(std::move(value))
|
2016-06-29 17:28:11 +00:00
|
|
|
{
|
|
|
|
}
|
2016-06-29 01:54:19 +00:00
|
|
|
|
|
|
|
void SkDrawAnnotationCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->drawAnnotation(fRect, fKey.c_str(), fValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value SkDrawAnnotationCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
|
|
|
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
|
|
|
|
result["key"] = Json::Value(fKey.c_str());
|
|
|
|
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());
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(desc.c_str());
|
|
|
|
|
2016-06-29 01:54:19 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
////
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
2014-08-13 17:46:23 +00:00
|
|
|
const SkPaint* paint)
|
2018-05-29 17:38:07 +00:00
|
|
|
: INHERITED(kDrawBitmap_OpType)
|
|
|
|
, fBitmap(bitmap)
|
|
|
|
, fLeft(left)
|
|
|
|
, fTop(top)
|
|
|
|
, fPaint(paint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawBitmapCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawBitmapCommand::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
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawBitmapCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value encoded;
|
2016-02-11 18:35:21 +00:00
|
|
|
if (flatten(fBitmap, &encoded, urlDataManager)) {
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value command(Json::objectValue);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded;
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(fLeft, fTop);
|
2018-05-29 17:38:07 +00:00
|
|
|
if (fPaint.isValid()) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-05-18 20:59:13 +00:00
|
|
|
SkDrawBitmapLatticeCommand::SkDrawBitmapLatticeCommand(const SkBitmap& bitmap,
|
|
|
|
const SkCanvas::Lattice& lattice,
|
|
|
|
const SkRect& dst, const SkPaint* paint)
|
|
|
|
: INHERITED(kDrawBitmapLattice_OpType)
|
|
|
|
, fBitmap(bitmap)
|
|
|
|
, fLattice(lattice)
|
2018-05-29 17:38:07 +00:00
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint) {}
|
2018-05-18 20:59:13 +00:00
|
|
|
|
|
|
|
void SkDrawBitmapLatticeCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->drawBitmapLattice(fBitmap, fLattice, fDst, fPaint.getMaybeNull());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawBitmapLatticeCommand::render(SkCanvas* canvas) const {
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value SkDrawBitmapLatticeCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
|
|
|
Json::Value encoded;
|
|
|
|
if (flatten(fBitmap, &encoded, urlDataManager)) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_LATTICE] = MakeJsonLattice(fLattice);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
|
|
|
|
if (fPaint.isValid()) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SkString desc;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fDst)->c_str());
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
|
2014-03-27 03:02:48 +00:00
|
|
|
const SkRect& dst, const SkPaint* paint)
|
2018-05-29 17:38:07 +00:00
|
|
|
: INHERITED(kDrawBitmapNine_OpType)
|
|
|
|
, fBitmap(bitmap)
|
|
|
|
, fCenter(center)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawBitmapNineCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawBitmapNineCommand::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
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawBitmapNineCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value encoded;
|
2016-02-11 18:35:21 +00:00
|
|
|
if (flatten(fBitmap, &encoded, urlDataManager)) {
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded;
|
2016-03-03 19:39:38 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = MakeJsonIRect(fCenter);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
|
2018-05-29 17:38:07 +00:00
|
|
|
if (fPaint.isValid()) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
|
2013-08-16 10:24:37 +00:00
|
|
|
const SkRect& dst, const SkPaint* paint,
|
2015-07-14 17:54:12 +00:00
|
|
|
SkCanvas::SrcRectConstraint constraint)
|
2018-05-29 17:38:07 +00:00
|
|
|
: INHERITED(kDrawBitmapRect_OpType)
|
|
|
|
, fBitmap(bitmap)
|
|
|
|
, fSrc(src)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint)
|
|
|
|
, fConstraint(constraint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const {
|
2018-05-29 17:38:07 +00:00
|
|
|
canvas->legacy_drawBitmapRect(fBitmap, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(),
|
|
|
|
fConstraint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawBitmapRectCommand::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
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawBitmapRectCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value encoded;
|
2016-02-11 18:35:21 +00:00
|
|
|
if (flatten(fBitmap, &encoded, urlDataManager)) {
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded;
|
2018-05-29 17:38:07 +00:00
|
|
|
if (fSrc.isValid()) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(*fSrc.get());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
|
2018-05-29 17:38:07 +00:00
|
|
|
if (fPaint.isValid()) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true);
|
|
|
|
}
|
|
|
|
}
|
2016-06-29 18:36:34 +00:00
|
|
|
|
|
|
|
SkString desc;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fDst)->c_str());
|
|
|
|
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-07-22 17:23:01 +00:00
|
|
|
SkDrawImageCommand::SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top,
|
|
|
|
const SkPaint* paint)
|
|
|
|
: INHERITED(kDrawImage_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fLeft(left)
|
2018-05-29 17:38:07 +00:00
|
|
|
, fTop(top)
|
|
|
|
, fPaint(paint) {}
|
2015-07-22 17:23:01 +00:00
|
|
|
|
|
|
|
void SkDrawImageCommand::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
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawImageCommand::render(SkCanvas* canvas) const {
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, SkRect::MakeXYWH(fLeft, fTop,
|
|
|
|
SkIntToScalar(fImage->width()),
|
|
|
|
SkIntToScalar(fImage->height())));
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawImageCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value encoded;
|
2016-02-11 18:35:21 +00:00
|
|
|
if (flatten(*fImage, &encoded, urlDataManager)) {
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded;
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(fLeft, fTop);
|
2016-02-10 13:40:46 +00:00
|
|
|
if (fPaint.isValid()) {
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2016-08-29 16:15:33 +00:00
|
|
|
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_UNIQUE_ID] = fImage->uniqueID();
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_WIDTH] = fImage->width();
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_HEIGHT] = fImage->height();
|
|
|
|
switch (fImage->alphaType()) {
|
|
|
|
case kOpaque_SkAlphaType:
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = SKDEBUGCANVAS_ALPHATYPE_OPAQUE;
|
|
|
|
break;
|
|
|
|
case kPremul_SkAlphaType:
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = SKDEBUGCANVAS_ALPHATYPE_PREMUL;
|
|
|
|
break;
|
|
|
|
case kUnpremul_SkAlphaType:
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = SKDEBUGCANVAS_ALPHATYPE_UNPREMUL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = SKDEBUGCANVAS_ALPHATYPE_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-01-12 21:20:50 +00:00
|
|
|
SkDrawImageLatticeCommand::SkDrawImageLatticeCommand(const SkImage* image,
|
|
|
|
const SkCanvas::Lattice& lattice,
|
|
|
|
const SkRect& dst, const SkPaint* paint)
|
|
|
|
: INHERITED(kDrawImageLattice_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fLattice(lattice)
|
2018-05-29 17:38:07 +00:00
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint) {}
|
2017-01-12 21:20:50 +00:00
|
|
|
|
|
|
|
void SkDrawImageLatticeCommand::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
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawImageLatticeCommand::render(SkCanvas* canvas) const {
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value SkDrawImageLatticeCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
|
|
|
Json::Value encoded;
|
|
|
|
if (flatten(*fImage.get(), &encoded, urlDataManager)) {
|
2018-03-12 14:57:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded;
|
2017-01-12 21:20:50 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_LATTICE] = MakeJsonLattice(fLattice);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
|
|
|
|
if (fPaint.isValid()) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SkString desc;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fDst)->c_str());
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-07-22 17:23:01 +00:00
|
|
|
SkDrawImageRectCommand::SkDrawImageRectCommand(const SkImage* image, const SkRect* src,
|
|
|
|
const SkRect& dst, const SkPaint* paint,
|
|
|
|
SkCanvas::SrcRectConstraint constraint)
|
|
|
|
: INHERITED(kDrawImageRect_OpType)
|
|
|
|
, fImage(SkRef(image))
|
2018-05-29 17:38:07 +00:00
|
|
|
, fSrc(src)
|
2015-07-22 17:23:01 +00:00
|
|
|
, fDst(dst)
|
2018-05-29 17:38:07 +00:00
|
|
|
, fPaint(paint)
|
|
|
|
, fConstraint(constraint) {}
|
2015-07-22 17:23:01 +00:00
|
|
|
|
|
|
|
void SkDrawImageRectCommand::execute(SkCanvas* canvas) const {
|
2016-11-03 20:26:13 +00:00
|
|
|
canvas->legacy_drawImageRect(fImage.get(), fSrc.getMaybeNull(), fDst,
|
|
|
|
fPaint.getMaybeNull(), fConstraint);
|
2015-07-22 17:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawImageRectCommand::render(SkCanvas* canvas) const {
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawImageRectCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value encoded;
|
2016-02-11 18:35:21 +00:00
|
|
|
if (flatten(*fImage.get(), &encoded, urlDataManager)) {
|
2018-03-12 14:57:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded;
|
2016-02-10 13:40:46 +00:00
|
|
|
if (fSrc.isValid()) {
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = MakeJsonRect(*fSrc.get());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
|
2016-02-10 13:40:46 +00:00
|
|
|
if (fPaint.isValid()) {
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true);
|
|
|
|
}
|
|
|
|
}
|
2016-06-29 18:36:34 +00:00
|
|
|
|
|
|
|
SkString desc;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fDst)->c_str());
|
|
|
|
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-10-12 15:42:02 +00:00
|
|
|
SkDrawImageSetCommand::SkDrawImageSetCommand(const SkCanvas::ImageSetEntry set[], int count,
|
2018-11-26 18:25:05 +00:00
|
|
|
SkFilterQuality filterQuality, SkBlendMode mode)
|
2018-10-12 15:42:02 +00:00
|
|
|
: INHERITED(kDrawImageSet_OpType)
|
|
|
|
, fSet(count)
|
|
|
|
, fCount(count)
|
|
|
|
, fFilterQuality(filterQuality)
|
|
|
|
, fMode(mode) {
|
|
|
|
std::copy_n(set, count, fSet.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDrawImageSetCommand::execute(SkCanvas* canvas) const {
|
2018-11-26 18:25:05 +00:00
|
|
|
canvas->experimental_DrawImageSetV1(fSet.get(), fCount, fFilterQuality, fMode);
|
2018-10-12 15:42:02 +00:00
|
|
|
}
|
|
|
|
|
2018-03-12 14:57:28 +00:00
|
|
|
SkDrawImageNineCommand::SkDrawImageNineCommand(const SkImage* image, const SkIRect& center,
|
|
|
|
const SkRect& dst, const SkPaint* paint)
|
2018-05-29 17:38:07 +00:00
|
|
|
: INHERITED(kDrawImageNine_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fCenter(center)
|
|
|
|
, fDst(dst)
|
|
|
|
, fPaint(paint) {}
|
2018-03-12 14:57:28 +00:00
|
|
|
|
|
|
|
void SkDrawImageNineCommand::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
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawImageNineCommand::render(SkCanvas* canvas) const {
|
|
|
|
SkAutoCanvasRestore acr(canvas, true);
|
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
|
|
|
|
xlate_and_scale_to_bounds(canvas, fDst);
|
|
|
|
|
|
|
|
this->execute(canvas);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value SkDrawImageNineCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
|
|
|
Json::Value encoded;
|
|
|
|
if (flatten(*fImage.get(), &encoded, urlDataManager)) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = MakeJsonIRect(fCenter);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_DST] = MakeJsonRect(fDst);
|
2018-05-29 17:38:07 +00:00
|
|
|
if (fPaint.isValid()) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
|
2018-03-12 14:57:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawOval_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fOval = oval;
|
|
|
|
fPaint = paint;
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawOvalCommand::execute(SkCanvas* canvas) const {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->drawOval(fOval, fPaint);
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawOvalCommand::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;
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawOvalCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fOval);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-08-19 18:25:19 +00:00
|
|
|
SkDrawArcCommand::SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
|
|
|
bool useCenter, const SkPaint& paint)
|
2018-03-12 14:57:28 +00:00
|
|
|
: INHERITED(kDrawArc_OpType) {
|
2016-08-19 18:25:19 +00:00
|
|
|
fOval = oval;
|
|
|
|
fStartAngle = startAngle;
|
|
|
|
fSweepAngle = sweepAngle;
|
|
|
|
fUseCenter = useCenter;
|
|
|
|
fPaint = paint;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDrawArcCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->drawArc(fOval, fStartAngle, fSweepAngle, fUseCenter, fPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawArcCommand::render(SkCanvas* canvas) const {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value SkDrawArcCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fOval);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE] = MakeJsonScalar(fStartAngle);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE] = MakeJsonScalar(fSweepAngle);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_USECENTER] = fUseCenter;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawPaint_OpType) {
|
2013-03-22 12:25:30 +00:00
|
|
|
fPaint = paint;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawPaintCommand::execute(SkCanvas* canvas) const {
|
2013-03-22 12:25:30 +00:00
|
|
|
canvas->drawPaint(fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawPaintCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
canvas->clear(0xFFFFFFFF);
|
|
|
|
canvas->drawPaint(fPaint);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawPaintCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawPath_OpType) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fPath = path;
|
|
|
|
fPaint = paint;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawPathCommand::execute(SkCanvas* canvas) const {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawPath(fPath, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawPathCommand::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
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawPathCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = MakeJsonPath(fPath);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-03-12 14:57:28 +00:00
|
|
|
SkDrawRegionCommand::SkDrawRegionCommand(const SkRegion& region, const SkPaint& paint)
|
|
|
|
: INHERITED(kDrawRegion_OpType) {
|
|
|
|
fRegion = region;
|
|
|
|
fPaint = paint;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDrawRegionCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->drawRegion(fRegion, fPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawRegionCommand::render(SkCanvas* canvas) const {
|
|
|
|
render_region(canvas, fRegion);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value SkDrawRegionCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_REGION] = MakeJsonRegion(fRegion);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
SkBeginDrawPictureCommand::SkBeginDrawPictureCommand(const SkPicture* picture,
|
|
|
|
const SkMatrix* matrix,
|
|
|
|
const SkPaint* paint)
|
|
|
|
: INHERITED(kBeginDrawPicture_OpType)
|
2018-05-29 17:38:07 +00:00
|
|
|
, fPicture(SkRef(picture))
|
|
|
|
, fMatrix(matrix)
|
|
|
|
, fPaint(paint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
void SkBeginDrawPictureCommand::execute(SkCanvas* canvas) const {
|
|
|
|
if (fPaint.isValid()) {
|
|
|
|
SkRect bounds = fPicture->cullRect();
|
|
|
|
if (fMatrix.isValid()) {
|
|
|
|
fMatrix.get()->mapRect(&bounds);
|
|
|
|
}
|
|
|
|
canvas->saveLayer(&bounds, fPaint.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fMatrix.isValid()) {
|
|
|
|
if (!fPaint.isValid()) {
|
|
|
|
canvas->save();
|
|
|
|
}
|
|
|
|
canvas->concat(*fMatrix.get());
|
|
|
|
}
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
bool SkBeginDrawPictureCommand::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;
|
|
|
|
}
|
|
|
|
|
2015-04-02 03:58:37 +00:00
|
|
|
SkEndDrawPictureCommand::SkEndDrawPictureCommand(bool restore)
|
|
|
|
: INHERITED(kEndDrawPicture_OpType) , fRestore(restore) { }
|
|
|
|
|
|
|
|
void SkEndDrawPictureCommand::execute(SkCanvas* canvas) const {
|
|
|
|
if (fRestore) {
|
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPoint pts[], const SkPaint& paint)
|
2018-05-29 17:38:07 +00:00
|
|
|
: INHERITED(kDrawPoints_OpType)
|
|
|
|
, fMode(mode)
|
|
|
|
, fPts(pts, count)
|
|
|
|
, fPaint(paint) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawPointsCommand::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
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawPointsCommand::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;
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawPointsCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_MODE] = make_json_pointmode(fMode);
|
|
|
|
Json::Value points(Json::arrayValue);
|
2018-05-29 17:38:07 +00:00
|
|
|
for (int i = 0; i < fPts.count(); i++) {
|
2016-05-04 18:06:28 +00:00
|
|
|
points.append(MakeJsonPoint(fPts[i]));
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_POINTS] = points;
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-05-29 18:25:39 +00:00
|
|
|
static Json::Value make_json_text(sk_sp<SkData> text) {
|
|
|
|
return Json::Value((const char*)text->data(), (const char*)text->data() + text->size());
|
|
|
|
}
|
|
|
|
|
2016-09-13 17:00:23 +00:00
|
|
|
SkDrawTextBlobCommand::SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y,
|
2014-08-26 14:56:44 +00:00
|
|
|
const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawTextBlob_OpType)
|
2016-09-13 17:00:23 +00:00
|
|
|
, fBlob(std::move(blob))
|
2014-08-26 14:56:44 +00:00
|
|
|
, fXPos(x)
|
|
|
|
, fYPos(y)
|
2018-04-06 18:51:42 +00:00
|
|
|
, fPaint(paint) {}
|
2014-08-26 14:56:44 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawTextBlobCommand::execute(SkCanvas* canvas) const {
|
2014-08-26 14:56:44 +00:00
|
|
|
canvas->drawTextBlob(fBlob, fXPos, fYPos, fPaint);
|
|
|
|
}
|
|
|
|
|
2014-08-29 22:08:20 +00:00
|
|
|
bool SkDrawTextBlobCommand::render(SkCanvas* canvas) const {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawTextBlobCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
Json::Value runs(Json::arrayValue);
|
|
|
|
SkTextBlobRunIterator iter(fBlob.get());
|
|
|
|
while (!iter.done()) {
|
|
|
|
Json::Value run(Json::objectValue);
|
|
|
|
Json::Value jsonPositions(Json::arrayValue);
|
|
|
|
Json::Value jsonGlyphs(Json::arrayValue);
|
|
|
|
const SkScalar* iterPositions = iter.pos();
|
|
|
|
const uint16_t* iterGlyphs = iter.glyphs();
|
|
|
|
for (uint32_t i = 0; i < iter.glyphCount(); i++) {
|
|
|
|
switch (iter.positioning()) {
|
2018-07-27 13:47:15 +00:00
|
|
|
case SkTextBlobRunIterator::kFull_Positioning:
|
2016-05-04 18:06:28 +00:00
|
|
|
jsonPositions.append(MakeJsonPoint(iterPositions[i * 2],
|
|
|
|
iterPositions[i * 2 + 1]));
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
2018-07-27 13:47:15 +00:00
|
|
|
case SkTextBlobRunIterator::kHorizontal_Positioning:
|
2016-02-10 13:40:46 +00:00
|
|
|
jsonPositions.append(Json::Value(iterPositions[i]));
|
|
|
|
break;
|
2018-07-27 13:47:15 +00:00
|
|
|
case SkTextBlobRunIterator::kDefault_Positioning:
|
2016-02-10 13:40:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
jsonGlyphs.append(Json::Value(iterGlyphs[i]));
|
|
|
|
}
|
2018-07-27 13:47:15 +00:00
|
|
|
if (iter.positioning() != SkTextBlobRunIterator::kDefault_Positioning) {
|
2016-02-10 13:40:46 +00:00
|
|
|
run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = jsonPositions;
|
|
|
|
}
|
|
|
|
run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS] = jsonGlyphs;
|
|
|
|
SkPaint fontPaint;
|
|
|
|
iter.applyFontToPaint(&fontPaint);
|
2016-05-04 18:06:28 +00:00
|
|
|
run[SKDEBUGCANVAS_ATTRIBUTE_FONT] = MakeJsonPaint(fontPaint, urlDataManager);
|
|
|
|
run[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(iter.offset());
|
2016-02-10 13:40:46 +00:00
|
|
|
runs.append(run);
|
|
|
|
iter.next();
|
|
|
|
}
|
2016-07-07 21:10:14 +00:00
|
|
|
SkRect bounds = fBlob->bounds();
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_RUNS] = runs;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_X] = Json::Value(fXPos);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fYPos);
|
2016-07-07 21:10:14 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(bounds);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(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);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, bounds)->c_str());
|
|
|
|
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-02-13 19:13:00 +00:00
|
|
|
SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
|
2016-10-28 19:42:34 +00:00
|
|
|
const SkPoint texCoords[4], SkBlendMode bmode,
|
2015-02-13 19:13:00 +00:00
|
|
|
const SkPaint& paint)
|
2016-10-28 19:42:34 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDrawPatchCommand::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
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawPatchCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 22:05:02 +00:00
|
|
|
Json::Value cubics = Json::Value(Json::arrayValue);
|
|
|
|
for (int i = 0; i < 12; i++) {
|
2016-05-04 18:06:28 +00:00
|
|
|
cubics.append(MakeJsonPoint(fCubics[i]));
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_CUBICS] = cubics;
|
|
|
|
if (fColorsPtr != nullptr) {
|
|
|
|
Json::Value colors = Json::Value(Json::arrayValue);
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2016-05-04 18:06:28 +00:00
|
|
|
colors.append(MakeJsonColor(fColorsPtr[i]));
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COLORS] = colors;
|
|
|
|
}
|
|
|
|
if (fTexCoordsPtr != nullptr) {
|
|
|
|
Json::Value texCoords = Json::Value(Json::arrayValue);
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2016-05-04 18:06:28 +00:00
|
|
|
texCoords.append(MakeJsonPoint(fTexCoords[i]));
|
2016-02-10 22:05:02 +00:00
|
|
|
}
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS] = texCoords;
|
|
|
|
}
|
2016-10-28 19:42:34 +00:00
|
|
|
// fBlendMode
|
2016-02-10 22:05:02 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawRect_OpType) {
|
2013-03-17 18:33:46 +00:00
|
|
|
fRect = rect;
|
|
|
|
fPaint = paint;
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawRectCommand::execute(SkCanvas* canvas) const {
|
2013-03-17 18:33:46 +00:00
|
|
|
canvas->drawRect(fRect, fPaint);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fRect);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
2016-06-29 18:36:34 +00:00
|
|
|
|
|
|
|
SkString desc;
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC] = Json::Value(str_append(&desc, fRect)->c_str());
|
|
|
|
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint)
|
2015-02-13 19:13: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
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawRRectCommand::execute(SkCanvas* canvas) const {
|
2013-03-11 22:53:11 +00:00
|
|
|
canvas->drawRRect(fRRect, fPaint);
|
2013-01-02 20:20:31 +00:00
|
|
|
}
|
|
|
|
|
2013-06-18 20:20:55 +00:00
|
|
|
bool SkDrawRRectCommand::render(SkCanvas* canvas) const {
|
2013-06-06 23:59:28 +00:00
|
|
|
render_rrect(canvas, fRRect);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawRRectCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-02-25 03:05:18 +00:00
|
|
|
SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer,
|
2014-02-24 17:28:55 +00:00
|
|
|
const SkRRect& inner,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint& paint)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kDrawDRRect_OpType) {
|
2014-02-24 17:28:55 +00:00
|
|
|
fOuter = outer;
|
|
|
|
fInner = inner;
|
|
|
|
fPaint = paint;
|
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawDRRectCommand::execute(SkCanvas* canvas) const {
|
2014-02-24 17:28:55 +00:00
|
|
|
canvas->drawDRRect(fOuter, fInner, fPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawDRRectCommand::render(SkCanvas* canvas) const {
|
|
|
|
render_drrect(canvas, fOuter, fInner);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkDrawDRRectCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_OUTER] = make_json_rrect(fOuter);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_INNER] = make_json_rrect(fInner);
|
2016-05-04 18:06:28 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-04-12 16:45:58 +00:00
|
|
|
SkDrawShadowCommand::SkDrawShadowCommand(const SkPath& path, const SkDrawShadowRec& rec)
|
|
|
|
: INHERITED(kDrawShadow_OpType) {
|
|
|
|
fPath = path;
|
|
|
|
fShadowRec = rec;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkDrawShadowCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->private_draw_shadow_rec(fPath, fShadowRec);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SkDrawShadowCommand::render(SkCanvas* canvas) const {
|
|
|
|
render_shadow(canvas, fPath, fShadowRec);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value SkDrawShadowCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = MakeJsonPath(fPath);
|
|
|
|
|
|
|
|
bool geometricOnly = SkToBool(fShadowRec.fFlags & SkShadowFlags::kGeometricOnly_ShadowFlag);
|
|
|
|
bool transparentOccluder =
|
|
|
|
SkToBool(fShadowRec.fFlags & SkShadowFlags::kTransparentOccluder_ShadowFlag);
|
|
|
|
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = MakeJsonPath(fPath);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_ZPLANE] = MakeJsonPoint3(fShadowRec.fZPlaneParams);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_LIGHTPOSITION] = MakeJsonPoint3(fShadowRec.fLightPos);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_LIGHTRADIUS] = MakeJsonScalar(fShadowRec.fLightRadius);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_AMBIENTCOLOR] = MakeJsonColor(fShadowRec.fAmbientColor);
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_SPOTCOLOR] = MakeJsonColor(fShadowRec.fSpotColor);
|
|
|
|
store_bool(&result, SKDEBUGCANVAS_SHADOWFLAG_TRANSPARENT_OCC, transparentOccluder, false);
|
|
|
|
store_bool(&result, SKDEBUGCANVAS_SHADOWFLAG_GEOMETRIC_ONLY, geometricOnly, false);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-05-29 18:55:50 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
SkDrawDrawableCommand::SkDrawDrawableCommand(SkDrawable* drawable, const SkMatrix* matrix)
|
|
|
|
: INHERITED(kDrawDrawable_OpType)
|
|
|
|
, fDrawable(SkRef(drawable))
|
|
|
|
, fMatrix(matrix) {}
|
|
|
|
|
|
|
|
void SkDrawDrawableCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->drawDrawable(fDrawable.get(), fMatrix.getMaybeNull());
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-07-07 19:47:17 +00:00
|
|
|
SkDrawTextRSXformCommand::SkDrawTextRSXformCommand(const void* text, size_t byteLength,
|
|
|
|
const SkRSXform xform[], const SkRect* cull,
|
|
|
|
const SkPaint& paint)
|
2016-07-07 23:32:51 +00:00
|
|
|
: INHERITED(kDrawTextRSXform_OpType)
|
2018-05-29 18:25:39 +00:00
|
|
|
, fText(SkData::MakeWithCopy(text, byteLength))
|
2018-12-12 20:48:16 +00:00
|
|
|
, fXform(xform, SkFont::LEGACY_ExtractFromPaint(paint).countText(text, byteLength, paint.getTextEncoding()))
|
2018-05-29 17:38:07 +00:00
|
|
|
, fCull(cull)
|
2018-05-29 18:25:39 +00:00
|
|
|
, fPaint(paint) {}
|
2016-07-07 19:47:17 +00:00
|
|
|
|
|
|
|
void SkDrawTextRSXformCommand::execute(SkCanvas* canvas) const {
|
2018-05-29 18:25:39 +00:00
|
|
|
canvas->drawTextRSXform(fText->data(), fText->size(), fXform.begin(), fCull.getMaybeNull(),
|
|
|
|
fPaint);
|
2016-07-07 19:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Json::Value SkDrawTextRSXformCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2018-05-29 18:25:39 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = make_json_text(fText);
|
2016-07-07 19:47:17 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-03-17 16:09:04 +00:00
|
|
|
SkDrawVerticesCommand::SkDrawVerticesCommand(sk_sp<SkVertices> vertices, SkBlendMode bmode,
|
2014-03-25 23:31:33 +00:00
|
|
|
const SkPaint& paint)
|
2016-10-28 19:42:34 +00:00
|
|
|
: INHERITED(kDrawVertices_OpType)
|
2017-03-17 16:09:04 +00:00
|
|
|
, fVertices(std::move(vertices))
|
2016-10-28 19:42:34 +00:00
|
|
|
, fBlendMode(bmode)
|
2018-04-06 18:51:42 +00:00
|
|
|
, fPaint(paint) {}
|
2013-03-25 11:50:42 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkDrawVerticesCommand::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
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
SkDrawAtlasCommand::SkDrawAtlasCommand(const SkImage* image, const SkRSXform xform[],
|
|
|
|
const SkRect tex[], const SkColor colors[], int count,
|
|
|
|
SkBlendMode bmode, const SkRect* cull,
|
|
|
|
const SkPaint* paint)
|
|
|
|
: INHERITED(kDrawAtlas_OpType)
|
|
|
|
, fImage(SkRef(image))
|
|
|
|
, fXform(xform, count)
|
|
|
|
, fTex(tex, count)
|
|
|
|
, fColors(colors, colors ? count : 0)
|
|
|
|
, fBlendMode(bmode)
|
|
|
|
, fCull(cull)
|
|
|
|
, fPaint(paint) {}
|
|
|
|
|
|
|
|
void SkDrawAtlasCommand::execute(SkCanvas* canvas) const {
|
|
|
|
canvas->drawAtlas(fImage.get(), fXform.begin(), fTex.begin(),
|
|
|
|
fColors.isEmpty() ? nullptr : fColors.begin(), fXform.count(), fBlendMode,
|
|
|
|
fCull.getMaybeNull(), fPaint.getMaybeNull());
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkRestoreCommand::SkRestoreCommand()
|
2018-04-06 18:51:42 +00:00
|
|
|
: INHERITED(kRestore_OpType) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkRestoreCommand::execute(SkCanvas* canvas) const {
|
2012-06-29 14:21:22 +00:00
|
|
|
canvas->restore();
|
|
|
|
}
|
|
|
|
|
2014-06-30 14:13:28 +00:00
|
|
|
SkSaveCommand::SkSaveCommand()
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kSave_OpType) {
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkSaveCommand::execute(SkCanvas* canvas) const {
|
2014-06-30 14:13:28 +00:00
|
|
|
canvas->save();
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-12-18 15:09:18 +00:00
|
|
|
SkSaveLayerCommand::SkSaveLayerCommand(const SkCanvas::SaveLayerRec& rec)
|
2018-05-29 17:38:07 +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
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkSaveLayerCommand::execute(SkCanvas* canvas) const {
|
2018-05-29 17:38:07 +00:00
|
|
|
canvas->saveLayer(SkCanvas::SaveLayerRec(fBounds.getMaybeNull(), fPaint.getMaybeNull(),
|
2015-12-18 15:09:18 +00:00
|
|
|
fSaveLayerFlags));
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkSaveLayerCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2018-05-29 17:38:07 +00:00
|
|
|
if (fBounds.isValid()) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS] = MakeJsonRect(*fBounds.get());
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
2018-05-29 17:38:07 +00:00
|
|
|
if (fPaint.isValid()) {
|
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(), urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
}
|
|
|
|
if (fBackdrop != nullptr) {
|
|
|
|
Json::Value jsonBackdrop;
|
2018-05-29 17:38:07 +00:00
|
|
|
flatten(fBackdrop.get(), &jsonBackdrop, urlDataManager);
|
2016-02-10 13:40:46 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_BACKDROP] = jsonBackdrop;
|
|
|
|
}
|
|
|
|
if (fSaveLayerFlags != 0) {
|
|
|
|
SkDebugf("unsupported: saveLayer flags\n");
|
|
|
|
SkASSERT(false);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix)
|
2015-02-13 19:13:00 +00:00
|
|
|
: INHERITED(kSetMatrix_OpType) {
|
2013-03-25 11:50:42 +00:00
|
|
|
fMatrix = matrix;
|
2014-10-16 21:28:28 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:18:56 +00:00
|
|
|
void SkSetMatrixCommand::execute(SkCanvas* canvas) const {
|
2018-04-06 18:51:42 +00:00
|
|
|
canvas->setMatrix(fMatrix);
|
2012-06-29 14:21:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-11 18:35:21 +00:00
|
|
|
Json::Value SkSetMatrixCommand::toJSON(UrlDataManager& urlDataManager) const {
|
|
|
|
Json::Value result = INHERITED::toJSON(urlDataManager);
|
2016-03-03 19:39:38 +00:00
|
|
|
result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix);
|
2016-02-10 13:40:46 +00:00
|
|
|
return result;
|
|
|
|
}
|