| 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 // Try the next scale | 467 // Try the next scale |
| 468 num -= 1; | 468 num -= 1; |
| 469 calc_output_dimensions(&dinfo, num, denom); | 469 calc_output_dimensions(&dinfo, num, denom); |
| 470 } | 470 } |
| 471 | 471 |
| 472 fDecoderMgr->dinfo()->scale_num = num; | 472 fDecoderMgr->dinfo()->scale_num = num; |
| 473 fDecoderMgr->dinfo()->scale_denom = denom; | 473 fDecoderMgr->dinfo()->scale_denom = denom; |
| 474 return true; | 474 return true; |
| 475 } | 475 } |
| 476 | 476 |
| 477 static bool needs_color_xform(const SkImageInfo& dstInfo, const SkImageInfo& src
Info) { | |
| 478 // FIXME (msarett): | |
| 479 // Do a better check for color space equality. | |
| 480 return (kRGBA_F16_SkColorType == dstInfo.colorType()) || | |
| 481 (dstInfo.colorSpace() && (dstInfo.colorSpace() != srcInfo.colorSpace(
))); | |
| 482 } | |
| 483 | |
| 484 int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes
, int count) { | 477 int SkJpegCodec::readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes
, int count) { |
| 485 // Set the jump location for libjpeg-turbo errors | 478 // Set the jump location for libjpeg-turbo errors |
| 486 if (setjmp(fDecoderMgr->getJmpBuf())) { | 479 if (setjmp(fDecoderMgr->getJmpBuf())) { |
| 487 return 0; | 480 return 0; |
| 488 } | 481 } |
| 489 | 482 |
| 490 // When fSwizzleSrcRow is non-null, it means that we need to swizzle. In th
is case, | 483 // When fSwizzleSrcRow is non-null, it means that we need to swizzle. In th
is case, |
| 491 // we will always decode into fSwizzlerSrcRow before swizzling into the next
buffer. | 484 // we will always decode into fSwizzlerSrcRow before swizzling into the next
buffer. |
| 492 // We can never swizzle "in place" because the swizzler may perform sampling
and/or | 485 // We can never swizzle "in place" because the swizzler may perform sampling
and/or |
| 493 // subsetting. | 486 // subsetting. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 519 sk_msan_mark_initialized(decodeDst, decodeDst + srcRowBytes, "skbug.com/
4550"); | 512 sk_msan_mark_initialized(decodeDst, decodeDst + srcRowBytes, "skbug.com/
4550"); |
| 520 if (0 == lines) { | 513 if (0 == lines) { |
| 521 return y; | 514 return y; |
| 522 } | 515 } |
| 523 | 516 |
| 524 if (fSwizzler) { | 517 if (fSwizzler) { |
| 525 fSwizzler->swizzle(swizzleDst, decodeDst); | 518 fSwizzler->swizzle(swizzleDst, decodeDst); |
| 526 } | 519 } |
| 527 | 520 |
| 528 if (fColorXform) { | 521 if (fColorXform) { |
| 529 int width = dstInfo.width(); | 522 fColorXform->apply(dst, swizzleDst, dstInfo.width(), dstInfo.colorTy
pe(), false); |
| 530 switch (dstInfo.colorType()) { | |
| 531 case kRGBA_8888_SkColorType: | |
| 532 fColorXform->applyToRGBA((uint32_t*) dst, swizzleDst, width)
; | |
| 533 break; | |
| 534 case kBGRA_8888_SkColorType: | |
| 535 fColorXform->applyToBGRA((uint32_t*) dst, swizzleDst, width)
; | |
| 536 break; | |
| 537 case kRGBA_F16_SkColorType: | |
| 538 fColorXform->applyToF16((uint64_t*) dst, swizzleDst, width); | |
| 539 break; | |
| 540 default: | |
| 541 SkASSERT(false); | |
| 542 break; | |
| 543 } | |
| 544 | |
| 545 dst = SkTAddOffset<void>(dst, rowBytes); | 523 dst = SkTAddOffset<void>(dst, rowBytes); |
| 546 } | 524 } |
| 547 | 525 |
| 548 decodeDst = SkTAddOffset<JSAMPLE>(decodeDst, decodeDstRowBytes); | 526 decodeDst = SkTAddOffset<JSAMPLE>(decodeDst, decodeDstRowBytes); |
| 549 swizzleDst = SkTAddOffset<uint32_t>(swizzleDst, swizzleDstRowBytes); | 527 swizzleDst = SkTAddOffset<uint32_t>(swizzleDst, swizzleDstRowBytes); |
| 550 } | 528 } |
| 551 | 529 |
| 552 return count; | 530 return count; |
| 553 } | 531 } |
| 554 | 532 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 | 971 |
| 994 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); | 972 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); |
| 995 if (linesRead < remainingRows) { | 973 if (linesRead < remainingRows) { |
| 996 // FIXME: Handle incomplete YUV decodes without signalling an error. | 974 // FIXME: Handle incomplete YUV decodes without signalling an error. |
| 997 return kInvalidInput; | 975 return kInvalidInput; |
| 998 } | 976 } |
| 999 } | 977 } |
| 1000 | 978 |
| 1001 return kSuccess; | 979 return kSuccess; |
| 1002 } | 980 } |
| OLD | NEW |