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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 // Read rows of the image | 347 // Read rows of the image |
348 uint32_t rowsDecoded = turbo_jpeg_read_scanlines(dinfo, &dstRow, 1); | 348 uint32_t rowsDecoded = turbo_jpeg_read_scanlines(dinfo, &dstRow, 1); |
349 | 349 |
350 // If we cannot read enough rows, assume the input is incomplete | 350 // If we cannot read enough rows, assume the input is incomplete |
351 if (rowsDecoded != 1) { | 351 if (rowsDecoded != 1) { |
352 // Fill the remainder of the image with black. This error handling | 352 // Fill the remainder of the image with black. This error handling |
353 // behavior is unspecified but SkCodec consistently uses black as | 353 // behavior is unspecified but SkCodec consistently uses black as |
354 // the fill color for opaque images. If the destination is kGray, | 354 // the fill color for opaque images. If the destination is kGray, |
355 // the low 8 bits of SK_ColorBLACK will be used. Conveniently, | 355 // the low 8 bits of SK_ColorBLACK will be used. Conveniently, |
356 // these are zeros, which is the representation for black in kGray. | 356 // these are zeros, which is the representation for black in kGray. |
357 // If the destination is kRGB_565, the low 16 bits of SK_ColorBLACK | |
358 // will be used. Conveniently, these are zeros, which is the | |
scroggo
2015/07/29 17:15:14
nit: if kYes_ZeroInitialized, we could skip this.
msarett
2015/07/29 17:29:39
Done.
| |
359 // representation for black in kRGB_565. | |
357 SkSwizzler::Fill(dstRow, dstInfo, dstRowBytes, dstHeight - y, SK_Col orBLACK, NULL); | 360 SkSwizzler::Fill(dstRow, dstInfo, dstRowBytes, dstHeight - y, SK_Col orBLACK, NULL); |
358 | 361 |
359 // Prevent libjpeg from failing on incomplete decode | 362 // Prevent libjpeg from failing on incomplete decode |
360 dinfo->output_scanline = dstHeight; | 363 dinfo->output_scanline = dstHeight; |
361 | 364 |
362 // Finish the decode and indicate that the input was incomplete. | 365 // Finish the decode and indicate that the input was incomplete. |
363 turbo_jpeg_finish_decompress(dinfo); | 366 turbo_jpeg_finish_decompress(dinfo); |
364 return fDecoderMgr->returnFailure("Incomplete image data", kIncomple teInput); | 367 return fDecoderMgr->returnFailure("Incomplete image data", kIncomple teInput); |
365 } | 368 } |
366 | 369 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 | 497 |
495 // Now, given valid output dimensions, we can start the decompress | 498 // Now, given valid output dimensions, we can start the decompress |
496 if (!turbo_jpeg_start_decompress(codec->fDecoderMgr->dinfo())) { | 499 if (!turbo_jpeg_start_decompress(codec->fDecoderMgr->dinfo())) { |
497 SkCodecPrintf("start decompress failed\n"); | 500 SkCodecPrintf("start decompress failed\n"); |
498 return NULL; | 501 return NULL; |
499 } | 502 } |
500 | 503 |
501 // Return the new scanline decoder | 504 // Return the new scanline decoder |
502 return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, codec.detach())); | 505 return SkNEW_ARGS(SkJpegScanlineDecoder, (dstInfo, codec.detach())); |
503 } | 506 } |
OLD | NEW |