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

Side by Side Diff: include/core/SkAnnotation.h

Issue 1758023003: Move annotations to canvas virtual (patchset #8 id:140001 of https://codereview.chromium.org/174410… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: manual rebase Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | include/core/SkCanvas.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1
1 /* 2 /*
2 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
3 * 4 *
4 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 6 * found in the LICENSE file.
6 */ 7 */
7 8
8 #ifndef SkAnnotation_DEFINED 9 #ifndef SkAnnotation_DEFINED
9 #define SkAnnotation_DEFINED 10 #define SkAnnotation_DEFINED
10 11
11 #include "SkRefCnt.h"
12 #include "SkString.h"
13 #include "SkTypes.h" 12 #include "SkTypes.h"
14 13
14 // for chrome in PrintContextTest.cpp
15 #define SK_SUPPORT_NEW_ANNOTATION_CANVAS_VIRTUAL
16
15 class SkData; 17 class SkData;
16 class SkReadBuffer;
17 class SkWriteBuffer;
18 struct SkPoint; 18 struct SkPoint;
19
20 /**
21 * Experimental class for annotating draws. Do not use directly yet.
22 * Use helper functions at the bottom of this file for now.
23 */
24 class SkAnnotation : public SkRefCnt {
25 public:
26 virtual ~SkAnnotation();
27
28 static SkAnnotation* Create(const char key[], SkData* value) {
29 return new SkAnnotation(key, value);
30 }
31
32 static SkAnnotation* Create(SkReadBuffer& buffer) { return new SkAnnotation( buffer); }
33
34 /**
35 * Return the data for the specified key, or NULL.
36 */
37 SkData* find(const char key[]) const;
38
39 void writeToBuffer(SkWriteBuffer&) const;
40
41 private:
42 SkAnnotation(const char key[], SkData* value);
43 SkAnnotation(SkReadBuffer&);
44
45 SkString fKey;
46 SkData* fData;
47
48 typedef SkRefCnt INHERITED;
49 };
50
51 /**
52 * Experimental collection of predefined Keys into the Annotation dictionary
53 */
54 class SkAnnotationKeys {
55 public:
56 /**
57 * Returns the canonical key whose payload is a URL
58 */
59 static const char* URL_Key();
60
61 /**
62 * Returns the canonical key whose payload is the name of a destination to
63 * be defined.
64 */
65 static const char* Define_Named_Dest_Key();
66
67 /**
68 * Returns the canonical key whose payload is the name of a destination to
69 * be linked to.
70 */
71 static const char* Link_Named_Dest_Key();
72 };
73
74 ///////////////////////////////////////////////////////////////////////////////
75 //
76 // Experimental helper functions to use Annotations
77 //
78
79 struct SkRect; 19 struct SkRect;
80 class SkCanvas; 20 class SkCanvas;
81 21
82 /** 22 /**
83 * Experimental! 23 * Annotate the canvas by associating the specified URL with the
24 * specified rectangle (in local coordinates, just like drawRect).
84 * 25 *
85 * Annotate the canvas by associating the specified URL with the 26 * If the backend of this canvas does not support annotations, this call is
86 * specified rectangle (in local coordinates, just like drawRect). If the
87 * backend of this canvas does not support annotations, this call is
88 * safely ignored. 27 * safely ignored.
89 * 28 *
90 * The caller is responsible for managing its ownership of the SkData. 29 * The caller is responsible for managing its ownership of the SkData.
91 */ 30 */
92 SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*); 31 SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*);
93 32
94 /** 33 /**
95 * Experimental!
96 *
97 * Annotate the canvas by associating a name with the specified point. 34 * Annotate the canvas by associating a name with the specified point.
98 * 35 *
99 * If the backend of this canvas does not support annotations, this call is 36 * If the backend of this canvas does not support annotations, this call is
100 * safely ignored. 37 * safely ignored.
101 * 38 *
102 * The caller is responsible for managing its ownership of the SkData. 39 * The caller is responsible for managing its ownership of the SkData.
103 */ 40 */
104 SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*); 41 SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*);
105 42
106 /** 43 /**
107 * Experimental!
108 *
109 * Annotate the canvas by making the specified rectangle link to a named 44 * Annotate the canvas by making the specified rectangle link to a named
110 * destination. 45 * destination.
111 * 46 *
112 * If the backend of this canvas does not support annotations, this call is 47 * If the backend of this canvas does not support annotations, this call is
113 * safely ignored. 48 * safely ignored.
114 * 49 *
115 * The caller is responsible for managing its ownership of the SkData. 50 * The caller is responsible for managing its ownership of the SkData.
116 */ 51 */
117 SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*); 52 SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*);
118 53
119
120 #endif 54 #endif
OLDNEW
« no previous file with comments | « no previous file | include/core/SkCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698