OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDrawCommand.h" | 8 #include "SkDrawCommand.h" |
9 | 9 |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 } | 602 } |
603 | 603 |
604 static void store_bool(Json::Value* target, const char* key, bool value, bool de
faultValue) { | 604 static void store_bool(Json::Value* target, const char* key, bool value, bool de
faultValue) { |
605 if (value != defaultValue) { | 605 if (value != defaultValue) { |
606 (*target)[key] = Json::Value(value); | 606 (*target)[key] = Json::Value(value); |
607 } | 607 } |
608 } | 608 } |
609 | 609 |
610 static void encode_data(const void* bytes, size_t count, const char* contentType
, | 610 static void encode_data(const void* bytes, size_t count, const char* contentType
, |
611 UrlDataManager& urlDataManager, Json::Value* target) { | 611 UrlDataManager& urlDataManager, Json::Value* target) { |
612 SkAutoTUnref<SkData> data(SkData::NewWithCopy(bytes, count)); | 612 sk_sp<SkData> data(SkData::MakeWithCopy(bytes, count)); |
613 SkString url = urlDataManager.addData(data, contentType); | 613 SkString url = urlDataManager.addData(data.get(), contentType); |
614 *target = Json::Value(url.c_str()); | 614 *target = Json::Value(url.c_str()); |
615 } | 615 } |
616 | 616 |
617 void SkDrawCommand::flatten(const SkFlattenable* flattenable, Json::Value* targe
t, | 617 void SkDrawCommand::flatten(const SkFlattenable* flattenable, Json::Value* targe
t, |
618 UrlDataManager& urlDataManager) { | 618 UrlDataManager& urlDataManager) { |
619 SkBinaryWriteBuffer buffer; | 619 SkBinaryWriteBuffer buffer; |
620 flattenable->flatten(buffer); | 620 flattenable->flatten(buffer); |
621 void* data = sk_malloc_throw(buffer.bytesWritten()); | 621 void* data = sk_malloc_throw(buffer.bytesWritten()); |
622 buffer.writeToMemory(data); | 622 buffer.writeToMemory(data); |
623 Json::Value jsonData; | 623 Json::Value jsonData; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 } | 814 } |
815 | 815 |
816 // caller is responsible for freeing return value | 816 // caller is responsible for freeing return value |
817 static SkBitmap* load_bitmap(const Json::Value& jsonBitmap, UrlDataManager& urlD
ataManager) { | 817 static SkBitmap* load_bitmap(const Json::Value& jsonBitmap, UrlDataManager& urlD
ataManager) { |
818 if (!jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_DATA)) { | 818 if (!jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_DATA)) { |
819 SkDebugf("invalid bitmap\n"); | 819 SkDebugf("invalid bitmap\n"); |
820 return nullptr; | 820 return nullptr; |
821 } | 821 } |
822 const void* data; | 822 const void* data; |
823 int size = decode_data(jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_DATA], urlDataMana
ger, &data); | 823 int size = decode_data(jsonBitmap[SKDEBUGCANVAS_ATTRIBUTE_DATA], urlDataMana
ger, &data); |
824 sk_sp<SkData> encoded(SkData::NewWithoutCopy(data, size)); | 824 sk_sp<SkData> encoded(SkData::MakeWithoutCopy(data, size)); |
825 sk_sp<SkImage> image(SkImage::MakeFromEncoded(std::move(encoded), nullptr)); | 825 sk_sp<SkImage> image(SkImage::MakeFromEncoded(std::move(encoded), nullptr)); |
826 | 826 |
827 SkAutoTDelete<SkBitmap> bitmap(new SkBitmap()); | 827 SkAutoTDelete<SkBitmap> bitmap(new SkBitmap()); |
828 if (nullptr != image) { | 828 if (nullptr != image) { |
829 if (!image->asLegacyBitmap(bitmap, SkImage::kRW_LegacyBitmapMode)) { | 829 if (!image->asLegacyBitmap(bitmap, SkImage::kRW_LegacyBitmapMode)) { |
830 SkDebugf("image decode failed\n"); | 830 SkDebugf("image decode failed\n"); |
831 return nullptr; | 831 return nullptr; |
832 } | 832 } |
833 | 833 |
834 if (jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) { | 834 if (jsonBitmap.isMember(SKDEBUGCANVAS_ATTRIBUTE_COLOR)) { |
(...skipping 2564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3399 SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command, | 3399 SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command, |
3400 UrlDataManager& urlDataManager) { | 3400 UrlDataManager& urlDataManager) { |
3401 SkScalar z; | 3401 SkScalar z; |
3402 #ifdef SK_EXPERIMENTAL_SHADOWING | 3402 #ifdef SK_EXPERIMENTAL_SHADOWING |
3403 extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z); | 3403 extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z); |
3404 #else | 3404 #else |
3405 z = 0; | 3405 z = 0; |
3406 #endif | 3406 #endif |
3407 return new SkTranslateZCommand(z); | 3407 return new SkTranslateZCommand(z); |
3408 } | 3408 } |
OLD | NEW |