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

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-26 (Tuesday) 15:55:33 EDT Created 4 years, 8 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
« no previous file with comments | « dm/DMSrcSink.h ('k') | gyp/common_variables.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.fTitle = src.name();
1120 metadata.fSubject = "rendering correctness test";
1121 metadata.fCreator = "Skia/DM";
1122 sk_sp<SkDocument> doc = SkDocument::MakePDF(dst, SK_ScalarDefaultRasterDPI,
1123 metadata, nullptr, fPDFA);
1119 if (!doc) { 1124 if (!doc) {
1120 return "SkDocument::CreatePDF() returned nullptr"; 1125 return "SkDocument::MakePDF() returned nullptr";
1121 } 1126 }
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); 1127 return draw_skdocument(src, doc.get(), dst);
1129 } 1128 }
1130 1129
1131 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1130 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1132 1131
1133 XPSSink::XPSSink() {} 1132 XPSSink::XPSSink() {}
1134 1133
1135 Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { 1134 Error XPSSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
1136 SkAutoTUnref<SkDocument> doc(SkDocument::CreateXPS(dst)); 1135 sk_sp<SkDocument> doc(SkDocument::MakeXPS(dst));
1137 if (!doc) { 1136 if (!doc) {
1138 return "SkDocument::CreateXPS() returned nullptr"; 1137 return "SkDocument::MakeXPS() returned nullptr";
1139 } 1138 }
1140 return draw_skdocument(src, doc.get(), dst); 1139 return draw_skdocument(src, doc.get(), dst);
1141 } 1140 }
1142 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 1141 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
1143 1142
1144 SKPSink::SKPSink() {} 1143 SKPSink::SKPSink() {}
1145 1144
1146 Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const { 1145 Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const {
1147 SkSize size; 1146 SkSize size;
1148 size = src.size(); 1147 size = src.size();
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 skr.visit(i, drawsAsSingletonPictures); 1498 skr.visit(i, drawsAsSingletonPictures);
1500 } 1499 }
1501 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture()); 1500 sk_sp<SkPicture> macroPic(macroRec.finishRecordingAsPicture());
1502 1501
1503 canvas->drawPicture(macroPic); 1502 canvas->drawPicture(macroPic);
1504 return check_against_reference(bitmap, src, fSink); 1503 return check_against_reference(bitmap, src, fSink);
1505 }); 1504 });
1506 } 1505 }
1507 1506
1508 } // namespace DM 1507 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMSrcSink.h ('k') | gyp/common_variables.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698