| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 return fSubstitute->emitObject(stream, catalog); | 51 return fSubstitute->emitObject(stream, catalog); |
| 52 } | 52 } |
| 53 | 53 |
| 54 this->INHERITED::emitObject(stream, catalog); | 54 this->INHERITED::emitObject(stream, catalog); |
| 55 stream->writeText(" stream\n"); | 55 stream->writeText(" stream\n"); |
| 56 stream->writeStream(fDataStream.get(), fDataStream->getLength()); | 56 stream->writeStream(fDataStream.get(), fDataStream->getLength()); |
| 57 SkAssertResult(fDataStream->rewind()); | 57 SkAssertResult(fDataStream->rewind()); |
| 58 stream->writeText("\nendstream"); | 58 stream->writeText("\nendstream"); |
| 59 } | 59 } |
| 60 | 60 |
| 61 size_t SkPDFStream::getOutputSize(SkPDFCatalog* catalog, bool indirect) { | |
| 62 if (indirect) { | |
| 63 return getIndirectOutputSize(catalog); | |
| 64 } | |
| 65 SkAutoMutexAcquire lock(fMutex); // multiple threads could be calling emit | |
| 66 if (!this->populate(catalog)) { | |
| 67 return fSubstitute->getOutputSize(catalog, indirect); | |
| 68 } | |
| 69 | |
| 70 return this->INHERITED::getOutputSize(catalog, false) + | |
| 71 strlen(" stream\n\nendstream") + this->dataSize(); | |
| 72 } | |
| 73 | |
| 74 SkPDFStream::SkPDFStream() : fState(kUnused_State) {} | 61 SkPDFStream::SkPDFStream() : fState(kUnused_State) {} |
| 75 | 62 |
| 76 void SkPDFStream::setData(SkData* data) { | 63 void SkPDFStream::setData(SkData* data) { |
| 77 fMemoryStream.setData(data); | 64 fMemoryStream.setData(data); |
| 78 if (&fMemoryStream != fDataStream.get()) { | 65 if (&fMemoryStream != fDataStream.get()) { |
| 79 fDataStream.reset(SkRef(&fMemoryStream)); | 66 fDataStream.reset(SkRef(&fMemoryStream)); |
| 80 } | 67 } |
| 81 } | 68 } |
| 82 | 69 |
| 83 void SkPDFStream::setData(SkStream* stream) { | 70 void SkPDFStream::setData(SkStream* stream) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } else if (fState == kNoCompression_State && !skip_compression(catalog) && | 110 } else if (fState == kNoCompression_State && !skip_compression(catalog) && |
| 124 SkFlate::HaveFlate()) { | 111 SkFlate::HaveFlate()) { |
| 125 if (!fSubstitute.get()) { | 112 if (!fSubstitute.get()) { |
| 126 fSubstitute.reset(new SkPDFStream(*this)); | 113 fSubstitute.reset(new SkPDFStream(*this)); |
| 127 catalog->setSubstitute(this, fSubstitute.get()); | 114 catalog->setSubstitute(this, fSubstitute.get()); |
| 128 } | 115 } |
| 129 return false; | 116 return false; |
| 130 } | 117 } |
| 131 return true; | 118 return true; |
| 132 } | 119 } |
| OLD | NEW |