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

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 1103163002: SkPDF: clean up uses of deprecated calls in SkPDFDevice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« src/pdf/SkPDFDevice.h ('K') | « src/pdf/SkPDFDevice.h ('k') | no next file » | 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 40a4576cb6997a8e2f4a703186776bbb1c25352b..88f9b810b608e5508ac0747c41b6b592377bbf1e 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1464,26 +1464,30 @@ bool SkPDFDevice::handlePointAnnotation(const SkPoint* points, size_t count,
return false;
}
-SkPDFDict* SkPDFDevice::createLinkAnnotation(const SkRect& r,
- const SkMatrix& matrix) {
+void SkPDFDevice::addAnnotation(SkPDFDict* annotation) {
+ if (NULL == fAnnotations) {
+ fAnnotations = SkNEW(SkPDFArray);
+ }
+ fAnnotations->appendObject(annotation);
+}
+
+static SkPDFDict* create_link_annotation(const SkRect& r,
+ const SkMatrix& initialTransform,
+ const SkMatrix& matrix) {
SkMatrix transform = matrix;
- transform.postConcat(fInitialTransform);
+ transform.postConcat(initialTransform);
SkRect translatedRect;
transform.mapRect(&translatedRect, r);
- if (NULL == fAnnotations) {
- fAnnotations = SkNEW(SkPDFArray);
- }
- SkPDFDict* annotation(SkNEW_ARGS(SkPDFDict, ("Annot")));
+ SkAutoTUnref<SkPDFDict> annotation(SkNEW_ARGS(SkPDFDict, ("Annot")));
annotation->insertName("Subtype", "Link");
- fAnnotations->append(annotation);
SkAutoTUnref<SkPDFArray> border(SkNEW(SkPDFArray));
border->reserve(3);
border->appendInt(0); // Horizontal corner radius.
border->appendInt(0); // Vertical corner radius.
border->appendInt(0); // Width, 0 = no border.
- annotation->insert("Border", border.get());
+ annotation->insertObject("Border", border.detach());
SkAutoTUnref<SkPDFArray> rect(SkNEW(SkPDFArray));
rect->reserve(4);
@@ -1491,29 +1495,33 @@ SkPDFDict* SkPDFDevice::createLinkAnnotation(const SkRect& r,
rect->appendScalar(translatedRect.fTop);
rect->appendScalar(translatedRect.fRight);
rect->appendScalar(translatedRect.fBottom);
- annotation->insert("Rect", rect.get());
+ annotation->insertObject("Rect", rect.detach());
- return annotation;
+ return annotation.detach();
}
void SkPDFDevice::handleLinkToURL(SkData* urlData, const SkRect& r,
const SkMatrix& matrix) {
- SkAutoTUnref<SkPDFDict> annotation(createLinkAnnotation(r, matrix));
+ SkAutoTUnref<SkPDFDict> annotation(
+ create_link_annotation(r, fInitialTransform, matrix));
SkString url(static_cast<const char *>(urlData->data()),
urlData->size() - 1);
SkAutoTUnref<SkPDFDict> action(SkNEW_ARGS(SkPDFDict, ("Action")));
action->insertName("S", "URI");
action->insertString("URI", url);
- annotation->insert("A", action.get());
+ annotation->insertObject("A", action.detach());
+ this->addAnnotation(annotation.detach());
}
void SkPDFDevice::handleLinkToNamedDest(SkData* nameData, const SkRect& r,
const SkMatrix& matrix) {
- SkAutoTUnref<SkPDFDict> annotation(createLinkAnnotation(r, matrix));
+ SkAutoTUnref<SkPDFDict> annotation(
+ create_link_annotation(r, fInitialTransform, matrix));
SkString name(static_cast<const char *>(nameData->data()),
nameData->size() - 1);
annotation->insertName("Dest", name);
+ this->addAnnotation(annotation.detach());
}
struct NamedDestination {
« src/pdf/SkPDFDevice.h ('K') | « src/pdf/SkPDFDevice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698