OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkDrawCommand.h" | 10 #include "SkDrawCommand.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner" | 35 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner" |
36 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode" | 36 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode" |
37 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points" | 37 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points" |
38 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path" | 38 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path" |
39 #define SKDEBUGCANVAS_ATTRIBUTE_TEXT "text" | 39 #define SKDEBUGCANVAS_ATTRIBUTE_TEXT "text" |
40 #define SKDEBUGCANVAS_ATTRIBUTE_COLOR "color" | 40 #define SKDEBUGCANVAS_ATTRIBUTE_COLOR "color" |
41 #define SKDEBUGCANVAS_ATTRIBUTE_ALPHA "alpha" | 41 #define SKDEBUGCANVAS_ATTRIBUTE_ALPHA "alpha" |
42 #define SKDEBUGCANVAS_ATTRIBUTE_STYLE "style" | 42 #define SKDEBUGCANVAS_ATTRIBUTE_STYLE "style" |
43 #define SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH "strokeWidth" | 43 #define SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH "strokeWidth" |
44 #define SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER "strokeMiter" | 44 #define SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER "strokeMiter" |
| 45 #define SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN "strokeJoin" |
45 #define SKDEBUGCANVAS_ATTRIBUTE_CAP "cap" | 46 #define SKDEBUGCANVAS_ATTRIBUTE_CAP "cap" |
46 #define SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS "antiAlias" | 47 #define SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS "antiAlias" |
| 48 #define SKDEBUGCANVAS_ATTRIBUTE_DITHER "dither" |
47 #define SKDEBUGCANVAS_ATTRIBUTE_REGION "region" | 49 #define SKDEBUGCANVAS_ATTRIBUTE_REGION "region" |
48 #define SKDEBUGCANVAS_ATTRIBUTE_REGIONOP "op" | 50 #define SKDEBUGCANVAS_ATTRIBUTE_REGIONOP "op" |
49 #define SKDEBUGCANVAS_ATTRIBUTE_EDGESTYLE "edgeStyle" | 51 #define SKDEBUGCANVAS_ATTRIBUTE_EDGESTYLE "edgeStyle" |
50 #define SKDEBUGCANVAS_ATTRIBUTE_DEVICEREGION "deviceRegion" | 52 #define SKDEBUGCANVAS_ATTRIBUTE_DEVICEREGION "deviceRegion" |
51 #define SKDEBUGCANVAS_ATTRIBUTE_BLUR "blur" | 53 #define SKDEBUGCANVAS_ATTRIBUTE_BLUR "blur" |
52 #define SKDEBUGCANVAS_ATTRIBUTE_SIGMA "sigma" | 54 #define SKDEBUGCANVAS_ATTRIBUTE_SIGMA "sigma" |
53 #define SKDEBUGCANVAS_ATTRIBUTE_QUALITY "quality" | 55 #define SKDEBUGCANVAS_ATTRIBUTE_QUALITY "quality" |
54 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN "textAlign" | 56 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN "textAlign" |
55 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize" | 57 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize" |
56 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX" | 58 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX" |
57 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX" | 59 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX" |
58 #define SKDEBUGCANVAS_ATTRIBUTE_DASHING "dashing" | 60 #define SKDEBUGCANVAS_ATTRIBUTE_DASHING "dashing" |
59 #define SKDEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals" | 61 #define SKDEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals" |
60 #define SKDEBUGCANVAS_ATTRIBUTE_PHASE "phase" | 62 #define SKDEBUGCANVAS_ATTRIBUTE_PHASE "phase" |
61 #define SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType" | 63 #define SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType" |
62 #define SKDEBUGCANVAS_ATTRIBUTE_VERBS "verbs" | 64 #define SKDEBUGCANVAS_ATTRIBUTE_VERBS "verbs" |
63 #define SKDEBUGCANVAS_ATTRIBUTE_NAME "name" | 65 #define SKDEBUGCANVAS_ATTRIBUTE_NAME "name" |
64 #define SKDEBUGCANVAS_ATTRIBUTE_BYTES "bytes" | 66 #define SKDEBUGCANVAS_ATTRIBUTE_BYTES "bytes" |
65 #define SKDEBUGCANVAS_ATTRIBUTE_SHADER "shader" | 67 #define SKDEBUGCANVAS_ATTRIBUTE_SHADER "shader" |
66 #define SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect" | 68 #define SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect" |
67 #define SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter" | 69 #define SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter" |
68 #define SKDEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode" | 70 #define SKDEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode" |
| 71 #define SKDEBUGCANVAS_ATTRIBUTE_LOOPER "looper" |
69 #define SKDEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop" | 72 #define SKDEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop" |
70 #define SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter" | 73 #define SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter" |
71 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter" | 74 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter" |
72 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGE "image" | 75 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGE "image" |
73 #define SKDEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap" | 76 #define SKDEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap" |
74 #define SKDEBUGCANVAS_ATTRIBUTE_SRC "src" | 77 #define SKDEBUGCANVAS_ATTRIBUTE_SRC "src" |
75 #define SKDEBUGCANVAS_ATTRIBUTE_DST "dst" | 78 #define SKDEBUGCANVAS_ATTRIBUTE_DST "dst" |
76 #define SKDEBUGCANVAS_ATTRIBUTE_CENTER "center" | 79 #define SKDEBUGCANVAS_ATTRIBUTE_CENTER "center" |
77 #define SKDEBUGCANVAS_ATTRIBUTE_STRICT "strict" | 80 #define SKDEBUGCANVAS_ATTRIBUTE_STRICT "strict" |
78 #define SKDEBUGCANVAS_ATTRIBUTE_DESCRIPTION "description" | 81 #define SKDEBUGCANVAS_ATTRIBUTE_DESCRIPTION "description" |
79 #define SKDEBUGCANVAS_ATTRIBUTE_X "x" | 82 #define SKDEBUGCANVAS_ATTRIBUTE_X "x" |
80 #define SKDEBUGCANVAS_ATTRIBUTE_Y "y" | 83 #define SKDEBUGCANVAS_ATTRIBUTE_Y "y" |
81 #define SKDEBUGCANVAS_ATTRIBUTE_RUNS "runs" | 84 #define SKDEBUGCANVAS_ATTRIBUTE_RUNS "runs" |
82 #define SKDEBUGCANVAS_ATTRIBUTE_POSITIONS "positions" | 85 #define SKDEBUGCANVAS_ATTRIBUTE_POSITIONS "positions" |
83 #define SKDEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs" | 86 #define SKDEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs" |
84 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font" | 87 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font" |
85 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface" | 88 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface" |
| 89 #define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics" |
| 90 #define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors" |
| 91 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords" |
| 92 #define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality" |
86 | 93 |
87 #define SKDEBUGCANVAS_VERB_MOVE "move" | 94 #define SKDEBUGCANVAS_VERB_MOVE "move" |
88 #define SKDEBUGCANVAS_VERB_LINE "line" | 95 #define SKDEBUGCANVAS_VERB_LINE "line" |
89 #define SKDEBUGCANVAS_VERB_QUAD "quad" | 96 #define SKDEBUGCANVAS_VERB_QUAD "quad" |
90 #define SKDEBUGCANVAS_VERB_CUBIC "cubic" | 97 #define SKDEBUGCANVAS_VERB_CUBIC "cubic" |
91 #define SKDEBUGCANVAS_VERB_CONIC "conic" | 98 #define SKDEBUGCANVAS_VERB_CONIC "conic" |
92 #define SKDEBUGCANVAS_VERB_CLOSE "close" | 99 #define SKDEBUGCANVAS_VERB_CLOSE "close" |
93 | 100 |
94 #define SKDEBUGCANVAS_STYLE_FILL "fill" | 101 #define SKDEBUGCANVAS_STYLE_FILL "fill" |
95 #define SKDEBUGCANVAS_STYLE_STROKE "stroke" | 102 #define SKDEBUGCANVAS_STYLE_STROKE "stroke" |
(...skipping 24 matching lines...) Expand all Loading... |
120 | 127 |
121 #define SKDEBUGCANVAS_FILLTYPE_WINDING "winding" | 128 #define SKDEBUGCANVAS_FILLTYPE_WINDING "winding" |
122 #define SKDEBUGCANVAS_FILLTYPE_EVENODD "evenOdd" | 129 #define SKDEBUGCANVAS_FILLTYPE_EVENODD "evenOdd" |
123 #define SKDEBUGCANVAS_FILLTYPE_INVERSEWINDING "inverseWinding" | 130 #define SKDEBUGCANVAS_FILLTYPE_INVERSEWINDING "inverseWinding" |
124 #define SKDEBUGCANVAS_FILLTYPE_INVERSEEVENODD "inverseEvenOdd" | 131 #define SKDEBUGCANVAS_FILLTYPE_INVERSEEVENODD "inverseEvenOdd" |
125 | 132 |
126 #define SKDEBUGCANVAS_CAP_BUTT "butt" | 133 #define SKDEBUGCANVAS_CAP_BUTT "butt" |
127 #define SKDEBUGCANVAS_CAP_ROUND "round" | 134 #define SKDEBUGCANVAS_CAP_ROUND "round" |
128 #define SKDEBUGCANVAS_CAP_SQUARE "square" | 135 #define SKDEBUGCANVAS_CAP_SQUARE "square" |
129 | 136 |
| 137 #define SKDEBUGCANVAS_MITER_JOIN "miter" |
| 138 #define SKDEBUGCANVAS_ROUND_JOIN "round" |
| 139 #define SKDEBUGCANVAS_BEVEL_JOIN "bevel" |
| 140 |
130 #define SKDEBUGCANVAS_COLORTYPE_ARGB4444 "ARGB4444" | 141 #define SKDEBUGCANVAS_COLORTYPE_ARGB4444 "ARGB4444" |
131 #define SKDEBUGCANVAS_COLORTYPE_RGBA8888 "RGBA8888" | 142 #define SKDEBUGCANVAS_COLORTYPE_RGBA8888 "RGBA8888" |
132 #define SKDEBUGCANVAS_COLORTYPE_BGRA8888 "BGRA8888" | 143 #define SKDEBUGCANVAS_COLORTYPE_BGRA8888 "BGRA8888" |
133 #define SKDEBUGCANVAS_COLORTYPE_565 "565" | 144 #define SKDEBUGCANVAS_COLORTYPE_565 "565" |
134 #define SKDEBUGCANVAS_COLORTYPE_GRAY8 "Gray8" | 145 #define SKDEBUGCANVAS_COLORTYPE_GRAY8 "Gray8" |
135 #define SKDEBUGCANVAS_COLORTYPE_INDEX8 "Index8" | 146 #define SKDEBUGCANVAS_COLORTYPE_INDEX8 "Index8" |
136 #define SKDEBUGCANVAS_COLORTYPE_ALPHA8 "Alpha8" | 147 #define SKDEBUGCANVAS_COLORTYPE_ALPHA8 "Alpha8" |
137 | 148 |
138 #define SKDEBUGCANVAS_ALPHATYPE_OPAQUE "opaque" | 149 #define SKDEBUGCANVAS_ALPHATYPE_OPAQUE "opaque" |
139 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul" | 150 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul" |
140 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul" | 151 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul" |
141 | 152 |
| 153 #define SKDEBUGCANVAS_FILTERQUALITY_NONE "none" |
| 154 #define SKDEBUGCANVAS_FILTERQUALITY_LOW "low" |
| 155 #define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium" |
| 156 #define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high" |
| 157 |
142 typedef SkDrawCommand* (*FROM_JSON)(Json::Value); | 158 typedef SkDrawCommand* (*FROM_JSON)(Json::Value); |
143 | 159 |
144 // TODO(chudy): Refactor into non subclass model. | 160 // TODO(chudy): Refactor into non subclass model. |
145 | 161 |
146 SkDrawCommand::SkDrawCommand(OpType type) | 162 SkDrawCommand::SkDrawCommand(OpType type) |
147 : fOpType(type) | 163 : fOpType(type) |
148 , fVisible(true) { | 164 , fVisible(true) { |
149 } | 165 } |
150 | 166 |
151 SkDrawCommand::~SkDrawCommand() { | 167 SkDrawCommand::~SkDrawCommand() { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 INSTALL_FACTORY(DrawPath); | 243 INSTALL_FACTORY(DrawPath); |
228 INSTALL_FACTORY(DrawPoints); | 244 INSTALL_FACTORY(DrawPoints); |
229 INSTALL_FACTORY(DrawText); | 245 INSTALL_FACTORY(DrawText); |
230 INSTALL_FACTORY(DrawPosText); | 246 INSTALL_FACTORY(DrawPosText); |
231 INSTALL_FACTORY(DrawTextOnPath); | 247 INSTALL_FACTORY(DrawTextOnPath); |
232 INSTALL_FACTORY(DrawTextBlob); | 248 INSTALL_FACTORY(DrawTextBlob); |
233 | 249 |
234 INSTALL_FACTORY(DrawRect); | 250 INSTALL_FACTORY(DrawRect); |
235 INSTALL_FACTORY(DrawRRect); | 251 INSTALL_FACTORY(DrawRRect); |
236 INSTALL_FACTORY(DrawDRRect); | 252 INSTALL_FACTORY(DrawDRRect); |
| 253 INSTALL_FACTORY(DrawPatch); |
237 INSTALL_FACTORY(Save); | 254 INSTALL_FACTORY(Save); |
238 INSTALL_FACTORY(SaveLayer); | 255 INSTALL_FACTORY(SaveLayer); |
239 INSTALL_FACTORY(SetMatrix); | 256 INSTALL_FACTORY(SetMatrix); |
240 } | 257 } |
241 SkString name = SkString(command[SKDEBUGCANVAS_ATTRIBUTE_COMMAND].asCString(
)); | 258 SkString name = SkString(command[SKDEBUGCANVAS_ATTRIBUTE_COMMAND].asCString(
)); |
242 FROM_JSON* factory = factories.find(name); | 259 FROM_JSON* factory = factories.find(name); |
243 if (factory == nullptr) { | 260 if (factory == nullptr) { |
244 SkDebugf("no JSON factory for '%s'\n", name.c_str()); | 261 SkDebugf("no JSON factory for '%s'\n", name.c_str()); |
245 return nullptr; | 262 return nullptr; |
246 } | 263 } |
247 return (*factory)(command); | 264 return (*factory)(command); |
248 } | 265 } |
249 | 266 |
250 SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) { | |
251 fColor = color; | |
252 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); | |
253 } | |
254 | |
255 void SkClearCommand::execute(SkCanvas* canvas) const { | |
256 canvas->clear(fColor); | |
257 } | |
258 | |
259 Json::Value SkClearCommand::toJSON() const { | |
260 Json::Value result = INHERITED::toJSON(); | |
261 Json::Value colorValue(Json::arrayValue); | |
262 colorValue.append(Json::Value(SkColorGetA(fColor))); | |
263 colorValue.append(Json::Value(SkColorGetR(fColor))); | |
264 colorValue.append(Json::Value(SkColorGetG(fColor))); | |
265 colorValue.append(Json::Value(SkColorGetB(fColor))); | |
266 result[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = colorValue;; | |
267 return result; | |
268 } | |
269 | |
270 SkClearCommand* SkClearCommand::fromJSON(Json::Value& command) { | |
271 Json::Value color = command[SKDEBUGCANVAS_ATTRIBUTE_COLOR]; | |
272 return new SkClearCommand(SkColorSetARGB(color[0].asInt(), color[1].asInt(),
color[2].asInt(), | |
273 color[3].asInt())); | |
274 } | |
275 | |
276 namespace { | 267 namespace { |
277 | 268 |
278 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) { | 269 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) { |
279 const SkISize& size = canvas->getDeviceSize(); | 270 const SkISize& size = canvas->getDeviceSize(); |
280 | 271 |
281 static const SkScalar kInsetFrac = 0.9f; // Leave a border around object | 272 static const SkScalar kInsetFrac = 0.9f; // Leave a border around object |
282 | 273 |
283 canvas->translate(size.fWidth/2.0f, size.fHeight/2.0f); | 274 canvas->translate(size.fWidth/2.0f, size.fHeight/2.0f); |
284 if (bounds.width() > bounds.height()) { | 275 if (bounds.width() > bounds.height()) { |
285 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.width()), | 276 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.width()), |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 SkPaint p; | 378 SkPaint p; |
388 p.setColor(SK_ColorBLACK); | 379 p.setColor(SK_ColorBLACK); |
389 p.setStyle(SkPaint::kStroke_Style); | 380 p.setStyle(SkPaint::kStroke_Style); |
390 | 381 |
391 canvas->drawDRRect(outer, inner, p); | 382 canvas->drawDRRect(outer, inner, p); |
392 canvas->restore(); | 383 canvas->restore(); |
393 } | 384 } |
394 | 385 |
395 }; | 386 }; |
396 | 387 |
| 388 static Json::Value make_json_color(const SkColor color) { |
| 389 Json::Value result(Json::arrayValue); |
| 390 result.append(Json::Value(SkColorGetA(color))); |
| 391 result.append(Json::Value(SkColorGetR(color))); |
| 392 result.append(Json::Value(SkColorGetG(color))); |
| 393 result.append(Json::Value(SkColorGetB(color))); |
| 394 return result; |
| 395 } |
| 396 |
| 397 |
397 static Json::Value make_json_point(const SkPoint& point) { | 398 static Json::Value make_json_point(const SkPoint& point) { |
398 Json::Value result(Json::arrayValue); | 399 Json::Value result(Json::arrayValue); |
399 result.append(Json::Value(point.x())); | 400 result.append(Json::Value(point.x())); |
400 result.append(Json::Value(point.y())); | 401 result.append(Json::Value(point.y())); |
401 return result; | 402 return result; |
402 } | 403 } |
403 | 404 |
404 static Json::Value make_json_point(SkScalar x, SkScalar y) { | 405 static Json::Value make_json_point(SkScalar x, SkScalar y) { |
405 Json::Value result(Json::arrayValue); | 406 Json::Value result(Json::arrayValue); |
406 result.append(Json::Value(x)); | 407 result.append(Json::Value(x)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 row2.append(Json::Value(matrix[4])); | 449 row2.append(Json::Value(matrix[4])); |
449 row2.append(Json::Value(matrix[5])); | 450 row2.append(Json::Value(matrix[5])); |
450 result.append(row2); | 451 result.append(row2); |
451 Json::Value row3(Json::arrayValue); | 452 Json::Value row3(Json::arrayValue); |
452 row3.append(Json::Value(matrix[6])); | 453 row3.append(Json::Value(matrix[6])); |
453 row3.append(Json::Value(matrix[7])); | 454 row3.append(Json::Value(matrix[7])); |
454 row3.append(Json::Value(matrix[8])); | 455 row3.append(Json::Value(matrix[8])); |
455 result.append(row3); | 456 result.append(row3); |
456 return result; | 457 return result; |
457 } | 458 } |
| 459 |
458 static Json::Value make_json_path(const SkPath& path) { | 460 static Json::Value make_json_path(const SkPath& path) { |
459 Json::Value result(Json::objectValue); | 461 Json::Value result(Json::objectValue); |
460 switch (path.getFillType()) { | 462 switch (path.getFillType()) { |
461 case SkPath::kWinding_FillType: | 463 case SkPath::kWinding_FillType: |
462 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_WI
NDING; | 464 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_WI
NDING; |
463 break; | 465 break; |
464 case SkPath::kEvenOdd_FillType: | 466 case SkPath::kEvenOdd_FillType: |
465 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_EV
ENODD; | 467 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_EV
ENODD; |
466 break; | 468 break; |
467 case SkPath::kInverseWinding_FillType: | 469 case SkPath::kInverseWinding_FillType: |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 } | 829 } |
828 default: SkASSERT(false); | 830 default: SkASSERT(false); |
829 } | 831 } |
830 } | 832 } |
831 } | 833 } |
832 | 834 |
833 static void apply_paint_cap(const SkPaint& paint, Json::Value* target) { | 835 static void apply_paint_cap(const SkPaint& paint, Json::Value* target) { |
834 SkPaint::Cap cap = paint.getStrokeCap(); | 836 SkPaint::Cap cap = paint.getStrokeCap(); |
835 if (cap != SkPaint::kDefault_Cap) { | 837 if (cap != SkPaint::kDefault_Cap) { |
836 switch (cap) { | 838 switch (cap) { |
837 case SkPaint::kButt_Cap: { | 839 case SkPaint::kButt_Cap: |
838 (*target)[SKDEBUGCANVAS_ATTRIBUTE_CAP] = Json::Value(SKDEBUGCANV
AS_CAP_BUTT); | 840 (*target)[SKDEBUGCANVAS_ATTRIBUTE_CAP] = Json::Value(SKDEBUGCANV
AS_CAP_BUTT); |
839 break; | 841 break; |
840 } | 842 case SkPaint::kRound_Cap: |
841 case SkPaint::kRound_Cap: { | |
842 (*target)[SKDEBUGCANVAS_ATTRIBUTE_CAP] = Json::Value(SKDEBUGCANV
AS_CAP_ROUND); | 843 (*target)[SKDEBUGCANVAS_ATTRIBUTE_CAP] = Json::Value(SKDEBUGCANV
AS_CAP_ROUND); |
843 break; | 844 break; |
844 } | 845 case SkPaint::kSquare_Cap: |
845 case SkPaint::kSquare_Cap: { | |
846 (*target)[SKDEBUGCANVAS_ATTRIBUTE_CAP] = Json::Value(SKDEBUGCANV
AS_CAP_SQUARE); | 846 (*target)[SKDEBUGCANVAS_ATTRIBUTE_CAP] = Json::Value(SKDEBUGCANV
AS_CAP_SQUARE); |
847 break; | 847 break; |
848 } | |
849 default: SkASSERT(false); | 848 default: SkASSERT(false); |
850 } | 849 } |
851 } | 850 } |
852 } | 851 } |
| 852 |
| 853 static void apply_paint_join(const SkPaint& paint, Json::Value* target) { |
| 854 SkPaint::Join join = paint.getStrokeJoin(); |
| 855 if (join != SkPaint::kDefault_Join) { |
| 856 switch (join) { |
| 857 case SkPaint::kMiter_Join: |
| 858 (*target)[SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN] = Json::Value( |
| 859 SKDEBU
GCANVAS_MITER_JOIN); |
| 860 break; |
| 861 case SkPaint::kRound_Join: |
| 862 (*target)[SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN] = Json::Value( |
| 863 SKDEBU
GCANVAS_ROUND_JOIN); |
| 864 break; |
| 865 case SkPaint::kBevel_Join: |
| 866 (*target)[SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN] = Json::Value( |
| 867 SKDEBUGC
ANVAS_BEVEL_JOIN); |
| 868 break; |
| 869 default: SkASSERT(false); |
| 870 } |
| 871 } |
| 872 } |
| 873 |
| 874 static void apply_paint_filterquality(const SkPaint& paint, Json::Value* target)
{ |
| 875 SkFilterQuality quality = paint.getFilterQuality(); |
| 876 switch (quality) { |
| 877 case kNone_SkFilterQuality: |
| 878 break; |
| 879 case kLow_SkFilterQuality: |
| 880 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value( |
| 881 SKDEBUGCANVAS
_FILTERQUALITY_LOW); |
| 882 break; |
| 883 case kMedium_SkFilterQuality: |
| 884 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value( |
| 885 SKDEBUGCANVAS_FI
LTERQUALITY_MEDIUM); |
| 886 break; |
| 887 case kHigh_SkFilterQuality: |
| 888 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value( |
| 889 SKDEBUGCANVAS_
FILTERQUALITY_HIGH); |
| 890 break; |
| 891 } |
| 892 } |
| 893 |
853 static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target, bo
ol sendBinaries) { | 894 static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target, bo
ol sendBinaries) { |
854 SkMaskFilter* maskFilter = paint.getMaskFilter(); | 895 SkMaskFilter* maskFilter = paint.getMaskFilter(); |
855 if (maskFilter != nullptr) { | 896 if (maskFilter != nullptr) { |
856 SkMaskFilter::BlurRec blurRec; | 897 SkMaskFilter::BlurRec blurRec; |
857 if (maskFilter->asABlur(&blurRec)) { | 898 if (maskFilter->asABlur(&blurRec)) { |
858 Json::Value blur(Json::objectValue); | 899 Json::Value blur(Json::objectValue); |
859 blur[SKDEBUGCANVAS_ATTRIBUTE_SIGMA] = Json::Value(blurRec.fSigma); | 900 blur[SKDEBUGCANVAS_ATTRIBUTE_SIGMA] = Json::Value(blurRec.fSigma); |
860 switch (blurRec.fStyle) { | 901 switch (blurRec.fStyle) { |
861 case SkBlurStyle::kNormal_SkBlurStyle: | 902 case SkBlurStyle::kNormal_SkBlurStyle: |
862 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value(SKDEBUGCAN
VAS_BLURSTYLE_NORMAL); | 903 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value( |
| 904 SKDEBUGCANVA
S_BLURSTYLE_NORMAL); |
863 break; | 905 break; |
864 case SkBlurStyle::kSolid_SkBlurStyle: | 906 case SkBlurStyle::kSolid_SkBlurStyle: |
865 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value(SKDEBUGCAN
VAS_BLURSTYLE_SOLID); | 907 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value( |
| 908 SKDEBUGCANV
AS_BLURSTYLE_SOLID); |
866 break; | 909 break; |
867 case SkBlurStyle::kOuter_SkBlurStyle: | 910 case SkBlurStyle::kOuter_SkBlurStyle: |
868 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value(SKDEBUGCAN
VAS_BLURSTYLE_OUTER); | 911 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value( |
| 912 SKDEBUGCANV
AS_BLURSTYLE_OUTER); |
869 break; | 913 break; |
870 case SkBlurStyle::kInner_SkBlurStyle: | 914 case SkBlurStyle::kInner_SkBlurStyle: |
871 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value(SKDEBUGCAN
VAS_BLURSTYLE_INNER); | 915 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value( |
| 916 SKDEBUGCANV
AS_BLURSTYLE_INNER); |
872 break; | 917 break; |
873 default: | 918 default: |
874 SkASSERT(false); | 919 SkASSERT(false); |
875 } | 920 } |
876 switch (blurRec.fQuality) { | 921 switch (blurRec.fQuality) { |
877 case SkBlurQuality::kLow_SkBlurQuality: | 922 case SkBlurQuality::kLow_SkBlurQuality: |
878 blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value(SKDEBUGC
ANVAS_BLURQUALITY_LOW); | 923 blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value( |
| 924 SKDEBUGCANV
AS_BLURQUALITY_LOW); |
879 break; | 925 break; |
880 case SkBlurQuality::kHigh_SkBlurQuality: | 926 case SkBlurQuality::kHigh_SkBlurQuality: |
881 blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value(SKDEBUGC
ANVAS_BLURQUALITY_HIGH); | 927 blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value( |
| 928 SKDEBUGCANVA
S_BLURQUALITY_HIGH); |
882 break; | 929 break; |
883 default: | 930 default: |
884 SkASSERT(false); | 931 SkASSERT(false); |
885 } | 932 } |
886 (*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur; | 933 (*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur; |
887 } else { | 934 } else { |
888 Json::Value jsonMaskFilter; | 935 Json::Value jsonMaskFilter; |
889 flatten(maskFilter, &jsonMaskFilter, sendBinaries); | 936 flatten(maskFilter, &jsonMaskFilter, sendBinaries); |
890 (*target)[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER] = jsonMaskFilter; | 937 (*target)[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER] = jsonMaskFilter; |
891 } | 938 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 | 1029 |
983 static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target, b
ool sendBinaries) { | 1030 static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target, b
ool sendBinaries) { |
984 SkFlattenable* colorFilter = paint.getColorFilter(); | 1031 SkFlattenable* colorFilter = paint.getColorFilter(); |
985 if (colorFilter != nullptr) { | 1032 if (colorFilter != nullptr) { |
986 Json::Value jsonColorFilter; | 1033 Json::Value jsonColorFilter; |
987 flatten(colorFilter, &jsonColorFilter, sendBinaries); | 1034 flatten(colorFilter, &jsonColorFilter, sendBinaries); |
988 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter; | 1035 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter; |
989 } | 1036 } |
990 } | 1037 } |
991 | 1038 |
| 1039 static void apply_paint_looper(const SkPaint& paint, Json::Value* target, bool s
endBinaries) { |
| 1040 SkFlattenable* looper = paint.getLooper(); |
| 1041 if (looper != nullptr) { |
| 1042 Json::Value jsonLooper; |
| 1043 flatten(looper, &jsonLooper, sendBinaries); |
| 1044 (*target)[SKDEBUGCANVAS_ATTRIBUTE_LOOPER] = jsonLooper; |
| 1045 } |
| 1046 } |
| 1047 |
992 Json::Value make_json_paint(const SkPaint& paint, bool sendBinaries) { | 1048 Json::Value make_json_paint(const SkPaint& paint, bool sendBinaries) { |
993 Json::Value result(Json::objectValue); | 1049 Json::Value result(Json::objectValue); |
994 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWi
dth(), 0.0f); | 1050 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWi
dth(), 0.0f); |
995 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMi
ter(), | 1051 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMi
ter(), |
996 SkPaintDefaults_MiterLimit); | 1052 SkPaintDefaults_MiterLimit); |
997 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(),
false); | 1053 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(),
false); |
| 1054 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false)
; |
998 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(),
| 1055 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(),
|
999 SkPaintDefaults_TextSize); | 1056 SkPaintDefaults_TextSize); |
1000 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScale
X(), SK_Scalar1); | 1057 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScale
X(), SK_Scalar1); |
1001 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX
(), 0.0f); | 1058 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX
(), 0.0f); |
1002 apply_paint_color(paint, &result); | 1059 apply_paint_color(paint, &result); |
1003 apply_paint_style(paint, &result); | 1060 apply_paint_style(paint, &result); |
1004 apply_paint_cap(paint, &result); | 1061 apply_paint_cap(paint, &result); |
| 1062 apply_paint_join(paint, &result); |
| 1063 apply_paint_filterquality(paint, &result); |
1005 apply_paint_textalign(paint, &result); | 1064 apply_paint_textalign(paint, &result); |
1006 apply_paint_patheffect(paint, &result, sendBinaries); | 1065 apply_paint_patheffect(paint, &result, sendBinaries); |
1007 apply_paint_maskfilter(paint, &result, sendBinaries); | 1066 apply_paint_maskfilter(paint, &result, sendBinaries); |
1008 apply_paint_shader(paint, &result, sendBinaries); | 1067 apply_paint_shader(paint, &result, sendBinaries); |
1009 apply_paint_xfermode(paint, &result, sendBinaries); | 1068 apply_paint_xfermode(paint, &result, sendBinaries); |
| 1069 apply_paint_looper(paint, &result, sendBinaries); |
1010 apply_paint_imagefilter(paint, &result, sendBinaries); | 1070 apply_paint_imagefilter(paint, &result, sendBinaries); |
1011 apply_paint_colorfilter(paint, &result, sendBinaries); | 1071 apply_paint_colorfilter(paint, &result, sendBinaries); |
1012 apply_paint_typeface(paint, &result, sendBinaries); | 1072 apply_paint_typeface(paint, &result, sendBinaries); |
1013 return result; | 1073 return result; |
1014 } | 1074 } |
1015 | 1075 |
| 1076 static SkPoint get_json_point(Json::Value point) { |
| 1077 return SkPoint::Make(point[0].asFloat(), point[1].asFloat()); |
| 1078 } |
| 1079 |
| 1080 static SkColor get_json_color(Json::Value color) { |
| 1081 return SkColorSetARGB(color[0].asInt(), color[1].asInt(), color[2].asInt(),
color[3].asInt()); |
| 1082 } |
| 1083 |
1016 static void extract_json_paint_color(Json::Value& jsonPaint, SkPaint* target) { | 1084 static void extract_json_paint_color(Json::Value& jsonPaint, SkPaint* target) { |
1017 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) { | 1085 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) { |
1018 Json::Value color = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLOR]; | 1086 target->setColor(get_json_color(jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLOR]
)); |
1019 target->setColor(SkColorSetARGB(color[0].asInt(), color[1].asInt(), colo
r[2].asInt(), | |
1020 color[3].asInt())); | |
1021 } | 1087 } |
1022 } | 1088 } |
1023 | 1089 |
1024 static void extract_json_paint_shader(Json::Value& jsonPaint, SkPaint* target) { | 1090 static void extract_json_paint_shader(Json::Value& jsonPaint, SkPaint* target) { |
1025 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_SHADER)) { | 1091 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_SHADER)) { |
1026 Json::Value jsonShader = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_SHADER]; | 1092 Json::Value jsonShader = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_SHADER]; |
1027 SkShader* shader = (SkShader*) load_flattenable(jsonShader); | 1093 SkShader* shader = (SkShader*) load_flattenable(jsonShader); |
1028 if (shader != nullptr) { | 1094 if (shader != nullptr) { |
1029 target->setShader(shader); | 1095 target->setShader(shader); |
1030 shader->unref(); | 1096 shader->unref(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) { | 1135 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) { |
1070 Json::Value jsonXfermode = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE]; | 1136 Json::Value jsonXfermode = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE]; |
1071 SkXfermode* xfermode = (SkXfermode*) load_flattenable(jsonXfermode); | 1137 SkXfermode* xfermode = (SkXfermode*) load_flattenable(jsonXfermode); |
1072 if (xfermode != nullptr) { | 1138 if (xfermode != nullptr) { |
1073 target->setXfermode(xfermode); | 1139 target->setXfermode(xfermode); |
1074 xfermode->unref(); | 1140 xfermode->unref(); |
1075 } | 1141 } |
1076 } | 1142 } |
1077 } | 1143 } |
1078 | 1144 |
| 1145 static void extract_json_paint_looper(Json::Value& jsonPaint, SkPaint* target) { |
| 1146 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_LOOPER)) { |
| 1147 Json::Value jsonLooper = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_LOOPER]; |
| 1148 SkDrawLooper* looper = (SkDrawLooper*) load_flattenable(jsonLooper); |
| 1149 if (looper != nullptr) { |
| 1150 target->setLooper(looper); |
| 1151 looper->unref(); |
| 1152 } |
| 1153 } |
| 1154 } |
| 1155 |
1079 static void extract_json_paint_imagefilter(Json::Value& jsonPaint, SkPaint* targ
et) { | 1156 static void extract_json_paint_imagefilter(Json::Value& jsonPaint, SkPaint* targ
et) { |
1080 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER)) { | 1157 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER)) { |
1081 Json::Value jsonImageFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFIL
TER]; | 1158 Json::Value jsonImageFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFIL
TER]; |
1082 SkImageFilter* imageFilter = (SkImageFilter*) load_flattenable(jsonImage
Filter); | 1159 SkImageFilter* imageFilter = (SkImageFilter*) load_flattenable(jsonImage
Filter); |
1083 if (imageFilter != nullptr) { | 1160 if (imageFilter != nullptr) { |
1084 target->setImageFilter(imageFilter); | 1161 target->setImageFilter(imageFilter); |
1085 imageFilter->unref(); | 1162 imageFilter->unref(); |
1086 } | 1163 } |
1087 } | 1164 } |
1088 } | 1165 } |
(...skipping 20 matching lines...) Expand all Loading... |
1109 } | 1186 } |
1110 } | 1187 } |
1111 | 1188 |
1112 static void extract_json_paint_strokemiter(Json::Value& jsonPaint, SkPaint* targ
et) { | 1189 static void extract_json_paint_strokemiter(Json::Value& jsonPaint, SkPaint* targ
et) { |
1113 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER)) { | 1190 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER)) { |
1114 float strokeMiter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER].asFlo
at(); | 1191 float strokeMiter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER].asFlo
at(); |
1115 target->setStrokeMiter(strokeMiter); | 1192 target->setStrokeMiter(strokeMiter); |
1116 } | 1193 } |
1117 } | 1194 } |
1118 | 1195 |
| 1196 static void extract_json_paint_strokejoin(Json::Value& jsonPaint, SkPaint* targe
t) { |
| 1197 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN)) { |
| 1198 const char* join = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN].asCStri
ng(); |
| 1199 if (!strcmp(join, SKDEBUGCANVAS_MITER_JOIN)) { |
| 1200 target->setStrokeJoin(SkPaint::kMiter_Join); |
| 1201 } |
| 1202 else if (!strcmp(join, SKDEBUGCANVAS_ROUND_JOIN)) { |
| 1203 target->setStrokeJoin(SkPaint::kRound_Join); |
| 1204 } |
| 1205 else if (!strcmp(join, SKDEBUGCANVAS_BEVEL_JOIN)) { |
| 1206 target->setStrokeJoin(SkPaint::kBevel_Join); |
| 1207 } |
| 1208 else { |
| 1209 SkASSERT(false); |
| 1210 } |
| 1211 } |
| 1212 } |
| 1213 |
1119 static void extract_json_paint_cap(Json::Value& jsonPaint, SkPaint* target) { | 1214 static void extract_json_paint_cap(Json::Value& jsonPaint, SkPaint* target) { |
1120 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_CAP)) { | 1215 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_CAP)) { |
1121 const char* cap = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_CAP].asCString(); | 1216 const char* cap = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_CAP].asCString(); |
1122 if (!strcmp(cap, SKDEBUGCANVAS_CAP_BUTT)) { | 1217 if (!strcmp(cap, SKDEBUGCANVAS_CAP_BUTT)) { |
1123 target->setStrokeCap(SkPaint::kButt_Cap); | 1218 target->setStrokeCap(SkPaint::kButt_Cap); |
1124 } | 1219 } |
1125 else if (!strcmp(cap, SKDEBUGCANVAS_CAP_ROUND)) { | 1220 else if (!strcmp(cap, SKDEBUGCANVAS_CAP_ROUND)) { |
1126 target->setStrokeCap(SkPaint::kRound_Cap); | 1221 target->setStrokeCap(SkPaint::kRound_Cap); |
1127 } | 1222 } |
1128 else if (!strcmp(cap, SKDEBUGCANVAS_CAP_SQUARE)) { | 1223 else if (!strcmp(cap, SKDEBUGCANVAS_CAP_SQUARE)) { |
1129 target->setStrokeCap(SkPaint::kSquare_Cap); | 1224 target->setStrokeCap(SkPaint::kSquare_Cap); |
1130 } | 1225 } |
1131 } | 1226 } |
1132 } | 1227 } |
1133 | 1228 |
| 1229 static void extract_json_paint_filterquality(Json::Value& jsonPaint, SkPaint* ta
rget) { |
| 1230 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY)) { |
| 1231 const char* quality = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY].a
sCString(); |
| 1232 if (!strcmp(quality, SKDEBUGCANVAS_FILTERQUALITY_NONE)) { |
| 1233 target->setFilterQuality(kNone_SkFilterQuality); |
| 1234 } |
| 1235 else if (!strcmp(quality, SKDEBUGCANVAS_FILTERQUALITY_LOW)) { |
| 1236 target->setFilterQuality(kLow_SkFilterQuality); |
| 1237 } |
| 1238 else if (!strcmp(quality, SKDEBUGCANVAS_FILTERQUALITY_MEDIUM)) { |
| 1239 target->setFilterQuality(kMedium_SkFilterQuality); |
| 1240 } |
| 1241 else if (!strcmp(quality, SKDEBUGCANVAS_FILTERQUALITY_HIGH)) { |
| 1242 target->setFilterQuality(kHigh_SkFilterQuality); |
| 1243 } |
| 1244 } |
| 1245 } |
| 1246 |
1134 static void extract_json_paint_antialias(Json::Value& jsonPaint, SkPaint* target
) { | 1247 static void extract_json_paint_antialias(Json::Value& jsonPaint, SkPaint* target
) { |
1135 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS)) { | 1248 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS)) { |
1136 target->setAntiAlias(jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBool
()); | 1249 target->setAntiAlias(jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBool
()); |
1137 } | 1250 } |
1138 } | 1251 } |
1139 | 1252 |
| 1253 static void extract_json_paint_dither(Json::Value& jsonPaint, SkPaint* target) { |
| 1254 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_DITHER)) { |
| 1255 target->setDither(jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_DITHER].asBool()); |
| 1256 } |
| 1257 } |
| 1258 |
1140 static void extract_json_paint_blur(Json::Value& jsonPaint, SkPaint* target) { | 1259 static void extract_json_paint_blur(Json::Value& jsonPaint, SkPaint* target) { |
1141 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_BLUR)) { | 1260 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_BLUR)) { |
1142 Json::Value blur = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_BLUR]; | 1261 Json::Value blur = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_BLUR]; |
1143 SkScalar sigma = blur[SKDEBUGCANVAS_ATTRIBUTE_SIGMA].asFloat(); | 1262 SkScalar sigma = blur[SKDEBUGCANVAS_ATTRIBUTE_SIGMA].asFloat(); |
1144 SkBlurStyle style; | 1263 SkBlurStyle style; |
1145 const char* jsonStyle = blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE].asCString(); | 1264 const char* jsonStyle = blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE].asCString(); |
1146 if (!strcmp(jsonStyle, SKDEBUGCANVAS_BLURSTYLE_NORMAL)) { | 1265 if (!strcmp(jsonStyle, SKDEBUGCANVAS_BLURSTYLE_NORMAL)) { |
1147 style = SkBlurStyle::kNormal_SkBlurStyle; | 1266 style = SkBlurStyle::kNormal_SkBlurStyle; |
1148 } | 1267 } |
1149 else if (!strcmp(jsonStyle, SKDEBUGCANVAS_BLURSTYLE_SOLID)) { | 1268 else if (!strcmp(jsonStyle, SKDEBUGCANVAS_BLURSTYLE_SOLID)) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 } | 1364 } |
1246 } | 1365 } |
1247 | 1366 |
1248 static void extract_json_paint(Json::Value& paint, SkPaint* result) { | 1367 static void extract_json_paint(Json::Value& paint, SkPaint* result) { |
1249 extract_json_paint_color(paint, result); | 1368 extract_json_paint_color(paint, result); |
1250 extract_json_paint_shader(paint, result); | 1369 extract_json_paint_shader(paint, result); |
1251 extract_json_paint_patheffect(paint, result); | 1370 extract_json_paint_patheffect(paint, result); |
1252 extract_json_paint_maskfilter(paint, result); | 1371 extract_json_paint_maskfilter(paint, result); |
1253 extract_json_paint_colorfilter(paint, result); | 1372 extract_json_paint_colorfilter(paint, result); |
1254 extract_json_paint_xfermode(paint, result); | 1373 extract_json_paint_xfermode(paint, result); |
| 1374 extract_json_paint_looper(paint, result); |
1255 extract_json_paint_imagefilter(paint, result); | 1375 extract_json_paint_imagefilter(paint, result); |
1256 extract_json_paint_style(paint, result); | 1376 extract_json_paint_style(paint, result); |
1257 extract_json_paint_strokewidth(paint, result); | 1377 extract_json_paint_strokewidth(paint, result); |
1258 extract_json_paint_strokemiter(paint, result); | 1378 extract_json_paint_strokemiter(paint, result); |
| 1379 extract_json_paint_strokejoin(paint, result); |
1259 extract_json_paint_cap(paint, result); | 1380 extract_json_paint_cap(paint, result); |
| 1381 extract_json_paint_filterquality(paint, result); |
1260 extract_json_paint_antialias(paint, result); | 1382 extract_json_paint_antialias(paint, result); |
| 1383 extract_json_paint_dither(paint, result); |
1261 extract_json_paint_blur(paint, result); | 1384 extract_json_paint_blur(paint, result); |
1262 extract_json_paint_dashing(paint, result); | 1385 extract_json_paint_dashing(paint, result); |
1263 extract_json_paint_textalign(paint, result); | 1386 extract_json_paint_textalign(paint, result); |
1264 extract_json_paint_textsize(paint, result); | 1387 extract_json_paint_textsize(paint, result); |
1265 extract_json_paint_textscalex(paint, result); | 1388 extract_json_paint_textscalex(paint, result); |
1266 extract_json_paint_textskewx(paint, result); | 1389 extract_json_paint_textskewx(paint, result); |
1267 extract_json_paint_typeface(paint, result); | 1390 extract_json_paint_typeface(paint, result); |
1268 } | 1391 } |
1269 | 1392 |
1270 static void extract_json_rect(Json::Value& rect, SkRect* result) { | 1393 static void extract_json_rect(Json::Value& rect, SkRect* result) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 else if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_REVERSE_DIFFERENCE)) { | 1490 else if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_REVERSE_DIFFERENCE)) { |
1368 return SkRegion::kReverseDifference_Op; | 1491 return SkRegion::kReverseDifference_Op; |
1369 } | 1492 } |
1370 else if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_REPLACE)) { | 1493 else if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_REPLACE)) { |
1371 return SkRegion::kReplace_Op; | 1494 return SkRegion::kReplace_Op; |
1372 } | 1495 } |
1373 SkASSERT(false); | 1496 SkASSERT(false); |
1374 return SkRegion::kIntersect_Op; | 1497 return SkRegion::kIntersect_Op; |
1375 } | 1498 } |
1376 | 1499 |
| 1500 SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) { |
| 1501 fColor = color; |
| 1502 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
| 1503 } |
| 1504 |
| 1505 void SkClearCommand::execute(SkCanvas* canvas) const { |
| 1506 canvas->clear(fColor); |
| 1507 } |
| 1508 |
| 1509 Json::Value SkClearCommand::toJSON() const { |
| 1510 Json::Value result = INHERITED::toJSON(); |
| 1511 result[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = make_json_color(fColor); |
| 1512 return result; |
| 1513 } |
| 1514 |
| 1515 SkClearCommand* SkClearCommand::fromJSON(Json::Value& command) { |
| 1516 Json::Value color = command[SKDEBUGCANVAS_ATTRIBUTE_COLOR]; |
| 1517 return new SkClearCommand(get_json_color(color)); |
| 1518 } |
1377 | 1519 |
1378 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) | 1520 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) |
1379 : INHERITED(kClipPath_OpType) { | 1521 : INHERITED(kClipPath_OpType) { |
1380 fPath = path; | 1522 fPath = path; |
1381 fOp = op; | 1523 fOp = op; |
1382 fDoAA = doAA; | 1524 fDoAA = doAA; |
1383 | 1525 |
1384 fInfo.push(SkObjectParser::PathToString(path)); | 1526 fInfo.push(SkObjectParser::PathToString(path)); |
1385 fInfo.push(SkObjectParser::RegionOpToString(op)); | 1527 fInfo.push(SkObjectParser::RegionOpToString(op)); |
1386 fInfo.push(SkObjectParser::BoolToString(doAA)); | 1528 fInfo.push(SkObjectParser::BoolToString(doAA)); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1555 } | 1697 } |
1556 | 1698 |
1557 Json::Value SkDrawBitmapCommand::toJSON() const { | 1699 Json::Value SkDrawBitmapCommand::toJSON() const { |
1558 Json::Value result = INHERITED::toJSON(); | 1700 Json::Value result = INHERITED::toJSON(); |
1559 Json::Value encoded; | 1701 Json::Value encoded; |
1560 if (flatten(fBitmap, &encoded, SKDEBUGCANVAS_SEND_BINARIES)) { | 1702 if (flatten(fBitmap, &encoded, SKDEBUGCANVAS_SEND_BINARIES)) { |
1561 Json::Value command(Json::objectValue); | 1703 Json::Value command(Json::objectValue); |
1562 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; | 1704 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; |
1563 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); | 1705 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); |
1564 if (fPaintPtr != nullptr) { | 1706 if (fPaintPtr != nullptr) { |
1565 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
SKDEBUGCANVAS_SEND_BINARIES); | 1707 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, |
| 1708 SKDEBUGCANVA
S_SEND_BINARIES); |
1566 } | 1709 } |
1567 } | 1710 } |
1568 return result; | 1711 return result; |
1569 } | 1712 } |
1570 | 1713 |
1571 SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command) { | 1714 SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command) { |
1572 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP]); | 1715 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP]); |
1573 if (bitmap == nullptr) { | 1716 if (bitmap == nullptr) { |
1574 return nullptr; | 1717 return nullptr; |
1575 } | 1718 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); | 1988 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); |
1846 } | 1989 } |
1847 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); | 1990 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
1848 if (paint) { | 1991 if (paint) { |
1849 fInfo.push(SkObjectParser::PaintToString(*paint)); | 1992 fInfo.push(SkObjectParser::PaintToString(*paint)); |
1850 } | 1993 } |
1851 fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: ")); | 1994 fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: ")); |
1852 } | 1995 } |
1853 | 1996 |
1854 void SkDrawImageRectCommand::execute(SkCanvas* canvas) const { | 1997 void SkDrawImageRectCommand::execute(SkCanvas* canvas) const { |
1855 canvas->legacy_drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMa
ybeNull(), fConstraint); | 1998 canvas->legacy_drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMa
ybeNull(), |
| 1999 fConstraint); |
1856 } | 2000 } |
1857 | 2001 |
1858 bool SkDrawImageRectCommand::render(SkCanvas* canvas) const { | 2002 bool SkDrawImageRectCommand::render(SkCanvas* canvas) const { |
1859 SkAutoCanvasRestore acr(canvas, true); | 2003 SkAutoCanvasRestore acr(canvas, true); |
1860 canvas->clear(0xFFFFFFFF); | 2004 canvas->clear(0xFFFFFFFF); |
1861 | 2005 |
1862 xlate_and_scale_to_bounds(canvas, fDst); | 2006 xlate_and_scale_to_bounds(canvas, fDst); |
1863 | 2007 |
1864 this->execute(canvas); | 2008 this->execute(canvas); |
1865 return true; | 2009 return true; |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 SkPaint paint; | 2545 SkPaint paint; |
2402 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); | 2546 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); |
2403 return new SkDrawTextBlobCommand(builder.build(), x, y, paint); | 2547 return new SkDrawTextBlobCommand(builder.build(), x, y, paint); |
2404 } | 2548 } |
2405 | 2549 |
2406 SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor c
olors[4], | 2550 SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor c
olors[4], |
2407 const SkPoint texCoords[4], SkXfermode* x
fermode, | 2551 const SkPoint texCoords[4], SkXfermode* x
fermode, |
2408 const SkPaint& paint) | 2552 const SkPaint& paint) |
2409 : INHERITED(kDrawPatch_OpType) { | 2553 : INHERITED(kDrawPatch_OpType) { |
2410 memcpy(fCubics, cubics, sizeof(fCubics)); | 2554 memcpy(fCubics, cubics, sizeof(fCubics)); |
2411 memcpy(fColors, colors, sizeof(fColors)); | 2555 if (colors != nullptr) { |
2412 memcpy(fTexCoords, texCoords, sizeof(fTexCoords)); | 2556 memcpy(fColors, colors, sizeof(fColors)); |
2413 fXfermode.reset(xfermode); | 2557 fColorsPtr = fColors; |
| 2558 } else { |
| 2559 fColorsPtr = nullptr; |
| 2560 } |
| 2561 if (texCoords != nullptr) { |
| 2562 memcpy(fTexCoords, texCoords, sizeof(fTexCoords)); |
| 2563 fTexCoordsPtr = fTexCoords; |
| 2564 } else { |
| 2565 fTexCoordsPtr = nullptr; |
| 2566 } |
| 2567 if (xfermode != nullptr) { |
| 2568 fXfermode.reset(SkRef(xfermode)); |
| 2569 } |
2414 fPaint = paint; | 2570 fPaint = paint; |
2415 | 2571 |
2416 fInfo.push(SkObjectParser::PaintToString(paint)); | 2572 fInfo.push(SkObjectParser::PaintToString(paint)); |
2417 } | 2573 } |
2418 | 2574 |
2419 void SkDrawPatchCommand::execute(SkCanvas* canvas) const { | 2575 void SkDrawPatchCommand::execute(SkCanvas* canvas) const { |
2420 canvas->drawPatch(fCubics, fColors, fTexCoords, fXfermode, fPaint); | 2576 canvas->drawPatch(fCubics, fColorsPtr, fTexCoordsPtr, fXfermode, fPaint); |
| 2577 } |
| 2578 |
| 2579 Json::Value SkDrawPatchCommand::toJSON() const { |
| 2580 Json::Value result = INHERITED::toJSON(); |
| 2581 Json::Value cubics = Json::Value(Json::arrayValue); |
| 2582 for (int i = 0; i < 12; i++) { |
| 2583 cubics.append(make_json_point(fCubics[i])); |
| 2584 } |
| 2585 result[SKDEBUGCANVAS_ATTRIBUTE_CUBICS] = cubics; |
| 2586 if (fColorsPtr != nullptr) { |
| 2587 Json::Value colors = Json::Value(Json::arrayValue); |
| 2588 for (int i = 0; i < 4; i++) { |
| 2589 colors.append(make_json_color(fColorsPtr[i])); |
| 2590 } |
| 2591 result[SKDEBUGCANVAS_ATTRIBUTE_COLORS] = colors; |
| 2592 } |
| 2593 if (fTexCoordsPtr != nullptr) { |
| 2594 Json::Value texCoords = Json::Value(Json::arrayValue); |
| 2595 for (int i = 0; i < 4; i++) { |
| 2596 texCoords.append(make_json_point(fTexCoords[i])); |
| 2597 } |
| 2598 result[SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS] = texCoords; |
| 2599 } |
| 2600 if (fXfermode.get() != nullptr) { |
| 2601 Json::Value jsonXfermode; |
| 2602 flatten(fXfermode, &jsonXfermode, SKDEBUGCANVAS_SEND_BINARIES); |
| 2603 result[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; |
| 2604 } |
| 2605 return result; |
| 2606 } |
| 2607 |
| 2608 SkDrawPatchCommand* SkDrawPatchCommand::fromJSON(Json::Value& command) { |
| 2609 Json::Value jsonCubics = command[SKDEBUGCANVAS_ATTRIBUTE_CUBICS]; |
| 2610 SkPoint cubics[12]; |
| 2611 for (int i = 0; i < 12; i++) { |
| 2612 cubics[i] = get_json_point(jsonCubics[i]); |
| 2613 } |
| 2614 SkColor* colorsPtr; |
| 2615 SkColor colors[4]; |
| 2616 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORS)) { |
| 2617 Json::Value jsonColors = command[SKDEBUGCANVAS_ATTRIBUTE_COLORS]; |
| 2618 for (int i = 0; i < 4; i++) { |
| 2619 colors[i] = get_json_color(jsonColors[i]); |
| 2620 } |
| 2621 colorsPtr = colors; |
| 2622 } |
| 2623 else { |
| 2624 colorsPtr = nullptr; |
| 2625 } |
| 2626 SkPoint* texCoordsPtr; |
| 2627 SkPoint texCoords[4]; |
| 2628 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS)) { |
| 2629 Json::Value jsonTexCoords = command[SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORD
S]; |
| 2630 for (int i = 0; i < 4; i++) { |
| 2631 texCoords[i] = get_json_point(jsonTexCoords[i]); |
| 2632 } |
| 2633 texCoordsPtr = texCoords; |
| 2634 } |
| 2635 else { |
| 2636 texCoordsPtr = nullptr; |
| 2637 } |
| 2638 SkAutoTUnref<SkXfermode> xfermode; |
| 2639 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) { |
| 2640 Json::Value jsonXfermode = command[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE]; |
| 2641 xfermode.reset((SkXfermode*) load_flattenable(jsonXfermode)); |
| 2642 } |
| 2643 SkPaint paint; |
| 2644 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); |
| 2645 return new SkDrawPatchCommand(cubics, colorsPtr, texCoordsPtr, xfermode, pai
nt); |
2421 } | 2646 } |
2422 | 2647 |
2423 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) | 2648 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) |
2424 : INHERITED(kDrawRect_OpType) { | 2649 : INHERITED(kDrawRect_OpType) { |
2425 fRect = rect; | 2650 fRect = rect; |
2426 fPaint = paint; | 2651 fPaint = paint; |
2427 | 2652 |
2428 fInfo.push(SkObjectParser::RectToString(rect)); | 2653 fInfo.push(SkObjectParser::RectToString(rect)); |
2429 fInfo.push(SkObjectParser::PaintToString(paint)); | 2654 fInfo.push(SkObjectParser::PaintToString(paint)); |
2430 } | 2655 } |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2795 if (rec.fBackdrop != nullptr) { | 3020 if (rec.fBackdrop != nullptr) { |
2796 rec.fBackdrop->unref(); | 3021 rec.fBackdrop->unref(); |
2797 } | 3022 } |
2798 return result; | 3023 return result; |
2799 } | 3024 } |
2800 | 3025 |
2801 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) | 3026 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) |
2802 : INHERITED(kSetMatrix_OpType) { | 3027 : INHERITED(kSetMatrix_OpType) { |
2803 fUserMatrix.reset(); | 3028 fUserMatrix.reset(); |
2804 fMatrix = matrix; | 3029 fMatrix = matrix; |
2805 | |
2806 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 3030 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
2807 } | 3031 } |
2808 | 3032 |
2809 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { | 3033 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { |
2810 fUserMatrix = userMatrix; | 3034 fUserMatrix = userMatrix; |
2811 } | 3035 } |
2812 | 3036 |
2813 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { | 3037 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
2814 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 3038 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
2815 canvas->setMatrix(temp); | 3039 canvas->setMatrix(temp); |
2816 } | 3040 } |
2817 | 3041 |
2818 Json::Value SkSetMatrixCommand::toJSON() const { | 3042 Json::Value SkSetMatrixCommand::toJSON() const { |
2819 Json::Value result = INHERITED::toJSON(); | 3043 Json::Value result = INHERITED::toJSON(); |
2820 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); | 3044 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); |
2821 return result; | 3045 return result; |
2822 } | 3046 } |
2823 | 3047 |
2824 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command) { | 3048 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command) { |
2825 SkMatrix matrix; | 3049 SkMatrix matrix; |
2826 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3050 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
2827 return new SkSetMatrixCommand(matrix); | 3051 return new SkSetMatrixCommand(matrix); |
2828 } | 3052 } |
OLD | NEW |