Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(7297)

Unified Diff: src/pdf/SkPDFTypes.cpp

Issue 2342043: High level pdf classes and pdf specific interface. (Closed)
Patch Set: Address agl's comments Created 14 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFStream.cpp ('k') | src/pdf/pdf_files.mk » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+}
« no previous file with comments | « src/pdf/SkPDFStream.cpp ('k') | src/pdf/pdf_files.mk » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b