Index: src/pdf/SkPDFDevice.cpp |
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp |
index 315c84317d72c42abc3da60b7e388d463b3a9c22..f473e0f9813010dc8fe88245a3b689782d5bf62d 100644 |
--- a/src/pdf/SkPDFDevice.cpp |
+++ b/src/pdf/SkPDFDevice.cpp |
@@ -7,7 +7,7 @@ |
#include "SkPDFDevice.h" |
-#include "SkAnnotation.h" |
+#include "SkAnnotationKeys.h" |
#include "SkColor.h" |
#include "SkColorFilter.h" |
#include "SkClipStack.h" |
@@ -757,6 +757,17 @@ void SkPDFDevice::cleanUp(bool clearFontUsage) { |
} |
} |
+void SkPDFDevice::drawAnnotation(const SkDraw& d, const SkRect& rect, const char key[], |
+ SkData* value) { |
+ if (0 == rect.width() && 0 == rect.height()) { |
+ handlePointAnnotation({ rect.x(), rect.y() }, *d.fMatrix, key, value); |
+ } else { |
+ SkPath path; |
+ path.addRect(rect); |
+ handlePathAnnotation(path, d, key, value); |
+ } |
+} |
+ |
void SkPDFDevice::drawPaint(const SkDraw& d, const SkPaint& paint) { |
SkPaint newPaint = paint; |
replace_srcmode_on_opaque_paint(&newPaint); |
@@ -796,12 +807,6 @@ void SkPDFDevice::drawPoints(const SkDraw& d, |
return; |
} |
- if (SkAnnotation* annotation = passedPaint.getAnnotation()) { |
- if (handlePointAnnotation(points, count, *d.fMatrix, annotation)) { |
- return; |
- } |
- } |
- |
// SkDraw::drawPoints converts to multiple calls to fDevice->drawPath. |
// We only use this when there's a path effect because of the overhead |
// of multiple calls to setUpContentEntry it causes. |
@@ -939,14 +944,6 @@ void SkPDFDevice::drawRect(const SkDraw& d, |
return; |
} |
- if (SkAnnotation* annotation = paint.getAnnotation()) { |
- SkPath path; |
- path.addRect(rect); |
- if (handlePathAnnotation(path, d, annotation)) { |
- return; |
- } |
- } |
- |
ScopedContentEntry content(this, d, paint); |
if (!content.entry()) { |
return; |
@@ -1025,12 +1022,6 @@ void SkPDFDevice::drawPath(const SkDraw& d, |
return; |
} |
- if (SkAnnotation* annotation = paint.getAnnotation()) { |
- if (handlePathAnnotation(*pathPtr, d, annotation)) { |
- return; |
- } |
- } |
- |
ScopedContentEntry content(this, d.fClipStack, *d.fClip, matrix, paint); |
if (!content.entry()) { |
return; |
@@ -1684,26 +1675,26 @@ bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath, |
return true; |
} |
-bool SkPDFDevice::handlePointAnnotation(const SkPoint* points, size_t count, |
+void SkPDFDevice::handlePointAnnotation(const SkPoint& point, |
const SkMatrix& matrix, |
- SkAnnotation* annotationInfo) { |
- SkData* nameData = annotationInfo->find( |
- SkAnnotationKeys::Define_Named_Dest_Key()); |
- if (nameData) { |
- for (size_t i = 0; i < count; i++) { |
- SkPoint transformedPoint; |
- matrix.mapXY(points[i].x(), points[i].y(), &transformedPoint); |
- fNamedDestinations.push(new NamedDestination(nameData, transformedPoint)); |
- } |
- return true; |
+ const char key[], SkData* value) { |
+ if (!value) { |
+ return; |
+ } |
+ |
+ if (!strcmp(SkAnnotationKeys::Define_Named_Dest_Key(), key)) { |
+ SkPoint transformedPoint; |
+ matrix.mapXY(point.x(), point.y(), &transformedPoint); |
+ fNamedDestinations.push(new NamedDestination(value, transformedPoint)); |
} |
- return false; |
} |
-bool SkPDFDevice::handlePathAnnotation(const SkPath& path, |
+void SkPDFDevice::handlePathAnnotation(const SkPath& path, |
const SkDraw& d, |
- SkAnnotation* annotation) { |
- SkASSERT(annotation); |
+ const char key[], SkData* value) { |
+ if (!value) { |
+ return; |
+ } |
SkPath transformedPath = path; |
transformedPath.transform(*d.fMatrix); |
@@ -1712,24 +1703,15 @@ bool SkPDFDevice::handlePathAnnotation(const SkPath& path, |
false); |
SkRect transformedRect = SkRect::Make(clip.getBounds()); |
- SkData* urlData = annotation->find(SkAnnotationKeys::URL_Key()); |
- if (urlData) { |
+ if (!strcmp(SkAnnotationKeys::URL_Key(), key)) { |
if (!transformedRect.isEmpty()) { |
- fLinkToURLs.push(new RectWithData(transformedRect, urlData)); |
+ fLinkToURLs.push(new RectWithData(transformedRect, value)); |
} |
- return true; |
- } |
- |
- SkData* linkToDestination = |
- annotation->find(SkAnnotationKeys::Link_Named_Dest_Key()); |
- if (linkToDestination) { |
+ } else if (!strcmp(SkAnnotationKeys::Link_Named_Dest_Key(), key)) { |
if (!transformedRect.isEmpty()) { |
- fLinkToDestinations.push(new RectWithData(transformedRect, linkToDestination)); |
+ fLinkToDestinations.push(new RectWithData(transformedRect, value)); |
} |
- return true; |
} |
- |
- return false; |
} |
void SkPDFDevice::appendAnnotations(SkPDFArray* array) const { |