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 #include "SkAnnotation.h" | 8 #include "SkAnnotation.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkFlattenableBuffers.h" | 10 #include "SkReadBuffer.h" |
| 11 #include "SkWriteBuffer.h" |
11 #include "SkPoint.h" | 12 #include "SkPoint.h" |
12 #include "SkStream.h" | 13 #include "SkStream.h" |
13 | 14 |
14 SkAnnotation::SkAnnotation(const char key[], SkData* value) : fKey(key) { | 15 SkAnnotation::SkAnnotation(const char key[], SkData* value) : fKey(key) { |
15 if (NULL == value) { | 16 if (NULL == value) { |
16 value = SkData::NewEmpty(); | 17 value = SkData::NewEmpty(); |
17 } else { | 18 } else { |
18 value->ref(); | 19 value->ref(); |
19 } | 20 } |
20 fData = value; | 21 fData = value; |
21 } | 22 } |
22 | 23 |
23 SkAnnotation::~SkAnnotation() { | 24 SkAnnotation::~SkAnnotation() { |
24 fData->unref(); | 25 fData->unref(); |
25 } | 26 } |
26 | 27 |
27 SkData* SkAnnotation::find(const char key[]) const { | 28 SkData* SkAnnotation::find(const char key[]) const { |
28 return fKey.equals(key) ? fData : NULL; | 29 return fKey.equals(key) ? fData : NULL; |
29 } | 30 } |
30 | 31 |
31 SkAnnotation::SkAnnotation(SkFlattenableReadBuffer& buffer) { | 32 SkAnnotation::SkAnnotation(SkReadBuffer& buffer) { |
32 buffer.readString(&fKey); | 33 buffer.readString(&fKey); |
33 fData = buffer.readByteArrayAsData(); | 34 fData = buffer.readByteArrayAsData(); |
34 } | 35 } |
35 | 36 |
36 void SkAnnotation::writeToBuffer(SkFlattenableWriteBuffer& buffer) const { | 37 void SkAnnotation::writeToBuffer(SkWriteBuffer& buffer) const { |
37 buffer.writeString(fKey.c_str()); | 38 buffer.writeString(fKey.c_str()); |
38 buffer.writeDataAsByteArray(fData); | 39 buffer.writeDataAsByteArray(fData); |
39 } | 40 } |
40 | 41 |
41 const char* SkAnnotationKeys::URL_Key() { | 42 const char* SkAnnotationKeys::URL_Key() { |
42 return "SkAnnotationKey_URL"; | 43 return "SkAnnotationKey_URL"; |
43 }; | 44 }; |
44 | 45 |
45 const char* SkAnnotationKeys::Define_Named_Dest_Key() { | 46 const char* SkAnnotationKeys::Define_Named_Dest_Key() { |
46 return "SkAnnotationKey_Define_Named_Dest"; | 47 return "SkAnnotationKey_Define_Named_Dest"; |
(...skipping 30 matching lines...) Expand all Loading... |
77 } | 78 } |
78 | 79 |
79 void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* n
ame) { | 80 void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* n
ame) { |
80 if (NULL == name) { | 81 if (NULL == name) { |
81 return; | 82 return; |
82 } | 83 } |
83 SkPaint paint; | 84 SkPaint paint; |
84 annotate_paint(paint, SkAnnotationKeys::Link_Named_Dest_Key(), name); | 85 annotate_paint(paint, SkAnnotationKeys::Link_Named_Dest_Key(), name); |
85 canvas->drawRect(rect, paint); | 86 canvas->drawRect(rect, paint); |
86 } | 87 } |
OLD | NEW |