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 18 matching lines...) Expand all Loading... |
29 SkPDFStream::SkPDFStream(const SkPDFStream& pdfStream) | 29 SkPDFStream::SkPDFStream(const SkPDFStream& pdfStream) |
30 : SkPDFDict(), | 30 : SkPDFDict(), |
31 fState(kUnused_State) { | 31 fState(kUnused_State) { |
32 setData(pdfStream.fData.get()); | 32 setData(pdfStream.fData.get()); |
33 bool removeLength = true; | 33 bool removeLength = true; |
34 // Don't uncompress an already compressed stream, but we could. | 34 // Don't uncompress an already compressed stream, but we could. |
35 if (pdfStream.fState == kCompressed_State) { | 35 if (pdfStream.fState == kCompressed_State) { |
36 fState = kCompressed_State; | 36 fState = kCompressed_State; |
37 removeLength = false; | 37 removeLength = false; |
38 } | 38 } |
39 SkPDFDict::Iter dict(pdfStream); | 39 this->mergeFrom(pdfStream); |
40 SkPDFName* key; | 40 if (removeLength) { |
41 SkPDFObject* value; | 41 this->remove("Length"); |
42 SkPDFName lengthName("Length"); | |
43 for (key = dict.next(&value); key != NULL; key = dict.next(&value)) { | |
44 if (removeLength && *key == lengthName) { | |
45 continue; | |
46 } | |
47 this->insert(key, value); | |
48 } | 42 } |
49 } | 43 } |
50 | 44 |
51 SkPDFStream::~SkPDFStream() {} | 45 SkPDFStream::~SkPDFStream() {} |
52 | 46 |
53 void SkPDFStream::emitObject(SkWStream* stream, SkPDFCatalog* catalog, | 47 void SkPDFStream::emitObject(SkWStream* stream, SkPDFCatalog* catalog, |
54 bool indirect) { | 48 bool indirect) { |
55 if (indirect) { | 49 if (indirect) { |
56 return emitIndirectObject(stream, catalog); | 50 return emitIndirectObject(stream, catalog); |
57 } | 51 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } else if (fState == kNoCompression_State && !skip_compression(catalog) && | 110 } else if (fState == kNoCompression_State && !skip_compression(catalog) && |
117 SkFlate::HaveFlate()) { | 111 SkFlate::HaveFlate()) { |
118 if (!fSubstitute.get()) { | 112 if (!fSubstitute.get()) { |
119 fSubstitute.reset(new SkPDFStream(*this)); | 113 fSubstitute.reset(new SkPDFStream(*this)); |
120 catalog->setSubstitute(this, fSubstitute.get()); | 114 catalog->setSubstitute(this, fSubstitute.get()); |
121 } | 115 } |
122 return false; | 116 return false; |
123 } | 117 } |
124 return true; | 118 return true; |
125 } | 119 } |
OLD | NEW |