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 return false; |
| 169 } |
| 170 |
168 if (kOpaque_SkAlphaType != dst.alphaType()) { | 171 if (kOpaque_SkAlphaType != dst.alphaType()) { |
169 return false; | 172 SkCodecPrintf("Warning: an opaque image should be decoded as opaque " |
| 173 "- it is being decoded as non-opaque, which will draw slow
er\n"); |
170 } | 174 } |
171 | 175 |
172 // Check if we will decode to CMYK because a conversion to RGBA is not suppo
rted | 176 // 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; | 177 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; |
174 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; | 178 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; |
175 | 179 |
176 // Check for valid color types and set the output color space | 180 // Check for valid color types and set the output color space |
177 switch (dst.colorType()) { | 181 switch (dst.colorType()) { |
178 case kN32_SkColorType: | 182 case kN32_SkColorType: |
179 if (isCMYK) { | 183 if (isCMYK) { |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 | 641 |
638 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); | 642 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); |
639 if (linesRead < remainingRows) { | 643 if (linesRead < remainingRows) { |
640 // FIXME: Handle incomplete YUV decodes without signalling an error. | 644 // FIXME: Handle incomplete YUV decodes without signalling an error. |
641 return kInvalidInput; | 645 return kInvalidInput; |
642 } | 646 } |
643 } | 647 } |
644 | 648 |
645 return kSuccess; | 649 return kSuccess; |
646 } | 650 } |
OLD | NEW |