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 "SkAndroidCodec.h" | 9 #include "SkAndroidCodec.h" |
10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 } | 1065 } |
1066 doc->endPage(); | 1066 doc->endPage(); |
1067 } | 1067 } |
1068 if (!doc->close()) { | 1068 if (!doc->close()) { |
1069 return "SkDocument::close() returned false"; | 1069 return "SkDocument::close() returned false"; |
1070 } | 1070 } |
1071 dst->flush(); | 1071 dst->flush(); |
1072 return ""; | 1072 return ""; |
1073 } | 1073 } |
1074 | 1074 |
1075 PDFSink::PDFSink(const char* rasterizer) : fRasterizer(rasterizer) {} | |
1076 | |
1077 Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ | 1075 Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ |
1078 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(dst)); | 1076 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(dst)); |
1079 if (!doc) { | 1077 if (!doc) { |
1080 return "SkDocument::CreatePDF() returned nullptr"; | 1078 return "SkDocument::CreatePDF() returned nullptr"; |
1081 } | 1079 } |
1082 SkTArray<SkDocument::Attribute> info; | 1080 SkTArray<SkDocument::Attribute> info; |
1083 info.emplace_back(SkString("Title"), src.name()); | 1081 info.emplace_back(SkString("Title"), src.name()); |
1084 info.emplace_back(SkString("Subject"), | 1082 info.emplace_back(SkString("Subject"), |
1085 SkString("rendering correctness test")); | 1083 SkString("rendering correctness test")); |
1086 info.emplace_back(SkString("Creator"), SkString("Skia/DM")); | 1084 info.emplace_back(SkString("Creator"), SkString("Skia/DM")); |
1087 | |
1088 info.emplace_back(SkString("Keywords"), | |
1089 SkStringPrintf("Rasterizer:%s;", fRasterizer)); | |
1090 doc->setMetadata(&info[0], info.count(), nullptr, nullptr); | 1085 doc->setMetadata(&info[0], info.count(), nullptr, nullptr); |
1091 return draw_skdocument(src, doc.get(), dst); | 1086 return draw_skdocument(src, doc.get(), dst); |
1092 } | 1087 } |
1093 | 1088 |
1094 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 1089 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
1095 | 1090 |
1096 XPSSink::XPSSink() {} | 1091 XPSSink::XPSSink() {} |
1097 | 1092 |
1098 Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ | 1093 Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
{ |
1099 SkAutoTUnref<SkDocument> doc(SkDocument::CreateXPS(dst)); | 1094 SkAutoTUnref<SkDocument> doc(SkDocument::CreateXPS(dst)); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 skr.visit(i, drawsAsSingletonPictures); | 1504 skr.visit(i, drawsAsSingletonPictures); |
1510 } | 1505 } |
1511 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); | 1506 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); |
1512 | 1507 |
1513 canvas->drawPicture(macroPic); | 1508 canvas->drawPicture(macroPic); |
1514 return check_against_reference(bitmap, src, fSink); | 1509 return check_against_reference(bitmap, src, fSink); |
1515 }); | 1510 }); |
1516 } | 1511 } |
1517 | 1512 |
1518 } // namespace DM | 1513 } // namespace DM |
OLD | NEW |