SkDocument: remove use of SkTArray (part 1/3).

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1689683002

Review URL: https://codereview.chromium.org/1689683002
This commit is contained in:
halcanary 2016-02-11 07:59:59 -08:00 committed by Commit bot
parent db6a254bdc
commit 7001576c71
4 changed files with 16 additions and 7 deletions

View File

@ -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);
}

View File

@ -131,7 +131,7 @@ public:
* nullptr. For example:
*
* SkDocument* make_doc(SkWStream* output) {
* SkTArray<SkDocument::Attribute> info;
* std::vector<SkDocument::Attribute> 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<SkDocument::Attribute>&,
virtual void setMetadata(const SkDocument::Attribute[],
int /* attributeCount */,
const SkTime::DateTime* /* creationDate */,
const SkTime::DateTime* /* modifiedDate */) {}
// This version is deprecated.
void setMetadata(const SkTArray<SkDocument::Attribute>& att,
const SkTime::DateTime* creation,
const SkTime::DateTime* modified) {
this->setMetadata(&att[0], att.count(), creation, modified);
}
protected:
SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted));

View File

@ -370,10 +370,11 @@ protected:
fCanon.reset();
}
void setMetadata(const SkTArray<SkDocument::Attribute>& 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));
}

View File

@ -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<SkData> data(pdf.copyToData());