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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 } | 322 } |
323 | 323 |
324 return kSuccess; | 324 return kSuccess; |
325 } | 325 } |
326 | 326 |
327 void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options&
options) { | 327 void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options&
options) { |
328 SkSwizzler::SrcConfig srcConfig = SkSwizzler::kUnknown; | 328 SkSwizzler::SrcConfig srcConfig = SkSwizzler::kUnknown; |
329 if (JCS_CMYK == fDecoderMgr->dinfo()->out_color_space) { | 329 if (JCS_CMYK == fDecoderMgr->dinfo()->out_color_space) { |
330 srcConfig = SkSwizzler::kCMYK; | 330 srcConfig = SkSwizzler::kCMYK; |
331 } else { | 331 } else { |
| 332 // If the out_color_space is not CMYK, the only reason we would need a s
wizzler is |
| 333 // for sampling and/or subsetting. |
332 switch (dstInfo.colorType()) { | 334 switch (dstInfo.colorType()) { |
333 case kGray_8_SkColorType: | 335 case kGray_8_SkColorType: |
334 srcConfig = SkSwizzler::kGray; | 336 srcConfig = SkSwizzler::kNoOp8; |
335 break; | 337 break; |
336 case kRGBA_8888_SkColorType: | 338 case kN32_SkColorType: |
337 srcConfig = SkSwizzler::kRGBX; | 339 srcConfig = SkSwizzler::kNoOp32; |
338 break; | |
339 case kBGRA_8888_SkColorType: | |
340 srcConfig = SkSwizzler::kBGRX; | |
341 break; | 340 break; |
342 case kRGB_565_SkColorType: | 341 case kRGB_565_SkColorType: |
343 srcConfig = SkSwizzler::kRGB_565; | 342 srcConfig = SkSwizzler::kNoOp16; |
344 break; | 343 break; |
345 default: | 344 default: |
346 // This function should only be called if the colorType is suppo
rted by jpeg | 345 // This function should only be called if the colorType is suppo
rted by jpeg |
347 SkASSERT(false); | 346 SkASSERT(false); |
348 } | 347 } |
349 } | 348 } |
350 | 349 |
351 fSwizzler.reset(SkSwizzler::CreateSwizzler(srcConfig, nullptr, dstInfo, opti
ons)); | 350 fSwizzler.reset(SkSwizzler::CreateSwizzler(srcConfig, nullptr, dstInfo, opti
ons)); |
352 fStorage.reset(get_row_bytes(fDecoderMgr->dinfo())); | 351 fStorage.reset(get_row_bytes(fDecoderMgr->dinfo())); |
353 fSrcRow = fStorage.get(); | 352 fSrcRow = fStorage.get(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 #endif | 444 #endif |
446 | 445 |
447 bool SkJpegCodec::onSkipScanlines(int count) { | 446 bool SkJpegCodec::onSkipScanlines(int count) { |
448 // Set the jump location for libjpeg errors | 447 // Set the jump location for libjpeg errors |
449 if (setjmp(fDecoderMgr->getJmpBuf())) { | 448 if (setjmp(fDecoderMgr->getJmpBuf())) { |
450 return fDecoderMgr->returnFalse("setjmp"); | 449 return fDecoderMgr->returnFalse("setjmp"); |
451 } | 450 } |
452 | 451 |
453 return (uint32_t) count == jpeg_skip_scanlines(fDecoderMgr->dinfo(), count); | 452 return (uint32_t) count == jpeg_skip_scanlines(fDecoderMgr->dinfo(), count); |
454 } | 453 } |
OLD | NEW |