High level pdf classes and pdf specific interface.
The guts of the implementation will be in SkPDFDevice and below. This is a first implementation of everything above that point.
Review URL: http://codereview.appspot.com/2342043
git-svn-id: http://skia.googlecode.com/svn/trunk@602 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp
index f5f23ca..a01fcba 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -211,11 +211,15 @@
}
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 @@
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();
+}