| 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 "SkMSAN.h" | 9 #include "SkMSAN.h" |
| 10 #include "SkJpegCodec.h" | 10 #include "SkJpegCodec.h" |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 // Try the next scale | 462 // Try the next scale |
| 463 num -= 1; | 463 num -= 1; |
| 464 calc_output_dimensions(&dinfo, num, denom); | 464 calc_output_dimensions(&dinfo, num, denom); |
| 465 } | 465 } |
| 466 | 466 |
| 467 fDecoderMgr->dinfo()->scale_num = num; | 467 fDecoderMgr->dinfo()->scale_num = num; |
| 468 fDecoderMgr->dinfo()->scale_denom = denom; | 468 fDecoderMgr->dinfo()->scale_denom = denom; |
| 469 return true; | 469 return true; |
| 470 } | 470 } |
| 471 | 471 |
| 472 static bool needs_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& src
Info) { | |
| 473 // FIXME (msarett): | |
| 474 // Do a better check for color space equality. | |
| 475 return (kRGBA_F16_SkColorType == dstInfo.colorType()) || | |
| 476 (dstInfo.colorSpace() && (dstInfo.colorSpace() != srcInfo.colorSpace(
))); | |
| 477 } | |
| 478 | |
| 479 int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes
, int count) { | 472 int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes
, int count) { |
| 480 // Set the jump location for libjpeg-turbo errors | 473 // Set the jump location for libjpeg-turbo errors |
| 481 if (setjmp(fDecoderMgr->getJmpBuf())) { | 474 if (setjmp(fDecoderMgr->getJmpBuf())) { |
| 482 return 0; | 475 return 0; |
| 483 } | 476 } |
| 484 | 477 |
| 485 // When fSwizzleSrcRow is non-null, it means that we need to swizzle. In th
is case, | 478 // When fSwizzleSrcRow is non-null, it means that we need to swizzle. In th
is case, |
| 486 // we will always decode into fSwizzlerSrcRow before swizzling into the next
buffer. | 479 // we will always decode into fSwizzlerSrcRow before swizzling into the next
buffer. |
| 487 // We can never swizzle "in place" because the swizzler may perform sampling
and/or | 480 // We can never swizzle "in place" because the swizzler may perform sampling
and/or |
| 488 // subsetting. | 481 // subsetting. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 513 sk_msan_mark_initialized(decodeDst, decodeDst + rowBytes, "skbug.com/455
0"); | 506 sk_msan_mark_initialized(decodeDst, decodeDst + rowBytes, "skbug.com/455
0"); |
| 514 if (0 == lines) { | 507 if (0 == lines) { |
| 515 return y; | 508 return y; |
| 516 } | 509 } |
| 517 | 510 |
| 518 if (fSwizzler) { | 511 if (fSwizzler) { |
| 519 fSwizzler->swizzle(swizzleDst, decodeDst); | 512 fSwizzler->swizzle(swizzleDst, decodeDst); |
| 520 } | 513 } |
| 521 | 514 |
| 522 if (fColorXform) { | 515 if (fColorXform) { |
| 523 int width = dstInfo.width(); | 516 fColorXform->apply(dst, swizzleDst, dstInfo.width(), dstInfo.colorTy
pe(), false); |
| 524 switch (dstInfo.colorType()) { | |
| 525 case kRGBA_8888_SkColorType: | |
| 526 fColorXform->applyToRGBA((uint32_t*) dst, swizzleDst, width)
; | |
| 527 break; | |
| 528 case kBGRA_8888_SkColorType: | |
| 529 fColorXform->applyToBGRA((uint32_t*) dst, swizzleDst, width)
; | |
| 530 break; | |
| 531 case kRGBA_F16_SkColorType: | |
| 532 fColorXform->applyToF16((uint64_t*) dst, swizzleDst, width); | |
| 533 break; | |
| 534 default: | |
| 535 SkASSERT(false); | |
| 536 break; | |
| 537 } | |
| 538 | |
| 539 dst = SkTAddOffset<void>(dst, rowBytes); | 517 dst = SkTAddOffset<void>(dst, rowBytes); |
| 540 } | 518 } |
| 541 | 519 |
| 542 decodeDst = SkTAddOffset<JSAMPLE>(decodeDst, decodeDstRowBytes); | 520 decodeDst = SkTAddOffset<JSAMPLE>(decodeDst, decodeDstRowBytes); |
| 543 swizzleDst = SkTAddOffset<uint32_t>(swizzleDst, swizzleDstRowBytes); | 521 swizzleDst = SkTAddOffset<uint32_t>(swizzleDst, swizzleDstRowBytes); |
| 544 } | 522 } |
| 545 | 523 |
| 546 return count; | 524 return count; |
| 547 } | 525 } |
| 548 | 526 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 | 964 |
| 987 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); | 965 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); |
| 988 if (linesRead < remainingRows) { | 966 if (linesRead < remainingRows) { |
| 989 // FIXME: Handle incomplete YUV decodes without signalling an error. | 967 // FIXME: Handle incomplete YUV decodes without signalling an error. |
| 990 return kInvalidInput; | 968 return kInvalidInput; |
| 991 } | 969 } |
| 992 } | 970 } |
| 993 | 971 |
| 994 return kSuccess; | 972 return kSuccess; |
| 995 } | 973 } |
| OLD | NEW |