OLD | NEW |
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" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #if !defined(GOOGLE3) | |
13 #include "SkJpegCodec.h" | 12 #include "SkJpegCodec.h" |
14 #endif | |
15 #include "SkRawCodec.h" | 13 #include "SkRawCodec.h" |
16 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
17 #include "SkStream.h" | 15 #include "SkStream.h" |
18 #include "SkStreamPriv.h" | 16 #include "SkStreamPriv.h" |
19 #include "SkSwizzler.h" | 17 #include "SkSwizzler.h" |
20 #include "SkTaskGroup.h" | 18 #include "SkTaskGroup.h" |
21 #include "SkTemplates.h" | 19 #include "SkTemplates.h" |
22 #include "SkTypes.h" | 20 #include "SkTypes.h" |
23 | 21 |
24 #include "dng_area_task.h" | 22 #include "dng_area_task.h" |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 rawStream.reset(new SkRawBufferedStream(stream)); | 564 rawStream.reset(new SkRawBufferedStream(stream)); |
567 } | 565 } |
568 | 566 |
569 // Does not take the ownership of rawStream. | 567 // Does not take the ownership of rawStream. |
570 SkPiexStream piexStream(rawStream.get()); | 568 SkPiexStream piexStream(rawStream.get()); |
571 ::piex::PreviewImageData imageData; | 569 ::piex::PreviewImageData imageData; |
572 if (::piex::IsRaw(&piexStream)) { | 570 if (::piex::IsRaw(&piexStream)) { |
573 ::piex::Error error = ::piex::GetPreviewImageData(&piexStream, &imageDat
a); | 571 ::piex::Error error = ::piex::GetPreviewImageData(&piexStream, &imageDat
a); |
574 | 572 |
575 if (error == ::piex::Error::kOk && imageData.preview.length > 0) { | 573 if (error == ::piex::Error::kOk && imageData.preview.length > 0) { |
576 #if !defined(GOOGLE3) | |
577 // transferBuffer() is destructive to the rawStream. Abandon the raw
Stream after this | 574 // transferBuffer() is destructive to the rawStream. Abandon the raw
Stream after this |
578 // function call. | 575 // function call. |
579 // FIXME: one may avoid the copy of memoryStream and use the buffere
d rawStream. | 576 // FIXME: one may avoid the copy of memoryStream and use the buffere
d rawStream. |
580 SkMemoryStream* memoryStream = | 577 SkMemoryStream* memoryStream = |
581 rawStream->transferBuffer(imageData.preview.offset, imageData.pr
eview.length); | 578 rawStream->transferBuffer(imageData.preview.offset, imageData.pr
eview.length); |
582 return memoryStream ? SkJpegCodec::NewFromStream(memoryStream) : nul
lptr; | 579 return memoryStream ? SkJpegCodec::NewFromStream(memoryStream) : nul
lptr; |
583 #else | |
584 return nullptr; | |
585 #endif | |
586 } else if (error == ::piex::Error::kFail) { | 580 } else if (error == ::piex::Error::kFail) { |
587 return nullptr; | 581 return nullptr; |
588 } | 582 } |
589 } | 583 } |
590 | 584 |
591 // Takes the ownership of the rawStream. | 585 // Takes the ownership of the rawStream. |
592 SkAutoTDelete<SkDngImage> dngImage(SkDngImage::NewFromStream(rawStream.relea
se())); | 586 SkAutoTDelete<SkDngImage> dngImage(SkDngImage::NewFromStream(rawStream.relea
se())); |
593 if (!dngImage) { | 587 if (!dngImage) { |
594 return nullptr; | 588 return nullptr; |
595 } | 589 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd
ge / shortEdge)); | 682 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd
ge / shortEdge)); |
689 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge
/ shortEdge)); | 683 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge
/ shortEdge)); |
690 return sizeFloor == dim || sizeCeil == dim; | 684 return sizeFloor == dim || sizeCeil == dim; |
691 } | 685 } |
692 | 686 |
693 SkRawCodec::~SkRawCodec() {} | 687 SkRawCodec::~SkRawCodec() {} |
694 | 688 |
695 SkRawCodec::SkRawCodec(SkDngImage* dngImage) | 689 SkRawCodec::SkRawCodec(SkDngImage* dngImage) |
696 : INHERITED(dngImage->getImageInfo(), nullptr) | 690 : INHERITED(dngImage->getImageInfo(), nullptr) |
697 , fDngImage(dngImage) {} | 691 , fDngImage(dngImage) {} |
OLD | NEW |