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" |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // This will allow read less than the requested "size", because the JPEG
codec wants to | 374 // This will allow read less than the requested "size", because the JPEG
codec wants to |
375 // handle also a partial JPEG file. | 375 // handle also a partial JPEG file. |
376 const size_t bytesToRead = SkTMin(sum, fStream->getLength()) - offset; | 376 const size_t bytesToRead = SkTMin(sum, fStream->getLength()) - offset; |
377 if (bytesToRead == 0) { | 377 if (bytesToRead == 0) { |
378 return nullptr; | 378 return nullptr; |
379 } | 379 } |
380 | 380 |
381 if (fStream->getMemoryBase()) { // directly copy if getMemoryBase() is
available. | 381 if (fStream->getMemoryBase()) { // directly copy if getMemoryBase() is
available. |
382 SkAutoTUnref<SkData> data(SkData::NewWithCopy( | 382 SkAutoTUnref<SkData> data(SkData::NewWithCopy( |
383 static_cast<const uint8_t*>(fStream->getMemoryBase()) + offset,
bytesToRead)); | 383 static_cast<const uint8_t*>(fStream->getMemoryBase()) + offset,
bytesToRead)); |
384 fStream.free(); | 384 fStream.reset(); |
385 return new SkMemoryStream(data); | 385 return new SkMemoryStream(data); |
386 } else { | 386 } else { |
387 SkAutoTUnref<SkData> data(SkData::NewUninitialized(bytesToRead)); | 387 SkAutoTUnref<SkData> data(SkData::NewUninitialized(bytesToRead)); |
388 if (!fStream->seek(offset)) { | 388 if (!fStream->seek(offset)) { |
389 return nullptr; | 389 return nullptr; |
390 } | 390 } |
391 const size_t bytesRead = fStream->read(data->writable_data(), bytesT
oRead); | 391 const size_t bytesRead = fStream->read(data->writable_data(), bytesT
oRead); |
392 if (bytesRead < bytesToRead) { | 392 if (bytesRead < bytesToRead) { |
393 data.reset(SkData::NewSubset(data.get(), 0, bytesRead)); | 393 data.reset(SkData::NewSubset(data.get(), 0, bytesRead)); |
394 } | 394 } |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd
ge / shortEdge)); | 752 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd
ge / shortEdge)); |
753 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge
/ shortEdge)); | 753 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge
/ shortEdge)); |
754 return sizeFloor == dim || sizeCeil == dim; | 754 return sizeFloor == dim || sizeCeil == dim; |
755 } | 755 } |
756 | 756 |
757 SkRawCodec::~SkRawCodec() {} | 757 SkRawCodec::~SkRawCodec() {} |
758 | 758 |
759 SkRawCodec::SkRawCodec(SkDngImage* dngImage) | 759 SkRawCodec::SkRawCodec(SkDngImage* dngImage) |
760 : INHERITED(dngImage->getImageInfo(), nullptr) | 760 : INHERITED(dngImage->getImageInfo(), nullptr) |
761 , fDngImage(dngImage) {} | 761 , fDngImage(dngImage) {} |
OLD | NEW |