OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | 8 |
10 #include "SkDrawCommand.h" | 9 #include "SkDrawCommand.h" |
11 | 10 |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 break; | 466 break; |
468 case SkPath::kEvenOdd_FillType: | 467 case SkPath::kEvenOdd_FillType: |
469 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_EV
ENODD; | 468 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_EV
ENODD; |
470 break; | 469 break; |
471 case SkPath::kInverseWinding_FillType: | 470 case SkPath::kInverseWinding_FillType: |
472 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_IN
VERSEWINDING; | 471 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_IN
VERSEWINDING; |
473 break; | 472 break; |
474 case SkPath::kInverseEvenOdd_FillType: | 473 case SkPath::kInverseEvenOdd_FillType: |
475 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_IN
VERSEEVENODD; | 474 result[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE] = SKDEBUGCANVAS_FILLTYPE_IN
VERSEEVENODD; |
476 break; | 475 break; |
477 } | 476 } |
478 Json::Value verbs(Json::arrayValue); | 477 Json::Value verbs(Json::arrayValue); |
479 SkPath::Iter iter(path, false); | 478 SkPath::Iter iter(path, false); |
480 SkPoint pts[4]; | 479 SkPoint pts[4]; |
481 SkPath::Verb verb; | 480 SkPath::Verb verb; |
482 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { | 481 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { |
483 switch (verb) { | 482 switch (verb) { |
484 case SkPath::kLine_Verb: { | 483 case SkPath::kLine_Verb: { |
485 Json::Value line(Json::objectValue); | 484 Json::Value line(Json::objectValue); |
486 line[SKDEBUGCANVAS_VERB_LINE] = make_json_point(pts[1]); | 485 line[SKDEBUGCANVAS_VERB_LINE] = make_json_point(pts[1]); |
487 verbs.append(line); | 486 verbs.append(line); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 return Json::Value("<invalid region op>"); | 555 return Json::Value("<invalid region op>"); |
557 }; | 556 }; |
558 } | 557 } |
559 | 558 |
560 static Json::Value make_json_pointmode(SkCanvas::PointMode mode) { | 559 static Json::Value make_json_pointmode(SkCanvas::PointMode mode) { |
561 switch (mode) { | 560 switch (mode) { |
562 case SkCanvas::kPoints_PointMode: | 561 case SkCanvas::kPoints_PointMode: |
563 return Json::Value(SKDEBUGCANVAS_POINTMODE_POINTS); | 562 return Json::Value(SKDEBUGCANVAS_POINTMODE_POINTS); |
564 case SkCanvas::kLines_PointMode: | 563 case SkCanvas::kLines_PointMode: |
565 return Json::Value(SKDEBUGCANVAS_POINTMODE_LINES); | 564 return Json::Value(SKDEBUGCANVAS_POINTMODE_LINES); |
566 case SkCanvas::kPolygon_PointMode: | 565 case SkCanvas::kPolygon_PointMode: |
567 return Json::Value(SKDEBUGCANVAS_POINTMODE_POLYGON); | 566 return Json::Value(SKDEBUGCANVAS_POINTMODE_POLYGON); |
568 default: | 567 default: |
569 SkASSERT(false); | 568 SkASSERT(false); |
570 return Json::Value("<invalid point mode>"); | 569 return Json::Value("<invalid point mode>"); |
571 }; | 570 }; |
572 } | 571 } |
573 | 572 |
574 static void store_scalar(Json::Value* target, const char* key, SkScalar value, | 573 static void store_scalar(Json::Value* target, const char* key, SkScalar value, |
575 SkScalar defaultValue) { | 574 SkScalar defaultValue) { |
576 if (value != defaultValue) { | 575 if (value != defaultValue) { |
577 (*target)[key] = Json::Value(value); | 576 (*target)[key] = Json::Value(value); |
578 } | 577 } |
579 } | 578 } |
580 | 579 |
581 static void store_bool(Json::Value* target, const char* key, bool value, bool de
faultValue) { | 580 static void store_bool(Json::Value* target, const char* key, bool value, bool de
faultValue) { |
582 if (value != defaultValue) { | 581 if (value != defaultValue) { |
583 (*target)[key] = Json::Value(value); | 582 (*target)[key] = Json::Value(value); |
584 } | 583 } |
585 } | 584 } |
586 | 585 |
587 static void encode_data(const void* bytes, size_t count, const char* contentType
, | 586 static void encode_data(const void* bytes, size_t count, const char* contentType
, |
588 UrlDataManager& urlDataManager, Json::Value* target) { | 587 UrlDataManager& urlDataManager, Json::Value* target) { |
589 SkAutoTUnref<SkData> data(SkData::NewWithCopy(bytes, count)); | 588 SkAutoTUnref<SkData> data(SkData::NewWithCopy(bytes, count)); |
590 SkString url = urlDataManager.addData(data, contentType); | 589 SkString url = urlDataManager.addData(data, contentType); |
591 *target = Json::Value(url.c_str()); | 590 *target = Json::Value(url.c_str()); |
592 } | 591 } |
593 | 592 |
594 static void flatten(const SkFlattenable* flattenable, Json::Value* target, | 593 static void flatten(const SkFlattenable* flattenable, Json::Value* target, |
595 UrlDataManager& urlDataManager) { | 594 UrlDataManager& urlDataManager) { |
596 SkWriteBuffer buffer; | 595 SkWriteBuffer buffer; |
597 flattenable->flatten(buffer); | 596 flattenable->flatten(buffer); |
598 void* data = sk_malloc_throw(buffer.bytesWritten()); | 597 void* data = sk_malloc_throw(buffer.bytesWritten()); |
599 buffer.writeToMemory(data); | 598 buffer.writeToMemory(data); |
600 Json::Value jsonData; | 599 Json::Value jsonData; |
601 encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlData
Manager, &jsonData); | 600 encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlData
Manager, &jsonData); |
602 Json::Value jsonFlattenable; | 601 Json::Value jsonFlattenable; |
603 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME] = Json::Value(flattenable->get
TypeName()); | 602 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME] = Json::Value(flattenable->get
TypeName()); |
604 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData; | 603 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData; |
605 (*target) = jsonFlattenable; | 604 (*target) = jsonFlattenable; |
606 sk_free(data); | 605 sk_free(data); |
607 } | 606 } |
608 | 607 |
609 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l
ength) { | 608 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l
ength) { |
610 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); | 609 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); |
611 out->write(data, length); | 610 out->write(data, length); |
612 } | 611 } |
613 | 612 |
614 void SkDrawCommand::WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_3
2 height, | 613 void SkDrawCommand::WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_3
2 height, |
615 SkWStream& out) { | 614 SkWStream& out) { |
616 png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL,
NULL); | 615 png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL,
NULL); |
617 SkASSERT(png != nullptr); | 616 SkASSERT(png != nullptr); |
618 png_infop info_ptr = png_create_info_struct(png); | 617 png_infop info_ptr = png_create_info_struct(png); |
619 SkASSERT(info_ptr != nullptr); | 618 SkASSERT(info_ptr != nullptr); |
620 if (setjmp(png_jmpbuf(png))) { | 619 if (setjmp(png_jmpbuf(png))) { |
621 SkFAIL("png encode error"); | 620 SkFAIL("png encode error"); |
622 } | 621 } |
623 png_set_IHDR(png, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERL
ACE_NONE, | 622 png_set_IHDR(png, info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERL
ACE_NONE, |
624 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); | 623 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); |
(...skipping 12 matching lines...) Expand all Loading... |
637 } | 636 } |
638 png_set_filter(png, 0, PNG_NO_FILTERS); | 637 png_set_filter(png, 0, PNG_NO_FILTERS); |
639 png_set_rows(png, info_ptr, &rows[0]); | 638 png_set_rows(png, info_ptr, &rows[0]); |
640 png_set_write_fn(png, &out, write_png_callback, NULL); | 639 png_set_write_fn(png, &out, write_png_callback, NULL); |
641 png_write_png(png, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); | 640 png_write_png(png, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); |
642 png_destroy_write_struct(&png, NULL); | 641 png_destroy_write_struct(&png, NULL); |
643 sk_free(rows); | 642 sk_free(rows); |
644 sk_free(pixels); | 643 sk_free(pixels); |
645 } | 644 } |
646 | 645 |
647 static bool SK_WARN_UNUSED_RESULT flatten(const SkImage& image, Json::Value* tar
get, | 646 static bool SK_WARN_UNUSED_RESULT flatten(const SkImage& image, Json::Value* tar
get, |
648 UrlDataManager& urlDataManager) { | 647 UrlDataManager& urlDataManager) { |
649 size_t rowBytes = 4 * image.width(); | 648 size_t rowBytes = 4 * image.width(); |
650 SkAutoFree buffer(sk_malloc_throw(rowBytes * image.height())); | 649 SkAutoFree buffer(sk_malloc_throw(rowBytes * image.height())); |
651 SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(), | 650 SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(), |
652 kN32_SkColorType, kPremul_SkAlphaTyp
e); | 651 kN32_SkColorType, kPremul_SkAlphaTyp
e); |
653 if (!image.readPixels(dstInfo, buffer.get(), rowBytes, 0, 0)) { | 652 if (!image.readPixels(dstInfo, buffer.get(), rowBytes, 0, 0)) { |
654 SkDebugf("readPixels failed\n"); | 653 SkDebugf("readPixels failed\n"); |
655 return false; | 654 return false; |
656 } | 655 } |
657 SkDynamicMemoryWStream out; | 656 SkDynamicMemoryWStream out; |
658 SkDrawCommand::WritePNG((png_bytep) buffer.get(), image.width(), image.heigh
t(), out); | 657 SkDrawCommand::WritePNG((png_bytep) buffer.get(), image.width(), image.heigh
t(), out); |
659 SkData* encoded = out.copyToData(); | 658 SkData* encoded = out.copyToData(); |
660 Json::Value jsonData; | 659 Json::Value jsonData; |
661 encode_data(encoded->data(), encoded->size(), "image/png", urlDataManager, &
jsonData); | 660 encode_data(encoded->data(), encoded->size(), "image/png", urlDataManager, &
jsonData); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 case kPremul_SkAlphaType: | 692 case kPremul_SkAlphaType: |
694 return SKDEBUGCANVAS_ALPHATYPE_PREMUL; | 693 return SKDEBUGCANVAS_ALPHATYPE_PREMUL; |
695 case kUnpremul_SkAlphaType: | 694 case kUnpremul_SkAlphaType: |
696 return SKDEBUGCANVAS_ALPHATYPE_UNPREMUL; | 695 return SKDEBUGCANVAS_ALPHATYPE_UNPREMUL; |
697 default: | 696 default: |
698 SkASSERT(false); | 697 SkASSERT(false); |
699 return SKDEBUGCANVAS_ALPHATYPE_OPAQUE; | 698 return SKDEBUGCANVAS_ALPHATYPE_OPAQUE; |
700 } | 699 } |
701 } | 700 } |
702 | 701 |
703 static Json::ArrayIndex decode_data(Json::Value data, UrlDataManager& urlDataMan
ager, | 702 static Json::ArrayIndex decode_data(Json::Value data, UrlDataManager& urlDataMan
ager, |
704 const void** target) { | 703 const void** target) { |
705 UrlDataManager::UrlData* urlData = urlDataManager.getDataFromUrl(SkString(da
ta.asCString())); | 704 UrlDataManager::UrlData* urlData = urlDataManager.getDataFromUrl(SkString(da
ta.asCString())); |
706 if (urlData == nullptr) { | 705 if (urlData == nullptr) { |
707 SkASSERT(false); | 706 SkASSERT(false); |
708 *target = nullptr; | 707 *target = nullptr; |
709 return 0; | 708 return 0; |
710 } | 709 } |
711 *target = urlData->fData->data(); | 710 *target = urlData->fData->data(); |
712 // cast should be safe for any reasonably-sized object... | 711 // cast should be safe for any reasonably-sized object... |
713 return (Json::ArrayIndex) urlData->fData->size(); | 712 return (Json::ArrayIndex) urlData->fData->size(); |
714 } | 713 } |
715 | 714 |
716 static SkFlattenable* load_flattenable(Json::Value jsonFlattenable, | 715 static SkFlattenable* load_flattenable(Json::Value jsonFlattenable, |
717 UrlDataManager& urlDataManager) { | 716 UrlDataManager& urlDataManager) { |
718 if (!jsonFlattenable.isMember(SKDEBUGCANVAS_ATTRIBUTE_NAME)) { | 717 if (!jsonFlattenable.isMember(SKDEBUGCANVAS_ATTRIBUTE_NAME)) { |
719 return nullptr; | 718 return nullptr; |
720 } | 719 } |
721 const char* name = jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME].asCString()
; | 720 const char* name = jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME].asCString()
; |
722 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name); | 721 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name); |
723 if (factory == nullptr) { | 722 if (factory == nullptr) { |
724 SkDebugf("no factory for loading '%s'\n", name); | 723 SkDebugf("no factory for loading '%s'\n", name); |
725 return nullptr; | 724 return nullptr; |
726 } | 725 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 static sk_sp<SkImage> load_image(const Json::Value& jsonImage, UrlDataManager& u
rlDataManager) { | 808 static sk_sp<SkImage> load_image(const Json::Value& jsonImage, UrlDataManager& u
rlDataManager) { |
810 SkBitmap* bitmap = load_bitmap(jsonImage, urlDataManager); | 809 SkBitmap* bitmap = load_bitmap(jsonImage, urlDataManager); |
811 if (bitmap == nullptr) { | 810 if (bitmap == nullptr) { |
812 return nullptr; | 811 return nullptr; |
813 } | 812 } |
814 auto result = SkImage::MakeFromBitmap(*bitmap); | 813 auto result = SkImage::MakeFromBitmap(*bitmap); |
815 delete bitmap; | 814 delete bitmap; |
816 return result; | 815 return result; |
817 } | 816 } |
818 | 817 |
819 static bool SK_WARN_UNUSED_RESULT flatten(const SkBitmap& bitmap, Json::Value* t
arget, | 818 static bool SK_WARN_UNUSED_RESULT flatten(const SkBitmap& bitmap, Json::Value* t
arget, |
820 UrlDataManager& urlDataManager) { | 819 UrlDataManager& urlDataManager) { |
821 bitmap.lockPixels(); | 820 bitmap.lockPixels(); |
822 sk_sp<SkImage> image(SkImage::MakeFromBitmap(bitmap)); | 821 sk_sp<SkImage> image(SkImage::MakeFromBitmap(bitmap)); |
823 bitmap.unlockPixels(); | 822 bitmap.unlockPixels(); |
824 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = Json::Value(color_type_name(bitma
p.colorType())); | 823 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = Json::Value(color_type_name(bitma
p.colorType())); |
825 (*target)[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = Json::Value(alpha_type_name(bitma
p.alphaType())); | 824 (*target)[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = Json::Value(alpha_type_name(bitma
p.alphaType())); |
826 bool success = flatten(*image, target, urlDataManager); | 825 bool success = flatten(*image, target, urlDataManager); |
827 return success; | 826 return success; |
828 } | 827 } |
829 | 828 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value( | 909 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value( |
911 SKDEBUGCANVAS_FI
LTERQUALITY_MEDIUM); | 910 SKDEBUGCANVAS_FI
LTERQUALITY_MEDIUM); |
912 break; | 911 break; |
913 case kHigh_SkFilterQuality: | 912 case kHigh_SkFilterQuality: |
914 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value( | 913 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value( |
915 SKDEBUGCANVAS_
FILTERQUALITY_HIGH); | 914 SKDEBUGCANVAS_
FILTERQUALITY_HIGH); |
916 break; | 915 break; |
917 } | 916 } |
918 } | 917 } |
919 | 918 |
920 static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target, | 919 static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target, |
921 UrlDataManager& urlDataManager) { | 920 UrlDataManager& urlDataManager) { |
922 SkMaskFilter* maskFilter = paint.getMaskFilter(); | 921 SkMaskFilter* maskFilter = paint.getMaskFilter(); |
923 if (maskFilter != nullptr) { | 922 if (maskFilter != nullptr) { |
924 SkMaskFilter::BlurRec blurRec; | 923 SkMaskFilter::BlurRec blurRec; |
925 if (maskFilter->asABlur(&blurRec)) { | 924 if (maskFilter->asABlur(&blurRec)) { |
926 Json::Value blur(Json::objectValue); | 925 Json::Value blur(Json::objectValue); |
927 blur[SKDEBUGCANVAS_ATTRIBUTE_SIGMA] = Json::Value(blurRec.fSigma); | 926 blur[SKDEBUGCANVAS_ATTRIBUTE_SIGMA] = Json::Value(blurRec.fSigma); |
928 switch (blurRec.fStyle) { | 927 switch (blurRec.fStyle) { |
929 case SkBlurStyle::kNormal_SkBlurStyle: | 928 case SkBlurStyle::kNormal_SkBlurStyle: |
930 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value( | 929 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value( |
(...skipping 28 matching lines...) Expand all Loading... |
959 } | 958 } |
960 (*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur; | 959 (*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur; |
961 } else { | 960 } else { |
962 Json::Value jsonMaskFilter; | 961 Json::Value jsonMaskFilter; |
963 flatten(maskFilter, &jsonMaskFilter, urlDataManager); | 962 flatten(maskFilter, &jsonMaskFilter, urlDataManager); |
964 (*target)[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER] = jsonMaskFilter; | 963 (*target)[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER] = jsonMaskFilter; |
965 } | 964 } |
966 } | 965 } |
967 } | 966 } |
968 | 967 |
969 static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target, | 968 static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target, |
970 UrlDataManager& urlDataManager) { | 969 UrlDataManager& urlDataManager) { |
971 SkPathEffect* pathEffect = paint.getPathEffect(); | 970 SkPathEffect* pathEffect = paint.getPathEffect(); |
972 if (pathEffect != nullptr) { | 971 if (pathEffect != nullptr) { |
973 SkPathEffect::DashInfo dashInfo; | 972 SkPathEffect::DashInfo dashInfo; |
974 SkPathEffect::DashType dashType = pathEffect->asADash(&dashInfo); | 973 SkPathEffect::DashType dashType = pathEffect->asADash(&dashInfo); |
975 if (dashType == SkPathEffect::kDash_DashType) { | 974 if (dashType == SkPathEffect::kDash_DashType) { |
976 dashInfo.fIntervals = (SkScalar*) sk_malloc_throw(dashInfo.fCount *
sizeof(SkScalar)); | 975 dashInfo.fIntervals = (SkScalar*) sk_malloc_throw(dashInfo.fCount *
sizeof(SkScalar)); |
977 pathEffect->asADash(&dashInfo); | 976 pathEffect->asADash(&dashInfo); |
978 Json::Value dashing(Json::objectValue); | 977 Json::Value dashing(Json::objectValue); |
979 Json::Value intervals(Json::arrayValue); | 978 Json::Value intervals(Json::arrayValue); |
980 for (int32_t i = 0; i < dashInfo.fCount; i++) { | 979 for (int32_t i = 0; i < dashInfo.fCount; i++) { |
981 intervals.append(Json::Value(dashInfo.fIntervals[i])); | 980 intervals.append(Json::Value(dashInfo.fIntervals[i])); |
982 } | 981 } |
983 sk_free(dashInfo.fIntervals); | 982 sk_free(dashInfo.fIntervals); |
984 dashing[SKDEBUGCANVAS_ATTRIBUTE_INTERVALS] = intervals; | 983 dashing[SKDEBUGCANVAS_ATTRIBUTE_INTERVALS] = intervals; |
985 dashing[SKDEBUGCANVAS_ATTRIBUTE_PHASE] = dashInfo.fPhase; | 984 dashing[SKDEBUGCANVAS_ATTRIBUTE_PHASE] = dashInfo.fPhase; |
986 (*target)[SKDEBUGCANVAS_ATTRIBUTE_DASHING] = dashing; | 985 (*target)[SKDEBUGCANVAS_ATTRIBUTE_DASHING] = dashing; |
987 } else { | 986 } else { |
988 Json::Value jsonPathEffect; | 987 Json::Value jsonPathEffect; |
989 flatten(pathEffect, &jsonPathEffect, urlDataManager); | 988 flatten(pathEffect, &jsonPathEffect, urlDataManager); |
990 (*target)[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT] = jsonPathEffect; | 989 (*target)[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT] = jsonPathEffect; |
991 } | 990 } |
992 } | 991 } |
993 } | 992 } |
994 | 993 |
995 static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) { | 994 static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) { |
996 SkPaint::Align textAlign = paint.getTextAlign(); | 995 SkPaint::Align textAlign = paint.getTextAlign(); |
997 if (textAlign != SkPaint::kLeft_Align) { | 996 if (textAlign != SkPaint::kLeft_Align) { |
998 switch (textAlign) { | 997 switch (textAlign) { |
999 case SkPaint::kCenter_Align: { | 998 case SkPaint::kCenter_Align: { |
1000 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN] = SKDEBUGCANVAS_ALI
GN_CENTER; | 999 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN] = SKDEBUGCANVAS_ALI
GN_CENTER; |
1001 break; | 1000 break; |
1002 } | 1001 } |
1003 case SkPaint::kRight_Align: { | 1002 case SkPaint::kRight_Align: { |
1004 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN] = SKDEBUGCANVAS_ALI
GN_RIGHT; | 1003 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN] = SKDEBUGCANVAS_ALI
GN_RIGHT; |
1005 break; | 1004 break; |
1006 } | 1005 } |
1007 default: SkASSERT(false); | 1006 default: SkASSERT(false); |
1008 } | 1007 } |
1009 } | 1008 } |
1010 } | 1009 } |
1011 | 1010 |
1012 static void apply_paint_typeface(const SkPaint& paint, Json::Value* target, | 1011 static void apply_paint_typeface(const SkPaint& paint, Json::Value* target, |
1013 UrlDataManager& urlDataManager) { | 1012 UrlDataManager& urlDataManager) { |
1014 SkTypeface* typeface = paint.getTypeface(); | 1013 SkTypeface* typeface = paint.getTypeface(); |
1015 if (typeface != nullptr) { | 1014 if (typeface != nullptr) { |
1016 Json::Value jsonTypeface; | 1015 Json::Value jsonTypeface; |
1017 SkDynamicMemoryWStream buffer; | 1016 SkDynamicMemoryWStream buffer; |
1018 typeface->serialize(&buffer); | 1017 typeface->serialize(&buffer); |
1019 void* data = sk_malloc_throw(buffer.bytesWritten()); | 1018 void* data = sk_malloc_throw(buffer.bytesWritten()); |
1020 buffer.copyTo(data); | 1019 buffer.copyTo(data); |
1021 Json::Value jsonData; | 1020 Json::Value jsonData; |
1022 encode_data(data, buffer.bytesWritten(), "application/octet-stream", url
DataManager, | 1021 encode_data(data, buffer.bytesWritten(), "application/octet-stream", url
DataManager, |
1023 &jsonData); | 1022 &jsonData); |
1024 jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData; | 1023 jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData; |
1025 sk_free(data); | 1024 sk_free(data); |
1026 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE] = jsonTypeface; | 1025 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE] = jsonTypeface; |
1027 } | 1026 } |
1028 } | 1027 } |
1029 | 1028 |
1030 static void apply_paint_shader(const SkPaint& paint, Json::Value* target, | 1029 static void apply_paint_shader(const SkPaint& paint, Json::Value* target, |
1031 UrlDataManager& urlDataManager) { | 1030 UrlDataManager& urlDataManager) { |
1032 SkFlattenable* shader = paint.getShader(); | 1031 SkFlattenable* shader = paint.getShader(); |
1033 if (shader != nullptr) { | 1032 if (shader != nullptr) { |
1034 Json::Value jsonShader; | 1033 Json::Value jsonShader; |
1035 flatten(shader, &jsonShader, urlDataManager); | 1034 flatten(shader, &jsonShader, urlDataManager); |
1036 (*target)[SKDEBUGCANVAS_ATTRIBUTE_SHADER] = jsonShader; | 1035 (*target)[SKDEBUGCANVAS_ATTRIBUTE_SHADER] = jsonShader; |
1037 } | 1036 } |
1038 } | 1037 } |
1039 | 1038 |
1040 static void apply_paint_xfermode(const SkPaint& paint, Json::Value* target, | 1039 static void apply_paint_xfermode(const SkPaint& paint, Json::Value* target, |
1041 UrlDataManager& urlDataManager) { | 1040 UrlDataManager& urlDataManager) { |
1042 SkFlattenable* xfermode = paint.getXfermode(); | 1041 SkFlattenable* xfermode = paint.getXfermode(); |
1043 if (xfermode != nullptr) { | 1042 if (xfermode != nullptr) { |
1044 Json::Value jsonXfermode; | 1043 Json::Value jsonXfermode; |
1045 flatten(xfermode, &jsonXfermode, urlDataManager); | 1044 flatten(xfermode, &jsonXfermode, urlDataManager); |
1046 (*target)[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; | 1045 (*target)[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; |
1047 } | 1046 } |
1048 } | 1047 } |
1049 | 1048 |
1050 static void apply_paint_imagefilter(const SkPaint& paint, Json::Value* target, | 1049 static void apply_paint_imagefilter(const SkPaint& paint, Json::Value* target, |
1051 UrlDataManager& urlDataManager) { | 1050 UrlDataManager& urlDataManager) { |
1052 SkFlattenable* imageFilter = paint.getImageFilter(); | 1051 SkFlattenable* imageFilter = paint.getImageFilter(); |
1053 if (imageFilter != nullptr) { | 1052 if (imageFilter != nullptr) { |
1054 Json::Value jsonImageFilter; | 1053 Json::Value jsonImageFilter; |
1055 flatten(imageFilter, &jsonImageFilter, urlDataManager); | 1054 flatten(imageFilter, &jsonImageFilter, urlDataManager); |
1056 (*target)[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER] = jsonImageFilter; | 1055 (*target)[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER] = jsonImageFilter; |
1057 } | 1056 } |
1058 } | 1057 } |
1059 | 1058 |
1060 static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target, | 1059 static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target, |
1061 UrlDataManager& urlDataManager) { | 1060 UrlDataManager& urlDataManager) { |
1062 SkFlattenable* colorFilter = paint.getColorFilter(); | 1061 SkFlattenable* colorFilter = paint.getColorFilter(); |
1063 if (colorFilter != nullptr) { | 1062 if (colorFilter != nullptr) { |
1064 Json::Value jsonColorFilter; | 1063 Json::Value jsonColorFilter; |
1065 flatten(colorFilter, &jsonColorFilter, urlDataManager); | 1064 flatten(colorFilter, &jsonColorFilter, urlDataManager); |
1066 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter; | 1065 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter; |
1067 } | 1066 } |
1068 } | 1067 } |
1069 | 1068 |
1070 static void apply_paint_looper(const SkPaint& paint, Json::Value* target, | 1069 static void apply_paint_looper(const SkPaint& paint, Json::Value* target, |
1071 UrlDataManager& urlDataManager) { | 1070 UrlDataManager& urlDataManager) { |
1072 SkFlattenable* looper = paint.getLooper(); | 1071 SkFlattenable* looper = paint.getLooper(); |
1073 if (looper != nullptr) { | 1072 if (looper != nullptr) { |
1074 Json::Value jsonLooper; | 1073 Json::Value jsonLooper; |
1075 flatten(looper, &jsonLooper, urlDataManager); | 1074 flatten(looper, &jsonLooper, urlDataManager); |
1076 (*target)[SKDEBUGCANVAS_ATTRIBUTE_LOOPER] = jsonLooper; | 1075 (*target)[SKDEBUGCANVAS_ATTRIBUTE_LOOPER] = jsonLooper; |
1077 } | 1076 } |
1078 } | 1077 } |
1079 | 1078 |
1080 Json::Value make_json_paint(const SkPaint& paint, UrlDataManager& urlDataManager
) { | 1079 Json::Value make_json_paint(const SkPaint& paint, UrlDataManager& urlDataManager
) { |
1081 Json::Value result(Json::objectValue); | 1080 Json::Value result(Json::objectValue); |
1082 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWi
dth(), 0.0f); | 1081 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWi
dth(), 0.0f); |
1083 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMi
ter(), | 1082 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMi
ter(), |
1084 SkPaintDefaults_MiterLimit); | 1083 SkPaintDefaults_MiterLimit); |
1085 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(),
false); | 1084 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(),
false); |
1086 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false)
; | 1085 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false)
; |
1087 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(),
| 1086 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(), |
1088 SkPaintDefaults_TextSize); | 1087 SkPaintDefaults_TextSize); |
1089 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScale
X(), SK_Scalar1); | 1088 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScale
X(), SK_Scalar1); |
1090 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX
(), 0.0f); | 1089 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX
(), 0.0f); |
1091 apply_paint_color(paint, &result); | 1090 apply_paint_color(paint, &result); |
1092 apply_paint_style(paint, &result); | 1091 apply_paint_style(paint, &result); |
1093 apply_paint_cap(paint, &result); | 1092 apply_paint_cap(paint, &result); |
1094 apply_paint_join(paint, &result); | 1093 apply_paint_join(paint, &result); |
1095 apply_paint_filterquality(paint, &result); | 1094 apply_paint_filterquality(paint, &result); |
1096 apply_paint_textalign(paint, &result); | 1095 apply_paint_textalign(paint, &result); |
1097 apply_paint_patheffect(paint, &result, urlDataManager); | 1096 apply_paint_patheffect(paint, &result, urlDataManager); |
(...skipping 14 matching lines...) Expand all Loading... |
1112 static SkColor get_json_color(Json::Value color) { | 1111 static SkColor get_json_color(Json::Value color) { |
1113 return SkColorSetARGB(color[0].asInt(), color[1].asInt(), color[2].asInt(),
color[3].asInt()); | 1112 return SkColorSetARGB(color[0].asInt(), color[1].asInt(), color[2].asInt(),
color[3].asInt()); |
1114 } | 1113 } |
1115 | 1114 |
1116 static void extract_json_paint_color(Json::Value& jsonPaint, SkPaint* target) { | 1115 static void extract_json_paint_color(Json::Value& jsonPaint, SkPaint* target) { |
1117 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) { | 1116 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) { |
1118 target->setColor(get_json_color(jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLOR]
)); | 1117 target->setColor(get_json_color(jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLOR]
)); |
1119 } | 1118 } |
1120 } | 1119 } |
1121 | 1120 |
1122 static void extract_json_paint_shader(Json::Value& jsonPaint, UrlDataManager& ur
lDataManager, | 1121 static void extract_json_paint_shader(Json::Value& jsonPaint, UrlDataManager& ur
lDataManager, |
1123 SkPaint* target) { | 1122 SkPaint* target) { |
1124 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_SHADER)) { | 1123 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_SHADER)) { |
1125 Json::Value jsonShader = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_SHADER]; | 1124 Json::Value jsonShader = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_SHADER]; |
1126 SkShader* shader = (SkShader*) load_flattenable(jsonShader, urlDataManag
er); | 1125 SkShader* shader = (SkShader*) load_flattenable(jsonShader, urlDataManag
er); |
1127 if (shader != nullptr) { | 1126 if (shader != nullptr) { |
1128 target->setShader(sk_ref_sp(shader)); | 1127 target->setShader(sk_ref_sp(shader)); |
1129 } | 1128 } |
1130 } | 1129 } |
1131 } | 1130 } |
1132 | 1131 |
1133 static void extract_json_paint_patheffect(Json::Value& jsonPaint, UrlDataManager
& urlDataManager, | 1132 static void extract_json_paint_patheffect(Json::Value& jsonPaint, UrlDataManager
& urlDataManager, |
1134 SkPaint* target) { | 1133 SkPaint* target) { |
1135 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT)) { | 1134 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT)) { |
1136 Json::Value jsonPathEffect = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFEC
T]; | 1135 Json::Value jsonPathEffect = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFEC
T]; |
1137 sk_sp<SkPathEffect> pathEffect((SkPathEffect*)load_flattenable(jsonPathE
ffect, | 1136 sk_sp<SkPathEffect> pathEffect((SkPathEffect*)load_flattenable(jsonPathE
ffect, |
1138 urlDataMa
nager)); | 1137 urlDataMa
nager)); |
1139 if (pathEffect != nullptr) { | 1138 if (pathEffect != nullptr) { |
1140 target->setPathEffect(pathEffect); | 1139 target->setPathEffect(pathEffect); |
1141 } | 1140 } |
1142 } | 1141 } |
1143 } | 1142 } |
1144 | 1143 |
1145 static void extract_json_paint_maskfilter(Json::Value& jsonPaint, UrlDataManager
& urlDataManager, | 1144 static void extract_json_paint_maskfilter(Json::Value& jsonPaint, UrlDataManager
& urlDataManager, |
1146 SkPaint* target) { | 1145 SkPaint* target) { |
1147 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER)) { | 1146 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER)) { |
1148 Json::Value jsonMaskFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTE
R]; | 1147 Json::Value jsonMaskFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTE
R]; |
1149 SkMaskFilter* maskFilter = (SkMaskFilter*) load_flattenable(jsonMaskFilt
er, urlDataManager); | 1148 SkMaskFilter* maskFilter = (SkMaskFilter*) load_flattenable(jsonMaskFilt
er, urlDataManager); |
1150 if (maskFilter != nullptr) { | 1149 if (maskFilter != nullptr) { |
1151 target->setMaskFilter(maskFilter); | 1150 target->setMaskFilter(maskFilter); |
1152 maskFilter->unref(); | 1151 maskFilter->unref(); |
1153 } | 1152 } |
1154 } | 1153 } |
1155 } | 1154 } |
1156 | 1155 |
1157 static void extract_json_paint_colorfilter(Json::Value& jsonPaint, UrlDataManage
r& urlDataManager, | 1156 static void extract_json_paint_colorfilter(Json::Value& jsonPaint, UrlDataManage
r& urlDataManager, |
1158 SkPaint* target) { | 1157 SkPaint* target) { |
1159 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER)) { | 1158 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER)) { |
1160 Json::Value jsonColorFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLORFIL
TER]; | 1159 Json::Value jsonColorFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLORFIL
TER]; |
1161 sk_sp<SkColorFilter> colorFilter((SkColorFilter*)load_flattenable(jsonCo
lorFilter, | 1160 sk_sp<SkColorFilter> colorFilter((SkColorFilter*)load_flattenable(jsonCo
lorFilter, |
1162 urlDat
aManager)); | 1161 urlDat
aManager)); |
1163 if (colorFilter != nullptr) { | 1162 if (colorFilter != nullptr) { |
1164 target->setColorFilter(colorFilter); | 1163 target->setColorFilter(colorFilter); |
1165 } | 1164 } |
1166 } | 1165 } |
1167 } | 1166 } |
1168 | 1167 |
1169 static void extract_json_paint_xfermode(Json::Value& jsonPaint, UrlDataManager&
urlDataManager, | 1168 static void extract_json_paint_xfermode(Json::Value& jsonPaint, UrlDataManager&
urlDataManager, |
1170 SkPaint* target) { | 1169 SkPaint* target) { |
1171 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) { | 1170 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) { |
1172 Json::Value jsonXfermode = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE]; | 1171 Json::Value jsonXfermode = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE]; |
1173 SkXfermode* xfermode = (SkXfermode*) load_flattenable(jsonXfermode, urlD
ataManager); | 1172 SkXfermode* xfermode = (SkXfermode*) load_flattenable(jsonXfermode, urlD
ataManager); |
1174 if (xfermode != nullptr) { | 1173 if (xfermode != nullptr) { |
1175 target->setXfermode(xfermode); | 1174 target->setXfermode(xfermode); |
1176 xfermode->unref(); | 1175 xfermode->unref(); |
1177 } | 1176 } |
1178 } | 1177 } |
1179 } | 1178 } |
1180 | 1179 |
1181 static void extract_json_paint_looper(Json::Value& jsonPaint, UrlDataManager& ur
lDataManager, | 1180 static void extract_json_paint_looper(Json::Value& jsonPaint, UrlDataManager& ur
lDataManager, |
1182 SkPaint* target) { | 1181 SkPaint* target) { |
1183 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_LOOPER)) { | 1182 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_LOOPER)) { |
1184 Json::Value jsonLooper = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_LOOPER]; | 1183 Json::Value jsonLooper = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_LOOPER]; |
1185 sk_sp<SkDrawLooper> looper((SkDrawLooper*) load_flattenable(jsonLooper,
urlDataManager)); | 1184 sk_sp<SkDrawLooper> looper((SkDrawLooper*) load_flattenable(jsonLooper,
urlDataManager)); |
1186 if (looper != nullptr) { | 1185 if (looper != nullptr) { |
1187 target->setLooper(std::move(looper)); | 1186 target->setLooper(std::move(looper)); |
1188 } | 1187 } |
1189 } | 1188 } |
1190 } | 1189 } |
1191 | 1190 |
1192 static void extract_json_paint_imagefilter(Json::Value& jsonPaint, UrlDataManage
r& urlDataManager, | 1191 static void extract_json_paint_imagefilter(Json::Value& jsonPaint, UrlDataManage
r& urlDataManager, |
1193 SkPaint* target) { | 1192 SkPaint* target) { |
1194 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER)) { | 1193 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER)) { |
1195 Json::Value jsonImageFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFIL
TER]; | 1194 Json::Value jsonImageFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFIL
TER]; |
1196 SkImageFilter* imageFilter = (SkImageFilter*) load_flattenable(jsonImage
Filter, | 1195 SkImageFilter* imageFilter = (SkImageFilter*) load_flattenable(jsonImage
Filter, |
1197 urlDataMa
nager); | 1196 urlDataMa
nager); |
1198 if (imageFilter != nullptr) { | 1197 if (imageFilter != nullptr) { |
1199 target->setImageFilter(imageFilter); | 1198 target->setImageFilter(imageFilter); |
1200 imageFilter->unref(); | 1199 imageFilter->unref(); |
1201 } | 1200 } |
1202 } | 1201 } |
1203 } | 1202 } |
1204 | 1203 |
1205 static void extract_json_paint_typeface(Json::Value& jsonPaint, UrlDataManager&
urlDataManager, | 1204 static void extract_json_paint_typeface(Json::Value& jsonPaint, UrlDataManager&
urlDataManager, |
1206 SkPaint* target) { | 1205 SkPaint* target) { |
1207 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE)) { | 1206 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE)) { |
1208 Json::Value jsonTypeface = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE]; | 1207 Json::Value jsonTypeface = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE]; |
1209 Json::Value jsonData = jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_DATA]; | 1208 Json::Value jsonData = jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_DATA]; |
1210 const void* data; | 1209 const void* data; |
1211 Json::ArrayIndex length = decode_data(jsonData, urlDataManager, &data); | 1210 Json::ArrayIndex length = decode_data(jsonData, urlDataManager, &data); |
1212 SkMemoryStream buffer(data, length); | 1211 SkMemoryStream buffer(data, length); |
1213 SkTypeface* typeface = SkTypeface::Deserialize(&buffer); | 1212 SkTypeface* typeface = SkTypeface::Deserialize(&buffer); |
1214 target->setTypeface(typeface); | 1213 target->setTypeface(typeface); |
1215 } | 1214 } |
(...skipping 11 matching lines...) Expand all Loading... |
1227 else if (!strcmp(style, SKDEBUGCANVAS_STYLE_STROKEANDFILL)) { | 1226 else if (!strcmp(style, SKDEBUGCANVAS_STYLE_STROKEANDFILL)) { |
1228 target->setStyle(SkPaint::kStrokeAndFill_Style); | 1227 target->setStyle(SkPaint::kStrokeAndFill_Style); |
1229 } | 1228 } |
1230 } | 1229 } |
1231 } | 1230 } |
1232 | 1231 |
1233 static void extract_json_paint_strokewidth(Json::Value& jsonPaint, SkPaint* targ
et) { | 1232 static void extract_json_paint_strokewidth(Json::Value& jsonPaint, SkPaint* targ
et) { |
1234 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH)) { | 1233 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH)) { |
1235 float strokeWidth = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH].asFlo
at(); | 1234 float strokeWidth = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH].asFlo
at(); |
1236 target->setStrokeWidth(strokeWidth); | 1235 target->setStrokeWidth(strokeWidth); |
1237 } | 1236 } |
1238 } | 1237 } |
1239 | 1238 |
1240 static void extract_json_paint_strokemiter(Json::Value& jsonPaint, SkPaint* targ
et) { | 1239 static void extract_json_paint_strokemiter(Json::Value& jsonPaint, SkPaint* targ
et) { |
1241 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER)) { | 1240 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER)) { |
1242 float strokeMiter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER].asFlo
at(); | 1241 float strokeMiter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER].asFlo
at(); |
1243 target->setStrokeMiter(strokeMiter); | 1242 target->setStrokeMiter(strokeMiter); |
1244 } | 1243 } |
1245 } | 1244 } |
1246 | 1245 |
1247 static void extract_json_paint_strokejoin(Json::Value& jsonPaint, SkPaint* targe
t) { | 1246 static void extract_json_paint_strokejoin(Json::Value& jsonPaint, SkPaint* targe
t) { |
1248 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN)) { | 1247 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN)) { |
1249 const char* join = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN].asCStri
ng(); | 1248 const char* join = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STROKEJOIN].asCStri
ng(); |
1250 if (!strcmp(join, SKDEBUGCANVAS_MITER_JOIN)) { | 1249 if (!strcmp(join, SKDEBUGCANVAS_MITER_JOIN)) { |
1251 target->setStrokeJoin(SkPaint::kMiter_Join); | 1250 target->setStrokeJoin(SkPaint::kMiter_Join); |
1252 } | 1251 } |
1253 else if (!strcmp(join, SKDEBUGCANVAS_ROUND_JOIN)) { | 1252 else if (!strcmp(join, SKDEBUGCANVAS_ROUND_JOIN)) { |
1254 target->setStrokeJoin(SkPaint::kRound_Join); | 1253 target->setStrokeJoin(SkPaint::kRound_Join); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 } | 1394 } |
1396 } | 1395 } |
1397 | 1396 |
1398 static void extract_json_paint_textskewx(Json::Value& jsonPaint, SkPaint* target
) { | 1397 static void extract_json_paint_textskewx(Json::Value& jsonPaint, SkPaint* target
) { |
1399 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX)) { | 1398 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX)) { |
1400 float textSkewX = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX].asFloat()
; | 1399 float textSkewX = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX].asFloat()
; |
1401 target->setTextSkewX(textSkewX); | 1400 target->setTextSkewX(textSkewX); |
1402 } | 1401 } |
1403 } | 1402 } |
1404 | 1403 |
1405 static void extract_json_paint(Json::Value& paint, UrlDataManager& urlDataManage
r, | 1404 static void extract_json_paint(Json::Value& paint, UrlDataManager& urlDataManage
r, |
1406 SkPaint* result) { | 1405 SkPaint* result) { |
1407 extract_json_paint_color(paint, result); | 1406 extract_json_paint_color(paint, result); |
1408 extract_json_paint_shader(paint, urlDataManager, result); | 1407 extract_json_paint_shader(paint, urlDataManager, result); |
1409 extract_json_paint_patheffect(paint, urlDataManager, result); | 1408 extract_json_paint_patheffect(paint, urlDataManager, result); |
1410 extract_json_paint_maskfilter(paint, urlDataManager, result); | 1409 extract_json_paint_maskfilter(paint, urlDataManager, result); |
1411 extract_json_paint_colorfilter(paint, urlDataManager, result); | 1410 extract_json_paint_colorfilter(paint, urlDataManager, result); |
1412 extract_json_paint_xfermode(paint, urlDataManager, result); | 1411 extract_json_paint_xfermode(paint, urlDataManager, result); |
1413 extract_json_paint_looper(paint, urlDataManager, result); | 1412 extract_json_paint_looper(paint, urlDataManager, result); |
1414 extract_json_paint_imagefilter(paint, urlDataManager, result); | 1413 extract_json_paint_imagefilter(paint, urlDataManager, result); |
1415 extract_json_paint_typeface(paint, urlDataManager, result); | 1414 extract_json_paint_typeface(paint, urlDataManager, result); |
(...skipping 16 matching lines...) Expand all Loading... |
1432 static void extract_json_rect(Json::Value& rect, SkRect* result) { | 1431 static void extract_json_rect(Json::Value& rect, SkRect* result) { |
1433 result->set(rect[0].asFloat(), rect[1].asFloat(), rect[2].asFloat(), rect[3]
.asFloat()); | 1432 result->set(rect[0].asFloat(), rect[1].asFloat(), rect[2].asFloat(), rect[3]
.asFloat()); |
1434 } | 1433 } |
1435 | 1434 |
1436 static void extract_json_irect(Json::Value& rect, SkIRect* result) { | 1435 static void extract_json_irect(Json::Value& rect, SkIRect* result) { |
1437 result->set(rect[0].asInt(), rect[1].asInt(), rect[2].asInt(), rect[3].asInt
()); | 1436 result->set(rect[0].asInt(), rect[1].asInt(), rect[2].asInt(), rect[3].asInt
()); |
1438 } | 1437 } |
1439 | 1438 |
1440 static void extract_json_rrect(Json::Value& rrect, SkRRect* result) { | 1439 static void extract_json_rrect(Json::Value& rrect, SkRRect* result) { |
1441 SkVector radii[4] = { | 1440 SkVector radii[4] = { |
1442 { rrect[1][0].asFloat(), rrect[1][1].asFloat() }, | 1441 { rrect[1][0].asFloat(), rrect[1][1].asFloat() }, |
1443 { rrect[2][0].asFloat(), rrect[2][1].asFloat() }, | 1442 { rrect[2][0].asFloat(), rrect[2][1].asFloat() }, |
1444 { rrect[3][0].asFloat(), rrect[3][1].asFloat() }, | 1443 { rrect[3][0].asFloat(), rrect[3][1].asFloat() }, |
1445 { rrect[4][0].asFloat(), rrect[4][1].asFloat() } | 1444 { rrect[4][0].asFloat(), rrect[4][1].asFloat() } |
1446 }; | 1445 }; |
1447 result->setRectRadii(SkRect::MakeLTRB(rrect[0][0].asFloat(), rrect[0][1].asF
loat(), | 1446 result->setRectRadii(SkRect::MakeLTRB(rrect[0][0].asFloat(), rrect[0][1].asF
loat(), |
1448 rrect[0][2].asFloat(), rrect[0][3].asF
loat()), | 1447 rrect[0][2].asFloat(), rrect[0][3].asF
loat()), |
1449 radii); | 1448 radii); |
1450 } | 1449 } |
1451 | 1450 |
1452 static void extract_json_matrix(Json::Value& matrix, SkMatrix* result) { | 1451 static void extract_json_matrix(Json::Value& matrix, SkMatrix* result) { |
1453 SkScalar values[] = { | 1452 SkScalar values[] = { |
1454 matrix[0][0].asFloat(), matrix[0][1].asFloat(), matrix[0][2].asFloat(), | 1453 matrix[0][0].asFloat(), matrix[0][1].asFloat(), matrix[0][2].asFloat(), |
1455 matrix[1][0].asFloat(), matrix[1][1].asFloat(), matrix[1][2].asFloat(), | 1454 matrix[1][0].asFloat(), matrix[1][1].asFloat(), matrix[1][2].asFloat(), |
1456 matrix[2][0].asFloat(), matrix[2][1].asFloat(), matrix[2][2].asFloat() | 1455 matrix[2][0].asFloat(), matrix[2][1].asFloat(), matrix[2][2].asFloat() |
1457 }; | 1456 }; |
1458 result->set9(values); | 1457 result->set9(values); |
1459 } | 1458 } |
1460 | 1459 |
1461 static void extract_json_path(Json::Value& path, SkPath* result) { | 1460 static void extract_json_path(Json::Value& path, SkPath* result) { |
1462 const char* fillType = path[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE].asCString(); | 1461 const char* fillType = path[SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE].asCString(); |
1463 if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_WINDING)) { | 1462 if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_WINDING)) { |
1464 result->setFillType(SkPath::kWinding_FillType); | 1463 result->setFillType(SkPath::kWinding_FillType); |
1465 } | 1464 } |
1466 else if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_EVENODD)) { | 1465 else if (!strcmp(fillType, SKDEBUGCANVAS_FILLTYPE_EVENODD)) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 } | 1576 } |
1578 | 1577 |
1579 Json::Value SkClipPathCommand::toJSON(UrlDataManager& urlDataManager) const { | 1578 Json::Value SkClipPathCommand::toJSON(UrlDataManager& urlDataManager) const { |
1580 Json::Value result = INHERITED::toJSON(urlDataManager); | 1579 Json::Value result = INHERITED::toJSON(urlDataManager); |
1581 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); | 1580 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); |
1582 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); | 1581 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); |
1583 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = fDoAA; | 1582 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = fDoAA; |
1584 return result; | 1583 return result; |
1585 } | 1584 } |
1586 | 1585 |
1587 SkClipPathCommand* SkClipPathCommand::fromJSON(Json::Value& command, | 1586 SkClipPathCommand* SkClipPathCommand::fromJSON(Json::Value& command, |
1588 UrlDataManager& urlDataManager) { | 1587 UrlDataManager& urlDataManager) { |
1589 SkPath path; | 1588 SkPath path; |
1590 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); | 1589 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); |
1591 return new SkClipPathCommand(path, get_json_regionop(command[SKDEBUGCANVAS_A
TTRIBUTE_REGIONOP]), | 1590 return new SkClipPathCommand(path, get_json_regionop(command[SKDEBUGCANVAS_A
TTRIBUTE_REGIONOP]), |
1592 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo
ol()); | 1591 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo
ol()); |
1593 } | 1592 } |
1594 | 1593 |
1595 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) | 1594 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) |
1596 : INHERITED(kClipRegion_OpType) { | 1595 : INHERITED(kClipRegion_OpType) { |
1597 fRegion = region; | 1596 fRegion = region; |
1598 fOp = op; | 1597 fOp = op; |
1599 | 1598 |
1600 fInfo.push(SkObjectParser::RegionToString(region)); | 1599 fInfo.push(SkObjectParser::RegionToString(region)); |
1601 fInfo.push(SkObjectParser::RegionOpToString(op)); | 1600 fInfo.push(SkObjectParser::RegionOpToString(op)); |
1602 } | 1601 } |
1603 | 1602 |
1604 void SkClipRegionCommand::execute(SkCanvas* canvas) const { | 1603 void SkClipRegionCommand::execute(SkCanvas* canvas) const { |
1605 canvas->clipRegion(fRegion, fOp); | 1604 canvas->clipRegion(fRegion, fOp); |
1606 } | 1605 } |
1607 | 1606 |
1608 Json::Value SkClipRegionCommand::toJSON(UrlDataManager& urlDataManager) const { | 1607 Json::Value SkClipRegionCommand::toJSON(UrlDataManager& urlDataManager) const { |
1609 Json::Value result = INHERITED::toJSON(urlDataManager); | 1608 Json::Value result = INHERITED::toJSON(urlDataManager); |
1610 result[SKDEBUGCANVAS_ATTRIBUTE_REGION] = make_json_region(fRegion); | 1609 result[SKDEBUGCANVAS_ATTRIBUTE_REGION] = make_json_region(fRegion); |
1611 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); | 1610 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); |
1612 return result; | 1611 return result; |
1613 } | 1612 } |
1614 | 1613 |
1615 SkClipRegionCommand* SkClipRegionCommand::fromJSON(Json::Value& command, | 1614 SkClipRegionCommand* SkClipRegionCommand::fromJSON(Json::Value& command, |
1616 UrlDataManager& urlDataManage
r) { | 1615 UrlDataManager& urlDataManage
r) { |
1617 SkASSERT(false); | 1616 SkASSERT(false); |
1618 return nullptr; | 1617 return nullptr; |
1619 } | 1618 } |
1620 | 1619 |
1621 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) | 1620 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) |
1622 : INHERITED(kClipRect_OpType) { | 1621 : INHERITED(kClipRect_OpType) { |
1623 fRect = rect; | 1622 fRect = rect; |
1624 fOp = op; | 1623 fOp = op; |
1625 fDoAA = doAA; | 1624 fDoAA = doAA; |
1626 | 1625 |
1627 fInfo.push(SkObjectParser::RectToString(rect)); | 1626 fInfo.push(SkObjectParser::RectToString(rect)); |
1628 fInfo.push(SkObjectParser::RegionOpToString(op)); | 1627 fInfo.push(SkObjectParser::RegionOpToString(op)); |
1629 fInfo.push(SkObjectParser::BoolToString(doAA)); | 1628 fInfo.push(SkObjectParser::BoolToString(doAA)); |
1630 } | 1629 } |
1631 | 1630 |
1632 void SkClipRectCommand::execute(SkCanvas* canvas) const { | 1631 void SkClipRectCommand::execute(SkCanvas* canvas) const { |
1633 canvas->clipRect(fRect, fOp, fDoAA); | 1632 canvas->clipRect(fRect, fOp, fDoAA); |
1634 } | 1633 } |
1635 | 1634 |
1636 Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const { | 1635 Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const { |
1637 Json::Value result = INHERITED::toJSON(urlDataManager); | 1636 Json::Value result = INHERITED::toJSON(urlDataManager); |
1638 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect); | 1637 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect); |
1639 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); | 1638 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); |
1640 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); | 1639 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); |
1641 return result; | 1640 return result; |
1642 } | 1641 } |
1643 | 1642 |
1644 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command, | 1643 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command, |
1645 UrlDataManager& urlDataManager) { | 1644 UrlDataManager& urlDataManager) { |
1646 SkRect rect; | 1645 SkRect rect; |
1647 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); | 1646 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); |
1648 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A
TTRIBUTE_REGIONOP]), | 1647 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A
TTRIBUTE_REGIONOP]), |
1649 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo
ol()); | 1648 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo
ol()); |
1650 } | 1649 } |
1651 | 1650 |
1652 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo
ol doAA) | 1651 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo
ol doAA) |
1653 : INHERITED(kClipRRect_OpType) { | 1652 : INHERITED(kClipRRect_OpType) { |
1654 fRRect = rrect; | 1653 fRRect = rrect; |
1655 fOp = op; | 1654 fOp = op; |
1656 fDoAA = doAA; | 1655 fDoAA = doAA; |
1657 | 1656 |
1658 fInfo.push(SkObjectParser::RRectToString(rrect)); | 1657 fInfo.push(SkObjectParser::RRectToString(rrect)); |
(...skipping 11 matching lines...) Expand all Loading... |
1670 } | 1669 } |
1671 | 1670 |
1672 Json::Value SkClipRRectCommand::toJSON(UrlDataManager& urlDataManager) const { | 1671 Json::Value SkClipRRectCommand::toJSON(UrlDataManager& urlDataManager) const { |
1673 Json::Value result = INHERITED::toJSON(urlDataManager); | 1672 Json::Value result = INHERITED::toJSON(urlDataManager); |
1674 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect); | 1673 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect); |
1675 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); | 1674 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); |
1676 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); | 1675 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); |
1677 return result; | 1676 return result; |
1678 } | 1677 } |
1679 | 1678 |
1680 SkClipRRectCommand* SkClipRRectCommand::fromJSON(Json::Value& command, | 1679 SkClipRRectCommand* SkClipRRectCommand::fromJSON(Json::Value& command, |
1681 UrlDataManager& urlDataManager)
{ | 1680 UrlDataManager& urlDataManager)
{ |
1682 SkRRect rrect; | 1681 SkRRect rrect; |
1683 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rrect); | 1682 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rrect); |
1684 return new SkClipRRectCommand(rrect, | 1683 return new SkClipRRectCommand(rrect, |
1685 get_json_regionop(command[SKDEBUGCANVAS_ATTRIB
UTE_REGIONOP]), | 1684 get_json_regionop(command[SKDEBUGCANVAS_ATTRIB
UTE_REGIONOP]), |
1686 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asB
ool()); | 1685 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asB
ool()); |
1687 } | 1686 } |
1688 | 1687 |
1689 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) | 1688 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) |
1690 : INHERITED(kConcat_OpType) { | 1689 : INHERITED(kConcat_OpType) { |
1691 fMatrix = matrix; | 1690 fMatrix = matrix; |
1692 | 1691 |
1693 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 1692 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
1694 } | 1693 } |
1695 | 1694 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 Json::Value command(Json::objectValue); | 1745 Json::Value command(Json::objectValue); |
1747 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; | 1746 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; |
1748 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); | 1747 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); |
1749 if (fPaintPtr != nullptr) { | 1748 if (fPaintPtr != nullptr) { |
1750 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); | 1749 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); |
1751 } | 1750 } |
1752 } | 1751 } |
1753 return result; | 1752 return result; |
1754 } | 1753 } |
1755 | 1754 |
1756 SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command, | 1755 SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command, |
1757 UrlDataManager& urlDataManage
r) { | 1756 UrlDataManager& urlDataManage
r) { |
1758 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); | 1757 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); |
1759 if (bitmap == nullptr) { | 1758 if (bitmap == nullptr) { |
1760 return nullptr; | 1759 return nullptr; |
1761 } | 1760 } |
1762 Json::Value point = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; | 1761 Json::Value point = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; |
1763 SkPaint* paintPtr; | 1762 SkPaint* paintPtr; |
1764 SkPaint paint; | 1763 SkPaint paint; |
1765 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { | 1764 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { |
1766 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); | 1765 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); |
1767 paintPtr = &paint; | 1766 paintPtr = &paint; |
1768 } | 1767 } |
1769 else { | 1768 else { |
1770 paintPtr = nullptr; | 1769 paintPtr = nullptr; |
1771 } | 1770 } |
1772 SkDrawBitmapCommand* result = new SkDrawBitmapCommand(*bitmap, point[0].asFl
oat(), | 1771 SkDrawBitmapCommand* result = new SkDrawBitmapCommand(*bitmap, point[0].asFl
oat(), |
1773 point[1].asFloat(), pa
intPtr); | 1772 point[1].asFloat(), pa
intPtr); |
1774 delete bitmap; | 1773 delete bitmap; |
1775 return result; | 1774 return result; |
1776 } | 1775 } |
1777 | 1776 |
1778 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, | 1777 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, |
1779 const SkRect& dst, const SkPain
t* paint) | 1778 const SkRect& dst, const SkPain
t* paint) |
1780 : INHERITED(kDrawBitmapNine_OpType) { | 1779 : INHERITED(kDrawBitmapNine_OpType) { |
1781 fBitmap = bitmap; | 1780 fBitmap = bitmap; |
1782 fCenter = center; | 1781 fCenter = center; |
(...skipping 30 matching lines...) Expand all Loading... |
1813 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; | 1812 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; |
1814 result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = MakeJsonIRect(fCenter); | 1813 result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = MakeJsonIRect(fCenter); |
1815 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); | 1814 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); |
1816 if (fPaintPtr != nullptr) { | 1815 if (fPaintPtr != nullptr) { |
1817 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); | 1816 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); |
1818 } | 1817 } |
1819 } | 1818 } |
1820 return result; | 1819 return result; |
1821 } | 1820 } |
1822 | 1821 |
1823 SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command,
| 1822 SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command, |
1824 UrlDataManager& urlDa
taManager) { | 1823 UrlDataManager& urlDa
taManager) { |
1825 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); | 1824 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); |
1826 if (bitmap == nullptr) { | 1825 if (bitmap == nullptr) { |
1827 return nullptr; | 1826 return nullptr; |
1828 } | 1827 } |
1829 SkIRect center; | 1828 SkIRect center; |
1830 extract_json_irect(command[SKDEBUGCANVAS_ATTRIBUTE_CENTER], ¢er); | 1829 extract_json_irect(command[SKDEBUGCANVAS_ATTRIBUTE_CENTER], ¢er); |
1831 SkRect dst; | 1830 SkRect dst; |
1832 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst); | 1831 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst); |
1833 SkPaint* paintPtr; | 1832 SkPaint* paintPtr; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 if (fPaintPtr != nullptr) { | 1895 if (fPaintPtr != nullptr) { |
1897 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); | 1896 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
urlDataManager); |
1898 } | 1897 } |
1899 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { | 1898 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { |
1900 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); | 1899 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); |
1901 } | 1900 } |
1902 } | 1901 } |
1903 return result; | 1902 return result; |
1904 } | 1903 } |
1905 | 1904 |
1906 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command,
| 1905 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command, |
1907 UrlDataManager& urlDa
taManager) { | 1906 UrlDataManager& urlDa
taManager) { |
1908 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); | 1907 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD
ataManager); |
1909 if (bitmap == nullptr) { | 1908 if (bitmap == nullptr) { |
1910 return nullptr; | 1909 return nullptr; |
1911 } | 1910 } |
1912 SkRect dst; | 1911 SkRect dst; |
1913 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst); | 1912 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst); |
1914 SkPaint* paintPtr; | 1913 SkPaint* paintPtr; |
1915 SkPaint paint; | 1914 SkPaint paint; |
1916 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { | 1915 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { |
1917 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); | 1916 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); |
1918 paintPtr = &paint; | 1917 paintPtr = &paint; |
1919 } | 1918 } |
1920 else { | 1919 else { |
1921 paintPtr = nullptr; | 1920 paintPtr = nullptr; |
1922 } | 1921 } |
1923 SkCanvas::SrcRectConstraint constraint; | 1922 SkCanvas::SrcRectConstraint constraint; |
1924 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) && | 1923 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) && |
1925 command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) { | 1924 command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) { |
1926 constraint = SkCanvas::kStrict_SrcRectConstraint; | 1925 constraint = SkCanvas::kStrict_SrcRectConstraint; |
1927 } | 1926 } |
1928 else { | 1927 else { |
1929 constraint = SkCanvas::kFast_SrcRectConstraint; | 1928 constraint = SkCanvas::kFast_SrcRectConstraint; |
1930 } | 1929 } |
1931 SkRect* srcPtr; | 1930 SkRect* srcPtr; |
1932 SkRect src; | 1931 SkRect src; |
1933 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_SRC)) { | 1932 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_SRC)) { |
1934 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_SRC], &src); | 1933 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_SRC], &src); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 if (flatten(*fImage, &encoded, urlDataManager)) { | 1980 if (flatten(*fImage, &encoded, urlDataManager)) { |
1982 result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded; | 1981 result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded; |
1983 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); | 1982 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); |
1984 if (fPaint.isValid()) { | 1983 if (fPaint.isValid()) { |
1985 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get(
), urlDataManager); | 1984 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get(
), urlDataManager); |
1986 } | 1985 } |
1987 } | 1986 } |
1988 return result; | 1987 return result; |
1989 } | 1988 } |
1990 | 1989 |
1991 SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command, | 1990 SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command, |
1992 UrlDataManager& urlDataManager)
{ | 1991 UrlDataManager& urlDataManager)
{ |
1993 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur
lDataManager); | 1992 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur
lDataManager); |
1994 if (image == nullptr) { | 1993 if (image == nullptr) { |
1995 return nullptr; | 1994 return nullptr; |
1996 } | 1995 } |
1997 Json::Value point = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; | 1996 Json::Value point = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; |
1998 SkPaint* paintPtr; | 1997 SkPaint* paintPtr; |
1999 SkPaint paint; | 1998 SkPaint paint; |
2000 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { | 1999 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { |
2001 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); | 2000 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); |
(...skipping 28 matching lines...) Expand all Loading... |
2030 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); | 2029 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); |
2031 } | 2030 } |
2032 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); | 2031 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
2033 if (paint) { | 2032 if (paint) { |
2034 fInfo.push(SkObjectParser::PaintToString(*paint)); | 2033 fInfo.push(SkObjectParser::PaintToString(*paint)); |
2035 } | 2034 } |
2036 fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: ")); | 2035 fInfo.push(SkObjectParser::IntToString(fConstraint, "Constraint: ")); |
2037 } | 2036 } |
2038 | 2037 |
2039 void SkDrawImageRectCommand::execute(SkCanvas* canvas) const { | 2038 void SkDrawImageRectCommand::execute(SkCanvas* canvas) const { |
2040 canvas->legacy_drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMa
ybeNull(), | 2039 canvas->legacy_drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMa
ybeNull(), |
2041 fConstraint); | 2040 fConstraint); |
2042 } | 2041 } |
2043 | 2042 |
2044 bool SkDrawImageRectCommand::render(SkCanvas* canvas) const { | 2043 bool SkDrawImageRectCommand::render(SkCanvas* canvas) const { |
2045 SkAutoCanvasRestore acr(canvas, true); | 2044 SkAutoCanvasRestore acr(canvas, true); |
2046 canvas->clear(0xFFFFFFFF); | 2045 canvas->clear(0xFFFFFFFF); |
2047 | 2046 |
2048 xlate_and_scale_to_bounds(canvas, fDst); | 2047 xlate_and_scale_to_bounds(canvas, fDst); |
2049 | 2048 |
2050 this->execute(canvas); | 2049 this->execute(canvas); |
(...skipping 12 matching lines...) Expand all Loading... |
2063 if (fPaint.isValid()) { | 2062 if (fPaint.isValid()) { |
2064 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get(
), urlDataManager); | 2063 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get(
), urlDataManager); |
2065 } | 2064 } |
2066 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { | 2065 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { |
2067 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); | 2066 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); |
2068 } | 2067 } |
2069 } | 2068 } |
2070 return result; | 2069 return result; |
2071 } | 2070 } |
2072 | 2071 |
2073 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command, | 2072 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command, |
2074 UrlDataManager& urlData
Manager) { | 2073 UrlDataManager& urlData
Manager) { |
2075 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur
lDataManager); | 2074 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur
lDataManager); |
2076 if (image == nullptr) { | 2075 if (image == nullptr) { |
2077 return nullptr; | 2076 return nullptr; |
2078 } | 2077 } |
2079 SkRect dst; | 2078 SkRect dst; |
2080 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst); | 2079 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst); |
2081 SkPaint* paintPtr; | 2080 SkPaint* paintPtr; |
2082 SkPaint paint; | 2081 SkPaint paint; |
2083 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { | 2082 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { |
2084 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); | 2083 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); |
2085 paintPtr = &paint; | 2084 paintPtr = &paint; |
2086 } | 2085 } |
2087 else { | 2086 else { |
2088 paintPtr = nullptr; | 2087 paintPtr = nullptr; |
2089 } | 2088 } |
2090 SkCanvas::SrcRectConstraint constraint; | 2089 SkCanvas::SrcRectConstraint constraint; |
2091 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) && | 2090 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) && |
2092 command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) { | 2091 command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) { |
2093 constraint = SkCanvas::kStrict_SrcRectConstraint; | 2092 constraint = SkCanvas::kStrict_SrcRectConstraint; |
2094 } | 2093 } |
2095 else { | 2094 else { |
2096 constraint = SkCanvas::kFast_SrcRectConstraint; | 2095 constraint = SkCanvas::kFast_SrcRectConstraint; |
2097 } | 2096 } |
2098 SkRect* srcPtr; | 2097 SkRect* srcPtr; |
2099 SkRect src; | 2098 SkRect src; |
2100 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_SRC)) { | 2099 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_SRC)) { |
2101 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_SRC], &src); | 2100 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_SRC], &src); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2138 return true; | 2137 return true; |
2139 } | 2138 } |
2140 | 2139 |
2141 Json::Value SkDrawOvalCommand::toJSON(UrlDataManager& urlDataManager) const { | 2140 Json::Value SkDrawOvalCommand::toJSON(UrlDataManager& urlDataManager) const { |
2142 Json::Value result = INHERITED::toJSON(urlDataManager); | 2141 Json::Value result = INHERITED::toJSON(urlDataManager); |
2143 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fOval); | 2142 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fOval); |
2144 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2143 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2145 return result; | 2144 return result; |
2146 } | 2145 } |
2147 | 2146 |
2148 SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command, | 2147 SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command, |
2149 UrlDataManager& urlDataManager) { | 2148 UrlDataManager& urlDataManager) { |
2150 SkRect coords; | 2149 SkRect coords; |
2151 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); | 2150 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); |
2152 SkPaint paint; | 2151 SkPaint paint; |
2153 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2152 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2154 return new SkDrawOvalCommand(coords, paint); | 2153 return new SkDrawOvalCommand(coords, paint); |
2155 } | 2154 } |
2156 | 2155 |
2157 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) | 2156 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) |
2158 : INHERITED(kDrawPaint_OpType) { | 2157 : INHERITED(kDrawPaint_OpType) { |
(...skipping 11 matching lines...) Expand all Loading... |
2170 canvas->drawPaint(fPaint); | 2169 canvas->drawPaint(fPaint); |
2171 return true; | 2170 return true; |
2172 } | 2171 } |
2173 | 2172 |
2174 Json::Value SkDrawPaintCommand::toJSON(UrlDataManager& urlDataManager) const { | 2173 Json::Value SkDrawPaintCommand::toJSON(UrlDataManager& urlDataManager) const { |
2175 Json::Value result = INHERITED::toJSON(urlDataManager); | 2174 Json::Value result = INHERITED::toJSON(urlDataManager); |
2176 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2175 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2177 return result; | 2176 return result; |
2178 } | 2177 } |
2179 | 2178 |
2180 SkDrawPaintCommand* SkDrawPaintCommand::fromJSON(Json::Value& command, | 2179 SkDrawPaintCommand* SkDrawPaintCommand::fromJSON(Json::Value& command, |
2181 UrlDataManager& urlDataManager)
{ | 2180 UrlDataManager& urlDataManager)
{ |
2182 SkPaint paint; | 2181 SkPaint paint; |
2183 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2182 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2184 return new SkDrawPaintCommand(paint); | 2183 return new SkDrawPaintCommand(paint); |
2185 } | 2184 } |
2186 | 2185 |
2187 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) | 2186 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) |
2188 : INHERITED(kDrawPath_OpType) { | 2187 : INHERITED(kDrawPath_OpType) { |
2189 fPath = path; | 2188 fPath = path; |
2190 fPaint = paint; | 2189 fPaint = paint; |
(...skipping 11 matching lines...) Expand all Loading... |
2202 return true; | 2201 return true; |
2203 } | 2202 } |
2204 | 2203 |
2205 Json::Value SkDrawPathCommand::toJSON(UrlDataManager& urlDataManager) const { | 2204 Json::Value SkDrawPathCommand::toJSON(UrlDataManager& urlDataManager) const { |
2206 Json::Value result = INHERITED::toJSON(urlDataManager); | 2205 Json::Value result = INHERITED::toJSON(urlDataManager); |
2207 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); | 2206 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); |
2208 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2207 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2209 return result; | 2208 return result; |
2210 } | 2209 } |
2211 | 2210 |
2212 SkDrawPathCommand* SkDrawPathCommand::fromJSON(Json::Value& command, | 2211 SkDrawPathCommand* SkDrawPathCommand::fromJSON(Json::Value& command, |
2213 UrlDataManager& urlDataManager) { | 2212 UrlDataManager& urlDataManager) { |
2214 SkPath path; | 2213 SkPath path; |
2215 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); | 2214 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); |
2216 SkPaint paint; | 2215 SkPaint paint; |
2217 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2216 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2218 return new SkDrawPathCommand(path, paint); | 2217 return new SkDrawPathCommand(path, paint); |
2219 } | 2218 } |
2220 | 2219 |
2221 SkBeginDrawPictureCommand::SkBeginDrawPictureCommand(const SkPicture* picture, | 2220 SkBeginDrawPictureCommand::SkBeginDrawPictureCommand(const SkPicture* picture, |
2222 const SkMatrix* matrix, | 2221 const SkMatrix* matrix, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2329 result[SKDEBUGCANVAS_ATTRIBUTE_MODE] = make_json_pointmode(fMode); | 2328 result[SKDEBUGCANVAS_ATTRIBUTE_MODE] = make_json_pointmode(fMode); |
2330 Json::Value points(Json::arrayValue); | 2329 Json::Value points(Json::arrayValue); |
2331 for (size_t i = 0; i < fCount; i++) { | 2330 for (size_t i = 0; i < fCount; i++) { |
2332 points.append(make_json_point(fPts[i])); | 2331 points.append(make_json_point(fPts[i])); |
2333 } | 2332 } |
2334 result[SKDEBUGCANVAS_ATTRIBUTE_POINTS] = points; | 2333 result[SKDEBUGCANVAS_ATTRIBUTE_POINTS] = points; |
2335 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2334 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2336 return result; | 2335 return result; |
2337 } | 2336 } |
2338 | 2337 |
2339 SkDrawPointsCommand* SkDrawPointsCommand::fromJSON(Json::Value& command, | 2338 SkDrawPointsCommand* SkDrawPointsCommand::fromJSON(Json::Value& command, |
2340 UrlDataManager& urlDataManage
r) { | 2339 UrlDataManager& urlDataManage
r) { |
2341 SkCanvas::PointMode mode; | 2340 SkCanvas::PointMode mode; |
2342 const char* jsonMode = command[SKDEBUGCANVAS_ATTRIBUTE_MODE].asCString(); | 2341 const char* jsonMode = command[SKDEBUGCANVAS_ATTRIBUTE_MODE].asCString(); |
2343 if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POINTS)) { | 2342 if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POINTS)) { |
2344 mode = SkCanvas::kPoints_PointMode; | 2343 mode = SkCanvas::kPoints_PointMode; |
2345 } | 2344 } |
2346 else if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_LINES)) { | 2345 else if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_LINES)) { |
2347 mode = SkCanvas::kLines_PointMode; | 2346 mode = SkCanvas::kLines_PointMode; |
2348 } | 2347 } |
2349 else if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POLYGON)) { | 2348 else if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POLYGON)) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2385 fInfo.push(SkObjectParser::PointsToString(pos, 1)); | 2384 fInfo.push(SkObjectParser::PointsToString(pos, 1)); |
2386 fInfo.push(SkObjectParser::PaintToString(paint)); | 2385 fInfo.push(SkObjectParser::PaintToString(paint)); |
2387 } | 2386 } |
2388 | 2387 |
2389 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { | 2388 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { |
2390 canvas->drawPosText(fText, fByteLength, fPos, fPaint); | 2389 canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
2391 } | 2390 } |
2392 | 2391 |
2393 Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const { | 2392 Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const { |
2394 Json::Value result = INHERITED::toJSON(urlDataManager); | 2393 Json::Value result = INHERITED::toJSON(urlDataManager); |
2395 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | 2394 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
2396 ((const char*) fText) + f
ByteLength); | 2395 ((const char*) fText) + f
ByteLength); |
2397 Json::Value coords(Json::arrayValue); | 2396 Json::Value coords(Json::arrayValue); |
2398 size_t numCoords = fPaint.textToGlyphs(fText, fByteLength, nullptr); | 2397 size_t numCoords = fPaint.textToGlyphs(fText, fByteLength, nullptr); |
2399 for (size_t i = 0; i < numCoords; i++) { | 2398 for (size_t i = 0; i < numCoords; i++) { |
2400 coords.append(make_json_point(fPos[i])); | 2399 coords.append(make_json_point(fPos[i])); |
2401 } | 2400 } |
2402 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords; | 2401 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords; |
2403 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2402 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2404 return result; | 2403 return result; |
2405 } | 2404 } |
2406 | 2405 |
2407 SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command, | 2406 SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command, |
2408 UrlDataManager& urlDataMana
ger) { | 2407 UrlDataManager& urlDataMana
ger) { |
2409 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2408 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
2410 SkPaint paint; | 2409 SkPaint paint; |
2411 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2410 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2412 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; | 2411 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; |
2413 int count = (int) coords.size(); | 2412 int count = (int) coords.size(); |
2414 SkPoint* points = (SkPoint*) sk_malloc_throw(count * sizeof(SkPoint)); | 2413 SkPoint* points = (SkPoint*) sk_malloc_throw(count * sizeof(SkPoint)); |
2415 for (int i = 0; i < count; i++) { | 2414 for (int i = 0; i < count; i++) { |
2416 points[i] = SkPoint::Make(coords[i][0].asFloat(), coords[i][1].asFloat()
); | 2415 points[i] = SkPoint::Make(coords[i][0].asFloat(), coords[i][1].asFloat()
); |
2417 } | 2416 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 runs.append(run); | 2571 runs.append(run); |
2573 iter.next(); | 2572 iter.next(); |
2574 } | 2573 } |
2575 result[SKDEBUGCANVAS_ATTRIBUTE_RUNS] = runs; | 2574 result[SKDEBUGCANVAS_ATTRIBUTE_RUNS] = runs; |
2576 result[SKDEBUGCANVAS_ATTRIBUTE_X] = Json::Value(fXPos); | 2575 result[SKDEBUGCANVAS_ATTRIBUTE_X] = Json::Value(fXPos); |
2577 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fYPos); | 2576 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fYPos); |
2578 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2577 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2579 return result; | 2578 return result; |
2580 } | 2579 } |
2581 | 2580 |
2582 SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command, | 2581 SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command, |
2583 UrlDataManager& urlDataMa
nager) { | 2582 UrlDataManager& urlDataMa
nager) { |
2584 SkTextBlobBuilder builder; | 2583 SkTextBlobBuilder builder; |
2585 Json::Value runs = command[SKDEBUGCANVAS_ATTRIBUTE_RUNS]; | 2584 Json::Value runs = command[SKDEBUGCANVAS_ATTRIBUTE_RUNS]; |
2586 for (Json::ArrayIndex i = 0 ; i < runs.size(); i++) { | 2585 for (Json::ArrayIndex i = 0 ; i < runs.size(); i++) { |
2587 Json::Value run = runs[i]; | 2586 Json::Value run = runs[i]; |
2588 SkPaint font; | 2587 SkPaint font; |
2589 font.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 2588 font.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
2590 extract_json_paint(run[SKDEBUGCANVAS_ATTRIBUTE_FONT], urlDataManager, &f
ont); | 2589 extract_json_paint(run[SKDEBUGCANVAS_ATTRIBUTE_FONT], urlDataManager, &f
ont); |
2591 Json::Value glyphs = run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS]; | 2590 Json::Value glyphs = run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS]; |
2592 int count = glyphs.size(); | 2591 int count = glyphs.size(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2676 result[SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS] = texCoords; | 2675 result[SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS] = texCoords; |
2677 } | 2676 } |
2678 if (fXfermode.get() != nullptr) { | 2677 if (fXfermode.get() != nullptr) { |
2679 Json::Value jsonXfermode; | 2678 Json::Value jsonXfermode; |
2680 flatten(fXfermode, &jsonXfermode, urlDataManager); | 2679 flatten(fXfermode, &jsonXfermode, urlDataManager); |
2681 result[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; | 2680 result[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; |
2682 } | 2681 } |
2683 return result; | 2682 return result; |
2684 } | 2683 } |
2685 | 2684 |
2686 SkDrawPatchCommand* SkDrawPatchCommand::fromJSON(Json::Value& command, | 2685 SkDrawPatchCommand* SkDrawPatchCommand::fromJSON(Json::Value& command, |
2687 UrlDataManager& urlDataManager)
{ | 2686 UrlDataManager& urlDataManager)
{ |
2688 Json::Value jsonCubics = command[SKDEBUGCANVAS_ATTRIBUTE_CUBICS]; | 2687 Json::Value jsonCubics = command[SKDEBUGCANVAS_ATTRIBUTE_CUBICS]; |
2689 SkPoint cubics[12]; | 2688 SkPoint cubics[12]; |
2690 for (int i = 0; i < 12; i++) { | 2689 for (int i = 0; i < 12; i++) { |
2691 cubics[i] = get_json_point(jsonCubics[i]); | 2690 cubics[i] = get_json_point(jsonCubics[i]); |
2692 } | 2691 } |
2693 SkColor* colorsPtr; | 2692 SkColor* colorsPtr; |
2694 SkColor colors[4]; | 2693 SkColor colors[4]; |
2695 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORS)) { | 2694 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORS)) { |
2696 Json::Value jsonColors = command[SKDEBUGCANVAS_ATTRIBUTE_COLORS]; | 2695 Json::Value jsonColors = command[SKDEBUGCANVAS_ATTRIBUTE_COLORS]; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 canvas->drawRect(fRect, fPaint); | 2736 canvas->drawRect(fRect, fPaint); |
2738 } | 2737 } |
2739 | 2738 |
2740 Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const { | 2739 Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const { |
2741 Json::Value result = INHERITED::toJSON(urlDataManager); | 2740 Json::Value result = INHERITED::toJSON(urlDataManager); |
2742 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect); | 2741 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect); |
2743 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2742 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2744 return result; | 2743 return result; |
2745 } | 2744 } |
2746 | 2745 |
2747 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command, | 2746 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command, |
2748 UrlDataManager& urlDataManager) { | 2747 UrlDataManager& urlDataManager) { |
2749 SkRect coords; | 2748 SkRect coords; |
2750 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); | 2749 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); |
2751 SkPaint paint; | 2750 SkPaint paint; |
2752 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2751 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2753 return new SkDrawRectCommand(coords, paint); | 2752 return new SkDrawRectCommand(coords, paint); |
2754 } | 2753 } |
2755 | 2754 |
2756 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
t) | 2755 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
t) |
2757 : INHERITED(kDrawRRect_OpType) { | 2756 : INHERITED(kDrawRRect_OpType) { |
(...skipping 13 matching lines...) Expand all Loading... |
2771 return true; | 2770 return true; |
2772 } | 2771 } |
2773 | 2772 |
2774 Json::Value SkDrawRRectCommand::toJSON(UrlDataManager& urlDataManager) const { | 2773 Json::Value SkDrawRRectCommand::toJSON(UrlDataManager& urlDataManager) const { |
2775 Json::Value result = INHERITED::toJSON(urlDataManager); | 2774 Json::Value result = INHERITED::toJSON(urlDataManager); |
2776 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect); | 2775 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect); |
2777 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2776 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2778 return result; | 2777 return result; |
2779 } | 2778 } |
2780 | 2779 |
2781 SkDrawRRectCommand* SkDrawRRectCommand::fromJSON(Json::Value& command, | 2780 SkDrawRRectCommand* SkDrawRRectCommand::fromJSON(Json::Value& command, |
2782 UrlDataManager& urlDataManager)
{ | 2781 UrlDataManager& urlDataManager)
{ |
2783 SkRRect coords; | 2782 SkRRect coords; |
2784 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); | 2783 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); |
2785 SkPaint paint; | 2784 SkPaint paint; |
2786 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2785 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2787 return new SkDrawRRectCommand(coords, paint); | 2786 return new SkDrawRRectCommand(coords, paint); |
2788 } | 2787 } |
2789 | 2788 |
2790 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, | 2789 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, |
2791 const SkRRect& inner, | 2790 const SkRRect& inner, |
(...skipping 18 matching lines...) Expand all Loading... |
2810 } | 2809 } |
2811 | 2810 |
2812 Json::Value SkDrawDRRectCommand::toJSON(UrlDataManager& urlDataManager) const { | 2811 Json::Value SkDrawDRRectCommand::toJSON(UrlDataManager& urlDataManager) const { |
2813 Json::Value result = INHERITED::toJSON(urlDataManager); | 2812 Json::Value result = INHERITED::toJSON(urlDataManager); |
2814 result[SKDEBUGCANVAS_ATTRIBUTE_OUTER] = make_json_rrect(fOuter); | 2813 result[SKDEBUGCANVAS_ATTRIBUTE_OUTER] = make_json_rrect(fOuter); |
2815 result[SKDEBUGCANVAS_ATTRIBUTE_INNER] = make_json_rrect(fInner); | 2814 result[SKDEBUGCANVAS_ATTRIBUTE_INNER] = make_json_rrect(fInner); |
2816 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2815 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2817 return result; | 2816 return result; |
2818 } | 2817 } |
2819 | 2818 |
2820 SkDrawDRRectCommand* SkDrawDRRectCommand::fromJSON(Json::Value& command, | 2819 SkDrawDRRectCommand* SkDrawDRRectCommand::fromJSON(Json::Value& command, |
2821 UrlDataManager& urlDataManage
r) { | 2820 UrlDataManager& urlDataManage
r) { |
2822 SkRRect outer; | 2821 SkRRect outer; |
2823 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &outer); | 2822 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &outer); |
2824 SkRRect inner; | 2823 SkRRect inner; |
2825 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &inner); | 2824 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &inner); |
2826 SkPaint paint; | 2825 SkPaint paint; |
2827 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2826 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2828 return new SkDrawDRRectCommand(outer, inner, paint); | 2827 return new SkDrawDRRectCommand(outer, inner, paint); |
2829 } | 2828 } |
2830 | 2829 |
(...skipping 12 matching lines...) Expand all Loading... |
2843 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); | 2842 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); |
2844 fInfo.push(SkObjectParser::PaintToString(paint)); | 2843 fInfo.push(SkObjectParser::PaintToString(paint)); |
2845 } | 2844 } |
2846 | 2845 |
2847 void SkDrawTextCommand::execute(SkCanvas* canvas) const { | 2846 void SkDrawTextCommand::execute(SkCanvas* canvas) const { |
2848 canvas->drawText(fText, fByteLength, fX, fY, fPaint); | 2847 canvas->drawText(fText, fByteLength, fX, fY, fPaint); |
2849 } | 2848 } |
2850 | 2849 |
2851 Json::Value SkDrawTextCommand::toJSON(UrlDataManager& urlDataManager) const { | 2850 Json::Value SkDrawTextCommand::toJSON(UrlDataManager& urlDataManager) const { |
2852 Json::Value result = INHERITED::toJSON(urlDataManager); | 2851 Json::Value result = INHERITED::toJSON(urlDataManager); |
2853 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | 2852 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
2854 ((const char*) fText) + f
ByteLength); | 2853 ((const char*) fText) + f
ByteLength); |
2855 Json::Value coords(Json::arrayValue); | 2854 Json::Value coords(Json::arrayValue); |
2856 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fX, fY); | 2855 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fX, fY); |
2857 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2856 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2858 return result; | 2857 return result; |
2859 } | 2858 } |
2860 | 2859 |
2861 SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command, | 2860 SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command, |
2862 UrlDataManager& urlDataManager) { | 2861 UrlDataManager& urlDataManager) { |
2863 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2862 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
2864 SkPaint paint; | 2863 SkPaint paint; |
2865 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2864 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2866 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; | 2865 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; |
2867 return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords
[1].asFloat(), | 2866 return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords
[1].asFloat(), |
2868 paint); | 2867 paint); |
2869 } | 2868 } |
2870 | 2869 |
2871 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, | 2870 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, |
2872 const SkPath& path, const SkMat
rix* matrix, | 2871 const SkPath& path, const SkMat
rix* matrix, |
2873 const SkPaint& paint) | 2872 const SkPaint& paint) |
2874 : INHERITED(kDrawTextOnPath_OpType) { | 2873 : INHERITED(kDrawTextOnPath_OpType) { |
2875 fText = new char[byteLength]; | 2874 fText = new char[byteLength]; |
2876 memcpy(fText, text, byteLength); | 2875 memcpy(fText, text, byteLength); |
2877 fByteLength = byteLength; | 2876 fByteLength = byteLength; |
(...skipping 14 matching lines...) Expand all Loading... |
2892 } | 2891 } |
2893 | 2892 |
2894 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) const { | 2893 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) const { |
2895 canvas->drawTextOnPath(fText, fByteLength, fPath, | 2894 canvas->drawTextOnPath(fText, fByteLength, fPath, |
2896 fMatrix.isIdentity() ? nullptr : &fMatrix, | 2895 fMatrix.isIdentity() ? nullptr : &fMatrix, |
2897 fPaint); | 2896 fPaint); |
2898 } | 2897 } |
2899 | 2898 |
2900 Json::Value SkDrawTextOnPathCommand::toJSON(UrlDataManager& urlDataManager) cons
t { | 2899 Json::Value SkDrawTextOnPathCommand::toJSON(UrlDataManager& urlDataManager) cons
t { |
2901 Json::Value result = INHERITED::toJSON(urlDataManager); | 2900 Json::Value result = INHERITED::toJSON(urlDataManager); |
2902 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, | 2901 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, |
2903 ((const char*) fText) + f
ByteLength); | 2902 ((const char*) fText) + f
ByteLength); |
2904 Json::Value coords(Json::arrayValue); | 2903 Json::Value coords(Json::arrayValue); |
2905 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); | 2904 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); |
2906 if (!fMatrix.isIdentity()) { | 2905 if (!fMatrix.isIdentity()) { |
2907 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); | 2906 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
2908 } | 2907 } |
2909 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); | 2908 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag
er); |
2910 return result; | 2909 return result; |
2911 } | 2910 } |
2912 | 2911 |
2913 SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command,
| 2912 SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command, |
2914 UrlDataManager& urlDa
taManager) { | 2913 UrlDataManager& urlDa
taManager) { |
2915 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); | 2914 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); |
2916 SkPaint paint; | 2915 SkPaint paint; |
2917 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2916 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2918 SkPath path; | 2917 SkPath path; |
2919 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); | 2918 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); |
2920 SkMatrix* matrixPtr; | 2919 SkMatrix* matrixPtr; |
2921 SkMatrix matrix; | 2920 SkMatrix matrix; |
2922 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_MATRIX)) { | 2921 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_MATRIX)) { |
2923 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 2922 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3062 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { | 3061 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { |
3063 canvas->save(); | 3062 canvas->save(); |
3064 } | 3063 } |
3065 | 3064 |
3066 Json::Value SkSaveLayerCommand::toJSON(UrlDataManager& urlDataManager) const { | 3065 Json::Value SkSaveLayerCommand::toJSON(UrlDataManager& urlDataManager) const { |
3067 Json::Value result = INHERITED::toJSON(urlDataManager); | 3066 Json::Value result = INHERITED::toJSON(urlDataManager); |
3068 if (!fBounds.isEmpty()) { | 3067 if (!fBounds.isEmpty()) { |
3069 result[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS] = make_json_rect(fBounds); | 3068 result[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS] = make_json_rect(fBounds); |
3070 } | 3069 } |
3071 if (fPaintPtr != nullptr) { | 3070 if (fPaintPtr != nullptr) { |
3072 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, | 3071 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, |
3073 urlDataManager); | 3072 urlDataManager); |
3074 } | 3073 } |
3075 if (fBackdrop != nullptr) { | 3074 if (fBackdrop != nullptr) { |
3076 Json::Value jsonBackdrop; | 3075 Json::Value jsonBackdrop; |
3077 flatten(fBackdrop, &jsonBackdrop, urlDataManager); | 3076 flatten(fBackdrop, &jsonBackdrop, urlDataManager); |
3078 result[SKDEBUGCANVAS_ATTRIBUTE_BACKDROP] = jsonBackdrop; | 3077 result[SKDEBUGCANVAS_ATTRIBUTE_BACKDROP] = jsonBackdrop; |
3079 } | 3078 } |
3080 if (fSaveLayerFlags != 0) { | 3079 if (fSaveLayerFlags != 0) { |
3081 SkDebugf("unsupported: saveLayer flags\n"); | 3080 SkDebugf("unsupported: saveLayer flags\n"); |
3082 SkASSERT(false); | 3081 SkASSERT(false); |
3083 } | 3082 } |
3084 return result; | 3083 return result; |
3085 } | 3084 } |
3086 | 3085 |
3087 SkSaveLayerCommand* SkSaveLayerCommand::fromJSON(Json::Value& command, | 3086 SkSaveLayerCommand* SkSaveLayerCommand::fromJSON(Json::Value& command, |
3088 UrlDataManager& urlDataManager)
{ | 3087 UrlDataManager& urlDataManager)
{ |
3089 SkCanvas::SaveLayerRec rec; | 3088 SkCanvas::SaveLayerRec rec; |
3090 SkRect bounds; | 3089 SkRect bounds; |
3091 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_BOUNDS)) { | 3090 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_BOUNDS)) { |
3092 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS], &bounds); | 3091 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS], &bounds); |
3093 rec.fBounds = &bounds; | 3092 rec.fBounds = &bounds; |
3094 } | 3093 } |
3095 SkPaint paint; | 3094 SkPaint paint; |
3096 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { | 3095 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { |
3097 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); | 3096 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage
r, &paint); |
(...skipping 25 matching lines...) Expand all Loading... |
3123 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 3122 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
3124 canvas->setMatrix(temp); | 3123 canvas->setMatrix(temp); |
3125 } | 3124 } |
3126 | 3125 |
3127 Json::Value SkSetMatrixCommand::toJSON(UrlDataManager& urlDataManager) const { | 3126 Json::Value SkSetMatrixCommand::toJSON(UrlDataManager& urlDataManager) const { |
3128 Json::Value result = INHERITED::toJSON(urlDataManager); | 3127 Json::Value result = INHERITED::toJSON(urlDataManager); |
3129 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); | 3128 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
3130 return result; | 3129 return result; |
3131 } | 3130 } |
3132 | 3131 |
3133 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3132 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
3134 UrlDataManager& urlDataManager)
{ | 3133 UrlDataManager& urlDataManager)
{ |
3135 SkMatrix matrix; | 3134 SkMatrix matrix; |
3136 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3135 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
3137 return new SkSetMatrixCommand(matrix); | 3136 return new SkSetMatrixCommand(matrix); |
3138 } | 3137 } |
OLD | NEW |