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

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

Issue 933523007: zlib/pdf: remove HaveFlate(), depend on preprocessor defines (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-02-17 (Tuesday) 17:35:15 EST Created 5 years, 10 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
« no previous file with comments | « src/pdf/SkPDFImage.cpp ('k') | tests/FlateTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 fDataStream.reset(SkNEW(SkMemoryStream)); 76 fDataStream.reset(SkNEW(SkMemoryStream));
77 } 77 }
78 } 78 }
79 79
80 size_t SkPDFStream::dataSize() const { 80 size_t SkPDFStream::dataSize() const {
81 SkASSERT(fDataStream->hasLength()); 81 SkASSERT(fDataStream->hasLength());
82 return fDataStream->getLength(); 82 return fDataStream->getLength();
83 } 83 }
84 84
85 bool SkPDFStream::populate(SkPDFCatalog* catalog) { 85 bool SkPDFStream::populate(SkPDFCatalog* catalog) {
86 #ifdef SK_NO_FLATE
86 if (fState == kUnused_State) { 87 if (fState == kUnused_State) {
87 if (!skip_compression(catalog) && SkFlate::HaveFlate()) { 88 fState = kNoCompression_State;
89 insertInt("Length", this->dataSize());
90 }
91 return true;
92
93 #else // !SK_NO_FLATE
94
95 if (fState == kUnused_State) {
96 fState = kNoCompression_State;
97 if (!skip_compression(catalog)) {
88 SkDynamicMemoryWStream compressedData; 98 SkDynamicMemoryWStream compressedData;
89 99
90 SkAssertResult( 100 SkAssertResult(
91 SkFlate::Deflate(fDataStream.get(), &compressedData)); 101 SkFlate::Deflate(fDataStream.get(), &compressedData));
92 SkAssertResult(fDataStream->rewind()); 102 SkAssertResult(fDataStream->rewind());
93 if (compressedData.getOffset() < this->dataSize()) { 103 if (compressedData.getOffset() < this->dataSize()) {
94 SkAutoTDelete<SkStream> compressed( 104 SkAutoTDelete<SkStream> compressed(
95 compressedData.detachAsStream()); 105 compressedData.detachAsStream());
96 this->setData(compressed.get()); 106 this->setData(compressed.get());
97 insertName("Filter", "FlateDecode"); 107 insertName("Filter", "FlateDecode");
98 } 108 }
99 fState = kCompressed_State; 109 fState = kCompressed_State;
100 } else { 110 } else {
101 fState = kNoCompression_State; 111 fState = kNoCompression_State;
102 } 112 }
103 insertInt("Length", this->dataSize()); 113 insertInt("Length", this->dataSize());
104 } else if (fState == kNoCompression_State && !skip_compression(catalog) && 114 }
105 SkFlate::HaveFlate()) { 115 else if (fState == kNoCompression_State && !skip_compression(catalog)) {
106 if (!fSubstitute.get()) { 116 if (!fSubstitute.get()) {
107 fSubstitute.reset(new SkPDFStream(*this)); 117 fSubstitute.reset(new SkPDFStream(*this));
108 catalog->setSubstitute(this, fSubstitute.get()); 118 catalog->setSubstitute(this, fSubstitute.get());
109 } 119 }
110 return false; 120 return false;
111 } 121 }
112 return true; 122 return true;
123 #endif // SK_NO_FLATE
113 } 124 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFImage.cpp ('k') | tests/FlateTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698