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

Unified Diff: src/core/SkAnnotation.cpp

Issue 12533009: PDF: add support for named destinations. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: attempt_to_fix_warnings_in_internal_links.cpp Created 7 years, 9 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 | « include/pdf/SkPDFDevice.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAnnotation.cpp
===================================================================
--- src/core/SkAnnotation.cpp (revision 8005)
+++ src/core/SkAnnotation.cpp (working copy)
@@ -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 @@
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);
+}
« no previous file with comments | « include/pdf/SkPDFDevice.h ('k') | src/core/SkDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698