| 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 } | 511 } |
| 512 } | 512 } |
| 513 | 513 |
| 514 return kSuccess; | 514 return kSuccess; |
| 515 } | 515 } |
| 516 | 516 |
| 517 void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options&
options) { | 517 void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options&
options) { |
| 518 // libjpeg-turbo may have already performed color conversion. We must indic
ate the | 518 // libjpeg-turbo may have already performed color conversion. We must indic
ate the |
| 519 // appropriate format to the swizzler. | 519 // appropriate format to the swizzler. |
| 520 SkEncodedInfo swizzlerInfo = this->getEncodedInfo(); | 520 SkEncodedInfo swizzlerInfo = this->getEncodedInfo(); |
| 521 bool preSwizzled = true; |
| 521 switch (fDecoderMgr->dinfo()->out_color_space) { | 522 switch (fDecoderMgr->dinfo()->out_color_space) { |
| 522 case JCS_RGB: | 523 case JCS_RGB: |
| 524 preSwizzled = false; |
| 523 swizzlerInfo.setColor(SkEncodedInfo::kRGB_Color); | 525 swizzlerInfo.setColor(SkEncodedInfo::kRGB_Color); |
| 524 break; | 526 break; |
| 525 case JCS_CMYK: | 527 case JCS_CMYK: |
| 528 preSwizzled = false; |
| 526 swizzlerInfo.setColor(SkEncodedInfo::kInvertedCMYK_Color); | 529 swizzlerInfo.setColor(SkEncodedInfo::kInvertedCMYK_Color); |
| 527 break; | 530 break; |
| 528 default: | 531 default: |
| 529 swizzlerInfo.setColor(SkEncodedInfo::kPreSwizzled_Color); | |
| 530 break; | 532 break; |
| 531 } | 533 } |
| 532 | 534 |
| 533 Options swizzlerOptions = options; | 535 Options swizzlerOptions = options; |
| 534 if (options.fSubset) { | 536 if (options.fSubset) { |
| 535 // Use fSwizzlerSubset if this is a subset decode. This is necessary in
the case | 537 // Use fSwizzlerSubset if this is a subset decode. This is necessary in
the case |
| 536 // where libjpeg-turbo provides a subset and then we need to subset it f
urther. | 538 // where libjpeg-turbo provides a subset and then we need to subset it f
urther. |
| 537 // Also, verify that fSwizzlerSubset is initialized and valid. | 539 // Also, verify that fSwizzlerSubset is initialized and valid. |
| 538 SkASSERT(!fSwizzlerSubset.isEmpty() && fSwizzlerSubset.x() <= options.fS
ubset->x() && | 540 SkASSERT(!fSwizzlerSubset.isEmpty() && fSwizzlerSubset.x() <= options.fS
ubset->x() && |
| 539 fSwizzlerSubset.width() == options.fSubset->width()); | 541 fSwizzlerSubset.width() == options.fSubset->width()); |
| 540 swizzlerOptions.fSubset = &fSwizzlerSubset; | 542 swizzlerOptions.fSubset = &fSwizzlerSubset; |
| 541 } | 543 } |
| 542 fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, nullptr, dstInfo, s
wizzlerOptions)); | 544 fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, nullptr, dstInfo, s
wizzlerOptions, |
| 545 nullptr, preSwizzled)); |
| 543 SkASSERT(fSwizzler); | 546 SkASSERT(fSwizzler); |
| 544 fStorage.reset(get_row_bytes(fDecoderMgr->dinfo())); | 547 fStorage.reset(get_row_bytes(fDecoderMgr->dinfo())); |
| 545 fSrcRow = fStorage.get(); | 548 fSrcRow = fStorage.get(); |
| 546 } | 549 } |
| 547 | 550 |
| 548 SkSampler* SkJpegCodec::getSampler(bool createIfNecessary) { | 551 SkSampler* SkJpegCodec::getSampler(bool createIfNecessary) { |
| 549 if (!createIfNecessary || fSwizzler) { | 552 if (!createIfNecessary || fSwizzler) { |
| 550 SkASSERT(!fSwizzler || (fSrcRow && fStorage.get() == fSrcRow)); | 553 SkASSERT(!fSwizzler || (fSrcRow && fStorage.get() == fSrcRow)); |
| 551 return fSwizzler; | 554 return fSwizzler; |
| 552 } | 555 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 | 890 |
| 888 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); | 891 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); |
| 889 if (linesRead < remainingRows) { | 892 if (linesRead < remainingRows) { |
| 890 // FIXME: Handle incomplete YUV decodes without signalling an error. | 893 // FIXME: Handle incomplete YUV decodes without signalling an error. |
| 891 return kInvalidInput; | 894 return kInvalidInput; |
| 892 } | 895 } |
| 893 } | 896 } |
| 894 | 897 |
| 895 return kSuccess; | 898 return kSuccess; |
| 896 } | 899 } |
| OLD | NEW |