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

Unified Diff: src/pdf/SkPDFStream.cpp

Issue 1041183002: SkPDF: remove SK_NO_FLATE & dead code in SkPDFStream (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-03-30 (Monday) 12:19:51 EDT Created 5 years, 9 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/SkPDFStream.h ('k') | tests/DeflateWStream.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFStream.cpp
diff --git a/src/pdf/SkPDFStream.cpp b/src/pdf/SkPDFStream.cpp
index ae3fe4abc452ffdff2f545556461e1bb2958beae..939cdd8b3dbb97e457936c43703dc31b34d7fb61 100644
--- a/src/pdf/SkPDFStream.cpp
+++ b/src/pdf/SkPDFStream.cpp
@@ -22,29 +22,10 @@ SkPDFStream::SkPDFStream(SkData* data) : fState(kUnused_State) {
this->setData(data);
}
-SkPDFStream::SkPDFStream(const SkPDFStream& pdfStream)
- : SkPDFDict(),
- fState(kUnused_State) {
- this->setData(pdfStream.fDataStream.get());
- bool removeLength = true;
- // Don't uncompress an already compressed stream, but we could.
- if (pdfStream.fState == kCompressed_State) {
- fState = kCompressed_State;
- removeLength = false;
- }
- this->mergeFrom(pdfStream);
- if (removeLength) {
- this->remove("Length");
- }
-}
-
SkPDFStream::~SkPDFStream() {}
void SkPDFStream::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
- if (!this->populate(catalog)) {
- return fSubstitute->emitObject(stream, catalog);
- }
-
+ SkAssertResult(this->populate(catalog));
this->INHERITED::emitObject(stream, catalog);
stream->writeText(" stream\n");
stream->writeStream(fDataStream.get(), fDataStream->getLength());
@@ -60,15 +41,11 @@ void SkPDFStream::setData(SkData* data) {
}
void SkPDFStream::setData(SkStream* stream) {
+ SkASSERT(stream);
// Code assumes that the stream starts at the beginning and is rewindable.
- if (stream) {
- // SkStreamRewindableFromSkStream will try stream->duplicate().
- fDataStream.reset(SkStreamRewindableFromSkStream(stream));
- SkASSERT(fDataStream.get());
- } else {
- // Use an empty memory stream.
- fDataStream.reset(SkNEW(SkMemoryStream));
- }
+ // SkStreamRewindableFromSkStream will try stream->duplicate().
+ fDataStream.reset(SkStreamRewindableFromSkStream(stream));
+ SkASSERT(fDataStream.get());
}
size_t SkPDFStream::dataSize() const {
@@ -77,15 +54,6 @@ size_t SkPDFStream::dataSize() const {
}
bool SkPDFStream::populate(SkPDFCatalog* catalog) {
-#ifdef SK_NO_FLATE
- if (fState == kUnused_State) {
- fState = kNoCompression_State;
- insertInt("Length", this->dataSize());
- }
- return true;
-
-#else // !SK_NO_FLATE
-
if (fState == kUnused_State) {
fState = kNoCompression_State;
SkDynamicMemoryWStream compressedData;
@@ -102,13 +70,5 @@ bool SkPDFStream::populate(SkPDFCatalog* catalog) {
fState = kCompressed_State;
insertInt("Length", this->dataSize());
}
- else if (fState == kNoCompression_State) {
- if (!fSubstitute.get()) {
- fSubstitute.reset(new SkPDFStream(*this));
- catalog->setSubstitute(this, fSubstitute.get());
- }
- return false;
- }
return true;
-#endif // SK_NO_FLATE
}
« no previous file with comments | « src/pdf/SkPDFStream.h ('k') | tests/DeflateWStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698