Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: tools/debugger/SkDrawCommand.cpp

Issue 1686143004: integrated SkDebugCanvas JSON support with UrlDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: added cast to deal with differing-size ints Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkDrawCommand.h" 10 #include "SkDrawCommand.h"
11 #include "SkBlurMaskFilter.h" 11 #include "SkBlurMaskFilter.h"
12 #include "SkColorFilter.h" 12 #include "SkColorFilter.h"
13 #include "SkDashPathEffect.h" 13 #include "SkDashPathEffect.h"
14 #include "SkImageFilter.h" 14 #include "SkImageFilter.h"
15 #include "SkMaskFilter.h" 15 #include "SkMaskFilter.h"
16 #include "SkObjectParser.h" 16 #include "SkObjectParser.h"
17 #include "SkPaintDefaults.h" 17 #include "SkPaintDefaults.h"
18 #include "SkPathEffect.h" 18 #include "SkPathEffect.h"
19 #include "SkPicture.h" 19 #include "SkPicture.h"
20 #include "SkTextBlob.h" 20 #include "SkTextBlob.h"
21 #include "SkTextBlobRunIterator.h" 21 #include "SkTextBlobRunIterator.h"
22 #include "SkTHash.h" 22 #include "SkTHash.h"
23 #include "SkTypeface.h" 23 #include "SkTypeface.h"
24 #include "SkValidatingReadBuffer.h" 24 #include "SkValidatingReadBuffer.h"
25 #include "SkWriteBuffer.h" 25 #include "SkWriteBuffer.h"
26 26
27 #define SKDEBUGCANVAS_SEND_BINARIES false
28
29 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command" 27 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command"
30 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix" 28 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
31 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords" 29 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords"
32 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds" 30 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
33 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint" 31 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint"
34 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer" 32 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer"
35 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner" 33 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner"
36 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode" 34 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode"
37 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points" 35 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points"
38 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path" 36 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path"
(...skipping 17 matching lines...) Expand all
56 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN "textAlign" 54 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN "textAlign"
57 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize" 55 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize"
58 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX" 56 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX"
59 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX" 57 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX"
60 #define SKDEBUGCANVAS_ATTRIBUTE_DASHING "dashing" 58 #define SKDEBUGCANVAS_ATTRIBUTE_DASHING "dashing"
61 #define SKDEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals" 59 #define SKDEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals"
62 #define SKDEBUGCANVAS_ATTRIBUTE_PHASE "phase" 60 #define SKDEBUGCANVAS_ATTRIBUTE_PHASE "phase"
63 #define SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType" 61 #define SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType"
64 #define SKDEBUGCANVAS_ATTRIBUTE_VERBS "verbs" 62 #define SKDEBUGCANVAS_ATTRIBUTE_VERBS "verbs"
65 #define SKDEBUGCANVAS_ATTRIBUTE_NAME "name" 63 #define SKDEBUGCANVAS_ATTRIBUTE_NAME "name"
66 #define SKDEBUGCANVAS_ATTRIBUTE_BYTES "bytes" 64 #define SKDEBUGCANVAS_ATTRIBUTE_DATA "data"
67 #define SKDEBUGCANVAS_ATTRIBUTE_SHADER "shader" 65 #define SKDEBUGCANVAS_ATTRIBUTE_SHADER "shader"
68 #define SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect" 66 #define SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect"
69 #define SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter" 67 #define SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter"
70 #define SKDEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode" 68 #define SKDEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode"
71 #define SKDEBUGCANVAS_ATTRIBUTE_LOOPER "looper" 69 #define SKDEBUGCANVAS_ATTRIBUTE_LOOPER "looper"
72 #define SKDEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop" 70 #define SKDEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop"
73 #define SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter" 71 #define SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter"
74 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter" 72 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter"
75 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGE "image" 73 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGE "image"
76 #define SKDEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap" 74 #define SKDEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 146
149 #define SKDEBUGCANVAS_ALPHATYPE_OPAQUE "opaque" 147 #define SKDEBUGCANVAS_ALPHATYPE_OPAQUE "opaque"
150 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul" 148 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul"
151 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul" 149 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul"
152 150
153 #define SKDEBUGCANVAS_FILTERQUALITY_NONE "none" 151 #define SKDEBUGCANVAS_FILTERQUALITY_NONE "none"
154 #define SKDEBUGCANVAS_FILTERQUALITY_LOW "low" 152 #define SKDEBUGCANVAS_FILTERQUALITY_LOW "low"
155 #define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium" 153 #define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium"
156 #define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high" 154 #define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high"
157 155
158 typedef SkDrawCommand* (*FROM_JSON)(Json::Value); 156 typedef SkDrawCommand* (*FROM_JSON)(Json::Value&, UrlDataManager&);
159 157
160 // TODO(chudy): Refactor into non subclass model. 158 // TODO(chudy): Refactor into non subclass model.
161 159
162 SkDrawCommand::SkDrawCommand(OpType type) 160 SkDrawCommand::SkDrawCommand(OpType type)
163 : fOpType(type) 161 : fOpType(type)
164 , fVisible(true) { 162 , fVisible(true) {
165 } 163 }
166 164
167 SkDrawCommand::~SkDrawCommand() { 165 SkDrawCommand::~SkDrawCommand() {
168 fInfo.deleteAll(); 166 fInfo.deleteAll();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 break; 205 break;
208 } 206 }
209 SkDEBUGFAIL("DrawType UNUSED\n"); 207 SkDEBUGFAIL("DrawType UNUSED\n");
210 return nullptr; 208 return nullptr;
211 } 209 }
212 210
213 SkString SkDrawCommand::toString() const { 211 SkString SkDrawCommand::toString() const {
214 return SkString(GetCommandString(fOpType)); 212 return SkString(GetCommandString(fOpType));
215 } 213 }
216 214
217 Json::Value SkDrawCommand::toJSON() const { 215 Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const {
218 Json::Value result; 216 Json::Value result;
219 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType); 217 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType);
220 return result; 218 return result;
221 } 219 }
222 220
223 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name ##_OpType)), \ 221 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name ##_OpType)), \
224 (FROM_JSON) Sk ## name ## Command::f romJSON) 222 (FROM_JSON) Sk ## name ## Command::f romJSON)
225 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command) { 223 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url DataManager) {
226 static SkTHashMap<SkString, FROM_JSON> factories; 224 static SkTHashMap<SkString, FROM_JSON> factories;
227 static bool initialized = false; 225 static bool initialized = false;
228 if (!initialized) { 226 if (!initialized) {
229 initialized = true; 227 initialized = true;
230 INSTALL_FACTORY(Restore); 228 INSTALL_FACTORY(Restore);
231 INSTALL_FACTORY(ClipPath); 229 INSTALL_FACTORY(ClipPath);
232 INSTALL_FACTORY(ClipRegion); 230 INSTALL_FACTORY(ClipRegion);
233 INSTALL_FACTORY(ClipRect); 231 INSTALL_FACTORY(ClipRect);
234 INSTALL_FACTORY(ClipRRect); 232 INSTALL_FACTORY(ClipRRect);
235 INSTALL_FACTORY(Concat); 233 INSTALL_FACTORY(Concat);
(...skipping 18 matching lines...) Expand all
254 INSTALL_FACTORY(Save); 252 INSTALL_FACTORY(Save);
255 INSTALL_FACTORY(SaveLayer); 253 INSTALL_FACTORY(SaveLayer);
256 INSTALL_FACTORY(SetMatrix); 254 INSTALL_FACTORY(SetMatrix);
257 } 255 }
258 SkString name = SkString(command[SKDEBUGCANVAS_ATTRIBUTE_COMMAND].asCString( )); 256 SkString name = SkString(command[SKDEBUGCANVAS_ATTRIBUTE_COMMAND].asCString( ));
259 FROM_JSON* factory = factories.find(name); 257 FROM_JSON* factory = factories.find(name);
260 if (factory == nullptr) { 258 if (factory == nullptr) {
261 SkDebugf("no JSON factory for '%s'\n", name.c_str()); 259 SkDebugf("no JSON factory for '%s'\n", name.c_str());
262 return nullptr; 260 return nullptr;
263 } 261 }
264 return (*factory)(command); 262 return (*factory)(command, urlDataManager);
265 } 263 }
266 264
267 namespace { 265 namespace {
268 266
269 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) { 267 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) {
270 const SkISize& size = canvas->getDeviceSize(); 268 const SkISize& size = canvas->getDeviceSize();
271 269
272 static const SkScalar kInsetFrac = 0.9f; // Leave a border around object 270 static const SkScalar kInsetFrac = 0.9f; // Leave a border around object
273 271
274 canvas->translate(size.fWidth/2.0f, size.fHeight/2.0f); 272 canvas->translate(size.fWidth/2.0f, size.fHeight/2.0f);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 (*target)[key] = Json::Value(value); 573 (*target)[key] = Json::Value(value);
576 } 574 }
577 } 575 }
578 576
579 static void store_bool(Json::Value* target, const char* key, bool value, bool de faultValue) { 577 static void store_bool(Json::Value* target, const char* key, bool value, bool de faultValue) {
580 if (value != defaultValue) { 578 if (value != defaultValue) {
581 (*target)[key] = Json::Value(value); 579 (*target)[key] = Json::Value(value);
582 } 580 }
583 } 581 }
584 582
585 static void encode_data(const void* data, size_t count, Json::Value* target) { 583 static void encode_data(const void* bytes, size_t count, const char* contentType ,
586 // just use a brain-dead JSON array for now, switch to base64 or something e lse smarter down the 584 UrlDataManager& urlDataManager, Json::Value* target) {
587 // road 585 SkAutoTUnref<SkData> data(SkData::NewWithCopy(bytes, count));
588 for (size_t i = 0; i < count; i++) { 586 SkString url = urlDataManager.addData(data, contentType);
589 target->append(((const uint8_t*)data)[i]); 587 *target = Json::Value(url.c_str());
590 }
591 } 588 }
592 589
593 static void flatten(const SkFlattenable* flattenable, Json::Value* target, bool sendBinaries) { 590 static void flatten(const SkFlattenable* flattenable, Json::Value* target,
594 if (sendBinaries) { 591 UrlDataManager& urlDataManager) {
595 SkWriteBuffer buffer; 592 SkWriteBuffer buffer;
596 flattenable->flatten(buffer); 593 flattenable->flatten(buffer);
597 void* data = sk_malloc_throw(buffer.bytesWritten()); 594 void* data = sk_malloc_throw(buffer.bytesWritten());
598 buffer.writeToMemory(data); 595 buffer.writeToMemory(data);
599 Json::Value bytes; 596 Json::Value jsonData;
600 encode_data(data, buffer.bytesWritten(), &bytes); 597 encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlData Manager, &jsonData);
601 Json::Value jsonFlattenable; 598 Json::Value jsonFlattenable;
602 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME] = Json::Value(flattenable- >getTypeName()); 599 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME] = Json::Value(flattenable->get TypeName());
603 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_BYTES] = bytes; 600 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData;
604 (*target) = jsonFlattenable; 601 (*target) = jsonFlattenable;
605 sk_free(data); 602 sk_free(data);
606 } else {
607 (*target)[SKDEBUGCANVAS_ATTRIBUTE_DESCRIPTION] = Json::Value(flattenable ->getTypeName());
608 }
609 } 603 }
610 604
611 static bool SK_WARN_UNUSED_RESULT flatten(const SkImage& image, Json::Value* tar get, 605 static bool SK_WARN_UNUSED_RESULT flatten(const SkImage& image, Json::Value* tar get,
612 bool sendBinaries) { 606 UrlDataManager& urlDataManager) {
613 if (sendBinaries) { 607 SkData* encoded = image.encode(SkImageEncoder::kPNG_Type, 100);
614 SkData* encoded = image.encode(SkImageEncoder::kPNG_Type, 100); 608 if (encoded == nullptr) {
609 // PNG encode doesn't necessarily support all color formats, convert to a different
610 // format
611 size_t rowBytes = 4 * image.width();
612 void* buffer = sk_malloc_throw(rowBytes * image.height());
613 SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height(),
614 kN32_SkColorType, kPremul_SkAlph aType);
615 if (!image.readPixels(dstInfo, buffer, rowBytes, 0, 0)) {
616 SkDebugf("readPixels failed\n");
617 return false;
618 }
619 SkImage* converted = SkImage::NewRasterCopy(dstInfo, buffer, rowBytes);
620 encoded = converted->encode(SkImageEncoder::kPNG_Type, 100);
615 if (encoded == nullptr) { 621 if (encoded == nullptr) {
616 // PNG encode doesn't necessarily support all color formats, convert to a different 622 SkDebugf("image encode failed\n");
617 // format 623 return false;
618 size_t rowBytes = 4 * image.width();
619 void* buffer = sk_malloc_throw(rowBytes * image.height());
620 SkImageInfo dstInfo = SkImageInfo::Make(image.width(), image.height( ),
621 kN32_SkColorType, kPremul_Sk AlphaType);
622 if (!image.readPixels(dstInfo, buffer, rowBytes, 0, 0)) {
623 SkDebugf("readPixels failed\n");
624 return false;
625 }
626 SkImage* converted = SkImage::NewRasterCopy(dstInfo, buffer, rowByte s);
627 encoded = converted->encode(SkImageEncoder::kPNG_Type, 100);
628 if (encoded == nullptr) {
629 SkDebugf("image encode failed\n");
630 return false;
631 }
632 sk_free(converted);
633 sk_free(buffer);
634 } 624 }
635 Json::Value bytes; 625 sk_free(converted);
636 encode_data(encoded->data(), encoded->size(), &bytes); 626 sk_free(buffer);
637 (*target)[SKDEBUGCANVAS_ATTRIBUTE_BYTES] = bytes;
638 encoded->unref();
639 } else {
640 SkString description = SkStringPrintf("%dx%d pixel image", image.width() , image.height());
641 (*target)[SKDEBUGCANVAS_ATTRIBUTE_DESCRIPTION] = Json::Value(description .c_str());
642 } 627 }
628 Json::Value jsonData;
629 encode_data(encoded->data(), encoded->size(), "image/png", urlDataManager, & jsonData);
630 (*target)[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData;
631 encoded->unref();
643 return true; 632 return true;
644 } 633 }
645 634
646 static const char* color_type_name(SkColorType colorType) { 635 static const char* color_type_name(SkColorType colorType) {
647 switch (colorType) { 636 switch (colorType) {
648 case kARGB_4444_SkColorType: 637 case kARGB_4444_SkColorType:
649 return SKDEBUGCANVAS_COLORTYPE_ARGB4444; 638 return SKDEBUGCANVAS_COLORTYPE_ARGB4444;
650 case kRGBA_8888_SkColorType: 639 case kRGBA_8888_SkColorType:
651 return SKDEBUGCANVAS_COLORTYPE_RGBA8888; 640 return SKDEBUGCANVAS_COLORTYPE_RGBA8888;
652 case kBGRA_8888_SkColorType: 641 case kBGRA_8888_SkColorType:
(...skipping 19 matching lines...) Expand all
672 case kPremul_SkAlphaType: 661 case kPremul_SkAlphaType:
673 return SKDEBUGCANVAS_ALPHATYPE_PREMUL; 662 return SKDEBUGCANVAS_ALPHATYPE_PREMUL;
674 case kUnpremul_SkAlphaType: 663 case kUnpremul_SkAlphaType:
675 return SKDEBUGCANVAS_ALPHATYPE_UNPREMUL; 664 return SKDEBUGCANVAS_ALPHATYPE_UNPREMUL;
676 default: 665 default:
677 SkASSERT(false); 666 SkASSERT(false);
678 return SKDEBUGCANVAS_ALPHATYPE_OPAQUE; 667 return SKDEBUGCANVAS_ALPHATYPE_OPAQUE;
679 } 668 }
680 } 669 }
681 670
682 // note that the caller is responsible for freeing the pointer 671 static Json::ArrayIndex decode_data(Json::Value data, UrlDataManager& urlDataMan ager,
683 static Json::ArrayIndex decode_data(Json::Value bytes, void** target) { 672 const void** target) {
684 Json::ArrayIndex size = bytes.size(); 673 UrlDataManager::UrlData* urlData = urlDataManager.getDataFromUrl(SkString(da ta.asCString()));
685 *target = sk_malloc_throw(size); 674 if (urlData == nullptr) {
686 for (Json::ArrayIndex i = 0; i < size; i++) { 675 SkASSERT(false);
687 ((uint8_t*) *target)[i] = bytes[i].asInt(); 676 *target = nullptr;
677 return 0;
688 } 678 }
689 return size; 679 *target = urlData->fData->data();
680 // cast should be safe for any reasonably-sized object...
681 return (Json::ArrayIndex) urlData->fData->size();
690 } 682 }
691 683
692 static SkFlattenable* load_flattenable(Json::Value jsonFlattenable) { 684 static SkFlattenable* load_flattenable(Json::Value jsonFlattenable,
685 UrlDataManager& urlDataManager) {
693 if (!jsonFlattenable.isMember(SKDEBUGCANVAS_ATTRIBUTE_NAME)) { 686 if (!jsonFlattenable.isMember(SKDEBUGCANVAS_ATTRIBUTE_NAME)) {
694 return nullptr; 687 return nullptr;
695 } 688 }
696 const char* name = jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME].asCString() ; 689 const char* name = jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME].asCString() ;
697 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name); 690 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name);
698 if (factory == nullptr) { 691 if (factory == nullptr) {
699 SkDebugf("no factory for loading '%s'\n", name); 692 SkDebugf("no factory for loading '%s'\n", name);
700 return nullptr; 693 return nullptr;
701 } 694 }
702 void* data; 695 const void* data;
703 int size = decode_data(jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_BYTES], &data ); 696 int size = decode_data(jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA], urlDat aManager, &data);
704 SkValidatingReadBuffer buffer(data, size); 697 SkValidatingReadBuffer buffer(data, size);
705 SkFlattenable* result = factory(buffer); 698 SkFlattenable* result = factory(buffer);
706 sk_free(data);
707 if (!buffer.isValid()) { 699 if (!buffer.isValid()) {
708 SkDebugf("invalid buffer loading flattenable\n"); 700 SkDebugf("invalid buffer loading flattenable\n");
709 return nullptr; 701 return nullptr;
710 } 702 }
711 return result; 703 return result;
712 } 704 }
713 705
714 static SkColorType colortype_from_name(const char* name) { 706 static SkColorType colortype_from_name(const char* name) {
715 if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_ARGB4444)) { 707 if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_ARGB4444)) {
716 return kARGB_4444_SkColorType; 708 return kARGB_4444_SkColorType;
(...skipping 28 matching lines...) Expand all
745 if (bitmap->copyTo(dst, colorType)) { 737 if (bitmap->copyTo(dst, colorType)) {
746 delete bitmap; 738 delete bitmap;
747 return dst; 739 return dst;
748 } 740 }
749 SkASSERT(false); 741 SkASSERT(false);
750 delete dst; 742 delete dst;
751 return bitmap; 743 return bitmap;
752 } 744 }
753 745
754 // caller is responsible for freeing return value 746 // caller is responsible for freeing return value
755 static SkBitmap* load_bitmap(const Json::Value& jsonBitmap) { 747 static SkBitmap* load_bitmap(const Json::Value& jsonBitmap, UrlDataManager& urlD ataManager) {
756 if (!jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_BYTES)) { 748 if (!jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_DATA)) {
757 SkDebugf("invalid bitmap\n"); 749 SkDebugf("invalid bitmap\n");
758 return nullptr; 750 return nullptr;
759 } 751 }
760 void* data; 752 const void* data;
761 int size = decode_data(jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_BYTES], &data); 753 int size = decode_data(jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_DATA], urlDataMana ger, &data);
762 SkMemoryStream stream(data, size); 754 SkMemoryStream stream(data, size);
763 SkImageDecoder* decoder = SkImageDecoder::Factory(&stream); 755 SkImageDecoder* decoder = SkImageDecoder::Factory(&stream);
764 SkBitmap* bitmap = new SkBitmap(); 756 SkBitmap* bitmap = new SkBitmap();
765 SkImageDecoder::Result result = decoder->decode(&stream, bitmap, 757 SkImageDecoder::Result result = decoder->decode(&stream, bitmap,
766 SkImageDecoder::kDecodePixel s_Mode); 758 SkImageDecoder::kDecodePixel s_Mode);
767 sk_free(decoder); 759 sk_free(decoder);
768 if (result != SkImageDecoder::kFailure) { 760 if (result != SkImageDecoder::kFailure) {
769 sk_free(data);
770 if (jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) { 761 if (jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) {
771 const char* ctName = jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_COLOR].asCSt ring(); 762 const char* ctName = jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_COLOR].asCSt ring();
772 SkColorType ct = colortype_from_name(ctName); 763 SkColorType ct = colortype_from_name(ctName);
773 if (ct != kIndex_8_SkColorType) { 764 if (ct != kIndex_8_SkColorType) {
774 bitmap = convert_colortype(bitmap, ct); 765 bitmap = convert_colortype(bitmap, ct);
775 } 766 }
776 } 767 }
777 return bitmap; 768 return bitmap;
778 } 769 }
779 SkDebugf("image decode failed\n"); 770 SkDebugf("image decode failed\n");
780 sk_free(data);
781 return nullptr; 771 return nullptr;
782 } 772 }
783 773
784 static SkImage* load_image(const Json::Value& jsonImage) { 774 static SkImage* load_image(const Json::Value& jsonImage, UrlDataManager& urlData Manager) {
785 SkBitmap* bitmap = load_bitmap(jsonImage); 775 SkBitmap* bitmap = load_bitmap(jsonImage, urlDataManager);
786 if (bitmap == nullptr) { 776 if (bitmap == nullptr) {
787 return nullptr; 777 return nullptr;
788 } 778 }
789 SkImage* result = SkImage::NewFromBitmap(*bitmap); 779 SkImage* result = SkImage::NewFromBitmap(*bitmap);
790 delete bitmap; 780 delete bitmap;
791 return result; 781 return result;
792 } 782 }
793 783
794 static bool SK_WARN_UNUSED_RESULT flatten(const SkBitmap& bitmap, Json::Value* t arget, 784 static bool SK_WARN_UNUSED_RESULT flatten(const SkBitmap& bitmap, Json::Value* t arget,
795 bool sendBinaries) { 785 UrlDataManager& urlDataManager) {
796 bitmap.lockPixels(); 786 bitmap.lockPixels();
797 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap)); 787 SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bitmap));
798 bitmap.unlockPixels(); 788 bitmap.unlockPixels();
799 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = Json::Value(color_type_name(bitma p.colorType())); 789 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = Json::Value(color_type_name(bitma p.colorType()));
800 (*target)[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = Json::Value(alpha_type_name(bitma p.alphaType())); 790 (*target)[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = Json::Value(alpha_type_name(bitma p.alphaType()));
801 bool success = flatten(*image, target, sendBinaries); 791 bool success = flatten(*image, target, urlDataManager);
802 return success; 792 return success;
803 } 793 }
804 794
805 static void apply_paint_color(const SkPaint& paint, Json::Value* target) { 795 static void apply_paint_color(const SkPaint& paint, Json::Value* target) {
806 SkColor color = paint.getColor(); 796 SkColor color = paint.getColor();
807 if (color != SK_ColorBLACK) { 797 if (color != SK_ColorBLACK) {
808 Json::Value colorValue(Json::arrayValue); 798 Json::Value colorValue(Json::arrayValue);
809 colorValue.append(Json::Value(SkColorGetA(color))); 799 colorValue.append(Json::Value(SkColorGetA(color)));
810 colorValue.append(Json::Value(SkColorGetR(color))); 800 colorValue.append(Json::Value(SkColorGetR(color)));
811 colorValue.append(Json::Value(SkColorGetG(color))); 801 colorValue.append(Json::Value(SkColorGetG(color)));
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value( 875 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value(
886 SKDEBUGCANVAS_FI LTERQUALITY_MEDIUM); 876 SKDEBUGCANVAS_FI LTERQUALITY_MEDIUM);
887 break; 877 break;
888 case kHigh_SkFilterQuality: 878 case kHigh_SkFilterQuality:
889 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value( 879 (*target)[SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY] = Json::Value(
890 SKDEBUGCANVAS_ FILTERQUALITY_HIGH); 880 SKDEBUGCANVAS_ FILTERQUALITY_HIGH);
891 break; 881 break;
892 } 882 }
893 } 883 }
894 884
895 static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target, bo ol sendBinaries) { 885 static void apply_paint_maskfilter(const SkPaint& paint, Json::Value* target,
886 UrlDataManager& urlDataManager) {
896 SkMaskFilter* maskFilter = paint.getMaskFilter(); 887 SkMaskFilter* maskFilter = paint.getMaskFilter();
897 if (maskFilter != nullptr) { 888 if (maskFilter != nullptr) {
898 SkMaskFilter::BlurRec blurRec; 889 SkMaskFilter::BlurRec blurRec;
899 if (maskFilter->asABlur(&blurRec)) { 890 if (maskFilter->asABlur(&blurRec)) {
900 Json::Value blur(Json::objectValue); 891 Json::Value blur(Json::objectValue);
901 blur[SKDEBUGCANVAS_ATTRIBUTE_SIGMA] = Json::Value(blurRec.fSigma); 892 blur[SKDEBUGCANVAS_ATTRIBUTE_SIGMA] = Json::Value(blurRec.fSigma);
902 switch (blurRec.fStyle) { 893 switch (blurRec.fStyle) {
903 case SkBlurStyle::kNormal_SkBlurStyle: 894 case SkBlurStyle::kNormal_SkBlurStyle:
904 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value( 895 blur[SKDEBUGCANVAS_ATTRIBUTE_STYLE] = Json::Value(
905 SKDEBUGCANVA S_BLURSTYLE_NORMAL); 896 SKDEBUGCANVA S_BLURSTYLE_NORMAL);
(...skipping 21 matching lines...) Expand all
927 case SkBlurQuality::kHigh_SkBlurQuality: 918 case SkBlurQuality::kHigh_SkBlurQuality:
928 blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value( 919 blur[SKDEBUGCANVAS_ATTRIBUTE_QUALITY] = Json::Value(
929 SKDEBUGCANVA S_BLURQUALITY_HIGH); 920 SKDEBUGCANVA S_BLURQUALITY_HIGH);
930 break; 921 break;
931 default: 922 default:
932 SkASSERT(false); 923 SkASSERT(false);
933 } 924 }
934 (*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur; 925 (*target)[SKDEBUGCANVAS_ATTRIBUTE_BLUR] = blur;
935 } else { 926 } else {
936 Json::Value jsonMaskFilter; 927 Json::Value jsonMaskFilter;
937 flatten(maskFilter, &jsonMaskFilter, sendBinaries); 928 flatten(maskFilter, &jsonMaskFilter, urlDataManager);
938 (*target)[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER] = jsonMaskFilter; 929 (*target)[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER] = jsonMaskFilter;
939 } 930 }
940 } 931 }
941 } 932 }
942 933
943 static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target, bo ol sendBinaries) { 934 static void apply_paint_patheffect(const SkPaint& paint, Json::Value* target,
935 UrlDataManager& urlDataManager) {
944 SkPathEffect* pathEffect = paint.getPathEffect(); 936 SkPathEffect* pathEffect = paint.getPathEffect();
945 if (pathEffect != nullptr) { 937 if (pathEffect != nullptr) {
946 SkPathEffect::DashInfo dashInfo; 938 SkPathEffect::DashInfo dashInfo;
947 SkPathEffect::DashType dashType = pathEffect->asADash(&dashInfo); 939 SkPathEffect::DashType dashType = pathEffect->asADash(&dashInfo);
948 if (dashType == SkPathEffect::kDash_DashType) { 940 if (dashType == SkPathEffect::kDash_DashType) {
949 dashInfo.fIntervals = (SkScalar*) sk_malloc_throw(dashInfo.fCount * sizeof(SkScalar)); 941 dashInfo.fIntervals = (SkScalar*) sk_malloc_throw(dashInfo.fCount * sizeof(SkScalar));
950 pathEffect->asADash(&dashInfo); 942 pathEffect->asADash(&dashInfo);
951 Json::Value dashing(Json::objectValue); 943 Json::Value dashing(Json::objectValue);
952 Json::Value intervals(Json::arrayValue); 944 Json::Value intervals(Json::arrayValue);
953 for (int32_t i = 0; i < dashInfo.fCount; i++) { 945 for (int32_t i = 0; i < dashInfo.fCount; i++) {
954 intervals.append(Json::Value(dashInfo.fIntervals[i])); 946 intervals.append(Json::Value(dashInfo.fIntervals[i]));
955 } 947 }
956 sk_free(dashInfo.fIntervals); 948 sk_free(dashInfo.fIntervals);
957 dashing[SKDEBUGCANVAS_ATTRIBUTE_INTERVALS] = intervals; 949 dashing[SKDEBUGCANVAS_ATTRIBUTE_INTERVALS] = intervals;
958 dashing[SKDEBUGCANVAS_ATTRIBUTE_PHASE] = dashInfo.fPhase; 950 dashing[SKDEBUGCANVAS_ATTRIBUTE_PHASE] = dashInfo.fPhase;
959 (*target)[SKDEBUGCANVAS_ATTRIBUTE_DASHING] = dashing; 951 (*target)[SKDEBUGCANVAS_ATTRIBUTE_DASHING] = dashing;
960 } else { 952 } else {
961 Json::Value jsonPathEffect; 953 Json::Value jsonPathEffect;
962 flatten(pathEffect, &jsonPathEffect, sendBinaries); 954 flatten(pathEffect, &jsonPathEffect, urlDataManager);
963 (*target)[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT] = jsonPathEffect; 955 (*target)[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT] = jsonPathEffect;
964 } 956 }
965 } 957 }
966 } 958 }
967 959
968 static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) { 960 static void apply_paint_textalign(const SkPaint& paint, Json::Value* target) {
969 SkPaint::Align textAlign = paint.getTextAlign(); 961 SkPaint::Align textAlign = paint.getTextAlign();
970 if (textAlign != SkPaint::kLeft_Align) { 962 if (textAlign != SkPaint::kLeft_Align) {
971 switch (textAlign) { 963 switch (textAlign) {
972 case SkPaint::kCenter_Align: { 964 case SkPaint::kCenter_Align: {
973 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN] = SKDEBUGCANVAS_ALI GN_CENTER; 965 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN] = SKDEBUGCANVAS_ALI GN_CENTER;
974 break; 966 break;
975 } 967 }
976 case SkPaint::kRight_Align: { 968 case SkPaint::kRight_Align: {
977 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN] = SKDEBUGCANVAS_ALI GN_RIGHT; 969 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TEXTALIGN] = SKDEBUGCANVAS_ALI GN_RIGHT;
978 break; 970 break;
979 } 971 }
980 default: SkASSERT(false); 972 default: SkASSERT(false);
981 } 973 }
982 } 974 }
983 } 975 }
984 976
985 static void apply_paint_typeface(const SkPaint& paint, Json::Value* target, 977 static void apply_paint_typeface(const SkPaint& paint, Json::Value* target,
986 bool sendBinaries) { 978 UrlDataManager& urlDataManager) {
987 SkTypeface* typeface = paint.getTypeface(); 979 SkTypeface* typeface = paint.getTypeface();
988 if (typeface != nullptr) { 980 if (typeface != nullptr) {
989 if (sendBinaries) { 981 Json::Value jsonTypeface;
990 Json::Value jsonTypeface; 982 SkDynamicMemoryWStream buffer;
991 SkDynamicMemoryWStream buffer; 983 typeface->serialize(&buffer);
992 typeface->serialize(&buffer); 984 void* data = sk_malloc_throw(buffer.bytesWritten());
993 void* data = sk_malloc_throw(buffer.bytesWritten()); 985 buffer.copyTo(data);
994 buffer.copyTo(data); 986 Json::Value jsonData;
995 Json::Value bytes; 987 encode_data(data, buffer.bytesWritten(), "application/octet-stream", url DataManager,
996 encode_data(data, buffer.bytesWritten(), &bytes); 988 &jsonData);
997 jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_BYTES] = bytes; 989 jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData;
998 sk_free(data); 990 sk_free(data);
999 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE] = jsonTypeface; 991 (*target)[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE] = jsonTypeface;
1000 }
1001 } 992 }
1002 } 993 }
1003 994
1004 static void apply_paint_shader(const SkPaint& paint, Json::Value* target, bool s endBinaries) { 995 static void apply_paint_shader(const SkPaint& paint, Json::Value* target,
996 UrlDataManager& urlDataManager) {
1005 SkFlattenable* shader = paint.getShader(); 997 SkFlattenable* shader = paint.getShader();
1006 if (shader != nullptr) { 998 if (shader != nullptr) {
1007 Json::Value jsonShader; 999 Json::Value jsonShader;
1008 flatten(shader, &jsonShader, sendBinaries); 1000 flatten(shader, &jsonShader, urlDataManager);
1009 (*target)[SKDEBUGCANVAS_ATTRIBUTE_SHADER] = jsonShader; 1001 (*target)[SKDEBUGCANVAS_ATTRIBUTE_SHADER] = jsonShader;
1010 } 1002 }
1011 } 1003 }
1012 1004
1013 static void apply_paint_xfermode(const SkPaint& paint, Json::Value* target, bool sendBinaries) { 1005 static void apply_paint_xfermode(const SkPaint& paint, Json::Value* target,
1006 UrlDataManager& urlDataManager) {
1014 SkFlattenable* xfermode = paint.getXfermode(); 1007 SkFlattenable* xfermode = paint.getXfermode();
1015 if (xfermode != nullptr) { 1008 if (xfermode != nullptr) {
1016 Json::Value jsonXfermode; 1009 Json::Value jsonXfermode;
1017 flatten(xfermode, &jsonXfermode, sendBinaries); 1010 flatten(xfermode, &jsonXfermode, urlDataManager);
1018 (*target)[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; 1011 (*target)[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode;
1019 } 1012 }
1020 } 1013 }
1021 1014
1022 static void apply_paint_imagefilter(const SkPaint& paint, Json::Value* target, b ool sendBinaries) { 1015 static void apply_paint_imagefilter(const SkPaint& paint, Json::Value* target,
1016 UrlDataManager& urlDataManager) {
1023 SkFlattenable* imageFilter = paint.getImageFilter(); 1017 SkFlattenable* imageFilter = paint.getImageFilter();
1024 if (imageFilter != nullptr) { 1018 if (imageFilter != nullptr) {
1025 Json::Value jsonImageFilter; 1019 Json::Value jsonImageFilter;
1026 flatten(imageFilter, &jsonImageFilter, sendBinaries); 1020 flatten(imageFilter, &jsonImageFilter, urlDataManager);
1027 (*target)[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER] = jsonImageFilter; 1021 (*target)[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER] = jsonImageFilter;
1028 } 1022 }
1029 } 1023 }
1030 1024
1031 static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target, b ool sendBinaries) { 1025 static void apply_paint_colorfilter(const SkPaint& paint, Json::Value* target,
1026 UrlDataManager& urlDataManager) {
1032 SkFlattenable* colorFilter = paint.getColorFilter(); 1027 SkFlattenable* colorFilter = paint.getColorFilter();
1033 if (colorFilter != nullptr) { 1028 if (colorFilter != nullptr) {
1034 Json::Value jsonColorFilter; 1029 Json::Value jsonColorFilter;
1035 flatten(colorFilter, &jsonColorFilter, sendBinaries); 1030 flatten(colorFilter, &jsonColorFilter, urlDataManager);
1036 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter; 1031 (*target)[SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER] = jsonColorFilter;
1037 } 1032 }
1038 } 1033 }
1039 1034
1040 static void apply_paint_looper(const SkPaint& paint, Json::Value* target, bool s endBinaries) { 1035 static void apply_paint_looper(const SkPaint& paint, Json::Value* target,
1036 UrlDataManager& urlDataManager) {
1041 SkFlattenable* looper = paint.getLooper(); 1037 SkFlattenable* looper = paint.getLooper();
1042 if (looper != nullptr) { 1038 if (looper != nullptr) {
1043 Json::Value jsonLooper; 1039 Json::Value jsonLooper;
1044 flatten(looper, &jsonLooper, sendBinaries); 1040 flatten(looper, &jsonLooper, urlDataManager);
1045 (*target)[SKDEBUGCANVAS_ATTRIBUTE_LOOPER] = jsonLooper; 1041 (*target)[SKDEBUGCANVAS_ATTRIBUTE_LOOPER] = jsonLooper;
1046 } 1042 }
1047 } 1043 }
1048 1044
1049 Json::Value make_json_paint(const SkPaint& paint, bool sendBinaries) { 1045 Json::Value make_json_paint(const SkPaint& paint, UrlDataManager& urlDataManager ) {
1050 Json::Value result(Json::objectValue); 1046 Json::Value result(Json::objectValue);
1051 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWi dth(), 0.0f); 1047 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEWIDTH, paint.getStrokeWi dth(), 0.0f);
1052 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMi ter(), 1048 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_STROKEMITER, paint.getStrokeMi ter(),
1053 SkPaintDefaults_MiterLimit); 1049 SkPaintDefaults_MiterLimit);
1054 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(), false); 1050 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS, paint.isAntiAlias(), false);
1055 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false) ; 1051 store_bool(&result, SKDEBUGCANVAS_ATTRIBUTE_DITHER, paint.isDither(), false) ;
1056 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(), 1052 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE, paint.getTextSize(),
1057 SkPaintDefaults_TextSize); 1053 SkPaintDefaults_TextSize);
1058 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScale X(), SK_Scalar1); 1054 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScale X(), SK_Scalar1);
1059 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX (), 0.0f); 1055 store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX (), 0.0f);
1060 apply_paint_color(paint, &result); 1056 apply_paint_color(paint, &result);
1061 apply_paint_style(paint, &result); 1057 apply_paint_style(paint, &result);
1062 apply_paint_cap(paint, &result); 1058 apply_paint_cap(paint, &result);
1063 apply_paint_join(paint, &result); 1059 apply_paint_join(paint, &result);
1064 apply_paint_filterquality(paint, &result); 1060 apply_paint_filterquality(paint, &result);
1065 apply_paint_textalign(paint, &result); 1061 apply_paint_textalign(paint, &result);
1066 apply_paint_patheffect(paint, &result, sendBinaries); 1062 apply_paint_patheffect(paint, &result, urlDataManager);
1067 apply_paint_maskfilter(paint, &result, sendBinaries); 1063 apply_paint_maskfilter(paint, &result, urlDataManager);
1068 apply_paint_shader(paint, &result, sendBinaries); 1064 apply_paint_shader(paint, &result, urlDataManager);
1069 apply_paint_xfermode(paint, &result, sendBinaries); 1065 apply_paint_xfermode(paint, &result, urlDataManager);
1070 apply_paint_looper(paint, &result, sendBinaries); 1066 apply_paint_looper(paint, &result, urlDataManager);
1071 apply_paint_imagefilter(paint, &result, sendBinaries); 1067 apply_paint_imagefilter(paint, &result, urlDataManager);
1072 apply_paint_colorfilter(paint, &result, sendBinaries); 1068 apply_paint_colorfilter(paint, &result, urlDataManager);
1073 apply_paint_typeface(paint, &result, sendBinaries); 1069 apply_paint_typeface(paint, &result, urlDataManager);
1074 return result; 1070 return result;
1075 } 1071 }
1076 1072
1077 static SkPoint get_json_point(Json::Value point) { 1073 static SkPoint get_json_point(Json::Value point) {
1078 return SkPoint::Make(point[0].asFloat(), point[1].asFloat()); 1074 return SkPoint::Make(point[0].asFloat(), point[1].asFloat());
1079 } 1075 }
1080 1076
1081 static SkColor get_json_color(Json::Value color) { 1077 static SkColor get_json_color(Json::Value color) {
1082 return SkColorSetARGB(color[0].asInt(), color[1].asInt(), color[2].asInt(), color[3].asInt()); 1078 return SkColorSetARGB(color[0].asInt(), color[1].asInt(), color[2].asInt(), color[3].asInt());
1083 } 1079 }
1084 1080
1085 static void extract_json_paint_color(Json::Value& jsonPaint, SkPaint* target) { 1081 static void extract_json_paint_color(Json::Value& jsonPaint, SkPaint* target) {
1086 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) { 1082 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) {
1087 target->setColor(get_json_color(jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLOR] )); 1083 target->setColor(get_json_color(jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLOR] ));
1088 } 1084 }
1089 } 1085 }
1090 1086
1091 static void extract_json_paint_shader(Json::Value& jsonPaint, SkPaint* target) { 1087 static void extract_json_paint_shader(Json::Value& jsonPaint, UrlDataManager& ur lDataManager,
1088 SkPaint* target) {
1092 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_SHADER)) { 1089 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_SHADER)) {
1093 Json::Value jsonShader = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_SHADER]; 1090 Json::Value jsonShader = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_SHADER];
1094 SkShader* shader = (SkShader*) load_flattenable(jsonShader); 1091 SkShader* shader = (SkShader*) load_flattenable(jsonShader, urlDataManag er);
1095 if (shader != nullptr) { 1092 if (shader != nullptr) {
1096 target->setShader(shader); 1093 target->setShader(shader);
1097 shader->unref(); 1094 shader->unref();
1098 } 1095 }
1099 } 1096 }
1100 } 1097 }
1101 1098
1102 static void extract_json_paint_patheffect(Json::Value& jsonPaint, SkPaint* targe t) { 1099 static void extract_json_paint_patheffect(Json::Value& jsonPaint, UrlDataManager & urlDataManager,
1100 SkPaint* target) {
1103 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT)) { 1101 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT)) {
1104 Json::Value jsonPathEffect = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFEC T]; 1102 Json::Value jsonPathEffect = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFEC T];
1105 SkPathEffect* pathEffect = (SkPathEffect*) load_flattenable(jsonPathEffe ct); 1103 SkPathEffect* pathEffect = (SkPathEffect*) load_flattenable(jsonPathEffe ct, urlDataManager);
1106 if (pathEffect != nullptr) { 1104 if (pathEffect != nullptr) {
1107 target->setPathEffect(pathEffect); 1105 target->setPathEffect(pathEffect);
1108 pathEffect->unref(); 1106 pathEffect->unref();
1109 } 1107 }
1110 } 1108 }
1111 } 1109 }
1112 1110
1113 static void extract_json_paint_maskfilter(Json::Value& jsonPaint, SkPaint* targe t) { 1111 static void extract_json_paint_maskfilter(Json::Value& jsonPaint, UrlDataManager & urlDataManager,
1112 SkPaint* target) {
1114 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER)) { 1113 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER)) {
1115 Json::Value jsonMaskFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTE R]; 1114 Json::Value jsonMaskFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_MASKFILTE R];
1116 SkMaskFilter* maskFilter = (SkMaskFilter*) load_flattenable(jsonMaskFilt er); 1115 SkMaskFilter* maskFilter = (SkMaskFilter*) load_flattenable(jsonMaskFilt er, urlDataManager);
1117 if (maskFilter != nullptr) { 1116 if (maskFilter != nullptr) {
1118 target->setMaskFilter(maskFilter); 1117 target->setMaskFilter(maskFilter);
1119 maskFilter->unref(); 1118 maskFilter->unref();
1120 } 1119 }
1121 } 1120 }
1122 } 1121 }
1123 1122
1124 static void extract_json_paint_colorfilter(Json::Value& jsonPaint, SkPaint* targ et) { 1123 static void extract_json_paint_colorfilter(Json::Value& jsonPaint, UrlDataManage r& urlDataManager,
1124 SkPaint* target) {
1125 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER)) { 1125 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER)) {
1126 Json::Value jsonColorFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLORFIL TER]; 1126 Json::Value jsonColorFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_COLORFIL TER];
1127 SkColorFilter* colorFilter = (SkColorFilter*) load_flattenable(jsonColor Filter); 1127 SkColorFilter* colorFilter = (SkColorFilter*) load_flattenable(jsonColor Filter,
1128 urlDataMa nager);
1128 if (colorFilter != nullptr) { 1129 if (colorFilter != nullptr) {
1129 target->setColorFilter(colorFilter); 1130 target->setColorFilter(colorFilter);
1130 colorFilter->unref(); 1131 colorFilter->unref();
1131 } 1132 }
1132 } 1133 }
1133 } 1134 }
1134 1135
1135 static void extract_json_paint_xfermode(Json::Value& jsonPaint, SkPaint* target) { 1136 static void extract_json_paint_xfermode(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
1137 SkPaint* target) {
1136 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) { 1138 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) {
1137 Json::Value jsonXfermode = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE]; 1139 Json::Value jsonXfermode = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE];
1138 SkXfermode* xfermode = (SkXfermode*) load_flattenable(jsonXfermode); 1140 SkXfermode* xfermode = (SkXfermode*) load_flattenable(jsonXfermode, urlD ataManager);
1139 if (xfermode != nullptr) { 1141 if (xfermode != nullptr) {
1140 target->setXfermode(xfermode); 1142 target->setXfermode(xfermode);
1141 xfermode->unref(); 1143 xfermode->unref();
1142 } 1144 }
1143 } 1145 }
1144 } 1146 }
1145 1147
1146 static void extract_json_paint_looper(Json::Value& jsonPaint, SkPaint* target) { 1148 static void extract_json_paint_looper(Json::Value& jsonPaint, UrlDataManager& ur lDataManager,
1149 SkPaint* target) {
1147 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_LOOPER)) { 1150 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_LOOPER)) {
1148 Json::Value jsonLooper = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_LOOPER]; 1151 Json::Value jsonLooper = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_LOOPER];
1149 SkDrawLooper* looper = (SkDrawLooper*) load_flattenable(jsonLooper); 1152 SkDrawLooper* looper = (SkDrawLooper*) load_flattenable(jsonLooper, urlD ataManager);
1150 if (looper != nullptr) { 1153 if (looper != nullptr) {
1151 target->setLooper(looper); 1154 target->setLooper(looper);
1152 looper->unref(); 1155 looper->unref();
1153 } 1156 }
1154 } 1157 }
1155 } 1158 }
1156 1159
1157 static void extract_json_paint_imagefilter(Json::Value& jsonPaint, SkPaint* targ et) { 1160 static void extract_json_paint_imagefilter(Json::Value& jsonPaint, UrlDataManage r& urlDataManager,
1161 SkPaint* target) {
1158 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER)) { 1162 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER)) {
1159 Json::Value jsonImageFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFIL TER]; 1163 Json::Value jsonImageFilter = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_IMAGEFIL TER];
1160 SkImageFilter* imageFilter = (SkImageFilter*) load_flattenable(jsonImage Filter); 1164 SkImageFilter* imageFilter = (SkImageFilter*) load_flattenable(jsonImage Filter,
1165 urlDataMa nager);
1161 if (imageFilter != nullptr) { 1166 if (imageFilter != nullptr) {
1162 target->setImageFilter(imageFilter); 1167 target->setImageFilter(imageFilter);
1163 imageFilter->unref(); 1168 imageFilter->unref();
1164 } 1169 }
1165 } 1170 }
1166 } 1171 }
1167 1172
1173 static void extract_json_paint_typeface(Json::Value& jsonPaint, UrlDataManager& urlDataManager,
1174 SkPaint* target) {
1175 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE)) {
1176 Json::Value jsonTypeface = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE];
1177 Json::Value jsonData = jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_DATA];
1178 const void* data;
1179 Json::ArrayIndex length = decode_data(jsonData, urlDataManager, &data);
1180 SkMemoryStream buffer(data, length);
1181 SkTypeface* typeface = SkTypeface::Deserialize(&buffer);
1182 target->setTypeface(typeface);
1183 }
1184 }
1185
1168 static void extract_json_paint_style(Json::Value& jsonPaint, SkPaint* target) { 1186 static void extract_json_paint_style(Json::Value& jsonPaint, SkPaint* target) {
1169 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STYLE)) { 1187 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STYLE)) {
1170 const char* style = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STYLE].asCString() ; 1188 const char* style = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STYLE].asCString() ;
1171 if (!strcmp(style, SKDEBUGCANVAS_STYLE_FILL)) { 1189 if (!strcmp(style, SKDEBUGCANVAS_STYLE_FILL)) {
1172 target->setStyle(SkPaint::kFill_Style); 1190 target->setStyle(SkPaint::kFill_Style);
1173 } 1191 }
1174 else if (!strcmp(style, SKDEBUGCANVAS_STYLE_STROKE)) { 1192 else if (!strcmp(style, SKDEBUGCANVAS_STYLE_STROKE)) {
1175 target->setStyle(SkPaint::kStroke_Style); 1193 target->setStyle(SkPaint::kStroke_Style);
1176 } 1194 }
1177 else if (!strcmp(style, SKDEBUGCANVAS_STYLE_STROKEANDFILL)) { 1195 else if (!strcmp(style, SKDEBUGCANVAS_STYLE_STROKEANDFILL)) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 } 1363 }
1346 } 1364 }
1347 1365
1348 static void extract_json_paint_textskewx(Json::Value& jsonPaint, SkPaint* target ) { 1366 static void extract_json_paint_textskewx(Json::Value& jsonPaint, SkPaint* target ) {
1349 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX)) { 1367 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX)) {
1350 float textSkewX = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX].asFloat() ; 1368 float textSkewX = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX].asFloat() ;
1351 target->setTextSkewX(textSkewX); 1369 target->setTextSkewX(textSkewX);
1352 } 1370 }
1353 } 1371 }
1354 1372
1355 static void extract_json_paint_typeface(Json::Value& jsonPaint, SkPaint* target) { 1373 static void extract_json_paint(Json::Value& paint, UrlDataManager& urlDataManage r,
1356 if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE)) { 1374 SkPaint* result) {
1357 Json::Value jsonTypeface = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE];
1358 Json::Value bytes = jsonTypeface[SKDEBUGCANVAS_ATTRIBUTE_BYTES];
1359 void* data;
1360 Json::ArrayIndex length = decode_data(bytes, &data);
1361 SkMemoryStream buffer(data, length);
1362 SkTypeface* typeface = SkTypeface::Deserialize(&buffer);
1363 sk_free(data);
1364 target->setTypeface(typeface);
1365 }
1366 }
1367
1368 static void extract_json_paint(Json::Value& paint, SkPaint* result) {
1369 extract_json_paint_color(paint, result); 1375 extract_json_paint_color(paint, result);
1370 extract_json_paint_shader(paint, result); 1376 extract_json_paint_shader(paint, urlDataManager, result);
1371 extract_json_paint_patheffect(paint, result); 1377 extract_json_paint_patheffect(paint, urlDataManager, result);
1372 extract_json_paint_maskfilter(paint, result); 1378 extract_json_paint_maskfilter(paint, urlDataManager, result);
1373 extract_json_paint_colorfilter(paint, result); 1379 extract_json_paint_colorfilter(paint, urlDataManager, result);
1374 extract_json_paint_xfermode(paint, result); 1380 extract_json_paint_xfermode(paint, urlDataManager, result);
1375 extract_json_paint_looper(paint, result); 1381 extract_json_paint_looper(paint, urlDataManager, result);
1376 extract_json_paint_imagefilter(paint, result); 1382 extract_json_paint_imagefilter(paint, urlDataManager, result);
1383 extract_json_paint_typeface(paint, urlDataManager, result);
1377 extract_json_paint_style(paint, result); 1384 extract_json_paint_style(paint, result);
1378 extract_json_paint_strokewidth(paint, result); 1385 extract_json_paint_strokewidth(paint, result);
1379 extract_json_paint_strokemiter(paint, result); 1386 extract_json_paint_strokemiter(paint, result);
1380 extract_json_paint_strokejoin(paint, result); 1387 extract_json_paint_strokejoin(paint, result);
1381 extract_json_paint_cap(paint, result); 1388 extract_json_paint_cap(paint, result);
1382 extract_json_paint_filterquality(paint, result); 1389 extract_json_paint_filterquality(paint, result);
1383 extract_json_paint_antialias(paint, result); 1390 extract_json_paint_antialias(paint, result);
1384 extract_json_paint_dither(paint, result); 1391 extract_json_paint_dither(paint, result);
1385 extract_json_paint_blur(paint, result); 1392 extract_json_paint_blur(paint, result);
1386 extract_json_paint_dashing(paint, result); 1393 extract_json_paint_dashing(paint, result);
1387 extract_json_paint_textalign(paint, result); 1394 extract_json_paint_textalign(paint, result);
1388 extract_json_paint_textsize(paint, result); 1395 extract_json_paint_textsize(paint, result);
1389 extract_json_paint_textscalex(paint, result); 1396 extract_json_paint_textscalex(paint, result);
1390 extract_json_paint_textskewx(paint, result); 1397 extract_json_paint_textskewx(paint, result);
1391 extract_json_paint_typeface(paint, result);
1392 } 1398 }
1393 1399
1394 static void extract_json_rect(Json::Value& rect, SkRect* result) { 1400 static void extract_json_rect(Json::Value& rect, SkRect* result) {
1395 result->set(rect[0].asFloat(), rect[1].asFloat(), rect[2].asFloat(), rect[3] .asFloat()); 1401 result->set(rect[0].asFloat(), rect[1].asFloat(), rect[2].asFloat(), rect[3] .asFloat());
1396 } 1402 }
1397 1403
1398 static void extract_json_irect(Json::Value& rect, SkIRect* result) { 1404 static void extract_json_irect(Json::Value& rect, SkIRect* result) {
1399 result->set(rect[0].asInt(), rect[1].asInt(), rect[2].asInt(), rect[3].asInt ()); 1405 result->set(rect[0].asInt(), rect[1].asInt(), rect[2].asInt(), rect[3].asInt ());
1400 } 1406 }
1401 1407
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 1506
1501 SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) { 1507 SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) {
1502 fColor = color; 1508 fColor = color;
1503 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); 1509 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
1504 } 1510 }
1505 1511
1506 void SkClearCommand::execute(SkCanvas* canvas) const { 1512 void SkClearCommand::execute(SkCanvas* canvas) const {
1507 canvas->clear(fColor); 1513 canvas->clear(fColor);
1508 } 1514 }
1509 1515
1510 Json::Value SkClearCommand::toJSON() const { 1516 Json::Value SkClearCommand::toJSON(UrlDataManager& urlDataManager) const {
1511 Json::Value result = INHERITED::toJSON(); 1517 Json::Value result = INHERITED::toJSON(urlDataManager);
1512 result[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = make_json_color(fColor); 1518 result[SKDEBUGCANVAS_ATTRIBUTE_COLOR] = make_json_color(fColor);
1513 return result; 1519 return result;
1514 } 1520 }
1515 1521
1516 SkClearCommand* SkClearCommand::fromJSON(Json::Value& command) { 1522 SkClearCommand* SkClearCommand::fromJSON(Json::Value& command, UrlDataManager& urlDataManager) {
1517 Json::Value color = command[SKDEBUGCANVAS_ATTRIBUTE_COLOR]; 1523 Json::Value color = command[SKDEBUGCANVAS_ATTRIBUTE_COLOR];
1518 return new SkClearCommand(get_json_color(color)); 1524 return new SkClearCommand(get_json_color(color));
1519 } 1525 }
1520 1526
1521 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d oAA) 1527 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d oAA)
1522 : INHERITED(kClipPath_OpType) { 1528 : INHERITED(kClipPath_OpType) {
1523 fPath = path; 1529 fPath = path;
1524 fOp = op; 1530 fOp = op;
1525 fDoAA = doAA; 1531 fDoAA = doAA;
1526 1532
1527 fInfo.push(SkObjectParser::PathToString(path)); 1533 fInfo.push(SkObjectParser::PathToString(path));
1528 fInfo.push(SkObjectParser::RegionOpToString(op)); 1534 fInfo.push(SkObjectParser::RegionOpToString(op));
1529 fInfo.push(SkObjectParser::BoolToString(doAA)); 1535 fInfo.push(SkObjectParser::BoolToString(doAA));
1530 } 1536 }
1531 1537
1532 void SkClipPathCommand::execute(SkCanvas* canvas) const { 1538 void SkClipPathCommand::execute(SkCanvas* canvas) const {
1533 canvas->clipPath(fPath, fOp, fDoAA); 1539 canvas->clipPath(fPath, fOp, fDoAA);
1534 } 1540 }
1535 1541
1536 bool SkClipPathCommand::render(SkCanvas* canvas) const { 1542 bool SkClipPathCommand::render(SkCanvas* canvas) const {
1537 render_path(canvas, fPath); 1543 render_path(canvas, fPath);
1538 return true; 1544 return true;
1539 } 1545 }
1540 1546
1541 Json::Value SkClipPathCommand::toJSON() const { 1547 Json::Value SkClipPathCommand::toJSON(UrlDataManager& urlDataManager) const {
1542 Json::Value result = INHERITED::toJSON(); 1548 Json::Value result = INHERITED::toJSON(urlDataManager);
1543 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); 1549 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath);
1544 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); 1550 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
1545 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = fDoAA; 1551 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = fDoAA;
1546 return result; 1552 return result;
1547 } 1553 }
1548 1554
1549 SkClipPathCommand* SkClipPathCommand::fromJSON(Json::Value& command) { 1555 SkClipPathCommand* SkClipPathCommand::fromJSON(Json::Value& command,
1556 UrlDataManager& urlDataManager) {
1550 SkPath path; 1557 SkPath path;
1551 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); 1558 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path);
1552 return new SkClipPathCommand(path, get_json_regionop(command[SKDEBUGCANVAS_A TTRIBUTE_REGIONOP]), 1559 return new SkClipPathCommand(path, get_json_regionop(command[SKDEBUGCANVAS_A TTRIBUTE_REGIONOP]),
1553 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo ol()); 1560 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo ol());
1554 } 1561 }
1555 1562
1556 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op ) 1563 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op )
1557 : INHERITED(kClipRegion_OpType) { 1564 : INHERITED(kClipRegion_OpType) {
1558 fRegion = region; 1565 fRegion = region;
1559 fOp = op; 1566 fOp = op;
1560 1567
1561 fInfo.push(SkObjectParser::RegionToString(region)); 1568 fInfo.push(SkObjectParser::RegionToString(region));
1562 fInfo.push(SkObjectParser::RegionOpToString(op)); 1569 fInfo.push(SkObjectParser::RegionOpToString(op));
1563 } 1570 }
1564 1571
1565 void SkClipRegionCommand::execute(SkCanvas* canvas) const { 1572 void SkClipRegionCommand::execute(SkCanvas* canvas) const {
1566 canvas->clipRegion(fRegion, fOp); 1573 canvas->clipRegion(fRegion, fOp);
1567 } 1574 }
1568 1575
1569 Json::Value SkClipRegionCommand::toJSON() const { 1576 Json::Value SkClipRegionCommand::toJSON(UrlDataManager& urlDataManager) const {
1570 Json::Value result = INHERITED::toJSON(); 1577 Json::Value result = INHERITED::toJSON(urlDataManager);
1571 result[SKDEBUGCANVAS_ATTRIBUTE_REGION] = make_json_region(fRegion); 1578 result[SKDEBUGCANVAS_ATTRIBUTE_REGION] = make_json_region(fRegion);
1572 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); 1579 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
1573 return result; 1580 return result;
1574 } 1581 }
1575 1582
1576 SkClipRegionCommand* SkClipRegionCommand::fromJSON(Json::Value& command) { 1583 SkClipRegionCommand* SkClipRegionCommand::fromJSON(Json::Value& command,
1584 UrlDataManager& urlDataManage r) {
1577 SkASSERT(false); 1585 SkASSERT(false);
1578 return nullptr; 1586 return nullptr;
1579 } 1587 }
1580 1588
1581 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d oAA) 1589 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d oAA)
1582 : INHERITED(kClipRect_OpType) { 1590 : INHERITED(kClipRect_OpType) {
1583 fRect = rect; 1591 fRect = rect;
1584 fOp = op; 1592 fOp = op;
1585 fDoAA = doAA; 1593 fDoAA = doAA;
1586 1594
1587 fInfo.push(SkObjectParser::RectToString(rect)); 1595 fInfo.push(SkObjectParser::RectToString(rect));
1588 fInfo.push(SkObjectParser::RegionOpToString(op)); 1596 fInfo.push(SkObjectParser::RegionOpToString(op));
1589 fInfo.push(SkObjectParser::BoolToString(doAA)); 1597 fInfo.push(SkObjectParser::BoolToString(doAA));
1590 } 1598 }
1591 1599
1592 void SkClipRectCommand::execute(SkCanvas* canvas) const { 1600 void SkClipRectCommand::execute(SkCanvas* canvas) const {
1593 canvas->clipRect(fRect, fOp, fDoAA); 1601 canvas->clipRect(fRect, fOp, fDoAA);
1594 } 1602 }
1595 1603
1596 Json::Value SkClipRectCommand::toJSON() const { 1604 Json::Value SkClipRectCommand::toJSON(UrlDataManager& urlDataManager) const {
1597 Json::Value result = INHERITED::toJSON(); 1605 Json::Value result = INHERITED::toJSON(urlDataManager);
1598 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect); 1606 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect);
1599 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); 1607 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
1600 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); 1608 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA);
1601 return result; 1609 return result;
1602 } 1610 }
1603 1611
1604 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command) { 1612 SkClipRectCommand* SkClipRectCommand::fromJSON(Json::Value& command,
1613 UrlDataManager& urlDataManager) {
1605 SkRect rect; 1614 SkRect rect;
1606 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect); 1615 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rect);
1607 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A TTRIBUTE_REGIONOP]), 1616 return new SkClipRectCommand(rect, get_json_regionop(command[SKDEBUGCANVAS_A TTRIBUTE_REGIONOP]),
1608 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo ol()); 1617 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBo ol());
1609 } 1618 }
1610 1619
1611 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo ol doAA) 1620 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo ol doAA)
1612 : INHERITED(kClipRRect_OpType) { 1621 : INHERITED(kClipRRect_OpType) {
1613 fRRect = rrect; 1622 fRRect = rrect;
1614 fOp = op; 1623 fOp = op;
1615 fDoAA = doAA; 1624 fDoAA = doAA;
1616 1625
1617 fInfo.push(SkObjectParser::RRectToString(rrect)); 1626 fInfo.push(SkObjectParser::RRectToString(rrect));
1618 fInfo.push(SkObjectParser::RegionOpToString(op)); 1627 fInfo.push(SkObjectParser::RegionOpToString(op));
1619 fInfo.push(SkObjectParser::BoolToString(doAA)); 1628 fInfo.push(SkObjectParser::BoolToString(doAA));
1620 } 1629 }
1621 1630
1622 void SkClipRRectCommand::execute(SkCanvas* canvas) const { 1631 void SkClipRRectCommand::execute(SkCanvas* canvas) const {
1623 canvas->clipRRect(fRRect, fOp, fDoAA); 1632 canvas->clipRRect(fRRect, fOp, fDoAA);
1624 } 1633 }
1625 1634
1626 bool SkClipRRectCommand::render(SkCanvas* canvas) const { 1635 bool SkClipRRectCommand::render(SkCanvas* canvas) const {
1627 render_rrect(canvas, fRRect); 1636 render_rrect(canvas, fRRect);
1628 return true; 1637 return true;
1629 } 1638 }
1630 1639
1631 Json::Value SkClipRRectCommand::toJSON() const { 1640 Json::Value SkClipRRectCommand::toJSON(UrlDataManager& urlDataManager) const {
1632 Json::Value result = INHERITED::toJSON(); 1641 Json::Value result = INHERITED::toJSON(urlDataManager);
1633 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect); 1642 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect);
1634 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp); 1643 result[SKDEBUGCANVAS_ATTRIBUTE_REGIONOP] = make_json_regionop(fOp);
1635 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA); 1644 result[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS] = Json::Value(fDoAA);
1636 return result; 1645 return result;
1637 } 1646 }
1638 1647
1639 SkClipRRectCommand* SkClipRRectCommand::fromJSON(Json::Value& command) { 1648 SkClipRRectCommand* SkClipRRectCommand::fromJSON(Json::Value& command,
1649 UrlDataManager& urlDataManager) {
1640 SkRRect rrect; 1650 SkRRect rrect;
1641 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rrect); 1651 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &rrect);
1642 return new SkClipRRectCommand(rrect, 1652 return new SkClipRRectCommand(rrect,
1643 get_json_regionop(command[SKDEBUGCANVAS_ATTRIB UTE_REGIONOP]), 1653 get_json_regionop(command[SKDEBUGCANVAS_ATTRIB UTE_REGIONOP]),
1644 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asB ool()); 1654 command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asB ool());
1645 } 1655 }
1646 1656
1647 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) 1657 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix)
1648 : INHERITED(kConcat_OpType) { 1658 : INHERITED(kConcat_OpType) {
1649 fMatrix = matrix; 1659 fMatrix = matrix;
1650 1660
1651 fInfo.push(SkObjectParser::MatrixToString(matrix)); 1661 fInfo.push(SkObjectParser::MatrixToString(matrix));
1652 } 1662 }
1653 1663
1654 void SkConcatCommand::execute(SkCanvas* canvas) const { 1664 void SkConcatCommand::execute(SkCanvas* canvas) const {
1655 canvas->concat(fMatrix); 1665 canvas->concat(fMatrix);
1656 } 1666 }
1657 1667
1658 Json::Value SkConcatCommand::toJSON() const { 1668 Json::Value SkConcatCommand::toJSON(UrlDataManager& urlDataManager) const {
1659 Json::Value result = INHERITED::toJSON(); 1669 Json::Value result = INHERITED::toJSON(urlDataManager);
1660 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); 1670 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix);
1661 return result; 1671 return result;
1662 } 1672 }
1663 1673
1664 SkConcatCommand* SkConcatCommand::fromJSON(Json::Value& command) { 1674 SkConcatCommand* SkConcatCommand::fromJSON(Json::Value& command, UrlDataManager& urlDataManager) {
1665 SkMatrix matrix; 1675 SkMatrix matrix;
1666 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 1676 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
1667 return new SkConcatCommand(matrix); 1677 return new SkConcatCommand(matrix);
1668 } 1678 }
1669 1679
1670 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, 1680 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
1671 const SkPaint* paint) 1681 const SkPaint* paint)
1672 : INHERITED(kDrawBitmap_OpType) { 1682 : INHERITED(kDrawBitmap_OpType) {
1673 fBitmap = bitmap; 1683 fBitmap = bitmap;
1674 fLeft = left; 1684 fLeft = left;
(...skipping 15 matching lines...) Expand all
1690 1700
1691 void SkDrawBitmapCommand::execute(SkCanvas* canvas) const { 1701 void SkDrawBitmapCommand::execute(SkCanvas* canvas) const {
1692 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); 1702 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr);
1693 } 1703 }
1694 1704
1695 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { 1705 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const {
1696 render_bitmap(canvas, fBitmap); 1706 render_bitmap(canvas, fBitmap);
1697 return true; 1707 return true;
1698 } 1708 }
1699 1709
1700 Json::Value SkDrawBitmapCommand::toJSON() const { 1710 Json::Value SkDrawBitmapCommand::toJSON(UrlDataManager& urlDataManager) const {
1701 Json::Value result = INHERITED::toJSON(); 1711 Json::Value result = INHERITED::toJSON(urlDataManager);
1702 Json::Value encoded; 1712 Json::Value encoded;
1703 if (flatten(fBitmap, &encoded, SKDEBUGCANVAS_SEND_BINARIES)) { 1713 if (flatten(fBitmap, &encoded, urlDataManager)) {
1704 Json::Value command(Json::objectValue); 1714 Json::Value command(Json::objectValue);
1705 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; 1715 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded;
1706 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); 1716 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop);
1707 if (fPaintPtr != nullptr) { 1717 if (fPaintPtr != nullptr) {
1708 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, 1718 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, urlDataManager);
1709 SKDEBUGCANVA S_SEND_BINARIES);
1710 } 1719 }
1711 } 1720 }
1712 return result; 1721 return result;
1713 } 1722 }
1714 1723
1715 SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command) { 1724 SkDrawBitmapCommand* SkDrawBitmapCommand::fromJSON(Json::Value& command,
1716 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP]); 1725 UrlDataManager& urlDataManage r) {
1726 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD ataManager);
1717 if (bitmap == nullptr) { 1727 if (bitmap == nullptr) {
1718 return nullptr; 1728 return nullptr;
1719 } 1729 }
1720 Json::Value point = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; 1730 Json::Value point = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS];
1721 SkPaint* paintPtr; 1731 SkPaint* paintPtr;
1722 SkPaint paint; 1732 SkPaint paint;
1723 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { 1733 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) {
1724 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 1734 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage r, &paint);
1725 paintPtr = &paint; 1735 paintPtr = &paint;
1726 } 1736 }
1727 else { 1737 else {
1728 paintPtr = nullptr; 1738 paintPtr = nullptr;
1729 } 1739 }
1730 SkDrawBitmapCommand* result = new SkDrawBitmapCommand(*bitmap, point[0].asFl oat(), 1740 SkDrawBitmapCommand* result = new SkDrawBitmapCommand(*bitmap, point[0].asFl oat(),
1731 point[1].asFloat(), pa intPtr); 1741 point[1].asFloat(), pa intPtr);
1732 delete bitmap; 1742 delete bitmap;
1733 return result; 1743 return result;
1734 } 1744 }
(...skipping 22 matching lines...) Expand all
1757 void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) const { 1767 void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) const {
1758 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); 1768 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr);
1759 } 1769 }
1760 1770
1761 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { 1771 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const {
1762 SkRect tmp = SkRect::Make(fCenter); 1772 SkRect tmp = SkRect::Make(fCenter);
1763 render_bitmap(canvas, fBitmap, &tmp); 1773 render_bitmap(canvas, fBitmap, &tmp);
1764 return true; 1774 return true;
1765 } 1775 }
1766 1776
1767 Json::Value SkDrawBitmapNineCommand::toJSON() const { 1777 Json::Value SkDrawBitmapNineCommand::toJSON(UrlDataManager& urlDataManager) cons t {
1768 Json::Value result = INHERITED::toJSON(); 1778 Json::Value result = INHERITED::toJSON(urlDataManager);
1769 Json::Value encoded; 1779 Json::Value encoded;
1770 if (flatten(fBitmap, &encoded, SKDEBUGCANVAS_SEND_BINARIES)) { 1780 if (flatten(fBitmap, &encoded, urlDataManager)) {
1771 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; 1781 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded;
1772 result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = make_json_irect(fCenter); 1782 result[SKDEBUGCANVAS_ATTRIBUTE_CENTER] = make_json_irect(fCenter);
1773 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); 1783 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst);
1774 if (fPaintPtr != nullptr) { 1784 if (fPaintPtr != nullptr) {
1775 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, 1785 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, urlDataManager);
1776 SKDEBUGCANVA S_SEND_BINARIES);
1777 } 1786 }
1778 } 1787 }
1779 return result; 1788 return result;
1780 } 1789 }
1781 1790
1782 SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command) { 1791 SkDrawBitmapNineCommand* SkDrawBitmapNineCommand::fromJSON(Json::Value& command,
1783 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP]); 1792 UrlDataManager& urlDa taManager) {
1793 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD ataManager);
1784 if (bitmap == nullptr) { 1794 if (bitmap == nullptr) {
1785 return nullptr; 1795 return nullptr;
1786 } 1796 }
1787 SkIRect center; 1797 SkIRect center;
1788 extract_json_irect(command[SKDEBUGCANVAS_ATTRIBUTE_CENTER], &center); 1798 extract_json_irect(command[SKDEBUGCANVAS_ATTRIBUTE_CENTER], &center);
1789 SkRect dst; 1799 SkRect dst;
1790 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst); 1800 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst);
1791 SkPaint* paintPtr; 1801 SkPaint* paintPtr;
1792 SkPaint paint; 1802 SkPaint paint;
1793 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { 1803 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) {
1794 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 1804 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage r, &paint);
1795 paintPtr = &paint; 1805 paintPtr = &paint;
1796 } 1806 }
1797 else { 1807 else {
1798 paintPtr = nullptr; 1808 paintPtr = nullptr;
1799 } 1809 }
1800 SkDrawBitmapNineCommand* result = new SkDrawBitmapNineCommand(*bitmap, cente r, dst, paintPtr); 1810 SkDrawBitmapNineCommand* result = new SkDrawBitmapNineCommand(*bitmap, cente r, dst, paintPtr);
1801 delete bitmap; 1811 delete bitmap;
1802 return result; 1812 return result;
1803 } 1813 }
1804 1814
(...skipping 30 matching lines...) Expand all
1835 1845
1836 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { 1846 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const {
1837 canvas->legacy_drawBitmapRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fCo nstraint); 1847 canvas->legacy_drawBitmapRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fCo nstraint);
1838 } 1848 }
1839 1849
1840 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { 1850 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
1841 render_bitmap(canvas, fBitmap, this->srcRect()); 1851 render_bitmap(canvas, fBitmap, this->srcRect());
1842 return true; 1852 return true;
1843 } 1853 }
1844 1854
1845 Json::Value SkDrawBitmapRectCommand::toJSON() const { 1855 Json::Value SkDrawBitmapRectCommand::toJSON(UrlDataManager& urlDataManager) cons t {
1846 Json::Value result = INHERITED::toJSON(); 1856 Json::Value result = INHERITED::toJSON(urlDataManager);
1847 Json::Value encoded; 1857 Json::Value encoded;
1848 if (flatten(fBitmap, &encoded, SKDEBUGCANVAS_SEND_BINARIES)) { 1858 if (flatten(fBitmap, &encoded, urlDataManager)) {
1849 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; 1859 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded;
1850 if (!fSrc.isEmpty()) { 1860 if (!fSrc.isEmpty()) {
1851 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = make_json_rect(fSrc); 1861 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = make_json_rect(fSrc);
1852 } 1862 }
1853 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); 1863 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst);
1854 if (fPaintPtr != nullptr) { 1864 if (fPaintPtr != nullptr) {
1855 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, 1865 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, urlDataManager);
1856 SKDEBUGCANVA S_SEND_BINARIES);
1857 } 1866 }
1858 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { 1867 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
1859 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); 1868 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true);
1860 } 1869 }
1861 } 1870 }
1862 return result; 1871 return result;
1863 } 1872 }
1864 1873
1865 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command) { 1874 SkDrawBitmapRectCommand* SkDrawBitmapRectCommand::fromJSON(Json::Value& command,
1866 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP]); 1875 UrlDataManager& urlDa taManager) {
1876 SkBitmap* bitmap = load_bitmap(command[SKDEBUGCANVAS_ATTRIBUTE_BITMAP], urlD ataManager);
1867 if (bitmap == nullptr) { 1877 if (bitmap == nullptr) {
1868 return nullptr; 1878 return nullptr;
1869 } 1879 }
1870 SkRect dst; 1880 SkRect dst;
1871 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst); 1881 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst);
1872 SkPaint* paintPtr; 1882 SkPaint* paintPtr;
1873 SkPaint paint; 1883 SkPaint paint;
1874 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { 1884 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) {
1875 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 1885 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage r, &paint);
1876 paintPtr = &paint; 1886 paintPtr = &paint;
1877 } 1887 }
1878 else { 1888 else {
1879 paintPtr = nullptr; 1889 paintPtr = nullptr;
1880 } 1890 }
1881 SkCanvas::SrcRectConstraint constraint; 1891 SkCanvas::SrcRectConstraint constraint;
1882 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) && 1892 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) &&
1883 command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) { 1893 command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) {
1884 constraint = SkCanvas::kStrict_SrcRectConstraint; 1894 constraint = SkCanvas::kStrict_SrcRectConstraint;
1885 } 1895 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 SkAutoCanvasRestore acr(canvas, true); 1936 SkAutoCanvasRestore acr(canvas, true);
1927 canvas->clear(0xFFFFFFFF); 1937 canvas->clear(0xFFFFFFFF);
1928 1938
1929 xlate_and_scale_to_bounds(canvas, SkRect::MakeXYWH(fLeft, fTop, 1939 xlate_and_scale_to_bounds(canvas, SkRect::MakeXYWH(fLeft, fTop,
1930 SkIntToScalar(fImage->wid th()), 1940 SkIntToScalar(fImage->wid th()),
1931 SkIntToScalar(fImage->hei ght()))); 1941 SkIntToScalar(fImage->hei ght())));
1932 this->execute(canvas); 1942 this->execute(canvas);
1933 return true; 1943 return true;
1934 } 1944 }
1935 1945
1936 Json::Value SkDrawImageCommand::toJSON() const { 1946 Json::Value SkDrawImageCommand::toJSON(UrlDataManager& urlDataManager) const {
1937 Json::Value result = INHERITED::toJSON(); 1947 Json::Value result = INHERITED::toJSON(urlDataManager);
1938 Json::Value encoded; 1948 Json::Value encoded;
1939 if (flatten(*fImage, &encoded, SKDEBUGCANVAS_SEND_BINARIES)) { 1949 if (flatten(*fImage, &encoded, urlDataManager)) {
1940 result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded; 1950 result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded;
1941 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop); 1951 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fLeft, fTop);
1942 if (fPaint.isValid()) { 1952 if (fPaint.isValid()) {
1943 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get( ), 1953 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get( ), urlDataManager);
1944 SKDEBUGCANVA S_SEND_BINARIES);
1945 } 1954 }
1946 } 1955 }
1947 return result; 1956 return result;
1948 } 1957 }
1949 1958
1950 SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command) { 1959 SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command,
1951 SkImage* image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE]); 1960 UrlDataManager& urlDataManager) {
1961 SkImage* image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], urlDataM anager);
1952 if (image == nullptr) { 1962 if (image == nullptr) {
1953 return nullptr; 1963 return nullptr;
1954 } 1964 }
1955 Json::Value point = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; 1965 Json::Value point = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS];
1956 SkPaint* paintPtr; 1966 SkPaint* paintPtr;
1957 SkPaint paint; 1967 SkPaint paint;
1958 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { 1968 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) {
1959 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 1969 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage r, &paint);
1960 paintPtr = &paint; 1970 paintPtr = &paint;
1961 } 1971 }
1962 else { 1972 else {
1963 paintPtr = nullptr; 1973 paintPtr = nullptr;
1964 } 1974 }
1965 SkDrawImageCommand* result = new SkDrawImageCommand(image, point[0].asFloat( ), 1975 SkDrawImageCommand* result = new SkDrawImageCommand(image, point[0].asFloat( ),
1966 point[1].asFloat(), pain tPtr); 1976 point[1].asFloat(), pain tPtr);
1967 image->unref(); 1977 image->unref();
1968 return result; 1978 return result;
1969 } 1979 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 bool SkDrawImageRectCommand::render(SkCanvas* canvas) const { 2013 bool SkDrawImageRectCommand::render(SkCanvas* canvas) const {
2004 SkAutoCanvasRestore acr(canvas, true); 2014 SkAutoCanvasRestore acr(canvas, true);
2005 canvas->clear(0xFFFFFFFF); 2015 canvas->clear(0xFFFFFFFF);
2006 2016
2007 xlate_and_scale_to_bounds(canvas, fDst); 2017 xlate_and_scale_to_bounds(canvas, fDst);
2008 2018
2009 this->execute(canvas); 2019 this->execute(canvas);
2010 return true; 2020 return true;
2011 } 2021 }
2012 2022
2013 Json::Value SkDrawImageRectCommand::toJSON() const { 2023 Json::Value SkDrawImageRectCommand::toJSON(UrlDataManager& urlDataManager) const {
2014 Json::Value result = INHERITED::toJSON(); 2024 Json::Value result = INHERITED::toJSON(urlDataManager);
2015 Json::Value encoded; 2025 Json::Value encoded;
2016 if (flatten(*fImage.get(), &encoded, SKDEBUGCANVAS_SEND_BINARIES)) { 2026 if (flatten(*fImage.get(), &encoded, urlDataManager)) {
2017 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded; 2027 result[SKDEBUGCANVAS_ATTRIBUTE_BITMAP] = encoded;
2018 if (fSrc.isValid()) { 2028 if (fSrc.isValid()) {
2019 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = make_json_rect(*fSrc.get()); 2029 result[SKDEBUGCANVAS_ATTRIBUTE_SRC] = make_json_rect(*fSrc.get());
2020 } 2030 }
2021 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst); 2031 result[SKDEBUGCANVAS_ATTRIBUTE_DST] = make_json_rect(fDst);
2022 if (fPaint.isValid()) { 2032 if (fPaint.isValid()) {
2023 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get( ), 2033 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaint.get( ), urlDataManager);
2024 SKDEBUGCANVA S_SEND_BINARIES);
2025 } 2034 }
2026 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) { 2035 if (fConstraint == SkCanvas::kStrict_SrcRectConstraint) {
2027 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true); 2036 result[SKDEBUGCANVAS_ATTRIBUTE_STRICT] = Json::Value(true);
2028 } 2037 }
2029 } 2038 }
2030 return result; 2039 return result;
2031 } 2040 }
2032 2041
2033 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command) { 2042 SkDrawImageRectCommand* SkDrawImageRectCommand::fromJSON(Json::Value& command,
2034 SkImage* image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE]); 2043 UrlDataManager& urlData Manager) {
2044 SkImage* image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], urlDataM anager);
2035 if (image == nullptr) { 2045 if (image == nullptr) {
2036 return nullptr; 2046 return nullptr;
2037 } 2047 }
2038 SkRect dst; 2048 SkRect dst;
2039 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst); 2049 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_DST], &dst);
2040 SkPaint* paintPtr; 2050 SkPaint* paintPtr;
2041 SkPaint paint; 2051 SkPaint paint;
2042 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { 2052 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) {
2043 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2053 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage r, &paint);
2044 paintPtr = &paint; 2054 paintPtr = &paint;
2045 } 2055 }
2046 else { 2056 else {
2047 paintPtr = nullptr; 2057 paintPtr = nullptr;
2048 } 2058 }
2049 SkCanvas::SrcRectConstraint constraint; 2059 SkCanvas::SrcRectConstraint constraint;
2050 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) && 2060 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_STRICT) &&
2051 command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) { 2061 command[SKDEBUGCANVAS_ATTRIBUTE_STRICT].asBool()) {
2052 constraint = SkCanvas::kStrict_SrcRectConstraint; 2062 constraint = SkCanvas::kStrict_SrcRectConstraint;
2053 } 2063 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 SkPaint p; 2101 SkPaint p;
2092 p.setColor(SK_ColorBLACK); 2102 p.setColor(SK_ColorBLACK);
2093 p.setStyle(SkPaint::kStroke_Style); 2103 p.setStyle(SkPaint::kStroke_Style);
2094 2104
2095 canvas->drawOval(fOval, p); 2105 canvas->drawOval(fOval, p);
2096 canvas->restore(); 2106 canvas->restore();
2097 2107
2098 return true; 2108 return true;
2099 } 2109 }
2100 2110
2101 Json::Value SkDrawOvalCommand::toJSON() const { 2111 Json::Value SkDrawOvalCommand::toJSON(UrlDataManager& urlDataManager) const {
2102 Json::Value result = INHERITED::toJSON(); 2112 Json::Value result = INHERITED::toJSON(urlDataManager);
2103 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fOval); 2113 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fOval);
2104 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2114 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2105 return result; 2115 return result;
2106 } 2116 }
2107 2117
2108 SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command) { 2118 SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command,
2119 UrlDataManager& urlDataManager) {
2109 SkRect coords; 2120 SkRect coords;
2110 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); 2121 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords);
2111 SkPaint paint; 2122 SkPaint paint;
2112 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2123 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2113 return new SkDrawOvalCommand(coords, paint); 2124 return new SkDrawOvalCommand(coords, paint);
2114 } 2125 }
2115 2126
2116 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) 2127 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint)
2117 : INHERITED(kDrawPaint_OpType) { 2128 : INHERITED(kDrawPaint_OpType) {
2118 fPaint = paint; 2129 fPaint = paint;
2119 2130
2120 fInfo.push(SkObjectParser::PaintToString(paint)); 2131 fInfo.push(SkObjectParser::PaintToString(paint));
2121 } 2132 }
2122 2133
2123 void SkDrawPaintCommand::execute(SkCanvas* canvas) const { 2134 void SkDrawPaintCommand::execute(SkCanvas* canvas) const {
2124 canvas->drawPaint(fPaint); 2135 canvas->drawPaint(fPaint);
2125 } 2136 }
2126 2137
2127 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { 2138 bool SkDrawPaintCommand::render(SkCanvas* canvas) const {
2128 canvas->clear(0xFFFFFFFF); 2139 canvas->clear(0xFFFFFFFF);
2129 canvas->drawPaint(fPaint); 2140 canvas->drawPaint(fPaint);
2130 return true; 2141 return true;
2131 } 2142 }
2132 2143
2133 Json::Value SkDrawPaintCommand::toJSON() const { 2144 Json::Value SkDrawPaintCommand::toJSON(UrlDataManager& urlDataManager) const {
2134 Json::Value result = INHERITED::toJSON(); 2145 Json::Value result = INHERITED::toJSON(urlDataManager);
2135 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2146 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2136 return result; 2147 return result;
2137 } 2148 }
2138 2149
2139 SkDrawPaintCommand* SkDrawPaintCommand::fromJSON(Json::Value& command) { 2150 SkDrawPaintCommand* SkDrawPaintCommand::fromJSON(Json::Value& command,
2151 UrlDataManager& urlDataManager) {
2140 SkPaint paint; 2152 SkPaint paint;
2141 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2153 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2142 return new SkDrawPaintCommand(paint); 2154 return new SkDrawPaintCommand(paint);
2143 } 2155 }
2144 2156
2145 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) 2157 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint)
2146 : INHERITED(kDrawPath_OpType) { 2158 : INHERITED(kDrawPath_OpType) {
2147 fPath = path; 2159 fPath = path;
2148 fPaint = paint; 2160 fPaint = paint;
2149 2161
2150 fInfo.push(SkObjectParser::PathToString(path)); 2162 fInfo.push(SkObjectParser::PathToString(path));
2151 fInfo.push(SkObjectParser::PaintToString(paint)); 2163 fInfo.push(SkObjectParser::PaintToString(paint));
2152 } 2164 }
2153 2165
2154 void SkDrawPathCommand::execute(SkCanvas* canvas) const { 2166 void SkDrawPathCommand::execute(SkCanvas* canvas) const {
2155 canvas->drawPath(fPath, fPaint); 2167 canvas->drawPath(fPath, fPaint);
2156 } 2168 }
2157 2169
2158 bool SkDrawPathCommand::render(SkCanvas* canvas) const { 2170 bool SkDrawPathCommand::render(SkCanvas* canvas) const {
2159 render_path(canvas, fPath); 2171 render_path(canvas, fPath);
2160 return true; 2172 return true;
2161 } 2173 }
2162 2174
2163 Json::Value SkDrawPathCommand::toJSON() const { 2175 Json::Value SkDrawPathCommand::toJSON(UrlDataManager& urlDataManager) const {
2164 Json::Value result = INHERITED::toJSON(); 2176 Json::Value result = INHERITED::toJSON(urlDataManager);
2165 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); 2177 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath);
2166 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2178 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2167 return result; 2179 return result;
2168 } 2180 }
2169 2181
2170 SkDrawPathCommand* SkDrawPathCommand::fromJSON(Json::Value& command) { 2182 SkDrawPathCommand* SkDrawPathCommand::fromJSON(Json::Value& command,
2183 UrlDataManager& urlDataManager) {
2171 SkPath path; 2184 SkPath path;
2172 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); 2185 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path);
2173 SkPaint paint; 2186 SkPaint paint;
2174 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2187 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2175 return new SkDrawPathCommand(path, paint); 2188 return new SkDrawPathCommand(path, paint);
2176 } 2189 }
2177 2190
2178 SkBeginDrawPictureCommand::SkBeginDrawPictureCommand(const SkPicture* picture, 2191 SkBeginDrawPictureCommand::SkBeginDrawPictureCommand(const SkPicture* picture,
2179 const SkMatrix* matrix, 2192 const SkMatrix* matrix,
2180 const SkPaint* paint) 2193 const SkPaint* paint)
2181 : INHERITED(kBeginDrawPicture_OpType) 2194 : INHERITED(kBeginDrawPicture_OpType)
2182 , fPicture(SkRef(picture)) { 2195 , fPicture(SkRef(picture)) {
2183 2196
2184 SkString* str = new SkString; 2197 SkString* str = new SkString;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2274 SkPaint p; 2287 SkPaint p;
2275 p.setColor(SK_ColorBLACK); 2288 p.setColor(SK_ColorBLACK);
2276 p.setStyle(SkPaint::kStroke_Style); 2289 p.setStyle(SkPaint::kStroke_Style);
2277 2290
2278 canvas->drawPoints(fMode, fCount, fPts, p); 2291 canvas->drawPoints(fMode, fCount, fPts, p);
2279 canvas->restore(); 2292 canvas->restore();
2280 2293
2281 return true; 2294 return true;
2282 } 2295 }
2283 2296
2284 Json::Value SkDrawPointsCommand::toJSON() const { 2297 Json::Value SkDrawPointsCommand::toJSON(UrlDataManager& urlDataManager) const {
2285 Json::Value result = INHERITED::toJSON(); 2298 Json::Value result = INHERITED::toJSON(urlDataManager);
2286 result[SKDEBUGCANVAS_ATTRIBUTE_MODE] = make_json_pointmode(fMode); 2299 result[SKDEBUGCANVAS_ATTRIBUTE_MODE] = make_json_pointmode(fMode);
2287 Json::Value points(Json::arrayValue); 2300 Json::Value points(Json::arrayValue);
2288 for (size_t i = 0; i < fCount; i++) { 2301 for (size_t i = 0; i < fCount; i++) {
2289 points.append(make_json_point(fPts[i])); 2302 points.append(make_json_point(fPts[i]));
2290 } 2303 }
2291 result[SKDEBUGCANVAS_ATTRIBUTE_POINTS] = points; 2304 result[SKDEBUGCANVAS_ATTRIBUTE_POINTS] = points;
2292 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2305 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2293 return result; 2306 return result;
2294 } 2307 }
2295 2308
2296 SkDrawPointsCommand* SkDrawPointsCommand::fromJSON(Json::Value& command) { 2309 SkDrawPointsCommand* SkDrawPointsCommand::fromJSON(Json::Value& command,
2310 UrlDataManager& urlDataManage r) {
2297 SkCanvas::PointMode mode; 2311 SkCanvas::PointMode mode;
2298 const char* jsonMode = command[SKDEBUGCANVAS_ATTRIBUTE_MODE].asCString(); 2312 const char* jsonMode = command[SKDEBUGCANVAS_ATTRIBUTE_MODE].asCString();
2299 if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POINTS)) { 2313 if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POINTS)) {
2300 mode = SkCanvas::kPoints_PointMode; 2314 mode = SkCanvas::kPoints_PointMode;
2301 } 2315 }
2302 else if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_LINES)) { 2316 else if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_LINES)) {
2303 mode = SkCanvas::kLines_PointMode; 2317 mode = SkCanvas::kLines_PointMode;
2304 } 2318 }
2305 else if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POLYGON)) { 2319 else if (!strcmp(jsonMode, SKDEBUGCANVAS_POINTMODE_POLYGON)) {
2306 mode = SkCanvas::kPolygon_PointMode; 2320 mode = SkCanvas::kPolygon_PointMode;
2307 } 2321 }
2308 else { 2322 else {
2309 SkASSERT(false); 2323 SkASSERT(false);
2310 return nullptr; 2324 return nullptr;
2311 } 2325 }
2312 Json::Value jsonPoints = command[SKDEBUGCANVAS_ATTRIBUTE_POINTS]; 2326 Json::Value jsonPoints = command[SKDEBUGCANVAS_ATTRIBUTE_POINTS];
2313 int count = (int) jsonPoints.size(); 2327 int count = (int) jsonPoints.size();
2314 SkPoint* points = (SkPoint*) sk_malloc_throw(count * sizeof(SkPoint)); 2328 SkPoint* points = (SkPoint*) sk_malloc_throw(count * sizeof(SkPoint));
2315 for (int i = 0; i < count; i++) { 2329 for (int i = 0; i < count; i++) {
2316 points[i] = SkPoint::Make(jsonPoints[i][0].asFloat(), jsonPoints[i][1].a sFloat()); 2330 points[i] = SkPoint::Make(jsonPoints[i][0].asFloat(), jsonPoints[i][1].a sFloat());
2317 } 2331 }
2318 SkPaint paint; 2332 SkPaint paint;
2319 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2333 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2320 SkDrawPointsCommand* result = new SkDrawPointsCommand(mode, count, points, p aint); 2334 SkDrawPointsCommand* result = new SkDrawPointsCommand(mode, count, points, p aint);
2321 sk_free(points); 2335 sk_free(points);
2322 return result; 2336 return result;
2323 } 2337 }
2324 2338
2325 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, 2339 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength,
2326 const SkPoint pos[], const SkPaint& p aint) 2340 const SkPoint pos[], const SkPaint& p aint)
2327 : INHERITED(kDrawPosText_OpType) { 2341 : INHERITED(kDrawPosText_OpType) {
2328 size_t numPts = paint.countText(text, byteLength); 2342 size_t numPts = paint.countText(text, byteLength);
2329 2343
2330 fText = new char[byteLength]; 2344 fText = new char[byteLength];
2331 memcpy(fText, text, byteLength); 2345 memcpy(fText, text, byteLength);
2332 fByteLength = byteLength; 2346 fByteLength = byteLength;
2333 2347
2334 fPos = new SkPoint[numPts]; 2348 fPos = new SkPoint[numPts];
2335 memcpy(fPos, pos, numPts * sizeof(SkPoint)); 2349 memcpy(fPos, pos, numPts * sizeof(SkPoint));
2336 2350
2337 fPaint = paint; 2351 fPaint = paint;
2338 2352
2339 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod ing())); 2353 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod ing()));
2340 // TODO(chudy): Test that this works. 2354 // TODO(chudy): Test that this works.
2341 fInfo.push(SkObjectParser::PointsToString(pos, 1)); 2355 fInfo.push(SkObjectParser::PointsToString(pos, 1));
2342 fInfo.push(SkObjectParser::PaintToString(paint)); 2356 fInfo.push(SkObjectParser::PaintToString(paint));
2343 } 2357 }
2344 2358
2345 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { 2359 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const {
2346 canvas->drawPosText(fText, fByteLength, fPos, fPaint); 2360 canvas->drawPosText(fText, fByteLength, fPos, fPaint);
2347 } 2361 }
2348 2362
2349 Json::Value SkDrawPosTextCommand::toJSON() const { 2363 Json::Value SkDrawPosTextCommand::toJSON(UrlDataManager& urlDataManager) const {
2350 Json::Value result = INHERITED::toJSON(); 2364 Json::Value result = INHERITED::toJSON(urlDataManager);
2351 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, 2365 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
2352 ((const char*) fText) + f ByteLength); 2366 ((const char*) fText) + f ByteLength);
2353 Json::Value coords(Json::arrayValue); 2367 Json::Value coords(Json::arrayValue);
2354 for (size_t i = 0; i < fByteLength; i++) { 2368 for (size_t i = 0; i < fByteLength; i++) {
2355 coords.append(make_json_point(fPos[i])); 2369 coords.append(make_json_point(fPos[i]));
2356 } 2370 }
2357 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords; 2371 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = coords;
2358 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2372 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2359 return result; 2373 return result;
2360 } 2374 }
2361 2375
2362 SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command) { 2376 SkDrawPosTextCommand* SkDrawPosTextCommand::fromJSON(Json::Value& command,
2377 UrlDataManager& urlDataMana ger) {
2363 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); 2378 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString();
2364 SkPaint paint; 2379 SkPaint paint;
2365 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2380 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2366 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; 2381 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS];
2367 int count = (int) coords.size(); 2382 int count = (int) coords.size();
2368 SkPoint* points = (SkPoint*) sk_malloc_throw(count * sizeof(SkPoint)); 2383 SkPoint* points = (SkPoint*) sk_malloc_throw(count * sizeof(SkPoint));
2369 for (int i = 0; i < count; i++) { 2384 for (int i = 0; i < count; i++) {
2370 points[i] = SkPoint::Make(coords[i][0].asFloat(), coords[i][1].asFloat() ); 2385 points[i] = SkPoint::Make(coords[i][0].asFloat(), coords[i][1].asFloat() );
2371 } 2386 }
2372 return new SkDrawPosTextCommand(text, strlen(text), points, paint); 2387 return new SkDrawPosTextCommand(text, strlen(text), points, paint);
2373 } 2388 }
2374 2389
2375 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength , 2390 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength ,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos); 2469 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos);
2455 xlate_and_scale_to_bounds(canvas, bounds); 2470 xlate_and_scale_to_bounds(canvas, bounds);
2456 2471
2457 canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint); 2472 canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint);
2458 2473
2459 canvas->restore(); 2474 canvas->restore();
2460 2475
2461 return true; 2476 return true;
2462 } 2477 }
2463 2478
2464 Json::Value SkDrawTextBlobCommand::toJSON() const { 2479 Json::Value SkDrawTextBlobCommand::toJSON(UrlDataManager& urlDataManager) const {
2465 Json::Value result = INHERITED::toJSON(); 2480 Json::Value result = INHERITED::toJSON(urlDataManager);
2466 Json::Value runs(Json::arrayValue); 2481 Json::Value runs(Json::arrayValue);
2467 SkTextBlobRunIterator iter(fBlob.get()); 2482 SkTextBlobRunIterator iter(fBlob.get());
2468 while (!iter.done()) { 2483 while (!iter.done()) {
2469 Json::Value run(Json::objectValue); 2484 Json::Value run(Json::objectValue);
2470 Json::Value jsonPositions(Json::arrayValue); 2485 Json::Value jsonPositions(Json::arrayValue);
2471 Json::Value jsonGlyphs(Json::arrayValue); 2486 Json::Value jsonGlyphs(Json::arrayValue);
2472 const SkScalar* iterPositions = iter.pos(); 2487 const SkScalar* iterPositions = iter.pos();
2473 const uint16_t* iterGlyphs = iter.glyphs(); 2488 const uint16_t* iterGlyphs = iter.glyphs();
2474 for (uint32_t i = 0; i < iter.glyphCount(); i++) { 2489 for (uint32_t i = 0; i < iter.glyphCount(); i++) {
2475 switch (iter.positioning()) { 2490 switch (iter.positioning()) {
2476 case SkTextBlob::kFull_Positioning: 2491 case SkTextBlob::kFull_Positioning:
2477 jsonPositions.append(make_json_point(iterPositions[i * 2], 2492 jsonPositions.append(make_json_point(iterPositions[i * 2],
2478 iterPositions[i * 2 + 1 ])); 2493 iterPositions[i * 2 + 1 ]));
2479 break; 2494 break;
2480 case SkTextBlob::kHorizontal_Positioning: 2495 case SkTextBlob::kHorizontal_Positioning:
2481 jsonPositions.append(Json::Value(iterPositions[i])); 2496 jsonPositions.append(Json::Value(iterPositions[i]));
2482 break; 2497 break;
2483 case SkTextBlob::kDefault_Positioning: 2498 case SkTextBlob::kDefault_Positioning:
2484 break; 2499 break;
2485 } 2500 }
2486 jsonGlyphs.append(Json::Value(iterGlyphs[i])); 2501 jsonGlyphs.append(Json::Value(iterGlyphs[i]));
2487 } 2502 }
2488 if (iter.positioning() != SkTextBlob::kDefault_Positioning) { 2503 if (iter.positioning() != SkTextBlob::kDefault_Positioning) {
2489 run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = jsonPositions; 2504 run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS] = jsonPositions;
2490 } 2505 }
2491 run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS] = jsonGlyphs; 2506 run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS] = jsonGlyphs;
2492 SkPaint fontPaint; 2507 SkPaint fontPaint;
2493 iter.applyFontToPaint(&fontPaint); 2508 iter.applyFontToPaint(&fontPaint);
2494 run[SKDEBUGCANVAS_ATTRIBUTE_FONT] = make_json_paint(fontPaint, SKDEBUGCA NVAS_SEND_BINARIES); 2509 run[SKDEBUGCANVAS_ATTRIBUTE_FONT] = make_json_paint(fontPaint, urlDataMa nager);
2495 run[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(iter.offset()); 2510 run[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(iter.offset());
2496 runs.append(run); 2511 runs.append(run);
2497 iter.next(); 2512 iter.next();
2498 } 2513 }
2499 result[SKDEBUGCANVAS_ATTRIBUTE_RUNS] = runs; 2514 result[SKDEBUGCANVAS_ATTRIBUTE_RUNS] = runs;
2500 result[SKDEBUGCANVAS_ATTRIBUTE_X] = Json::Value(fXPos); 2515 result[SKDEBUGCANVAS_ATTRIBUTE_X] = Json::Value(fXPos);
2501 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fYPos); 2516 result[SKDEBUGCANVAS_ATTRIBUTE_Y] = Json::Value(fYPos);
2502 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2517 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2503 return result; 2518 return result;
2504 } 2519 }
2505 2520
2506 SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command) { 2521 SkDrawTextBlobCommand* SkDrawTextBlobCommand::fromJSON(Json::Value& command,
2522 UrlDataManager& urlDataMa nager) {
2507 SkTextBlobBuilder builder; 2523 SkTextBlobBuilder builder;
2508 Json::Value runs = command[SKDEBUGCANVAS_ATTRIBUTE_RUNS]; 2524 Json::Value runs = command[SKDEBUGCANVAS_ATTRIBUTE_RUNS];
2509 for (Json::ArrayIndex i = 0 ; i < runs.size(); i++) { 2525 for (Json::ArrayIndex i = 0 ; i < runs.size(); i++) {
2510 Json::Value run = runs[i]; 2526 Json::Value run = runs[i];
2511 SkPaint font; 2527 SkPaint font;
2512 font.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 2528 font.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
2513 extract_json_paint(run[SKDEBUGCANVAS_ATTRIBUTE_FONT], &font); 2529 extract_json_paint(run[SKDEBUGCANVAS_ATTRIBUTE_FONT], urlDataManager, &f ont);
2514 Json::Value glyphs = run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS]; 2530 Json::Value glyphs = run[SKDEBUGCANVAS_ATTRIBUTE_GLYPHS];
2515 int count = glyphs.size(); 2531 int count = glyphs.size();
2516 Json::Value coords = run[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; 2532 Json::Value coords = run[SKDEBUGCANVAS_ATTRIBUTE_COORDS];
2517 SkScalar x = coords[0].asFloat(); 2533 SkScalar x = coords[0].asFloat();
2518 SkScalar y = coords[1].asFloat(); 2534 SkScalar y = coords[1].asFloat();
2519 if (run.isMember(SKDEBUGCANVAS_ATTRIBUTE_POSITIONS)) { 2535 if (run.isMember(SKDEBUGCANVAS_ATTRIBUTE_POSITIONS)) {
2520 Json::Value positions = run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS]; 2536 Json::Value positions = run[SKDEBUGCANVAS_ATTRIBUTE_POSITIONS];
2521 if (positions.size() > 0 && positions[0].isNumeric()) { 2537 if (positions.size() > 0 && positions[0].isNumeric()) {
2522 SkTextBlobBuilder::RunBuffer buffer = builder.allocRunPosH(font, count, y); 2538 SkTextBlobBuilder::RunBuffer buffer = builder.allocRunPosH(font, count, y);
2523 for (int j = 0; j < count; j++) { 2539 for (int j = 0; j < count; j++) {
(...skipping 13 matching lines...) Expand all
2537 else { 2553 else {
2538 SkTextBlobBuilder::RunBuffer buffer = builder.allocRun(font, count, x, y); 2554 SkTextBlobBuilder::RunBuffer buffer = builder.allocRun(font, count, x, y);
2539 for (int j = 0; j < count; j++) { 2555 for (int j = 0; j < count; j++) {
2540 buffer.glyphs[j] = glyphs[j].asUInt(); 2556 buffer.glyphs[j] = glyphs[j].asUInt();
2541 } 2557 }
2542 } 2558 }
2543 } 2559 }
2544 SkScalar x = command[SKDEBUGCANVAS_ATTRIBUTE_X].asFloat(); 2560 SkScalar x = command[SKDEBUGCANVAS_ATTRIBUTE_X].asFloat();
2545 SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat(); 2561 SkScalar y = command[SKDEBUGCANVAS_ATTRIBUTE_Y].asFloat();
2546 SkPaint paint; 2562 SkPaint paint;
2547 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2563 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2548 return new SkDrawTextBlobCommand(builder.build(), x, y, paint); 2564 return new SkDrawTextBlobCommand(builder.build(), x, y, paint);
2549 } 2565 }
2550 2566
2551 SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor c olors[4], 2567 SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor c olors[4],
2552 const SkPoint texCoords[4], SkXfermode* x fermode, 2568 const SkPoint texCoords[4], SkXfermode* x fermode,
2553 const SkPaint& paint) 2569 const SkPaint& paint)
2554 : INHERITED(kDrawPatch_OpType) { 2570 : INHERITED(kDrawPatch_OpType) {
2555 memcpy(fCubics, cubics, sizeof(fCubics)); 2571 memcpy(fCubics, cubics, sizeof(fCubics));
2556 if (colors != nullptr) { 2572 if (colors != nullptr) {
2557 memcpy(fColors, colors, sizeof(fColors)); 2573 memcpy(fColors, colors, sizeof(fColors));
(...skipping 12 matching lines...) Expand all
2570 } 2586 }
2571 fPaint = paint; 2587 fPaint = paint;
2572 2588
2573 fInfo.push(SkObjectParser::PaintToString(paint)); 2589 fInfo.push(SkObjectParser::PaintToString(paint));
2574 } 2590 }
2575 2591
2576 void SkDrawPatchCommand::execute(SkCanvas* canvas) const { 2592 void SkDrawPatchCommand::execute(SkCanvas* canvas) const {
2577 canvas->drawPatch(fCubics, fColorsPtr, fTexCoordsPtr, fXfermode, fPaint); 2593 canvas->drawPatch(fCubics, fColorsPtr, fTexCoordsPtr, fXfermode, fPaint);
2578 } 2594 }
2579 2595
2580 Json::Value SkDrawPatchCommand::toJSON() const { 2596 Json::Value SkDrawPatchCommand::toJSON(UrlDataManager& urlDataManager) const {
2581 Json::Value result = INHERITED::toJSON(); 2597 Json::Value result = INHERITED::toJSON(urlDataManager);
2582 Json::Value cubics = Json::Value(Json::arrayValue); 2598 Json::Value cubics = Json::Value(Json::arrayValue);
2583 for (int i = 0; i < 12; i++) { 2599 for (int i = 0; i < 12; i++) {
2584 cubics.append(make_json_point(fCubics[i])); 2600 cubics.append(make_json_point(fCubics[i]));
2585 } 2601 }
2586 result[SKDEBUGCANVAS_ATTRIBUTE_CUBICS] = cubics; 2602 result[SKDEBUGCANVAS_ATTRIBUTE_CUBICS] = cubics;
2587 if (fColorsPtr != nullptr) { 2603 if (fColorsPtr != nullptr) {
2588 Json::Value colors = Json::Value(Json::arrayValue); 2604 Json::Value colors = Json::Value(Json::arrayValue);
2589 for (int i = 0; i < 4; i++) { 2605 for (int i = 0; i < 4; i++) {
2590 colors.append(make_json_color(fColorsPtr[i])); 2606 colors.append(make_json_color(fColorsPtr[i]));
2591 } 2607 }
2592 result[SKDEBUGCANVAS_ATTRIBUTE_COLORS] = colors; 2608 result[SKDEBUGCANVAS_ATTRIBUTE_COLORS] = colors;
2593 } 2609 }
2594 if (fTexCoordsPtr != nullptr) { 2610 if (fTexCoordsPtr != nullptr) {
2595 Json::Value texCoords = Json::Value(Json::arrayValue); 2611 Json::Value texCoords = Json::Value(Json::arrayValue);
2596 for (int i = 0; i < 4; i++) { 2612 for (int i = 0; i < 4; i++) {
2597 texCoords.append(make_json_point(fTexCoords[i])); 2613 texCoords.append(make_json_point(fTexCoords[i]));
2598 } 2614 }
2599 result[SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS] = texCoords; 2615 result[SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS] = texCoords;
2600 } 2616 }
2601 if (fXfermode.get() != nullptr) { 2617 if (fXfermode.get() != nullptr) {
2602 Json::Value jsonXfermode; 2618 Json::Value jsonXfermode;
2603 flatten(fXfermode, &jsonXfermode, SKDEBUGCANVAS_SEND_BINARIES); 2619 flatten(fXfermode, &jsonXfermode, urlDataManager);
2604 result[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode; 2620 result[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE] = jsonXfermode;
2605 } 2621 }
2606 return result; 2622 return result;
2607 } 2623 }
2608 2624
2609 SkDrawPatchCommand* SkDrawPatchCommand::fromJSON(Json::Value& command) { 2625 SkDrawPatchCommand* SkDrawPatchCommand::fromJSON(Json::Value& command,
2626 UrlDataManager& urlDataManager) {
2610 Json::Value jsonCubics = command[SKDEBUGCANVAS_ATTRIBUTE_CUBICS]; 2627 Json::Value jsonCubics = command[SKDEBUGCANVAS_ATTRIBUTE_CUBICS];
2611 SkPoint cubics[12]; 2628 SkPoint cubics[12];
2612 for (int i = 0; i < 12; i++) { 2629 for (int i = 0; i < 12; i++) {
2613 cubics[i] = get_json_point(jsonCubics[i]); 2630 cubics[i] = get_json_point(jsonCubics[i]);
2614 } 2631 }
2615 SkColor* colorsPtr; 2632 SkColor* colorsPtr;
2616 SkColor colors[4]; 2633 SkColor colors[4];
2617 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORS)) { 2634 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLORS)) {
2618 Json::Value jsonColors = command[SKDEBUGCANVAS_ATTRIBUTE_COLORS]; 2635 Json::Value jsonColors = command[SKDEBUGCANVAS_ATTRIBUTE_COLORS];
2619 for (int i = 0; i < 4; i++) { 2636 for (int i = 0; i < 4; i++) {
(...skipping 12 matching lines...) Expand all
2632 texCoords[i] = get_json_point(jsonTexCoords[i]); 2649 texCoords[i] = get_json_point(jsonTexCoords[i]);
2633 } 2650 }
2634 texCoordsPtr = texCoords; 2651 texCoordsPtr = texCoords;
2635 } 2652 }
2636 else { 2653 else {
2637 texCoordsPtr = nullptr; 2654 texCoordsPtr = nullptr;
2638 } 2655 }
2639 SkAutoTUnref<SkXfermode> xfermode; 2656 SkAutoTUnref<SkXfermode> xfermode;
2640 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) { 2657 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_XFERMODE)) {
2641 Json::Value jsonXfermode = command[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE]; 2658 Json::Value jsonXfermode = command[SKDEBUGCANVAS_ATTRIBUTE_XFERMODE];
2642 xfermode.reset((SkXfermode*) load_flattenable(jsonXfermode)); 2659 xfermode.reset((SkXfermode*) load_flattenable(jsonXfermode, urlDataManag er));
2643 } 2660 }
2644 SkPaint paint; 2661 SkPaint paint;
2645 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2662 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2646 return new SkDrawPatchCommand(cubics, colorsPtr, texCoordsPtr, xfermode, pai nt); 2663 return new SkDrawPatchCommand(cubics, colorsPtr, texCoordsPtr, xfermode, pai nt);
2647 } 2664 }
2648 2665
2649 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) 2666 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint)
2650 : INHERITED(kDrawRect_OpType) { 2667 : INHERITED(kDrawRect_OpType) {
2651 fRect = rect; 2668 fRect = rect;
2652 fPaint = paint; 2669 fPaint = paint;
2653 2670
2654 fInfo.push(SkObjectParser::RectToString(rect)); 2671 fInfo.push(SkObjectParser::RectToString(rect));
2655 fInfo.push(SkObjectParser::PaintToString(paint)); 2672 fInfo.push(SkObjectParser::PaintToString(paint));
2656 } 2673 }
2657 2674
2658 void SkDrawRectCommand::execute(SkCanvas* canvas) const { 2675 void SkDrawRectCommand::execute(SkCanvas* canvas) const {
2659 canvas->drawRect(fRect, fPaint); 2676 canvas->drawRect(fRect, fPaint);
2660 } 2677 }
2661 2678
2662 Json::Value SkDrawRectCommand::toJSON() const { 2679 Json::Value SkDrawRectCommand::toJSON(UrlDataManager& urlDataManager) const {
2663 Json::Value result = INHERITED::toJSON(); 2680 Json::Value result = INHERITED::toJSON(urlDataManager);
2664 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect); 2681 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rect(fRect);
2665 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2682 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2666 return result; 2683 return result;
2667 } 2684 }
2668 2685
2669 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command) { 2686 SkDrawRectCommand* SkDrawRectCommand::fromJSON(Json::Value& command,
2687 UrlDataManager& urlDataManager) {
2670 SkRect coords; 2688 SkRect coords;
2671 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); 2689 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords);
2672 SkPaint paint; 2690 SkPaint paint;
2673 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2691 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2674 return new SkDrawRectCommand(coords, paint); 2692 return new SkDrawRectCommand(coords, paint);
2675 } 2693 }
2676 2694
2677 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain t) 2695 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain t)
2678 : INHERITED(kDrawRRect_OpType) { 2696 : INHERITED(kDrawRRect_OpType) {
2679 fRRect = rrect; 2697 fRRect = rrect;
2680 fPaint = paint; 2698 fPaint = paint;
2681 2699
2682 fInfo.push(SkObjectParser::RRectToString(rrect)); 2700 fInfo.push(SkObjectParser::RRectToString(rrect));
2683 fInfo.push(SkObjectParser::PaintToString(paint)); 2701 fInfo.push(SkObjectParser::PaintToString(paint));
2684 } 2702 }
2685 2703
2686 void SkDrawRRectCommand::execute(SkCanvas* canvas) const { 2704 void SkDrawRRectCommand::execute(SkCanvas* canvas) const {
2687 canvas->drawRRect(fRRect, fPaint); 2705 canvas->drawRRect(fRRect, fPaint);
2688 } 2706 }
2689 2707
2690 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { 2708 bool SkDrawRRectCommand::render(SkCanvas* canvas) const {
2691 render_rrect(canvas, fRRect); 2709 render_rrect(canvas, fRRect);
2692 return true; 2710 return true;
2693 } 2711 }
2694 2712
2695 Json::Value SkDrawRRectCommand::toJSON() const { 2713 Json::Value SkDrawRRectCommand::toJSON(UrlDataManager& urlDataManager) const {
2696 Json::Value result = INHERITED::toJSON(); 2714 Json::Value result = INHERITED::toJSON(urlDataManager);
2697 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect); 2715 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_rrect(fRRect);
2698 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2716 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2699 return result; 2717 return result;
2700 } 2718 }
2701 2719
2702 SkDrawRRectCommand* SkDrawRRectCommand::fromJSON(Json::Value& command) { 2720 SkDrawRRectCommand* SkDrawRRectCommand::fromJSON(Json::Value& command,
2721 UrlDataManager& urlDataManager) {
2703 SkRRect coords; 2722 SkRRect coords;
2704 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); 2723 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords);
2705 SkPaint paint; 2724 SkPaint paint;
2706 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2725 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2707 return new SkDrawRRectCommand(coords, paint); 2726 return new SkDrawRRectCommand(coords, paint);
2708 } 2727 }
2709 2728
2710 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, 2729 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer,
2711 const SkRRect& inner, 2730 const SkRRect& inner,
2712 const SkPaint& paint) 2731 const SkPaint& paint)
2713 : INHERITED(kDrawDRRect_OpType) { 2732 : INHERITED(kDrawDRRect_OpType) {
2714 fOuter = outer; 2733 fOuter = outer;
2715 fInner = inner; 2734 fInner = inner;
2716 fPaint = paint; 2735 fPaint = paint;
2717 2736
2718 fInfo.push(SkObjectParser::RRectToString(outer)); 2737 fInfo.push(SkObjectParser::RRectToString(outer));
2719 fInfo.push(SkObjectParser::RRectToString(inner)); 2738 fInfo.push(SkObjectParser::RRectToString(inner));
2720 fInfo.push(SkObjectParser::PaintToString(paint)); 2739 fInfo.push(SkObjectParser::PaintToString(paint));
2721 } 2740 }
2722 2741
2723 void SkDrawDRRectCommand::execute(SkCanvas* canvas) const { 2742 void SkDrawDRRectCommand::execute(SkCanvas* canvas) const {
2724 canvas->drawDRRect(fOuter, fInner, fPaint); 2743 canvas->drawDRRect(fOuter, fInner, fPaint);
2725 } 2744 }
2726 2745
2727 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { 2746 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const {
2728 render_drrect(canvas, fOuter, fInner); 2747 render_drrect(canvas, fOuter, fInner);
2729 return true; 2748 return true;
2730 } 2749 }
2731 2750
2732 Json::Value SkDrawDRRectCommand::toJSON() const { 2751 Json::Value SkDrawDRRectCommand::toJSON(UrlDataManager& urlDataManager) const {
2733 Json::Value result = INHERITED::toJSON(); 2752 Json::Value result = INHERITED::toJSON(urlDataManager);
2734 result[SKDEBUGCANVAS_ATTRIBUTE_OUTER] = make_json_rrect(fOuter); 2753 result[SKDEBUGCANVAS_ATTRIBUTE_OUTER] = make_json_rrect(fOuter);
2735 result[SKDEBUGCANVAS_ATTRIBUTE_INNER] = make_json_rrect(fInner); 2754 result[SKDEBUGCANVAS_ATTRIBUTE_INNER] = make_json_rrect(fInner);
2736 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2755 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2737 return result; 2756 return result;
2738 } 2757 }
2739 2758
2740 SkDrawDRRectCommand* SkDrawDRRectCommand::fromJSON(Json::Value& command) { 2759 SkDrawDRRectCommand* SkDrawDRRectCommand::fromJSON(Json::Value& command,
2760 UrlDataManager& urlDataManage r) {
2741 SkRRect outer; 2761 SkRRect outer;
2742 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &outer); 2762 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &outer);
2743 SkRRect inner; 2763 SkRRect inner;
2744 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &inner); 2764 extract_json_rrect(command[SKDEBUGCANVAS_ATTRIBUTE_INNER], &inner);
2745 SkPaint paint; 2765 SkPaint paint;
2746 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2766 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2747 return new SkDrawDRRectCommand(outer, inner, paint); 2767 return new SkDrawDRRectCommand(outer, inner, paint);
2748 } 2768 }
2749 2769
2750 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal ar x, SkScalar y, 2770 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal ar x, SkScalar y,
2751 const SkPaint& paint) 2771 const SkPaint& paint)
2752 : INHERITED(kDrawText_OpType) { 2772 : INHERITED(kDrawText_OpType) {
2753 fText = new char[byteLength]; 2773 fText = new char[byteLength];
2754 memcpy(fText, text, byteLength); 2774 memcpy(fText, text, byteLength);
2755 fByteLength = byteLength; 2775 fByteLength = byteLength;
2756 fX = x; 2776 fX = x;
2757 fY = y; 2777 fY = y;
2758 fPaint = paint; 2778 fPaint = paint;
2759 2779
2760 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod ing())); 2780 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod ing()));
2761 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); 2781 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
2762 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); 2782 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
2763 fInfo.push(SkObjectParser::PaintToString(paint)); 2783 fInfo.push(SkObjectParser::PaintToString(paint));
2764 } 2784 }
2765 2785
2766 void SkDrawTextCommand::execute(SkCanvas* canvas) const { 2786 void SkDrawTextCommand::execute(SkCanvas* canvas) const {
2767 canvas->drawText(fText, fByteLength, fX, fY, fPaint); 2787 canvas->drawText(fText, fByteLength, fX, fY, fPaint);
2768 } 2788 }
2769 2789
2770 Json::Value SkDrawTextCommand::toJSON() const { 2790 Json::Value SkDrawTextCommand::toJSON(UrlDataManager& urlDataManager) const {
2771 Json::Value result = INHERITED::toJSON(); 2791 Json::Value result = INHERITED::toJSON(urlDataManager);
2772 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, 2792 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
2773 ((const char*) fText) + f ByteLength); 2793 ((const char*) fText) + f ByteLength);
2774 Json::Value coords(Json::arrayValue); 2794 Json::Value coords(Json::arrayValue);
2775 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fX, fY); 2795 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = make_json_point(fX, fY);
2776 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2796 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2777 return result; 2797 return result;
2778 } 2798 }
2779 2799
2780 SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command) { 2800 SkDrawTextCommand* SkDrawTextCommand::fromJSON(Json::Value& command,
2801 UrlDataManager& urlDataManager) {
2781 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); 2802 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString();
2782 SkPaint paint; 2803 SkPaint paint;
2783 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2804 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2784 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS]; 2805 Json::Value coords = command[SKDEBUGCANVAS_ATTRIBUTE_COORDS];
2785 return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords [1].asFloat(), 2806 return new SkDrawTextCommand(text, strlen(text), coords[0].asFloat(), coords [1].asFloat(),
2786 paint); 2807 paint);
2787 } 2808 }
2788 2809
2789 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe ngth, 2810 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe ngth,
2790 const SkPath& path, const SkMat rix* matrix, 2811 const SkPath& path, const SkMat rix* matrix,
2791 const SkPaint& paint) 2812 const SkPaint& paint)
2792 : INHERITED(kDrawTextOnPath_OpType) { 2813 : INHERITED(kDrawTextOnPath_OpType) {
2793 fText = new char[byteLength]; 2814 fText = new char[byteLength];
(...skipping 14 matching lines...) Expand all
2808 } 2829 }
2809 fInfo.push(SkObjectParser::PaintToString(paint)); 2830 fInfo.push(SkObjectParser::PaintToString(paint));
2810 } 2831 }
2811 2832
2812 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) const { 2833 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) const {
2813 canvas->drawTextOnPath(fText, fByteLength, fPath, 2834 canvas->drawTextOnPath(fText, fByteLength, fPath,
2814 fMatrix.isIdentity() ? nullptr : &fMatrix, 2835 fMatrix.isIdentity() ? nullptr : &fMatrix,
2815 fPaint); 2836 fPaint);
2816 } 2837 }
2817 2838
2818 Json::Value SkDrawTextOnPathCommand::toJSON() const { 2839 Json::Value SkDrawTextOnPathCommand::toJSON(UrlDataManager& urlDataManager) cons t {
2819 Json::Value result = INHERITED::toJSON(); 2840 Json::Value result = INHERITED::toJSON(urlDataManager);
2820 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText, 2841 result[SKDEBUGCANVAS_ATTRIBUTE_TEXT] = Json::Value((const char*) fText,
2821 ((const char*) fText) + f ByteLength); 2842 ((const char*) fText) + f ByteLength);
2822 Json::Value coords(Json::arrayValue); 2843 Json::Value coords(Json::arrayValue);
2823 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath); 2844 result[SKDEBUGCANVAS_ATTRIBUTE_PATH] = make_json_path(fPath);
2824 if (!fMatrix.isIdentity()) { 2845 if (!fMatrix.isIdentity()) {
2825 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); 2846 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix);
2826 } 2847 }
2827 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, SKDEBUGCANVA S_SEND_BINARIES); 2848 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(fPaint, urlDataManag er);
2828 return result; 2849 return result;
2829 } 2850 }
2830 2851
2831 SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command) { 2852 SkDrawTextOnPathCommand* SkDrawTextOnPathCommand::fromJSON(Json::Value& command,
2853 UrlDataManager& urlDa taManager) {
2832 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString(); 2854 const char* text = command[SKDEBUGCANVAS_ATTRIBUTE_TEXT].asCString();
2833 SkPaint paint; 2855 SkPaint paint;
2834 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 2856 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, & paint);
2835 SkPath path; 2857 SkPath path;
2836 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path); 2858 extract_json_path(command[SKDEBUGCANVAS_ATTRIBUTE_PATH], &path);
2837 SkMatrix* matrixPtr; 2859 SkMatrix* matrixPtr;
2838 SkMatrix matrix; 2860 SkMatrix matrix;
2839 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_MATRIX)) { 2861 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_MATRIX)) {
2840 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 2862 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
2841 matrixPtr = &matrix; 2863 matrixPtr = &matrix;
2842 } 2864 }
2843 else { 2865 else {
2844 matrixPtr = nullptr; 2866 matrixPtr = nullptr;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2909 2931
2910 SkRestoreCommand::SkRestoreCommand() 2932 SkRestoreCommand::SkRestoreCommand()
2911 : INHERITED(kRestore_OpType) { 2933 : INHERITED(kRestore_OpType) {
2912 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); 2934 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
2913 } 2935 }
2914 2936
2915 void SkRestoreCommand::execute(SkCanvas* canvas) const { 2937 void SkRestoreCommand::execute(SkCanvas* canvas) const {
2916 canvas->restore(); 2938 canvas->restore();
2917 } 2939 }
2918 2940
2919 SkRestoreCommand* SkRestoreCommand::fromJSON(Json::Value& command) { 2941 SkRestoreCommand* SkRestoreCommand::fromJSON(Json::Value& command, UrlDataManage r& urlDataManager) {
2920 return new SkRestoreCommand(); 2942 return new SkRestoreCommand();
2921 } 2943 }
2922 2944
2923 SkSaveCommand::SkSaveCommand() 2945 SkSaveCommand::SkSaveCommand()
2924 : INHERITED(kSave_OpType) { 2946 : INHERITED(kSave_OpType) {
2925 } 2947 }
2926 2948
2927 void SkSaveCommand::execute(SkCanvas* canvas) const { 2949 void SkSaveCommand::execute(SkCanvas* canvas) const {
2928 canvas->save(); 2950 canvas->save();
2929 } 2951 }
2930 2952
2931 SkSaveCommand* SkSaveCommand::fromJSON(Json::Value& command) { 2953 SkSaveCommand* SkSaveCommand::fromJSON(Json::Value& command, UrlDataManager& url DataManager) {
2932 return new SkSaveCommand(); 2954 return new SkSaveCommand();
2933 } 2955 }
2934 2956
2935 SkSaveLayerCommand::SkSaveLayerCommand(const SkCanvas::SaveLayerRec& rec) 2957 SkSaveLayerCommand::SkSaveLayerCommand(const SkCanvas::SaveLayerRec& rec)
2936 : INHERITED(kSaveLayer_OpType) { 2958 : INHERITED(kSaveLayer_OpType) {
2937 if (rec.fBounds) { 2959 if (rec.fBounds) {
2938 fBounds = *rec.fBounds; 2960 fBounds = *rec.fBounds;
2939 } else { 2961 } else {
2940 fBounds.setEmpty(); 2962 fBounds.setEmpty();
2941 } 2963 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2973 void SkSaveLayerCommand::execute(SkCanvas* canvas) const { 2995 void SkSaveLayerCommand::execute(SkCanvas* canvas) const {
2974 canvas->saveLayer(SkCanvas::SaveLayerRec(fBounds.isEmpty() ? nullptr : &fBou nds, 2996 canvas->saveLayer(SkCanvas::SaveLayerRec(fBounds.isEmpty() ? nullptr : &fBou nds,
2975 fPaintPtr, 2997 fPaintPtr,
2976 fSaveLayerFlags)); 2998 fSaveLayerFlags));
2977 } 2999 }
2978 3000
2979 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { 3001 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const {
2980 canvas->save(); 3002 canvas->save();
2981 } 3003 }
2982 3004
2983 Json::Value SkSaveLayerCommand::toJSON() const { 3005 Json::Value SkSaveLayerCommand::toJSON(UrlDataManager& urlDataManager) const {
2984 Json::Value result = INHERITED::toJSON(); 3006 Json::Value result = INHERITED::toJSON(urlDataManager);
2985 if (!fBounds.isEmpty()) { 3007 if (!fBounds.isEmpty()) {
2986 result[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS] = make_json_rect(fBounds); 3008 result[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS] = make_json_rect(fBounds);
2987 } 3009 }
2988 if (fPaintPtr != nullptr) { 3010 if (fPaintPtr != nullptr) {
2989 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr, 3011 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = make_json_paint(*fPaintPtr,
2990 SKDEBUGCANVAS_SE ND_BINARIES); 3012 urlDataManager);
2991 } 3013 }
2992 if (fBackdrop != nullptr) { 3014 if (fBackdrop != nullptr) {
2993 Json::Value jsonBackdrop; 3015 Json::Value jsonBackdrop;
2994 flatten(fBackdrop, &jsonBackdrop, SKDEBUGCANVAS_SEND_BINARIES); 3016 flatten(fBackdrop, &jsonBackdrop, urlDataManager);
2995 result[SKDEBUGCANVAS_ATTRIBUTE_BACKDROP] = jsonBackdrop; 3017 result[SKDEBUGCANVAS_ATTRIBUTE_BACKDROP] = jsonBackdrop;
2996 } 3018 }
2997 if (fSaveLayerFlags != 0) { 3019 if (fSaveLayerFlags != 0) {
2998 SkDebugf("unsupported: saveLayer flags\n"); 3020 SkDebugf("unsupported: saveLayer flags\n");
2999 SkASSERT(false); 3021 SkASSERT(false);
3000 } 3022 }
3001 return result; 3023 return result;
3002 } 3024 }
3003 3025
3004 SkSaveLayerCommand* SkSaveLayerCommand::fromJSON(Json::Value& command) { 3026 SkSaveLayerCommand* SkSaveLayerCommand::fromJSON(Json::Value& command,
3027 UrlDataManager& urlDataManager) {
3005 SkCanvas::SaveLayerRec rec; 3028 SkCanvas::SaveLayerRec rec;
3006 SkRect bounds; 3029 SkRect bounds;
3007 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_BOUNDS)) { 3030 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_BOUNDS)) {
3008 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS], &bounds); 3031 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_BOUNDS], &bounds);
3009 rec.fBounds = &bounds; 3032 rec.fBounds = &bounds;
3010 } 3033 }
3011 SkPaint paint; 3034 SkPaint paint;
3012 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) { 3035 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_PAINT)) {
3013 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], &paint); 3036 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManage r, &paint);
3014 rec.fPaint = &paint; 3037 rec.fPaint = &paint;
3015 } 3038 }
3016 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_BACKDROP)) { 3039 if (command.isMember(SKDEBUGCANVAS_ATTRIBUTE_BACKDROP)) {
3017 Json::Value backdrop = command[SKDEBUGCANVAS_ATTRIBUTE_BACKDROP]; 3040 Json::Value backdrop = command[SKDEBUGCANVAS_ATTRIBUTE_BACKDROP];
3018 rec.fBackdrop = (SkImageFilter*) load_flattenable(backdrop); 3041 rec.fBackdrop = (SkImageFilter*) load_flattenable(backdrop, urlDataManag er);
3019 } 3042 }
3020 SkSaveLayerCommand* result = new SkSaveLayerCommand(rec); 3043 SkSaveLayerCommand* result = new SkSaveLayerCommand(rec);
3021 if (rec.fBackdrop != nullptr) { 3044 if (rec.fBackdrop != nullptr) {
3022 rec.fBackdrop->unref(); 3045 rec.fBackdrop->unref();
3023 } 3046 }
3024 return result; 3047 return result;
3025 } 3048 }
3026 3049
3027 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) 3050 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix)
3028 : INHERITED(kSetMatrix_OpType) { 3051 : INHERITED(kSetMatrix_OpType) {
3029 fUserMatrix.reset(); 3052 fUserMatrix.reset();
3030 fMatrix = matrix; 3053 fMatrix = matrix;
3031 fInfo.push(SkObjectParser::MatrixToString(matrix)); 3054 fInfo.push(SkObjectParser::MatrixToString(matrix));
3032 } 3055 }
3033 3056
3034 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { 3057 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) {
3035 fUserMatrix = userMatrix; 3058 fUserMatrix = userMatrix;
3036 } 3059 }
3037 3060
3038 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { 3061 void SkSetMatrixCommand::execute(SkCanvas* canvas) const {
3039 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); 3062 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix);
3040 canvas->setMatrix(temp); 3063 canvas->setMatrix(temp);
3041 } 3064 }
3042 3065
3043 Json::Value SkSetMatrixCommand::toJSON() const { 3066 Json::Value SkSetMatrixCommand::toJSON(UrlDataManager& urlDataManager) const {
3044 Json::Value result = INHERITED::toJSON(); 3067 Json::Value result = INHERITED::toJSON(urlDataManager);
3045 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); 3068 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix);
3046 return result; 3069 return result;
3047 } 3070 }
3048 3071
3049 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command) { 3072 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
3073 UrlDataManager& urlDataManager) {
3050 SkMatrix matrix; 3074 SkMatrix matrix;
3051 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 3075 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
3052 return new SkSetMatrixCommand(matrix); 3076 return new SkSetMatrixCommand(matrix);
3053 } 3077 }
OLDNEW
« no previous file with comments | « tools/debugger/SkDrawCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698