Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: src/pdf/SkPDFImage.cpp

Issue 340783013: Switch SkPDFStream's internal storage from SkStream to SkData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 }
OLDNEW
« src/pdf/SkPDFFont.cpp ('K') | « src/pdf/SkPDFFont.cpp ('k') | src/pdf/SkPDFStream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698