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

Unified Diff: src/pdf/SkPDFTypes.cpp

Issue 869783003: Cleanup SkPDFObject::emit* (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 | « src/pdf/SkPDFTypes.h ('k') | tests/PDFPrimitivesTest.cpp » ('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 4a84876b2021a94667d0f657ef9b10a1c2d668c5..b0763a3c5979de59ebb8ae4d41ef35eb4a41290a 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -19,32 +19,9 @@
///////////////////////////////////////////////////////////////////////////////
-void SkPDFObject::emit(SkWStream* stream, SkPDFCatalog* catalog,
- bool indirect) {
- SkPDFObject* realObject = catalog->getSubstituteObject(this);
- if (indirect) {
- realObject->emitIndirectObject(stream, catalog);
- } else {
- realObject->emitObject(stream, catalog);
- }
-}
-
-size_t SkPDFObject::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- SkDynamicMemoryWStream buffer;
- emit(&buffer, catalog, indirect);
- return buffer.getOffset();
-}
-
void SkPDFObject::getResources(const SkTSet<SkPDFObject*>& knownResourceObjects,
SkTSet<SkPDFObject*>* newResourceObjects) {}
-void SkPDFObject::emitIndirectObject(SkWStream* stream, SkPDFCatalog* catalog) {
- catalog->emitObjectNumber(stream, this);
- stream->writeText(" obj\n");
- emit(stream, catalog, false);
- stream->writeText("\nendobj\n");
-}
-
void SkPDFObject::AddResourceHelper(SkPDFObject* resource,
SkTDArray<SkPDFObject*>* list) {
list->push(resource);
@@ -70,6 +47,8 @@ void SkPDFObject::GetResourcesHelper(
}
}
+////////////////////////////////////////////////////////////////////////////////
+
SkPDFObjRef::SkPDFObjRef(SkPDFObject* obj) : fObj(obj) {
SkSafeRef(obj);
}
@@ -81,6 +60,8 @@ void SkPDFObjRef::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
stream->writeText(" R");
}
+////////////////////////////////////////////////////////////////////////////////
+
SkPDFInt::SkPDFInt(int32_t value) : fValue(value) {}
SkPDFInt::~SkPDFInt() {}
@@ -88,6 +69,8 @@ void SkPDFInt::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
stream->writeDecAsText(fValue);
}
+////////////////////////////////////////////////////////////////////////////////
+
SkPDFBool::SkPDFBool(bool value) : fValue(value) {}
SkPDFBool::~SkPDFBool() {}
@@ -99,6 +82,8 @@ void SkPDFBool::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
}
}
+////////////////////////////////////////////////////////////////////////////////
+
SkPDFScalar::SkPDFScalar(SkScalar value) : fValue(value) {}
SkPDFScalar::~SkPDFScalar() {}
@@ -155,6 +140,8 @@ void SkPDFScalar::Append(SkScalar value, SkWStream* stream) {
#endif // SK_ALLOW_LARGE_PDF_SCALARS
}
+////////////////////////////////////////////////////////////////////////////////
+
SkPDFString::SkPDFString(const char value[])
: fValue(FormatString(value, strlen(value))) {
}
@@ -238,6 +225,8 @@ SkString SkPDFString::DoFormatString(const void* input, size_t len,
return result;
}
+////////////////////////////////////////////////////////////////////////////////
+
SkPDFName::SkPDFName(const char name[]) : fValue(FormatName(SkString(name))) {}
SkPDFName::SkPDFName(const SkString& name) : fValue(FormatName(name)) {}
SkPDFName::~SkPDFName() {}
@@ -270,6 +259,8 @@ SkString SkPDFName::FormatName(const SkString& input) {
return result;
}
+////////////////////////////////////////////////////////////////////////////////
+
SkPDFArray::SkPDFArray() {}
SkPDFArray::~SkPDFArray() {
fValue.unrefAll();
@@ -278,7 +269,7 @@ SkPDFArray::~SkPDFArray() {
void SkPDFArray::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
stream->writeText("[");
for (int i = 0; i < fValue.count(); i++) {
- fValue[i]->emit(stream, catalog, false);
+ catalog->getSubstituteObject(fValue[i])->emitObject(stream, catalog);
if (i + 1 < fValue.count()) {
stream->writeText(" ");
}
@@ -338,7 +329,6 @@ int SkPDFDict::size() const {
return fValue.count();
}
-
void SkPDFDict::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
SkAutoMutexAcquire lock(fMutex); // If another thread triggers a
// resize while this thread is in
@@ -350,7 +340,8 @@ void SkPDFDict::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
SkASSERT(fValue[i].value);
fValue[i].key->emitObject(stream, catalog);
stream->writeText(" ");
- fValue[i].value->emit(stream, catalog, false);
+ catalog->getSubstituteObject(fValue[i].value)
+ ->emitObject(stream, catalog);
stream->writeText("\n");
}
stream->writeText(">>");
« no previous file with comments | « src/pdf/SkPDFTypes.h ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698