| OLD | NEW |
| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 306 // Rewind the stream if needed |
| 307 if (!this->handleRewind()) { | 307 if (!this->handleRewind()) { |
| 308 return fDecoderMgr->returnFailure("could not rewind stream", kCouldNotRe
wind); | 308 return fDecoderMgr->returnFailure("could not rewind stream", kCouldNotRe
wind); |
| 309 } | 309 } |
| 310 | 310 |
| 311 if (options.fSubset) { |
| 312 // Subsets are not supported. |
| 313 return kUnimplemented; |
| 314 } |
| 315 |
| 311 // Get a pointer to the decompress info since we will use it quite frequentl
y | 316 // Get a pointer to the decompress info since we will use it quite frequentl
y |
| 312 jpeg_decompress_struct* dinfo = fDecoderMgr->dinfo(); | 317 jpeg_decompress_struct* dinfo = fDecoderMgr->dinfo(); |
| 313 | 318 |
| 314 // Set the jump location for libjpeg errors | 319 // Set the jump location for libjpeg errors |
| 315 if (setjmp(fDecoderMgr->getJmpBuf())) { | 320 if (setjmp(fDecoderMgr->getJmpBuf())) { |
| 316 return fDecoderMgr->returnFailure("setjmp", kInvalidInput); | 321 return fDecoderMgr->returnFailure("setjmp", kInvalidInput); |
| 317 } | 322 } |
| 318 | 323 |
| 319 // Check if we can decode to the requested destination and set the output co
lor space | 324 // Check if we can decode to the requested destination and set the output co
lor space |
| 320 if (!this->setOutputColorSpace(dstInfo)) { | 325 if (!this->setOutputColorSpace(dstInfo)) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 | 494 |
| 490 // Now, given valid output dimensions, we can start the decompress | 495 // Now, given valid output dimensions, we can start the decompress |
| 491 if (!turbo_jpeg_start_decompress(codec->fDecoderMgr->dinfo())) { | 496 if (!turbo_jpeg_start_decompress(codec->fDecoderMgr->dinfo())) { |
| 492 SkCodecPrintf("start decompress failed\n"); | 497 SkCodecPrintf("start decompress failed\n"); |
| 493 return NULL; | 498 return NULL; |
| 494 } | 499 } |
| 495 | 500 |
| 496 // Return the new scanline decoder | 501 // Return the new scanline decoder |
| 497 return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, codec.detach())); | 502 return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, codec.detach())); |
| 498 } | 503 } |
| OLD | NEW |