Index: src/pdf/SkPDFTypes.cpp |
diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp |
index f5f23ca709c5e5627af33a320f2621b7aa9fbf56..a01fcbaf5d4f9f8d676d1b0745478f946310e346 100644 |
--- a/src/pdf/SkPDFTypes.cpp |
+++ b/src/pdf/SkPDFTypes.cpp |
@@ -211,11 +211,15 @@ void SkPDFArray::append(SkPDFObject* value) { |
} |
SkPDFDict::SkPDFDict() {} |
+ |
+SkPDFDict::SkPDFDict(const char type[]) { |
+ SkRefPtr<SkPDFName> typeName = new SkPDFName(type); |
+ typeName->unref(); // SkRefPtr and new both took a reference. |
+ insert("Type", typeName.get()); |
+} |
+ |
SkPDFDict::~SkPDFDict() { |
- for (int i = 0; i < fValue.count(); i++) { |
- SkSafeUnref(fValue[i].key); |
- SkSafeUnref(fValue[i].value); |
- } |
+ clear(); |
} |
void SkPDFDict::emitObject(SkWStream* stream, SkPDFCatalog* catalog, |
@@ -252,3 +256,17 @@ void SkPDFDict::insert(SkPDFName* key, SkPDFObject* value) { |
newEntry->value = value; |
SkSafeRef(newEntry->value); |
} |
+ |
+void SkPDFDict::insert(const char key[], SkPDFObject* value) { |
+ SkRefPtr<SkPDFName> keyName = new SkPDFName(key); |
+ keyName->unref(); // SkRefPtr and new both took a reference. |
+ insert(keyName.get(), value); |
+} |
+ |
+void SkPDFDict::clear() { |
+ for (int i = 0; i < fValue.count(); i++) { |
+ fValue[i].key->safeUnref(); |
+ fValue[i].value->safeUnref(); |
+ } |
+ fValue.reset(); |
+} |