OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
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 "SkPDFImage.h" | 8 #include "SkPDFImage.h" |
9 | 9 |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
591 get_uncompressed_size(fBitmap, fSrcRect) > 1) { | 591 get_uncompressed_size(fBitmap, fSrcRect) > 1) { |
592 SkBitmap subset; | 592 SkBitmap subset; |
593 // Extract subset | 593 // Extract subset |
594 if (!fBitmap.extractSubset(&subset, fSrcRect)) { | 594 if (!fBitmap.extractSubset(&subset, fSrcRect)) { |
595 return false; | 595 return false; |
596 } | 596 } |
597 size_t pixelRefOffset = 0; | 597 size_t pixelRefOffset = 0; |
598 SkAutoTUnref<SkData> data(fEncoder(&pixelRefOffset, subset)); | 598 SkAutoTUnref<SkData> data(fEncoder(&pixelRefOffset, subset)); |
599 if (data.get() && data->size() < get_uncompressed_size(fBitmap, | 599 if (data.get() && data->size() < get_uncompressed_size(fBitmap, |
600 fSrcRect)) { | 600 fSrcRect)) { |
601 SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream, | 601 setData(data.get()); |
mtklein
2014/06/25 18:12:31
this-> everywhere possible?
hal.canary
2014/06/25 18:56:26
Done.
| |
602 (data))); | |
603 setData(stream.get()); | |
604 | 602 |
605 insertName("Filter", "DCTDecode"); | 603 insertName("Filter", "DCTDecode"); |
606 insertInt("ColorTransform", kNoColorTransform); | 604 insertInt("ColorTransform", kNoColorTransform); |
607 insertInt("Length", getData()->getLength()); | 605 insertInt("Length", this->dataSize()); |
608 setState(kCompressed_State); | 606 setState(kCompressed_State); |
609 return true; | 607 return true; |
610 } | 608 } |
611 } | 609 } |
612 // Fallback method | 610 // Fallback method |
613 if (!fStreamValid) { | 611 if (!fStreamValid) { |
614 SkAutoTUnref<SkStream> stream( | 612 SkAutoTUnref<SkStream> stream( |
615 extract_image_data(fBitmap, fSrcRect, fIsAlpha, NULL)); | 613 extract_image_data(fBitmap, fSrcRect, fIsAlpha, NULL)); |
616 setData(stream); | 614 setData(stream); |
617 fStreamValid = true; | 615 fStreamValid = true; |
618 } | 616 } |
619 return INHERITED::populate(catalog); | 617 return INHERITED::populate(catalog); |
620 } else if (getState() == kNoCompression_State && | 618 } else if (getState() == kNoCompression_State && |
621 !skip_compression(catalog) && | 619 !skip_compression(catalog) && |
622 (SkFlate::HaveFlate() || fEncoder)) { | 620 (SkFlate::HaveFlate() || fEncoder)) { |
623 // Compression has not been requested when the stream was first created, | 621 // Compression has not been requested when the stream was first created, |
624 // but the new catalog wants it compressed. | 622 // but the new catalog wants it compressed. |
625 if (!getSubstitute()) { | 623 if (!getSubstitute()) { |
626 SkPDFStream* substitute = SkNEW_ARGS(SkPDFImage, (*this)); | 624 SkPDFStream* substitute = SkNEW_ARGS(SkPDFImage, (*this)); |
627 setSubstitute(substitute); | 625 setSubstitute(substitute); |
628 catalog->setSubstitute(this, substitute); | 626 catalog->setSubstitute(this, substitute); |
629 } | 627 } |
630 return false; | 628 return false; |
631 } | 629 } |
632 return true; | 630 return true; |
633 } | 631 } |
OLD | NEW |