| Index: src/pdf/SkPDFDevice.cpp
|
| diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
|
| index f473e0f9813010dc8fe88245a3b689782d5bf62d..315c84317d72c42abc3da60b7e388d463b3a9c22 100644
|
| --- a/src/pdf/SkPDFDevice.cpp
|
| +++ b/src/pdf/SkPDFDevice.cpp
|
| @@ -7,7 +7,7 @@
|
|
|
| #include "SkPDFDevice.h"
|
|
|
| -#include "SkAnnotationKeys.h"
|
| +#include "SkAnnotation.h"
|
| #include "SkColor.h"
|
| #include "SkColorFilter.h"
|
| #include "SkClipStack.h"
|
| @@ -757,17 +757,6 @@
|
| }
|
| }
|
|
|
| -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);
|
| @@ -805,6 +794,12 @@
|
|
|
| if (count == 0) {
|
| return;
|
| + }
|
| +
|
| + if (SkAnnotation* annotation = passedPaint.getAnnotation()) {
|
| + if (handlePointAnnotation(points, count, *d.fMatrix, annotation)) {
|
| + return;
|
| + }
|
| }
|
|
|
| // SkDraw::drawPoints converts to multiple calls to fDevice->drawPath.
|
| @@ -944,6 +939,14 @@
|
| 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;
|
| @@ -1020,6 +1023,12 @@
|
|
|
| if (handleInversePath(d, origPath, paint, pathIsMutable, prePathMatrix)) {
|
| return;
|
| + }
|
| +
|
| + if (SkAnnotation* annotation = paint.getAnnotation()) {
|
| + if (handlePathAnnotation(*pathPtr, d, annotation)) {
|
| + return;
|
| + }
|
| }
|
|
|
| ScopedContentEntry content(this, d.fClipStack, *d.fClip, matrix, paint);
|
| @@ -1675,26 +1684,26 @@
|
| return true;
|
| }
|
|
|
| -void SkPDFDevice::handlePointAnnotation(const SkPoint& point,
|
| +bool SkPDFDevice::handlePointAnnotation(const SkPoint* points, size_t count,
|
| const SkMatrix& matrix,
|
| - 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));
|
| - }
|
| -}
|
| -
|
| -void SkPDFDevice::handlePathAnnotation(const SkPath& path,
|
| + 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;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +bool SkPDFDevice::handlePathAnnotation(const SkPath& path,
|
| const SkDraw& d,
|
| - const char key[], SkData* value) {
|
| - if (!value) {
|
| - return;
|
| - }
|
| + SkAnnotation* annotation) {
|
| + SkASSERT(annotation);
|
|
|
| SkPath transformedPath = path;
|
| transformedPath.transform(*d.fMatrix);
|
| @@ -1703,15 +1712,24 @@
|
| false);
|
| SkRect transformedRect = SkRect::Make(clip.getBounds());
|
|
|
| - if (!strcmp(SkAnnotationKeys::URL_Key(), key)) {
|
| + SkData* urlData = annotation->find(SkAnnotationKeys::URL_Key());
|
| + if (urlData) {
|
| if (!transformedRect.isEmpty()) {
|
| - fLinkToURLs.push(new RectWithData(transformedRect, value));
|
| - }
|
| - } else if (!strcmp(SkAnnotationKeys::Link_Named_Dest_Key(), key)) {
|
| + fLinkToURLs.push(new RectWithData(transformedRect, urlData));
|
| + }
|
| + return true;
|
| + }
|
| +
|
| + SkData* linkToDestination =
|
| + annotation->find(SkAnnotationKeys::Link_Named_Dest_Key());
|
| + if (linkToDestination) {
|
| if (!transformedRect.isEmpty()) {
|
| - fLinkToDestinations.push(new RectWithData(transformedRect, value));
|
| - }
|
| - }
|
| + fLinkToDestinations.push(new RectWithData(transformedRect, linkToDestination));
|
| + }
|
| + return true;
|
| + }
|
| +
|
| + return false;
|
| }
|
|
|
| void SkPDFDevice::appendAnnotations(SkPDFArray* array) const {
|
|
|