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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 449 |
450 static Json::Value make_json_rect(const SkRect& rect) { | 450 static Json::Value make_json_rect(const SkRect& rect) { |
451 Json::Value result(Json::arrayValue); | 451 Json::Value result(Json::arrayValue); |
452 result.append(Json::Value(rect.left())); | 452 result.append(Json::Value(rect.left())); |
453 result.append(Json::Value(rect.top())); | 453 result.append(Json::Value(rect.top())); |
454 result.append(Json::Value(rect.right())); | 454 result.append(Json::Value(rect.right())); |
455 result.append(Json::Value(rect.bottom())); | 455 result.append(Json::Value(rect.bottom())); |
456 return result; | 456 return result; |
457 } | 457 } |
458 | 458 |
459 static Json::Value make_json_irect(const SkIRect& rect) { | 459 Json::Value SkDrawCommand::MakeJsonIRect(const SkIRect& rect) { |
460 Json::Value result(Json::arrayValue); | 460 Json::Value result(Json::arrayValue); |
461 result.append(Json::Value(rect.left())); | 461 result.append(Json::Value(rect.left())); |
462 result.append(Json::Value(rect.top())); | 462 result.append(Json::Value(rect.top())); |
463 result.append(Json::Value(rect.right())); | 463 result.append(Json::Value(rect.right())); |
464 result.append(Json::Value(rect.bottom())); | 464 result.append(Json::Value(rect.bottom())); |
465 return result; | 465 return result; |
466 } | 466 } |
467 | 467 |
468 static Json::Value make_json_rrect(const SkRRect& rrect) { | 468 static Json::Value make_json_rrect(const SkRRect& rrect) { |
469 Json::Value result(Json::arrayValue); | 469 Json::Value result(Json::arrayValue); |
470 result.append(make_json_rect(rrect.rect())); | 470 result.append(make_json_rect(rrect.rect())); |
471 result.append(make_json_point(rrect.radii(SkRRect::kUpperLeft_Corner))); | 471 result.append(make_json_point(rrect.radii(SkRRect::kUpperLeft_Corner))); |
472 result.append(make_json_point(rrect.radii(SkRRect::kUpperRight_Corner))); | 472 result.append(make_json_point(rrect.radii(SkRRect::kUpperRight_Corner))); |
473 result.append(make_json_point(rrect.radii(SkRRect::kLowerRight_Corner))); | 473 result.append(make_json_point(rrect.radii(SkRRect::kLowerRight_Corner))); |
474 result.append(make_json_point(rrect.radii(SkRRect::kLowerLeft_Corner))); | 474 result.append(make_json_point(rrect.radii(SkRRect::kLowerLeft_Corner))); |
475 return result; | 475 return result; |
476 } | 476 } |
477 | 477 |
478 static Json::Value make_json_matrix(const SkMatrix& matrix) { | 478 Json::Value SkDrawCommand::MakeJsonMatrix(const SkMatrix& matrix) { |
479 Json::Value result(Json::arrayValue); | 479 Json::Value result(Json::arrayValue); |
480 Json::Value row1(Json::arrayValue); | 480 Json::Value row1(Json::arrayValue); |
481 row1.append(Json::Value(matrix[0])); | 481 row1.append(Json::Value(matrix[0])); |
482 row1.append(Json::Value(matrix[1])); | 482 row1.append(Json::Value(matrix[1])); |
483 row1.append(Json::Value(matrix[2])); | 483 row1.append(Json::Value(matrix[2])); |
484 result.append(row1); | 484 result.append(row1); |
485 Json::Value row2(Json::arrayValue); | 485 Json::Value row2(Json::arrayValue); |
486 row2.append(Json::Value(matrix[3])); | 486 row2.append(Json::Value(matrix[3])); |
487 row2.append(Json::Value(matrix[4])); | 487 row2.append(Json::Value(matrix[4])); |
488 row2.append(Json::Value(matrix[5])); | 488 row2.append(Json::Value(matrix[5])); |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 | 1700 |
1701 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 1701 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
1702 } | 1702 } |
1703 | 1703 |
1704 void SkConcatCommand::execute(SkCanvas* canvas) const { | 1704 void SkConcatCommand::execute(SkCanvas* canvas) const { |
1705 canvas->concat(fMatrix); | 1705 canvas->concat(fMatrix); |
1706 } | 1706 } |
1707 | 1707 |
1708 Json::Value SkConcatCommand::toJSON(UrlDataManager& urlDataManager) const { | 1708 Json::Value SkConcatCommand::toJSON(UrlDataManager& urlDataManager) const { |
1709 Json::Value result = INHERITED::toJSON(urlDataManager); | 1709 Json::Value result = INHERITED::toJSON(urlDataManager); |
1710 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); | 1710 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
1711 return result; | 1711 return result; |
1712 } | 1712 } |
1713 | 1713 |
1714 SkConcatCommand* SkConcatCommand::fromJSON(Json::Value& command, UrlDataManager&
urlDataManager) { | 1714 SkConcatCommand* SkConcatCommand::fromJSON(Json::Value& command, UrlDataManager&
urlDataManager) { |
1715 SkMatrix matrix; | 1715 SkMatrix matrix; |
1716 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 1716 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
1717 return new SkConcatCommand(matrix); | 1717 return new SkConcatCommand(matrix); |
1718 } | 1718 } |
1719 | 1719 |
1720 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, | 1720 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 SkRect tmp = SkRect::Make(fCenter); | 1812 SkRect tmp = SkRect::Make(fCenter); |
1813 render_bitmap(canvas, fBitmap, &tmp); | 1813 render_bitmap(canvas, fBitmap, &tmp); |
1814 return true; | 1814 return true; |
1815 } | 1815 } |
1816 | 1816 |
1817 Json::Value SkDrawBitmapNineCommand::toJSON(UrlDataManager& urlDataManager) cons
t { | 1817 Json::Value SkDrawBitmapNineCommand::toJSON(UrlDataManager& urlDataManager) cons
t { |
1818 Json::Value result = INHERITED::toJSON(urlDataManager); | 1818 Json::Value result = INHERITED::toJSON(urlDataManager); |
1819 Json::Value encoded; | 1819 Json::Value encoded; |
1820 if (flatten(fBitmap, &encoded, urlDataManager)) { | 1820 if (flatten(fBitmap, &encoded, urlDataManager)) { |
1821 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; | 1821 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; |
1822 result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = make_json_irect(fCenter); | 1822 result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = MakeJsonIRect(fCenter); |
1823 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); | 1823 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); |
1824 if (fPaintPtr != nullptr) { | 1824 if (fPaintPtr != nullptr) { |
1825 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); | 1825 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); |
1826 } | 1826 } |
1827 } | 1827 } |
1828 return result; | 1828 return result; |
1829 } | 1829 } |
1830 | 1830 |
1831 SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command,
| 1831 SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command,
|
1832 UrlDataManager& urlDa
taManager) { | 1832 UrlDataManager& urlDa
taManager) { |
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2876 fPaint); | 2876 fPaint); |
2877 } | 2877 } |
2878 | 2878 |
2879 Json::Value SkDrawTextOnPathCommand::toJSON(UrlDataManager& urlDataManager) cons
t { | 2879 Json::Value SkDrawTextOnPathCommand::toJSON(UrlDataManager& urlDataManager) cons
t { |
2880 Json::Value result = INHERITED::toJSON(urlDataManager); | 2880 Json::Value result = INHERITED::toJSON(urlDataManager); |
2881 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | 2881 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
2882 ((const char*) fText) + f
ByteLength); | 2882 ((const char*) fText) + f
ByteLength); |
2883 Json::Value coords(Json::arrayValue); | 2883 Json::Value coords(Json::arrayValue); |
2884 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); | 2884 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); |
2885 if (!fMatrix.isIdentity()) { | 2885 if (!fMatrix.isIdentity()) { |
2886 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); | 2886 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
2887 } | 2887 } |
2888 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2888 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2889 return result; | 2889 return result; |
2890 } | 2890 } |
2891 | 2891 |
2892 SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command,
| 2892 SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command,
|
2893 UrlDataManager& urlDa
taManager) { | 2893 UrlDataManager& urlDa
taManager) { |
2894 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2894 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
2895 SkPaint paint; | 2895 SkPaint paint; |
2896 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2896 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3098 fUserMatrix = userMatrix; | 3098 fUserMatrix = userMatrix; |
3099 } | 3099 } |
3100 | 3100 |
3101 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { | 3101 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
3102 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 3102 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
3103 canvas->setMatrix(temp); | 3103 canvas->setMatrix(temp); |
3104 } | 3104 } |
3105 | 3105 |
3106 Json::Value SkSetMatrixCommand::toJSON(UrlDataManager& urlDataManager) const { | 3106 Json::Value SkSetMatrixCommand::toJSON(UrlDataManager& urlDataManager) const { |
3107 Json::Value result = INHERITED::toJSON(urlDataManager); | 3107 Json::Value result = INHERITED::toJSON(urlDataManager); |
3108 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); | 3108 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
3109 return result; | 3109 return result; |
3110 } | 3110 } |
3111 | 3111 |
3112 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3112 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
3113 UrlDataManager& urlDataManager)
{ | 3113 UrlDataManager& urlDataManager)
{ |
3114 SkMatrix matrix; | 3114 SkMatrix matrix; |
3115 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3115 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
3116 return new SkSetMatrixCommand(matrix); | 3116 return new SkSetMatrixCommand(matrix); |
3117 } | 3117 } |
OLD | NEW |