diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 9a62362010..0e2d307264 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -979,7 +979,7 @@ Error PDFSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const info.emplace_back(SkString("Keywords"), SkStringPrintf("Rasterizer:%s;", fRasterizer)); - doc->setMetadata(info, nullptr, nullptr); + doc->setMetadata(&info[0], info.count(), nullptr, nullptr); return draw_skdocument(src, doc.get(), dst); } diff --git a/include/core/SkDocument.h b/include/core/SkDocument.h index 6ee96b9ce3..9e1de8ae4e 100644 --- a/include/core/SkDocument.h +++ b/include/core/SkDocument.h @@ -131,7 +131,7 @@ public: * nullptr. For example: * * SkDocument* make_doc(SkWStream* output) { - * SkTArray info; + * std::vector info; * info.emplace_back(SkString("Title"), SkString("...")); * info.emplace_back(SkString("Author"), SkString("...")); * info.emplace_back(SkString("Subject"), SkString("...")); @@ -140,7 +140,7 @@ public: * SkTime::DateTime now; * SkTime::GetDateTime(&now); * SkDocument* doc = SkDocument::CreatePDF(output); - * doc->setMetadata(info, &now, &now); + * doc->setMetadata(&info[0], (int)info.size(), &now, &now); * return doc; * } */ @@ -148,10 +148,18 @@ public: SkString fKey, fValue; Attribute(const SkString& k, const SkString& v) : fKey(k), fValue(v) {} }; - virtual void setMetadata(const SkTArray&, + virtual void setMetadata(const SkDocument::Attribute[], + int /* attributeCount */, const SkTime::DateTime* /* creationDate */, const SkTime::DateTime* /* modifiedDate */) {} + // This version is deprecated. + void setMetadata(const SkTArray& att, + const SkTime::DateTime* creation, + const SkTime::DateTime* modified) { + this->setMetadata(&att[0], att.count(), creation, modified); + } + protected: SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted)); diff --git a/src/doc/SkDocument_PDF.cpp b/src/doc/SkDocument_PDF.cpp index fb560ea1e3..a56de707fe 100644 --- a/src/doc/SkDocument_PDF.cpp +++ b/src/doc/SkDocument_PDF.cpp @@ -370,10 +370,11 @@ protected: fCanon.reset(); } - void setMetadata(const SkTArray& info, + void setMetadata(const SkDocument::Attribute info[], + int infoCount, const SkTime::DateTime* creationDate, const SkTime::DateTime* modifiedDate) override { - fMetadata.fInfo = info; + fMetadata.fInfo.reset(info, infoCount); fMetadata.fCreation.reset(clone(creationDate)); fMetadata.fModified.reset(clone(modifiedDate)); } diff --git a/tests/PDFMetadataAttributeTest.cpp b/tests/PDFMetadataAttributeTest.cpp index e58146ba2b..e436ee29ef 100644 --- a/tests/PDFMetadataAttributeTest.cpp +++ b/tests/PDFMetadataAttributeTest.cpp @@ -21,7 +21,7 @@ DEF_TEST(SkPDF_MetadataAttribute, r) { info.emplace_back(SkString("Creator"), SkString("A5")); SkTime::DateTime now; SkTime::GetDateTime(&now); - doc->setMetadata(info, &now, &now); + doc->setMetadata(&info[0], info.count(), &now, &now); doc->beginPage(612.0f, 792.0f); doc->close(); SkAutoTUnref data(pdf.copyToData());