| 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 "SkRefCnt.h" |
| 12 #include "SkString.h" |
| 11 #include "SkTypes.h" | 13 #include "SkTypes.h" |
| 12 | 14 |
| 13 class SkData; | 15 class SkData; |
| 16 class SkReadBuffer; |
| 17 class SkWriteBuffer; |
| 14 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 |
| 15 struct SkRect; | 79 struct SkRect; |
| 16 class SkCanvas; | 80 class SkCanvas; |
| 17 | 81 |
| 18 /** | 82 /** |
| 83 * Experimental! |
| 84 * |
| 19 * Annotate the canvas by associating the specified URL with the | 85 * Annotate the canvas by associating the specified URL with the |
| 20 * specified rectangle (in local coordinates, just like drawRect). | 86 * specified rectangle (in local coordinates, just like drawRect). If the |
| 21 * | 87 * backend of this canvas does not support annotations, this call is |
| 22 * If the backend of this canvas does not support annotations, this call is | |
| 23 * safely ignored. | 88 * safely ignored. |
| 24 * | 89 * |
| 25 * The caller is responsible for managing its ownership of the SkData. | 90 * The caller is responsible for managing its ownership of the SkData. |
| 26 */ | 91 */ |
| 27 SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*); | 92 SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*); |
| 28 | 93 |
| 29 /** | 94 /** |
| 95 * Experimental! |
| 96 * |
| 30 * Annotate the canvas by associating a name with the specified point. | 97 * Annotate the canvas by associating a name with the specified point. |
| 31 * | 98 * |
| 32 * If the backend of this canvas does not support annotations, this call is | 99 * If the backend of this canvas does not support annotations, this call is |
| 33 * safely ignored. | 100 * safely ignored. |
| 34 * | 101 * |
| 35 * The caller is responsible for managing its ownership of the SkData. | 102 * The caller is responsible for managing its ownership of the SkData. |
| 36 */ | 103 */ |
| 37 SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*); | 104 SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*); |
| 38 | 105 |
| 39 /** | 106 /** |
| 107 * Experimental! |
| 108 * |
| 40 * Annotate the canvas by making the specified rectangle link to a named | 109 * Annotate the canvas by making the specified rectangle link to a named |
| 41 * destination. | 110 * destination. |
| 42 * | 111 * |
| 43 * If the backend of this canvas does not support annotations, this call is | 112 * If the backend of this canvas does not support annotations, this call is |
| 44 * safely ignored. | 113 * safely ignored. |
| 45 * | 114 * |
| 46 * The caller is responsible for managing its ownership of the SkData. | 115 * The caller is responsible for managing its ownership of the SkData. |
| 47 */ | 116 */ |
| 48 SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*); | 117 SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*); |
| 49 | 118 |
| 119 |
| 50 #endif | 120 #endif |
| OLD | NEW |