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

Unified Diff: src/pdf/SkPDFStream.cpp

Issue 2098393002: SkPDF: SkPDFStream takes only SkStreamAsset (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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') | no next file » | 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 bfe33a84655861d8061b8d7d91b29cd5fa441b00..48946e5e1beb5f9ed23748ab2787928a826ffbb4 100644
--- a/src/pdf/SkPDFStream.cpp
+++ b/src/pdf/SkPDFStream.cpp
@@ -25,7 +25,7 @@ void SkPDFStream::emitObject(SkWStream* stream,
SkASSERT(fCompressedData);
this->INHERITED::emitObject(stream, objNumMap, substitutes);
// duplicate (a cheap operation) preserves const on fCompressedData.
- std::unique_ptr<SkStreamRewindable> dup(fCompressedData->duplicate());
+ std::unique_ptr<SkStreamAsset> dup(fCompressedData->duplicate());
SkASSERT(dup);
SkASSERT(dup->hasLength());
stream->writeText(" stream\n");
@@ -34,13 +34,14 @@ void SkPDFStream::emitObject(SkWStream* stream,
}
-void SkPDFStream::setData(SkStream* stream) {
+void SkPDFStream::setData(SkStreamAsset* stream) {
SkASSERT(!fCompressedData); // Only call this function once.
SkASSERT(stream);
// Code assumes that the stream starts at the beginning.
#ifdef SK_PDF_LESS_COMPRESSION
- std::unique_ptr<SkStreamRewindable> duplicate(stream->duplicate());
+ std::unique_ptr<SkStreamAsset> duplicate(stream->duplicate());
+ SkASSERT(duplicate && duplicate->hasLength());
if (duplicate && duplicate->hasLength()) {
this->insertInt("Length", duplicate->getLength());
fCompressedData.reset(duplicate.release());
@@ -54,8 +55,12 @@ void SkPDFStream::setData(SkStream* stream) {
deflateWStream.finalize();
size_t length = compressedData.bytesWritten();
+ SkASSERT(stream->hasLength());
if (stream->hasLength()) {
- std::unique_ptr<SkStreamRewindable> dup(stream->duplicate());
+ std::unique_ptr<SkStreamAsset> dup(stream->duplicate());
+ SkASSERT(stream->hasLength());
+ SkASSERT(stream->getLength() == dup->getLength());
+ SkASSERT(dup && dup->hasLength());
if (dup && dup->hasLength() &&
dup->getLength() <= length + strlen("/Filter_/FlateDecode_")) {
this->insertInt("Length", dup->getLength());
« no previous file with comments | « src/pdf/SkPDFStream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698