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

Side by Side Diff: src/pdf/SkPDFStream.cpp

Issue 1298243002: SkPDF/Deflate: clean up old SkFlate code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-18 (Tuesday) 16:19:01 EDT Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 SkPDFStream::~SkPDFStream() {} 24 SkPDFStream::~SkPDFStream() {}
25 25
26 void SkPDFStream::emitObject(SkWStream* stream, 26 void SkPDFStream::emitObject(SkWStream* stream,
27 const SkPDFObjNumMap& objNumMap, 27 const SkPDFObjNumMap& objNumMap,
28 const SkPDFSubstituteMap& substitutes) { 28 const SkPDFSubstituteMap& substitutes) {
29 if (fState == kUnused_State) { 29 if (fState == kUnused_State) {
30 fState = kNoCompression_State; 30 fState = kNoCompression_State;
31 SkDynamicMemoryWStream compressedData; 31 SkDynamicMemoryWStream compressedData;
32 32 SkDeflateWStream deflateWStream(&compressedData);
33 SkAssertResult( 33 SkAssertResult(SkStreamCopy(&deflateWStream, fDataStream.get()));
34 SkFlate::Deflate(fDataStream.get(), &compressedData)); 34 deflateWStream.finalize();
35 SkAssertResult(fDataStream->rewind()); 35 SkAssertResult(fDataStream->rewind());
36 if (compressedData.getOffset() < this->dataSize()) { 36 if (compressedData.getOffset() < this->dataSize()) {
37 SkAutoTDelete<SkStream> compressed( 37 SkAutoTDelete<SkStream> compressed(
38 compressedData.detachAsStream()); 38 compressedData.detachAsStream());
39 this->setData(compressed.get()); 39 this->setData(compressed.get());
40 this->insertName("Filter", "FlateDecode"); 40 this->insertName("Filter", "FlateDecode");
41 } 41 }
42 fState = kCompressed_State; 42 fState = kCompressed_State;
43 this->insertInt("Length", this->dataSize()); 43 this->insertInt("Length", this->dataSize());
44 } 44 }
(...skipping 16 matching lines...) Expand all
61 // Code assumes that the stream starts at the beginning and is rewindable. 61 // Code assumes that the stream starts at the beginning and is rewindable.
62 // SkStreamRewindableFromSkStream will try stream->duplicate(). 62 // SkStreamRewindableFromSkStream will try stream->duplicate().
63 fDataStream.reset(SkStreamRewindableFromSkStream(stream)); 63 fDataStream.reset(SkStreamRewindableFromSkStream(stream));
64 SkASSERT(fDataStream.get()); 64 SkASSERT(fDataStream.get());
65 } 65 }
66 66
67 size_t SkPDFStream::dataSize() const { 67 size_t SkPDFStream::dataSize() const {
68 SkASSERT(fDataStream->hasLength()); 68 SkASSERT(fDataStream->hasLength());
69 return fDataStream->getLength(); 69 return fDataStream->getLength();
70 } 70 }
OLDNEW
« no previous file with comments | « src/pdf/SkDeflate.cpp ('k') | tests/PDFDeflateWStreamTest.cpp » ('j') | tests/StreamTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698