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

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

Issue 1516833003: Switch SkAutoMalloc to SkAutoTMalloc to avoid cast (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Go back to patch set 3 Created 5 years 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/codec/SkWebpCodec.cpp » ('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 2015 Google Inc. 2 * Copyright 2015 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 "SkMath.h" 10 #include "SkMath.h"
11 #include "SkSampledCodec.h" 11 #include "SkSampledCodec.h"
12 #include "SkTemplates.h"
12 13
13 SkSampledCodec::SkSampledCodec(SkCodec* codec) 14 SkSampledCodec::SkSampledCodec(SkCodec* codec)
14 : INHERITED(codec->getInfo()) 15 : INHERITED(codec->getInfo())
15 , fCodec(codec) 16 , fCodec(codec)
16 {} 17 {}
17 18
18 SkISize SkSampledCodec::accountForNativeScaling(int* sampleSizePtr, int* nativeS ampleSize) const { 19 SkISize SkSampledCodec::accountForNativeScaling(int* sampleSizePtr, int* nativeS ampleSize) const {
19 SkISize preSampledSize = fCodec->getInfo().dimensions(); 20 SkISize preSampledSize = fCodec->getInfo().dimensions();
20 int sampleSize = *sampleSizePtr; 21 int sampleSize = *sampleSizePtr;
21 SkASSERT(sampleSize > 1); 22 SkASSERT(sampleSize > 1);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 continue; 261 continue;
261 } 262 }
262 263
263 void* rowPtr = SkTAddOffset<void>(pixels, rowBytes * get_dst_coo rd(srcY, sampleY)); 264 void* rowPtr = SkTAddOffset<void>(pixels, rowBytes * get_dst_coo rd(srcY, sampleY));
264 SkSampler::Fill(fillInfo, rowPtr, rowBytes, fillValue, options.f ZeroInitialized); 265 SkSampler::Fill(fillInfo, rowPtr, rowBytes, fillValue, options.f ZeroInitialized);
265 } 266 }
266 return SkCodec::kIncompleteInput; 267 return SkCodec::kIncompleteInput;
267 } 268 }
268 case SkCodec::kNone_SkScanlineOrder: { 269 case SkCodec::kNone_SkScanlineOrder: {
269 const int linesNeeded = subsetHeight - samplingOffsetY; 270 const int linesNeeded = subsetHeight - samplingOffsetY;
270 SkAutoMalloc storage(linesNeeded * rowBytes); 271 SkAutoTMalloc<uint8_t> storage(linesNeeded * rowBytes);
271 uint8_t* storagePtr = static_cast<uint8_t*>(storage.get()); 272 uint8_t* storagePtr = storage.get();
272 273
273 if (!fCodec->skipScanlines(startY)) { 274 if (!fCodec->skipScanlines(startY)) {
274 fCodec->fillIncompleteImage(info, pixels, rowBytes, options.fZer oInitialized, 275 fCodec->fillIncompleteImage(info, pixels, rowBytes, options.fZer oInitialized,
275 dstHeight, 0); 276 dstHeight, 0);
276 return SkCodec::kIncompleteInput; 277 return SkCodec::kIncompleteInput;
277 } 278 }
278 int scanlines = fCodec->getScanlines(storagePtr, linesNeeded, rowByt es); 279 int scanlines = fCodec->getScanlines(storagePtr, linesNeeded, rowByt es);
279 280
280 for (int y = 0; y < dstHeight; y++) { 281 for (int y = 0; y < dstHeight; y++) {
281 memcpy(pixels, storagePtr, info.minRowBytes()); 282 memcpy(pixels, storagePtr, info.minRowBytes());
282 storagePtr += sampleY * rowBytes; 283 storagePtr += sampleY * rowBytes;
283 pixels = SkTAddOffset<void>(pixels, rowBytes); 284 pixels = SkTAddOffset<void>(pixels, rowBytes);
284 } 285 }
285 286
286 if (scanlines < dstHeight) { 287 if (scanlines < dstHeight) {
287 // fCodec has already handled filling uninitialized memory. 288 // fCodec has already handled filling uninitialized memory.
288 return SkCodec::kIncompleteInput; 289 return SkCodec::kIncompleteInput;
289 } 290 }
290 return SkCodec::kSuccess; 291 return SkCodec::kSuccess;
291 } 292 }
292 default: 293 default:
293 SkASSERT(false); 294 SkASSERT(false);
294 return SkCodec::kUnimplemented; 295 return SkCodec::kUnimplemented;
295 } 296 }
296 } 297 }
OLDNEW
« no previous file with comments | « src/codec/SkJpegCodec.cpp ('k') | src/codec/SkWebpCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698