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

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

Issue 1381483002: Call rewindIfNeeded in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@codecSDmerge
Patch Set: Rebase Created 5 years, 2 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/SkCodec_wbmp.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 "SkJpegCodec.h" 9 #include "SkJpegCodec.h"
10 #include "SkJpegDecoderMgr.h" 10 #include "SkJpegDecoderMgr.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 return true; 297 return true;
298 } 298 }
299 299
300 /* 300 /*
301 * Performs the jpeg decode 301 * Performs the jpeg decode
302 */ 302 */
303 SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo, 303 SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
304 void* dst, size_t dstRowBytes, 304 void* dst, size_t dstRowBytes,
305 const Options& options, SkPMColor*, int *) { 305 const Options& options, SkPMColor*, int *) {
306 // Rewind the stream if needed
307 if (!this->rewindIfNeeded()) {
308 return fDecoderMgr->returnFailure("could not rewind stream", kCouldNotRe wind);
309 }
310
311 if (options.fSubset) { 306 if (options.fSubset) {
312 // Subsets are not supported. 307 // Subsets are not supported.
313 return kUnimplemented; 308 return kUnimplemented;
314 } 309 }
315 310
316 // Get a pointer to the decompress info since we will use it quite frequentl y 311 // Get a pointer to the decompress info since we will use it quite frequentl y
317 jpeg_decompress_struct* dinfo = fDecoderMgr->dinfo(); 312 jpeg_decompress_struct* dinfo = fDecoderMgr->dinfo();
318 313
319 // Set the jump location for libjpeg errors 314 // Set the jump location for libjpeg errors
320 if (setjmp(fDecoderMgr->getJmpBuf())) { 315 if (setjmp(fDecoderMgr->getJmpBuf())) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 this->getInfo())); 400 this->getInfo()));
406 if (!fSwizzler) { 401 if (!fSwizzler) {
407 return SkCodec::kUnimplemented; 402 return SkCodec::kUnimplemented;
408 } 403 }
409 404
410 return kSuccess; 405 return kSuccess;
411 } 406 }
412 407
413 SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, 408 SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
414 const Options& options, SkPMColor ctable[], int* ctableCount) { 409 const Options& options, SkPMColor ctable[], int* ctableCount) {
415 // Rewind the stream if needed
416 if (!this->rewindIfNeeded()) {
417 return kCouldNotRewind;
418 }
419
420 // Set the jump location for libjpeg errors 410 // Set the jump location for libjpeg errors
421 if (setjmp(fDecoderMgr->getJmpBuf())) { 411 if (setjmp(fDecoderMgr->getJmpBuf())) {
422 SkCodecPrintf("setjmp: Error from libjpeg\n"); 412 SkCodecPrintf("setjmp: Error from libjpeg\n");
423 return kInvalidInput; 413 return kInvalidInput;
424 } 414 }
425 415
426 // Check if we can decode to the requested destination and set the output co lor space 416 // Check if we can decode to the requested destination and set the output co lor space
427 if (!this->setOutputColorSpace(dstInfo)) { 417 if (!this->setOutputColorSpace(dstInfo)) {
428 return kInvalidConversion; 418 return kInvalidConversion;
429 } 419 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 // Set the jump location for libjpeg errors 517 // Set the jump location for libjpeg errors
528 if (setjmp(fDecoderMgr->getJmpBuf())) { 518 if (setjmp(fDecoderMgr->getJmpBuf())) {
529 return fDecoderMgr->returnFailure("setjmp", kInvalidInput); 519 return fDecoderMgr->returnFailure("setjmp", kInvalidInput);
530 } 520 }
531 521
532 jpeg_skip_scanlines(fDecoderMgr->dinfo(), count); 522 jpeg_skip_scanlines(fDecoderMgr->dinfo(), count);
533 523
534 return kSuccess; 524 return kSuccess;
535 } 525 }
536 526
OLDNEW
« no previous file with comments | « src/codec/SkCodec_wbmp.cpp ('k') | src/codec/SkWebpCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698