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

Unified Diff: src/core/SkAnnotation.cpp

Issue 27208002: remove SkDataSet, and just store a key/value in SkAnnotation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkDataSet.h ('k') | src/core/SkData.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAnnotation.cpp
diff --git a/src/core/SkAnnotation.cpp b/src/core/SkAnnotation.cpp
index 52fa9b79f208d3ff1cde4f8e839e2411bcdd2b75..1230cb4de81003f0de90accbc8517706d685374d 100644
--- a/src/core/SkAnnotation.cpp
+++ b/src/core/SkAnnotation.cpp
@@ -6,37 +6,40 @@
*/
#include "SkAnnotation.h"
-#include "SkDataSet.h"
+#include "SkData.h"
#include "SkFlattenableBuffers.h"
#include "SkPoint.h"
#include "SkStream.h"
-SkAnnotation::SkAnnotation(SkDataSet* data, uint32_t flags) {
- if (NULL == data) {
- data = SkDataSet::NewEmpty();
+SkAnnotation::SkAnnotation(const char key[], SkData* value, uint32_t flags)
+ : fKey(key) {
+ if (NULL == value) {
+ value = SkData::NewEmpty();
} else {
- data->ref();
+ value->ref();
}
- fDataSet = data;
+ fData = value;
fFlags = flags;
}
SkAnnotation::~SkAnnotation() {
- fDataSet->unref();
+ fData->unref();
}
-SkData* SkAnnotation::find(const char name[]) const {
- return fDataSet->find(name);
+SkData* SkAnnotation::find(const char key[]) const {
+ return fKey.equals(key) ? fData : NULL;
}
SkAnnotation::SkAnnotation(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) {
fFlags = buffer.readUInt();
- fDataSet = buffer.readFlattenableT<SkDataSet>();
+ buffer.readString(&fKey);
+ fData = buffer.readByteArrayAsData();
}
void SkAnnotation::flatten(SkFlattenableWriteBuffer& buffer) const {
buffer.writeUInt(fFlags);
- buffer.writeFlattenable(fDataSet);
+ buffer.writeString(fKey.c_str());
+ buffer.writeDataAsByteArray(fData);
}
const char* SkAnnotationKeys::URL_Key() {
@@ -56,8 +59,7 @@ const char* SkAnnotationKeys::Link_Named_Dest_Key() {
#include "SkCanvas.h"
static void annotate_paint(SkPaint& paint, const char* key, SkData* value) {
- SkAutoTUnref<SkDataSet> dataset(SkNEW_ARGS(SkDataSet, (key, value)));
- SkAnnotation* ann = SkNEW_ARGS(SkAnnotation, (dataset,
+ SkAnnotation* ann = SkNEW_ARGS(SkAnnotation, (key, value,
SkAnnotation::kNoDraw_Flag));
paint.setAnnotation(ann)->unref();
« no previous file with comments | « include/core/SkDataSet.h ('k') | src/core/SkData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698