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

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 1069103003: SkPDF: Refactor SkPDFObject heiararchy. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-04-25 (Saturday) 09:40:48 EDT Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/doc/SkDocument_PDF.cpp ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index b08bb174b1638ad477bc8b023d2e8f03f91766f5..40a4576cb6997a8e2f4a703186776bbb1c25352b 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1299,15 +1299,14 @@ const SkTDArray<SkPDFFont*>& SkPDFDevice::getFontResources() const {
SkPDFArray* SkPDFDevice::copyMediaBox() const {
// should this be a singleton?
- SkAutoTUnref<SkPDFInt> zero(SkNEW_ARGS(SkPDFInt, (0)));
- SkPDFArray* mediaBox = SkNEW(SkPDFArray);
+ SkAutoTUnref<SkPDFArray> mediaBox(SkNEW(SkPDFArray));
mediaBox->reserve(4);
- mediaBox->append(zero.get());
- mediaBox->append(zero.get());
+ mediaBox->appendInt(0);
+ mediaBox->appendInt(0);
mediaBox->appendInt(fPageSize.fWidth);
mediaBox->appendInt(fPageSize.fHeight);
- return mediaBox;
+ return mediaBox.detach();
}
SkStreamAsset* SkPDFDevice::content() const {
@@ -1505,7 +1504,7 @@ void SkPDFDevice::handleLinkToURL(SkData* urlData, const SkRect& r,
urlData->size() - 1);
SkAutoTUnref<SkPDFDict> action(SkNEW_ARGS(SkPDFDict, ("Action")));
action->insertName("S", "URI");
- action->insert("URI", SkNEW_ARGS(SkPDFString, (url)))->unref();
+ action->insertString("URI", url);
annotation->insert("A", action.get());
}
@@ -1514,7 +1513,7 @@ void SkPDFDevice::handleLinkToNamedDest(SkData* nameData, const SkRect& r,
SkAutoTUnref<SkPDFDict> annotation(createLinkAnnotation(r, matrix));
SkString name(static_cast<const char *>(nameData->data()),
nameData->size() - 1);
- annotation->insert("Dest", SkNEW_ARGS(SkPDFName, (name)))->unref();
+ annotation->insertName("Dest", name);
}
struct NamedDestination {
@@ -1522,9 +1521,7 @@ struct NamedDestination {
SkPoint point;
NamedDestination(const SkData* nameData, const SkPoint& point)
- : nameData(nameData), point(point) {
- nameData->ref();
- }
+ : nameData(SkRef(nameData)), point(point) {}
~NamedDestination() {
nameData->unref();
@@ -1547,13 +1544,13 @@ void SkPDFDevice::appendDestinations(SkPDFDict* dict, SkPDFObject* page) const {
NamedDestination* dest = fNamedDestinations[i];
SkAutoTUnref<SkPDFArray> pdfDest(SkNEW(SkPDFArray));
pdfDest->reserve(5);
- pdfDest->append(SkNEW_ARGS(SkPDFObjRef, (page)))->unref();
+ pdfDest->appendObjRef(SkRef(page));
pdfDest->appendName("XYZ");
pdfDest->appendScalar(dest->point.x());
pdfDest->appendScalar(dest->point.y());
pdfDest->appendInt(0); // Leave zoom unchanged
- dict->insert(static_cast<const char *>(dest->nameData->data()),
- pdfDest);
+ SkString name(static_cast<const char*>(dest->nameData->data()));
+ dict->insertObject(name, pdfDest.detach());
}
}
« no previous file with comments | « src/doc/SkDocument_PDF.cpp ('k') | src/pdf/SkPDFFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698