Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1916093002: SkDocument/PDF: new API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-04-25 (Monday) 14:51:30 EDT Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 doc->endPage(); 1108 doc->endPage();
1109 } 1109 }
1110 if (!doc->close()) { 1110 if (!doc->close()) {
1111 return "SkDocument::close() returned false"; 1111 return "SkDocument::close() returned false";
1112 } 1112 }
1113 dst->flush(); 1113 dst->flush();
1114 return ""; 1114 return "";
1115 } 1115 }
1116 1116
1117 Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { 1117 Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
1118 SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(dst)); 1118 SkDocument::PDFMetadata metadata;
1119 metadata.title = src.name();
1120 metadata.subject = "rendering correctness test";
1121 metadata.creator = "Skia/DM";
1122 sk_sp<SkDocument> doc = SkDocument::MakePDF(
1123 dst,
1124 SK_ScalarDefaultRasterDPI,
1125 metadata,
1126 nullptr,
1127 fPDFA);
1119 if (!doc) { 1128 if (!doc) {
1120 return "SkDocument::CreatePDF() returned nullptr"; 1129 return "SkDocument::MakePDF() returned nullptr";
1121 } 1130 }
1122 SkTArray<SkDocument::Attribute> info;
1123 info.emplace_back(SkString("Title"), src.name());
1124 info.emplace_back(SkString("Subject"),
1125 SkString("rendering correctness test"));
1126 info.emplace_back(SkString("Creator"), SkString("Skia/DM"));
1127 doc->setMetadata(&info[0], info.count(), nullptr, nullptr);
1128 return draw_skdocument(src, doc.get(), dst); 1131 return draw_skdocument(src, doc.get(), dst);
1129 } 1132 }
1130 1133
1131 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1134 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1132 1135
1133 XPSSink::XPSSink() {} 1136 XPSSink::XPSSink() {}
1134 1137
1135 Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { 1138 Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
1136 SkAutoTUnref<SkDocument> doc(SkDocument::CreateXPS(dst)); 1139 SkAutoTUnref<SkDocument> doc(SkDocument::CreateXPS(dst));
1137 if (!doc) { 1140 if (!doc) {
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 skr.visit(i, drawsAsSingletonPictures); 1502 skr.visit(i, drawsAsSingletonPictures);
1500 } 1503 }
1501 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); 1504 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1502 1505
1503 canvas->drawPicture(macroPic); 1506 canvas->drawPicture(macroPic);
1504 return check_against_reference(bitmap, src, fSink); 1507 return check_against_reference(bitmap, src, fSink);
1505 }); 1508 });
1506 } 1509 }
1507 1510
1508 } // namespace DM 1511 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | gyp/common_variables.gypi » ('j') | include/core/SkDocument.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698