OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |