| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 * Sets the output color space | 219 * Sets the output color space |
| 220 */ | 220 */ |
| 221 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { | 221 bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { |
| 222 const SkImageInfo& src = this->getInfo(); | 222 const SkImageInfo& src = this->getInfo(); |
| 223 | 223 |
| 224 // Ensure that the profile type is unchanged | 224 // Ensure that the profile type is unchanged |
| 225 if (dst.profileType() != src.profileType()) { | 225 if (dst.profileType() != src.profileType()) { |
| 226 return false; | 226 return false; |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Ensure that the alpha type is opaque | |
| 230 if (kOpaque_SkAlphaType != dst.alphaType()) { | |
| 231 return false; | |
| 232 } | |
| 233 | |
| 234 // Check if we will decode to CMYK because a conversion to RGBA is not suppo
rted | 229 // Check if we will decode to CMYK because a conversion to RGBA is not suppo
rted |
| 235 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; | 230 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; |
| 236 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; | 231 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; |
| 237 | 232 |
| 238 // Check for valid color types and set the output color space | 233 // Check for valid color types and set the output color space |
| 239 switch (dst.colorType()) { | 234 switch (dst.colorType()) { |
| 240 case kN32_SkColorType: | 235 case kN32_SkColorType: |
| 241 if (isCMYK) { | 236 if (isCMYK) { |
| 242 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; | 237 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; |
| 243 } else { | 238 } else { |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 SkScanlineDecoder* SkJpegCodec::NewSDFromStream(SkStream* stream) { | 501 SkScanlineDecoder* SkJpegCodec::NewSDFromStream(SkStream* stream) { |
| 507 SkAutoTDelete<SkJpegCodec> codec(static_cast<SkJpegCodec*>(SkJpegCodec::NewF
romStream(stream))); | 502 SkAutoTDelete<SkJpegCodec> codec(static_cast<SkJpegCodec*>(SkJpegCodec::NewF
romStream(stream))); |
| 508 if (!codec) { | 503 if (!codec) { |
| 509 return NULL; | 504 return NULL; |
| 510 } | 505 } |
| 511 | 506 |
| 512 const SkImageInfo& srcInfo = codec->getInfo(); | 507 const SkImageInfo& srcInfo = codec->getInfo(); |
| 513 // Return the new scanline decoder | 508 // Return the new scanline decoder |
| 514 return SkNEW_ARGS(SkJpegScanlineDecoder, (srcInfo, codec.detach())); | 509 return SkNEW_ARGS(SkJpegScanlineDecoder, (srcInfo, codec.detach())); |
| 515 } | 510 } |
| OLD | NEW |