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

Unified Diff: src/pdf/SkPDFTypes.cpp

Issue 846023003: In SkPDFDocument::emitPDF(), stop pre-calculating file offsets. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit: space between functions 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 7562528c041dc2cc4e250f4215bdc7f557cda11d..4a84876b2021a94667d0f657ef9b10a1c2d668c5 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -45,11 +45,6 @@ void SkPDFObject::emitIndirectObject(SkWStream* stream, SkPDFCatalog* catalog) {
stream->writeText("\nendobj\n");
}
-size_t SkPDFObject::getIndirectOutputSize(SkPDFCatalog* catalog) {
- return catalog->getObjectNumberSize(this) + strlen(" obj\n") +
- this->getOutputSize(catalog, false) + strlen("\nendobj\n");
-}
-
void SkPDFObject::AddResourceHelper(SkPDFObject* resource,
SkTDArray<SkPDFObject*>* list) {
list->push(resource);
@@ -86,11 +81,6 @@ void SkPDFObjRef::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
stream->writeText(" R");
}
-size_t SkPDFObjRef::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- SkASSERT(!indirect);
- return catalog->getObjectNumberSize(fObj.get()) + strlen(" R");
-}
-
SkPDFInt::SkPDFInt(int32_t value) : fValue(value) {}
SkPDFInt::~SkPDFInt() {}
@@ -109,14 +99,6 @@ void SkPDFBool::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
}
}
-size_t SkPDFBool::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- SkASSERT(!indirect);
- if (fValue) {
- return strlen("true");
- }
- return strlen("false");
-}
-
SkPDFScalar::SkPDFScalar(SkScalar value) : fValue(value) {}
SkPDFScalar::~SkPDFScalar() {}
@@ -191,12 +173,6 @@ void SkPDFString::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
stream->write(fValue.c_str(), fValue.size());
}
-size_t SkPDFString::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- if (indirect)
- return getIndirectOutputSize(catalog);
- return fValue.size();
-}
-
// static
SkString SkPDFString::FormatString(const char* input, size_t len) {
return DoFormatString(input, len, false, false);
@@ -274,11 +250,6 @@ void SkPDFName::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
stream->write(fValue.c_str(), fValue.size());
}
-size_t SkPDFName::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- SkASSERT(!indirect);
- return fValue.size();
-}
-
// static
SkString SkPDFName::FormatName(const SkString& input) {
SkASSERT(input.size() <= kMaxLen);
@@ -315,21 +286,6 @@ void SkPDFArray::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
stream->writeText("]");
}
-size_t SkPDFArray::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- if (indirect) {
- return getIndirectOutputSize(catalog);
- }
-
- size_t result = strlen("[]");
- if (fValue.count()) {
- result += fValue.count() - 1;
- }
- for (int i = 0; i < fValue.count(); i++) {
- result += fValue[i]->getOutputSize(catalog, false);
- }
- return result;
-}
-
void SkPDFArray::reserve(int length) {
SkASSERT(length <= kMaxLen);
fValue.setReserve(length);
@@ -400,25 +356,6 @@ void SkPDFDict::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
stream->writeText(">>");
}
-size_t SkPDFDict::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
- if (indirect) {
- return getIndirectOutputSize(catalog);
- }
-
- SkAutoMutexAcquire lock(fMutex); // If another thread triggers a
- // resize while this thread is in
- // the for-loop, we can be left
- // with a bad fValue[i] reference.
- size_t result = strlen("<<>>") + (fValue.count() * 2);
- for (int i = 0; i < fValue.count(); i++) {
- SkASSERT(fValue[i].key);
- SkASSERT(fValue[i].value);
- result += fValue[i].key->getOutputSize(catalog, false);
- result += fValue[i].value->getOutputSize(catalog, false);
- }
- return result;
-}
-
SkPDFObject* SkPDFDict::append(SkPDFName* key, SkPDFObject* value) {
SkASSERT(key);
SkASSERT(value);
« 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