aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-08 09:09:10 +0000
committerGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-08 09:09:10 +0000
commitb58772f86659cfe0e8d9247fcee878dddd8fdad9 (patch)
tree78c54090d70af79ab206ef5137833c0703874203 /src/core
parent754a3eb73b796398062f09cc98eae224262a3bc8 (diff)
PDF: add support for named destinations.
Landing patchset 7 from https://codereview.appspot.com/7374052 for dml@google.com Review URL: https://codereview.chromium.org/12533009 git-svn-id: http://skia.googlecode.com/svn/trunk@8034 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkAnnotation.cpp42
-rw-r--r--src/core/SkDevice.cpp1
2 files changed, 36 insertions, 7 deletions
diff --git a/src/core/SkAnnotation.cpp b/src/core/SkAnnotation.cpp
index 5e4363e728..52fa9b79f2 100644
--- a/src/core/SkAnnotation.cpp
+++ b/src/core/SkAnnotation.cpp
@@ -8,6 +8,7 @@
#include "SkAnnotation.h"
#include "SkDataSet.h"
#include "SkFlattenableBuffers.h"
+#include "SkPoint.h"
#include "SkStream.h"
SkAnnotation::SkAnnotation(SkDataSet* data, uint32_t flags) {
@@ -42,23 +43,50 @@ const char* SkAnnotationKeys::URL_Key() {
return "SkAnnotationKey_URL";
};
+const char* SkAnnotationKeys::Define_Named_Dest_Key() {
+ return "SkAnnotationKey_Define_Named_Dest";
+};
+
+const char* SkAnnotationKeys::Link_Named_Dest_Key() {
+ return "SkAnnotationKey_Link_Named_Dest";
+};
+
///////////////////////////////////////////////////////////////////////////////
#include "SkCanvas.h"
-void SkAnnotateRectWithURL(SkCanvas* canvas, const SkRect& rect, SkData* value) {
- if (NULL == value) {
- return;
- }
-
- const char* key = SkAnnotationKeys::URL_Key();
+static void annotate_paint(SkPaint& paint, const char* key, SkData* value) {
SkAutoTUnref<SkDataSet> dataset(SkNEW_ARGS(SkDataSet, (key, value)));
SkAnnotation* ann = SkNEW_ARGS(SkAnnotation, (dataset,
SkAnnotation::kNoDraw_Flag));
- SkPaint paint;
paint.setAnnotation(ann)->unref();
SkASSERT(paint.isNoDrawAnnotation());
+}
+void SkAnnotateRectWithURL(SkCanvas* canvas, const SkRect& rect, SkData* value) {
+ if (NULL == value) {
+ return;
+ }
+ SkPaint paint;
+ annotate_paint(paint, SkAnnotationKeys::URL_Key(), value);
+ canvas->drawRect(rect, paint);
+}
+
+void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) {
+ if (NULL == name) {
+ return;
+ }
+ SkPaint paint;
+ annotate_paint(paint, SkAnnotationKeys::Define_Named_Dest_Key(), name);
+ canvas->drawPoint(point.x(), point.y(), paint);
+}
+
+void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* name) {
+ if (NULL == name) {
+ return;
+ }
+ SkPaint paint;
+ annotate_paint(paint, SkAnnotationKeys::Link_Named_Dest_Key(), name);
canvas->drawRect(rect, paint);
}
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index 78ce0f635d..90d41862de 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -348,6 +348,7 @@ void SkDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
void SkDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint) {
+ CHECK_FOR_NODRAW_ANNOTATION(paint);
draw.drawPoints(mode, count, pts, paint);
}