| 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 "SkFlattenableBuffers.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 SkAnnotation::~SkAnnotation() { | 25 SkAnnotation::~SkAnnotation() { |
| 26 fData->unref(); | 26 fData->unref(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 SkData* SkAnnotation::find(const char key[]) const { | 29 SkData* SkAnnotation::find(const char key[]) const { |
| 30 return fKey.equals(key) ? fData : NULL; | 30 return fKey.equals(key) ? fData : NULL; |
| 31 } | 31 } |
| 32 | 32 |
| 33 SkAnnotation::SkAnnotation(SkFlattenableReadBuffer& buffer) : INHERITED(buffer)
{ | 33 SkAnnotation::SkAnnotation(SkFlattenableReadBuffer& buffer) { |
| 34 fFlags = buffer.readUInt(); | 34 fFlags = buffer.readUInt(); |
| 35 buffer.readString(&fKey); | 35 buffer.readString(&fKey); |
| 36 fData = buffer.readByteArrayAsData(); | 36 fData = buffer.readByteArrayAsData(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void SkAnnotation::flatten(SkFlattenableWriteBuffer& buffer) const { | 39 void SkAnnotation::writeToBuffer(SkFlattenableWriteBuffer& buffer) const { |
| 40 buffer.writeUInt(fFlags); | 40 buffer.writeUInt(fFlags); |
| 41 buffer.writeString(fKey.c_str()); | 41 buffer.writeString(fKey.c_str()); |
| 42 buffer.writeDataAsByteArray(fData); | 42 buffer.writeDataAsByteArray(fData); |
| 43 } | 43 } |
| 44 | 44 |
| 45 const char* SkAnnotationKeys::URL_Key() { | 45 const char* SkAnnotationKeys::URL_Key() { |
| 46 return "SkAnnotationKey_URL"; | 46 return "SkAnnotationKey_URL"; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 const char* SkAnnotationKeys::Define_Named_Dest_Key() { | 49 const char* SkAnnotationKeys::Define_Named_Dest_Key() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* n
ame) { | 87 void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* n
ame) { |
| 88 if (NULL == name) { | 88 if (NULL == name) { |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 SkPaint paint; | 91 SkPaint paint; |
| 92 annotate_paint(paint, SkAnnotationKeys::Link_Named_Dest_Key(), name); | 92 annotate_paint(paint, SkAnnotationKeys::Link_Named_Dest_Key(), name); |
| 93 canvas->drawRect(rect, paint); | 93 canvas->drawRect(rect, paint); |
| 94 } | 94 } |
| OLD | NEW |