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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 376 |
377 return kSuccess; | 377 return kSuccess; |
378 } | 378 } |
379 | 379 |
380 /* | 380 /* |
381 * Enable scanline decoding for jpegs | 381 * Enable scanline decoding for jpegs |
382 */ | 382 */ |
383 class SkJpegScanlineDecoder : public SkScanlineDecoder { | 383 class SkJpegScanlineDecoder : public SkScanlineDecoder { |
384 public: | 384 public: |
385 SkJpegScanlineDecoder(const SkImageInfo& dstInfo, SkJpegCodec* codec) | 385 SkJpegScanlineDecoder(const SkImageInfo& dstInfo, SkJpegCodec* codec) |
386 : INHERITED(dstInfo) | 386 : INHERITED(dstInfo, codec->getInfo()) |
387 , fCodec(codec) | 387 , fCodec(codec) |
388 {} | 388 {} |
389 | 389 |
390 virtual ~SkJpegScanlineDecoder() { | 390 virtual ~SkJpegScanlineDecoder() { |
391 if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) { | 391 if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) { |
392 SkCodecPrintf("setjmp: Error in libjpeg finish_decompress\n"); | 392 SkCodecPrintf("setjmp: Error in libjpeg finish_decompress\n"); |
393 return; | 393 return; |
394 } | 394 } |
395 | 395 |
396 // We may not have decoded the entire image. Prevent libjpeg-turbo from
failing on a | 396 // We may not have decoded the entire image. Prevent libjpeg-turbo from
failing on a |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 494 |
495 // Now, given valid output dimensions, we can start the decompress | 495 // Now, given valid output dimensions, we can start the decompress |
496 if (!turbo_jpeg_start_decompress(codec->fDecoderMgr->dinfo())) { | 496 if (!turbo_jpeg_start_decompress(codec->fDecoderMgr->dinfo())) { |
497 SkCodecPrintf("start decompress failed\n"); | 497 SkCodecPrintf("start decompress failed\n"); |
498 return NULL; | 498 return NULL; |
499 } | 499 } |
500 | 500 |
501 // Return the new scanline decoder | 501 // Return the new scanline decoder |
502 return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, codec.detach())); | 502 return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, codec.detach())); |
503 } | 503 } |
OLD | NEW |