gfx/skia/trunk/include/core/SkAnnotation.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:93f2c627e6aa
1 /*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef SkAnnotation_DEFINED
9 #define SkAnnotation_DEFINED
10
11 #include "SkRefCnt.h"
12 #include "SkString.h"
13
14 class SkData;
15 class SkReadBuffer;
16 class SkWriteBuffer;
17 class SkStream;
18 class SkWStream;
19 struct SkPoint;
20
21 /**
22 * Experimental class for annotating draws. Do not use directly yet.
23 * Use helper functions at the bottom of this file for now.
24 */
25 class SkAnnotation : public SkRefCnt {
26 public:
27 virtual ~SkAnnotation();
28
29 static SkAnnotation* Create(const char key[], SkData* value) {
30 return SkNEW_ARGS(SkAnnotation, (key, value));
31 }
32
33 static SkAnnotation* Create(SkReadBuffer& buffer) {
34 return SkNEW_ARGS(SkAnnotation, (buffer));
35 }
36
37 /**
38 * Return the data for the specified key, or NULL.
39 */
40 SkData* find(const char key[]) const;
41
42 void writeToBuffer(SkWriteBuffer&) const;
43
44 private:
45 SkAnnotation(const char key[], SkData* value);
46 SkAnnotation(SkReadBuffer&);
47
48 SkString fKey;
49 SkData* fData;
50
51 typedef SkRefCnt INHERITED;
52 };
53
54 /**
55 * Experimental collection of predefined Keys into the Annotation dictionary
56 */
57 class SkAnnotationKeys {
58 public:
59 /**
60 * Returns the canonical key whose payload is a URL
61 */
62 static const char* URL_Key();
63
64 /**
65 * Returns the canonical key whose payload is the name of a destination to
66 * be defined.
67 */
68 static const char* Define_Named_Dest_Key();
69
70 /**
71 * Returns the canonical key whose payload is the name of a destination to
72 * be linked to.
73 */
74 static const char* Link_Named_Dest_Key();
75 };
76
77 ///////////////////////////////////////////////////////////////////////////////
78 //
79 // Experimental helper functions to use Annotations
80 //
81
82 struct SkRect;
83 class SkCanvas;
84
85 /**
86 * Experimental!
87 *
88 * Annotate the canvas by associating the specified URL with the
89 * specified rectangle (in local coordinates, just like drawRect). If the
90 * backend of this canvas does not support annotations, this call is
91 * safely ignored.
92 *
93 * The caller is responsible for managing its ownership of the SkData.
94 */
95 SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*);
96
97 /**
98 * Experimental!
99 *
100 * Annotate the canvas by associating a name with the specified point.
101 *
102 * If the backend of this canvas does not support annotations, this call is
103 * safely ignored.
104 *
105 * The caller is responsible for managing its ownership of the SkData.
106 */
107 SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*);
108
109 /**
110 * Experimental!
111 *
112 * Annotate the canvas by making the specified rectangle link to a named
113 * destination.
114 *
115 * If the backend of this canvas does not support annotations, this call is
116 * safely ignored.
117 *
118 * The caller is responsible for managing its ownership of the SkData.
119 */
120 SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*);
121
122
123 #endif

mercurial