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 | 8 |
9 #include "SkDrawCommand.h" | 9 #include "SkDrawCommand.h" |
10 | 10 |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 } | 719 } |
720 const char* name = jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME].asCString()
; | 720 const char* name = jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME].asCString()
; |
721 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name); | 721 SkFlattenable::Factory factory = SkFlattenable::NameToFactory(name); |
722 if (factory == nullptr) { | 722 if (factory == nullptr) { |
723 SkDebugf("no factory for loading '%s'\n", name); | 723 SkDebugf("no factory for loading '%s'\n", name); |
724 return nullptr; | 724 return nullptr; |
725 } | 725 } |
726 const void* data; | 726 const void* data; |
727 int size = decode_data(jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA], urlDat
aManager, &data); | 727 int size = decode_data(jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA], urlDat
aManager, &data); |
728 SkValidatingReadBuffer buffer(data, size); | 728 SkValidatingReadBuffer buffer(data, size); |
729 SkFlattenable* result = factory(buffer); | 729 sk_sp<SkFlattenable> result = factory(buffer); |
730 if (!buffer.isValid()) { | 730 if (!buffer.isValid()) { |
731 SkDebugf("invalid buffer loading flattenable\n"); | 731 SkDebugf("invalid buffer loading flattenable\n"); |
732 return nullptr; | 732 return nullptr; |
733 } | 733 } |
734 return result; | 734 return result.release(); |
735 } | 735 } |
736 | 736 |
737 static SkColorType colortype_from_name(const char* name) { | 737 static SkColorType colortype_from_name(const char* name) { |
738 if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_ARGB4444)) { | 738 if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_ARGB4444)) { |
739 return kARGB_4444_SkColorType; | 739 return kARGB_4444_SkColorType; |
740 } | 740 } |
741 else if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_RGBA8888)) { | 741 else if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_RGBA8888)) { |
742 return kRGBA_8888_SkColorType; | 742 return kRGBA_8888_SkColorType; |
743 } | 743 } |
744 else if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_BGRA8888)) { | 744 else if (!strcmp(name, SKDEBUGCANVAS_COLORTYPE_BGRA8888)) { |
(...skipping 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); | 3127 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
3128 return result; | 3128 return result; |
3129 } | 3129 } |
3130 | 3130 |
3131 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3131 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
3132 UrlDataManager& urlDataManager)
{ | 3132 UrlDataManager& urlDataManager)
{ |
3133 SkMatrix matrix; | 3133 SkMatrix matrix; |
3134 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3134 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
3135 return new SkSetMatrixCommand(matrix); | 3135 return new SkSetMatrixCommand(matrix); |
3136 } | 3136 } |
OLD | NEW |