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

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

Issue 1813843002: Revert of free -> reset (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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 | « src/codec/SkJpegCodec.cpp ('k') | src/core/SkAdvancedTypefaceMetrics.h » ('j') | 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.reset(); 384 fStream.free();
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
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) {}
OLDNEW
« no previous file with comments | « src/codec/SkJpegCodec.cpp ('k') | src/core/SkAdvancedTypefaceMetrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698