| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "DMSrcSink.h" | 8 #include "DMSrcSink.h" |
| 9 #include "Resources.h" | 9 #include "Resources.h" |
| 10 #include "SkAndroidCodec.h" | 10 #include "SkAndroidCodec.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "SkOSFile.h" | 27 #include "SkOSFile.h" |
| 28 #include "SkOpts.h" | 28 #include "SkOpts.h" |
| 29 #include "SkPictureData.h" | 29 #include "SkPictureData.h" |
| 30 #include "SkPictureRecorder.h" | 30 #include "SkPictureRecorder.h" |
| 31 #include "SkRandom.h" | 31 #include "SkRandom.h" |
| 32 #include "SkRecordDraw.h" | 32 #include "SkRecordDraw.h" |
| 33 #include "SkRecorder.h" | 33 #include "SkRecorder.h" |
| 34 #include "SkSVGCanvas.h" | 34 #include "SkSVGCanvas.h" |
| 35 #include "SkStream.h" | 35 #include "SkStream.h" |
| 36 #include "SkTLogic.h" | 36 #include "SkTLogic.h" |
| 37 #include "SkSVGDOM.h" |
| 37 #include "SkSwizzler.h" | 38 #include "SkSwizzler.h" |
| 38 #include <functional> | 39 #include <functional> |
| 39 | 40 |
| 40 #if defined(SK_BUILD_FOR_WIN) | 41 #if defined(SK_BUILD_FOR_WIN) |
| 41 #include "SkAutoCoInitialize.h" | 42 #include "SkAutoCoInitialize.h" |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 #if defined(SK_TEST_QCMS) | 45 #if defined(SK_TEST_QCMS) |
| 45 #include "qcms.h" | 46 #include "qcms.h" |
| 46 #endif | 47 #endif |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 SkRect viewport = kSKPViewport; | 1004 SkRect viewport = kSKPViewport; |
| 1004 if (!viewport.intersect(info.fCullRect)) { | 1005 if (!viewport.intersect(info.fCullRect)) { |
| 1005 return SkISize::Make(0,0); | 1006 return SkISize::Make(0,0); |
| 1006 } | 1007 } |
| 1007 return viewport.roundOut().size(); | 1008 return viewport.roundOut().size(); |
| 1008 } | 1009 } |
| 1009 | 1010 |
| 1010 Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); } | 1011 Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); } |
| 1011 | 1012 |
| 1012 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 1013 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 1014 #if defined(SK_XML) |
| 1015 // Should we try to use the SVG intrinsic size instead? |
| 1016 static const SkSize kSVGSize = SkSize::Make(1000, 1000); |
| 1017 |
| 1018 SVGSrc::SVGSrc(Path path) : fPath(path) {} |
| 1019 |
| 1020 Error SVGSrc::draw(SkCanvas* canvas) const { |
| 1021 SkFILEStream stream(fPath.c_str()); |
| 1022 if (!stream.isValid()) { |
| 1023 return SkStringPrintf("Unable to open file: %s", fPath.c_str()); |
| 1024 } |
| 1025 |
| 1026 sk_sp<SkSVGDOM> dom = SkSVGDOM::MakeFromStream(stream, kSVGSize); |
| 1027 if (!dom) { |
| 1028 return SkStringPrintf("Unable to parse file: %s", fPath.c_str()); |
| 1029 } |
| 1030 |
| 1031 dom->render(canvas); |
| 1032 |
| 1033 return ""; |
| 1034 } |
| 1035 |
| 1036 SkISize SVGSrc::size() const { |
| 1037 return kSVGSize.toRound(); |
| 1038 } |
| 1039 |
| 1040 Name SVGSrc::name() const { return SkOSPath::Basename(fPath.c_str()); } |
| 1041 |
| 1042 #endif // defined(SK_XML) |
| 1043 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 1013 | 1044 |
| 1014 MSKPSrc::MSKPSrc(Path path) : fPath(path) { | 1045 MSKPSrc::MSKPSrc(Path path) : fPath(path) { |
| 1015 std::unique_ptr<SkStreamAsset> stream(SkStream::NewFromFile(fPath.c_str())); | 1046 std::unique_ptr<SkStreamAsset> stream(SkStream::NewFromFile(fPath.c_str())); |
| 1016 (void)fReader.init(stream.get()); | 1047 (void)fReader.init(stream.get()); |
| 1017 } | 1048 } |
| 1018 | 1049 |
| 1019 int MSKPSrc::pageCount() const { return fReader.pageCount(); } | 1050 int MSKPSrc::pageCount() const { return fReader.pageCount(); } |
| 1020 | 1051 |
| 1021 SkISize MSKPSrc::size() const { return this->size(0); } | 1052 SkISize MSKPSrc::size() const { return this->size(0); } |
| 1022 SkISize MSKPSrc::size(int i) const { return fReader.pageSize(i).toCeil(); } | 1053 SkISize MSKPSrc::size(int i) const { return fReader.pageSize(i).toCeil(); } |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 skr.visit(i, drawsAsSingletonPictures); | 1588 skr.visit(i, drawsAsSingletonPictures); |
| 1558 } | 1589 } |
| 1559 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); | 1590 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); |
| 1560 | 1591 |
| 1561 canvas->drawPicture(macroPic); | 1592 canvas->drawPicture(macroPic); |
| 1562 return check_against_reference(bitmap, src, fSink); | 1593 return check_against_reference(bitmap, src, fSink); |
| 1563 }); | 1594 }); |
| 1564 } | 1595 } |
| 1565 | 1596 |
| 1566 } // namespace DM | 1597 } // namespace DM |
| OLD | NEW |