aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/core/SkAnnotation.h39
-rw-r--r--include/pdf/SkPDFDevice.h22
2 files changed, 59 insertions, 2 deletions
diff --git a/include/core/SkAnnotation.h b/include/core/SkAnnotation.h
index e1ecf6caf1..18ee1cd1a6 100644
--- a/include/core/SkAnnotation.h
+++ b/include/core/SkAnnotation.h
@@ -14,6 +14,7 @@ class SkData;
class SkDataSet;
class SkStream;
class SkWStream;
+struct SkPoint;
/**
* Experimental class for annotating draws. Do not use directly yet.
@@ -64,6 +65,18 @@ public:
* Returns the canonical key whose payload is a URL
*/
static const char* URL_Key();
+
+ /**
+ * Returns the canonical key whose payload is the name of a destination to
+ * be defined.
+ */
+ static const char* Define_Named_Dest_Key();
+
+ /**
+ * Returns the canonical key whose payload is the name of a destination to
+ * be linked to.
+ */
+ static const char* Link_Named_Dest_Key();
};
///////////////////////////////////////////////////////////////////////////////
@@ -86,4 +99,30 @@ class SkCanvas;
*/
SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*);
+/**
+ * Experimental!
+ *
+ * Annotate the canvas by associating a name with the specified point.
+ *
+ * If the backend of this canvas does not support annotations, this call is
+ * safely ignored.
+ *
+ * The caller is responsible for managing its ownership of the SkData.
+ */
+SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*);
+
+/**
+ * Experimental!
+ *
+ * Annotate the canvas by making the specified rectangle link to a named
+ * destination.
+ *
+ * If the backend of this canvas does not support annotations, this call is
+ * safely ignored.
+ *
+ * The caller is responsible for managing its ownership of the SkData.
+ */
+SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*);
+
+
#endif
diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h
index a13d6175c7..90379f9f6b 100644
--- a/include/pdf/SkPDFDevice.h
+++ b/include/pdf/SkPDFDevice.h
@@ -17,6 +17,7 @@
#include "SkRect.h"
#include "SkRefCnt.h"
#include "SkStream.h"
+#include "SkTDArray.h"
#include "SkTScopedPtr.h"
class SkPDFArray;
@@ -33,6 +34,7 @@ class SkPDFStream;
// Private classes.
struct ContentEntry;
struct GraphicStateEntry;
+struct NamedDestination;
/** \class SkPDFDevice
@@ -142,6 +144,12 @@ public:
*/
SK_API const SkTDArray<SkPDFFont*>& getFontResources() const;
+ /** Add our named destinations to the supplied dictionary.
+ * @param dict Dictionary to add destinations to.
+ * @param page The PDF object representing the page for this device.
+ */
+ void appendDestinations(SkPDFDict* dict, SkPDFObject* page);
+
/** Returns a copy of the media box for this device. The caller is required
* to unref() this when it is finished.
*/
@@ -191,6 +199,7 @@ private:
SkRegion fExistingClipRegion;
SkPDFArray* fAnnotations;
SkPDFDict* fResourceDict;
+ SkTDArray<NamedDestination*> fNamedDestinations;
SkTDArray<SkPDFGraphicState*> fGraphicStateResources;
SkTDArray<SkPDFObject*> fXObjectResources;
@@ -273,8 +282,17 @@ private:
*/
void copyContentEntriesToData(ContentEntry* entry, SkWStream* data) const;
- bool handleAnnotations(const SkRect& r, const SkMatrix& matrix,
- const SkPaint& paint);
+ bool handleRectAnnotation(const SkRect& r, const SkMatrix& matrix,
+ const SkPaint& paint);
+ bool handlePointAnnotation(const SkPoint* points, size_t count,
+ const SkMatrix& matrix, const SkPaint& paint);
+ SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix);
+ void handleLinkToURL(SkData* urlData, const SkRect& r,
+ const SkMatrix& matrix);
+ void handleLinkToNamedDest(SkData* nameData, const SkRect& r,
+ const SkMatrix& matrix);
+ void defineNamedDestination(SkData* nameData, const SkPoint& point,
+ const SkMatrix& matrix);
typedef SkDevice INHERITED;
};