| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 * Sets the output color space | 157 * Sets the output color space |
| 158 */ | 158 */ |
| 159 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { | 159 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { |
| 160 const SkImageInfo& src = this->getInfo(); | 160 const SkImageInfo& src = this->getInfo(); |
| 161 | 161 |
| 162 // Ensure that the profile type is unchanged | 162 // Ensure that the profile type is unchanged |
| 163 if (dst.profileType() != src.profileType()) { | 163 if (dst.profileType() != src.profileType()) { |
| 164 return false; | 164 return false; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Ensure that the alpha type is opaque | 167 if (kUnknown_SkAlphaType == dst.alphaType()) { |
| 168 if (kOpaque_SkAlphaType != dst.alphaType()) { | |
| 169 return false; | 168 return false; |
| 170 } | 169 } |
| 171 | 170 |
| 172 // Check if we will decode to CMYK because a conversion to RGBA is not suppo
rted | 171 // Check if we will decode to CMYK because a conversion to RGBA is not suppo
rted |
| 173 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; | 172 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; |
| 174 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; | 173 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; |
| 175 | 174 |
| 176 // Check for valid color types and set the output color space | 175 // Check for valid color types and set the output color space |
| 177 switch (dst.colorType()) { | 176 switch (dst.colorType()) { |
| 178 case kN32_SkColorType: | 177 case kN32_SkColorType: |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 | 636 |
| 638 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); | 637 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); |
| 639 if (linesRead < remainingRows) { | 638 if (linesRead < remainingRows) { |
| 640 // FIXME: Handle incomplete YUV decodes without signalling an error. | 639 // FIXME: Handle incomplete YUV decodes without signalling an error. |
| 641 return kInvalidInput; | 640 return kInvalidInput; |
| 642 } | 641 } |
| 643 } | 642 } |
| 644 | 643 |
| 645 return kSuccess; | 644 return kSuccess; |
| 646 } | 645 } |
| OLD | NEW |