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

Side by Side Diff: src/codec/SkRawCodec.cpp

Issue 1757353002: Verify the full size returned by PIEX (Closed) Base URL: https://skia.googlesource.com/skia.git@gifFix
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "SkCodec.h" 8 #include "SkCodec.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 fIsXtransImage = fIsScalable ? (cfaPatternSize.v == 6 && cfaPatternSize. h == 6) : false; 508 fIsXtransImage = fIsScalable ? (cfaPatternSize.v == 6 && cfaPatternSize. h == 6) : false;
509 } 509 }
510 510
511 bool initFromPiex() { 511 bool initFromPiex() {
512 // Does not take the ownership of rawStream. 512 // Does not take the ownership of rawStream.
513 SkPiexStream piexStream(fStream.get()); 513 SkPiexStream piexStream(fStream.get());
514 ::piex::PreviewImageData imageData; 514 ::piex::PreviewImageData imageData;
515 if (::piex::IsRaw(&piexStream) 515 if (::piex::IsRaw(&piexStream)
516 && ::piex::GetPreviewImageData(&piexStream, &imageData) == ::piex::E rror::kOk) 516 && ::piex::GetPreviewImageData(&piexStream, &imageData) == ::piex::E rror::kOk)
517 { 517 {
518 // Verify the size information, as it is only optional information f or PIEX.
519 if (imageData.full_width == 0 || imageData.full_height == 0) {
520 return false;
521 }
522
518 dng_point cfaPatternSize(imageData.cfa_pattern_dim[1], imageData.cfa _pattern_dim[0]); 523 dng_point cfaPatternSize(imageData.cfa_pattern_dim[1], imageData.cfa _pattern_dim[0]);
519 this->init(static_cast<int>(imageData.full_width), 524 this->init(static_cast<int>(imageData.full_width),
520 static_cast<int>(imageData.full_height), cfaPatternSize); 525 static_cast<int>(imageData.full_height), cfaPatternSize);
521 return true; 526 return true;
522 } 527 }
523 return false; 528 return false;
524 } 529 }
525 530
526 bool readDng() { 531 bool readDng() {
527 try { 532 try {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 } 668 }
664 669
665 swizzler->swizzle(dstRow, &srcRow[0]); 670 swizzler->swizzle(dstRow, &srcRow[0]);
666 dstRow = SkTAddOffset<void>(dstRow, dstRowBytes); 671 dstRow = SkTAddOffset<void>(dstRow, dstRowBytes);
667 } 672 }
668 return kSuccess; 673 return kSuccess;
669 } 674 }
670 675
671 SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const { 676 SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const {
672 SkASSERT(desiredScale <= 1.f); 677 SkASSERT(desiredScale <= 1.f);
678
673 const SkISize dim = this->getInfo().dimensions(); 679 const SkISize dim = this->getInfo().dimensions();
680 SkASSERT(dim.fWidth != 0 && dim.fHeight != 0);
681
674 if (!fDngImage->isScalable()) { 682 if (!fDngImage->isScalable()) {
675 return dim; 683 return dim;
676 } 684 }
677 685
678 // Limits the minimum size to be 80 on the short edge. 686 // Limits the minimum size to be 80 on the short edge.
679 const float shortEdge = static_cast<float>(SkTMin(dim.fWidth, dim.fHeight)); 687 const float shortEdge = static_cast<float>(SkTMin(dim.fWidth, dim.fHeight));
680 if (desiredScale < 80.f / shortEdge) { 688 if (desiredScale < 80.f / shortEdge) {
681 desiredScale = 80.f / shortEdge; 689 desiredScale = 80.f / shortEdge;
682 } 690 }
683 691
(...skipping 17 matching lines...) Expand all
701 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd ge / shortEdge)); 709 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd ge / shortEdge));
702 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge / shortEdge)); 710 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge / shortEdge));
703 return sizeFloor == dim || sizeCeil == dim; 711 return sizeFloor == dim || sizeCeil == dim;
704 } 712 }
705 713
706 SkRawCodec::~SkRawCodec() {} 714 SkRawCodec::~SkRawCodec() {}
707 715
708 SkRawCodec::SkRawCodec(SkDngImage* dngImage) 716 SkRawCodec::SkRawCodec(SkDngImage* dngImage)
709 : INHERITED(dngImage->getImageInfo(), nullptr) 717 : INHERITED(dngImage->getImageInfo(), nullptr)
710 , fDngImage(dngImage) {} 718 , fDngImage(dngImage) {}
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698