Chromium Code Reviews| 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 |
| 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 "SkJsonWriteBuffer.h" | |
| 15 #include "SkMaskFilter.h" | 16 #include "SkMaskFilter.h" |
| 16 #include "SkObjectParser.h" | 17 #include "SkObjectParser.h" |
| 17 #include "SkPaintDefaults.h" | 18 #include "SkPaintDefaults.h" |
| 18 #include "SkPathEffect.h" | 19 #include "SkPathEffect.h" |
| 19 #include "SkPicture.h" | 20 #include "SkPicture.h" |
| 20 #include "SkTextBlob.h" | 21 #include "SkTextBlob.h" |
| 21 #include "SkTextBlobRunIterator.h" | 22 #include "SkTextBlobRunIterator.h" |
| 22 #include "SkTHash.h" | 23 #include "SkTHash.h" |
| 23 #include "SkTypeface.h" | 24 #include "SkTypeface.h" |
| 24 #include "SkValidatingReadBuffer.h" | 25 #include "SkValidatingReadBuffer.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize" | 57 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSIZE "textSize" |
| 57 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX" | 58 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX "textScaleX" |
| 58 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX" | 59 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTSKEWX "textSkewX" |
| 59 #define SKDEBUGCANVAS_ATTRIBUTE_DASHING "dashing" | 60 #define SKDEBUGCANVAS_ATTRIBUTE_DASHING "dashing" |
| 60 #define SKDEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals" | 61 #define SKDEBUGCANVAS_ATTRIBUTE_INTERVALS "intervals" |
| 61 #define SKDEBUGCANVAS_ATTRIBUTE_PHASE "phase" | 62 #define SKDEBUGCANVAS_ATTRIBUTE_PHASE "phase" |
| 62 #define SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType" | 63 #define SKDEBUGCANVAS_ATTRIBUTE_FILLTYPE "fillType" |
| 63 #define SKDEBUGCANVAS_ATTRIBUTE_VERBS "verbs" | 64 #define SKDEBUGCANVAS_ATTRIBUTE_VERBS "verbs" |
| 64 #define SKDEBUGCANVAS_ATTRIBUTE_NAME "name" | 65 #define SKDEBUGCANVAS_ATTRIBUTE_NAME "name" |
| 65 #define SKDEBUGCANVAS_ATTRIBUTE_DATA "data" | 66 #define SKDEBUGCANVAS_ATTRIBUTE_DATA "data" |
| 67 #define SKDEBUGCANVAS_ATTRIBUTE_VALUES "values" | |
|
Brian Osman
2016/04/28 14:22:33
This was previously "flattened", and I think Mike'
| |
| 66 #define SKDEBUGCANVAS_ATTRIBUTE_SHADER "shader" | 68 #define SKDEBUGCANVAS_ATTRIBUTE_SHADER "shader" |
| 67 #define SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect" | 69 #define SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT "pathEffect" |
| 68 #define SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter" | 70 #define SKDEBUGCANVAS_ATTRIBUTE_MASKFILTER "maskFilter" |
| 69 #define SKDEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode" | 71 #define SKDEBUGCANVAS_ATTRIBUTE_XFERMODE "xfermode" |
| 70 #define SKDEBUGCANVAS_ATTRIBUTE_LOOPER "looper" | 72 #define SKDEBUGCANVAS_ATTRIBUTE_LOOPER "looper" |
| 71 #define SKDEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop" | 73 #define SKDEBUGCANVAS_ATTRIBUTE_BACKDROP "backdrop" |
| 72 #define SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter" | 74 #define SKDEBUGCANVAS_ATTRIBUTE_COLORFILTER "colorfilter" |
| 73 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter" | 75 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGEFILTER "imagefilter" |
| 74 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGE "image" | 76 #define SKDEBUGCANVAS_ATTRIBUTE_IMAGE "image" |
| 75 #define SKDEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap" | 77 #define SKDEBUGCANVAS_ATTRIBUTE_BITMAP "bitmap" |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 | 587 |
| 586 static void encode_data(const void* bytes, size_t count, const char* contentType , | 588 static void encode_data(const void* bytes, size_t count, const char* contentType , |
| 587 UrlDataManager& urlDataManager, Json::Value* target) { | 589 UrlDataManager& urlDataManager, Json::Value* target) { |
| 588 SkAutoTUnref<SkData> data(SkData::NewWithCopy(bytes, count)); | 590 SkAutoTUnref<SkData> data(SkData::NewWithCopy(bytes, count)); |
| 589 SkString url = urlDataManager.addData(data, contentType); | 591 SkString url = urlDataManager.addData(data, contentType); |
| 590 *target = Json::Value(url.c_str()); | 592 *target = Json::Value(url.c_str()); |
| 591 } | 593 } |
| 592 | 594 |
| 593 static void flatten(const SkFlattenable* flattenable, Json::Value* target, | 595 static void flatten(const SkFlattenable* flattenable, Json::Value* target, |
| 594 UrlDataManager& urlDataManager) { | 596 UrlDataManager& urlDataManager) { |
| 595 SkWriteBuffer buffer; | 597 SkBinaryWriteBuffer buffer; |
| 596 flattenable->flatten(buffer); | 598 flattenable->flatten(buffer); |
| 597 void* data = sk_malloc_throw(buffer.bytesWritten()); | 599 void* data = sk_malloc_throw(buffer.bytesWritten()); |
| 598 buffer.writeToMemory(data); | 600 buffer.writeToMemory(data); |
| 599 Json::Value jsonData; | 601 Json::Value jsonData; |
| 600 encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlData Manager, &jsonData); | 602 encode_data(data, buffer.bytesWritten(), "application/octet-stream", urlData Manager, &jsonData); |
| 601 Json::Value jsonFlattenable; | 603 Json::Value jsonFlattenable; |
| 602 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME] = Json::Value(flattenable->get TypeName()); | 604 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_NAME] = Json::Value(flattenable->get TypeName()); |
| 603 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData; | 605 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_DATA] = jsonData; |
| 606 | |
| 607 { | |
| 608 SkJsonWriteBuffer jsonBuffer(&urlDataManager); | |
| 609 flattenable->flatten(jsonBuffer); | |
| 610 jsonFlattenable[SKDEBUGCANVAS_ATTRIBUTE_VALUES] = jsonBuffer.getValue(); | |
| 611 } | |
| 612 | |
| 604 (*target) = jsonFlattenable; | 613 (*target) = jsonFlattenable; |
| 605 sk_free(data); | 614 sk_free(data); |
| 606 } | 615 } |
| 607 | 616 |
| 608 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l ength) { | 617 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l ength) { |
| 609 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); | 618 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); |
| 610 out->write(data, length); | 619 out->write(data, length); |
| 611 } | 620 } |
| 612 | 621 |
| 613 void SkDrawCommand::WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_3 2 height, | 622 void SkDrawCommand::WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_3 2 height, |
| (...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3127 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); | 3136 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); |
| 3128 return result; | 3137 return result; |
| 3129 } | 3138 } |
| 3130 | 3139 |
| 3131 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3140 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
| 3132 UrlDataManager& urlDataManager) { | 3141 UrlDataManager& urlDataManager) { |
| 3133 SkMatrix matrix; | 3142 SkMatrix matrix; |
| 3134 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3143 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
| 3135 return new SkSetMatrixCommand(matrix); | 3144 return new SkSetMatrixCommand(matrix); |
| 3136 } | 3145 } |
| OLD | NEW |