OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkAnnotation_DEFINED | 8 #ifndef SkAnnotation_DEFINED |
9 #define SkAnnotation_DEFINED | 9 #define SkAnnotation_DEFINED |
10 | 10 |
11 #include "SkFlattenable.h" | 11 #include "SkRefCnt.h" |
12 #include "SkString.h" | 12 #include "SkString.h" |
13 | 13 |
14 class SkData; | 14 class SkData; |
| 15 class SkFlattenableReadBuffer; |
| 16 class SkFlattenableWriteBuffer; |
15 class SkStream; | 17 class SkStream; |
16 class SkWStream; | 18 class SkWStream; |
17 struct SkPoint; | 19 struct SkPoint; |
18 | 20 |
19 /** | 21 /** |
20 * Experimental class for annotating draws. Do not use directly yet. | 22 * Experimental class for annotating draws. Do not use directly yet. |
21 * Use helper functions at the bottom of this file for now. | 23 * Use helper functions at the bottom of this file for now. |
22 */ | 24 */ |
23 class SkAnnotation : public SkFlattenable { | 25 class SkAnnotation : public SkRefCnt { |
24 public: | 26 public: |
25 enum Flags { | 27 enum Flags { |
26 // If set, the associated drawing primitive should not be drawn | 28 // If set, the associated drawing primitive should not be drawn |
27 kNoDraw_Flag = 1 << 0, | 29 kNoDraw_Flag = 1 << 0, |
28 }; | 30 }; |
29 | 31 |
30 SkAnnotation(const char key[], SkData* value, uint32_t flags); | 32 SkAnnotation(const char key[], SkData* value, uint32_t flags); |
31 virtual ~SkAnnotation(); | 33 virtual ~SkAnnotation(); |
32 | 34 |
33 uint32_t getFlags() const { return fFlags; } | 35 uint32_t getFlags() const { return fFlags; } |
34 | 36 |
35 bool isNoDraw() const { return SkToBool(fFlags & kNoDraw_Flag); } | 37 bool isNoDraw() const { return SkToBool(fFlags & kNoDraw_Flag); } |
36 | 38 |
37 /** | 39 /** |
38 * Return the data for the specified key, or NULL. | 40 * Return the data for the specified key, or NULL. |
39 */ | 41 */ |
40 SkData* find(const char key[]) const; | 42 SkData* find(const char key[]) const; |
41 | 43 |
42 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAnnotation) | |
43 | |
44 protected: | |
45 SkAnnotation(SkFlattenableReadBuffer&); | 44 SkAnnotation(SkFlattenableReadBuffer&); |
46 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; | 45 void writeToBuffer(SkFlattenableWriteBuffer&) const; |
47 | 46 |
48 private: | 47 private: |
49 SkString fKey; | 48 SkString fKey; |
50 SkData* fData; | 49 SkData* fData; |
51 uint32_t fFlags; | 50 uint32_t fFlags; |
52 | 51 |
53 void writeToStream(SkWStream*) const; | 52 typedef SkRefCnt INHERITED; |
54 void readFromStream(SkStream*); | |
55 | |
56 typedef SkFlattenable INHERITED; | |
57 }; | 53 }; |
58 | 54 |
59 /** | 55 /** |
60 * Experimental collection of predefined Keys into the Annotation dictionary | 56 * Experimental collection of predefined Keys into the Annotation dictionary |
61 */ | 57 */ |
62 class SkAnnotationKeys { | 58 class SkAnnotationKeys { |
63 public: | 59 public: |
64 /** | 60 /** |
65 * Returns the canonical key whose payload is a URL | 61 * Returns the canonical key whose payload is a URL |
66 */ | 62 */ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 * | 115 * |
120 * If the backend of this canvas does not support annotations, this call is | 116 * If the backend of this canvas does not support annotations, this call is |
121 * safely ignored. | 117 * safely ignored. |
122 * | 118 * |
123 * The caller is responsible for managing its ownership of the SkData. | 119 * The caller is responsible for managing its ownership of the SkData. |
124 */ | 120 */ |
125 SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*); | 121 SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*); |
126 | 122 |
127 | 123 |
128 #endif | 124 #endif |
OLD | NEW |