| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkData.h" | 8 #include "SkData.h" |
| 9 #include "SkDeflate.h" | 9 #include "SkDeflate.h" |
| 10 #include "SkPDFTypes.h" | 10 #include "SkPDFTypes.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 566 |
| 567 #ifdef SK_PDF_LESS_COMPRESSION | 567 #ifdef SK_PDF_LESS_COMPRESSION |
| 568 fCompressedData = std::move(stream); | 568 fCompressedData = std::move(stream); |
| 569 SkASSERT(fCompressedData && fCompressedData->hasLength()); | 569 SkASSERT(fCompressedData && fCompressedData->hasLength()); |
| 570 fDict.insertInt("Length", fCompressedData->getLength()); | 570 fDict.insertInt("Length", fCompressedData->getLength()); |
| 571 #else | 571 #else |
| 572 | 572 |
| 573 SkASSERT(stream->hasLength()); | 573 SkASSERT(stream->hasLength()); |
| 574 SkDynamicMemoryWStream compressedData; | 574 SkDynamicMemoryWStream compressedData; |
| 575 SkDeflateWStream deflateWStream(&compressedData); | 575 SkDeflateWStream deflateWStream(&compressedData); |
| 576 if (stream->getLength() > 0) { | 576 SkStreamCopy(&deflateWStream, stream.get()); |
| 577 SkStreamCopy(&deflateWStream, stream.get()); | |
| 578 } | |
| 579 deflateWStream.finalize(); | 577 deflateWStream.finalize(); |
| 580 size_t compressedLength = compressedData.bytesWritten(); | 578 size_t compressedLength = compressedData.bytesWritten(); |
| 581 size_t originalLength = stream->getLength(); | 579 size_t originalLength = stream->getLength(); |
| 582 | 580 |
| 583 if (originalLength <= compressedLength + strlen("/Filter_/FlateDecode_")) { | 581 if (originalLength <= compressedLength + strlen("/Filter_/FlateDecode_")) { |
| 584 SkAssertResult(stream->rewind()); | 582 SkAssertResult(stream->rewind()); |
| 585 fCompressedData = std::move(stream); | 583 fCompressedData = std::move(stream); |
| 586 fDict.insertInt("Length", originalLength); | 584 fDict.insertInt("Length", originalLength); |
| 587 return; | 585 return; |
| 588 } | 586 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 | 640 |
| 643 void SkPDFImageDumpStats() { | 641 void SkPDFImageDumpStats() { |
| 644 SkDebugf("\ntotal PDF drawImage/drawBitmap calls: %d\n" | 642 SkDebugf("\ntotal PDF drawImage/drawBitmap calls: %d\n" |
| 645 "total PDF jpeg images: %d\n" | 643 "total PDF jpeg images: %d\n" |
| 646 "total PDF regular images: %d\n", | 644 "total PDF regular images: %d\n", |
| 647 gDrawImageCalls.load(), | 645 gDrawImageCalls.load(), |
| 648 gJpegImageObjects.load(), | 646 gJpegImageObjects.load(), |
| 649 gRegularImageObjects.load()); | 647 gRegularImageObjects.load()); |
| 650 } | 648 } |
| 651 #endif // SK_PDF_IMAGE_STATS | 649 #endif // SK_PDF_IMAGE_STATS |
| OLD | NEW |