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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 SkCodecPrintf("Warning: an opaque image should be decoded as opaque " | 343 SkCodecPrintf("Warning: an opaque image should be decoded as opaque " |
344 "- it is being decoded as non-opaque, which will draw slow
er\n"); | 344 "- it is being decoded as non-opaque, which will draw slow
er\n"); |
345 } | 345 } |
346 | 346 |
347 // Check if we will decode to CMYK because a conversion to RGBA is not suppo
rted | 347 // Check if we will decode to CMYK because a conversion to RGBA is not suppo
rted |
348 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; | 348 J_COLOR_SPACE colorSpace = fDecoderMgr->dinfo()->jpeg_color_space; |
349 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; | 349 bool isCMYK = JCS_CMYK == colorSpace || JCS_YCCK == colorSpace; |
350 | 350 |
351 // Check for valid color types and set the output color space | 351 // Check for valid color types and set the output color space |
352 switch (dst.colorType()) { | 352 switch (dst.colorType()) { |
353 case kN32_SkColorType: | 353 case kRGBA_8888_SkColorType: |
354 if (isCMYK) { | 354 if (isCMYK) { |
355 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; | 355 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; |
356 } else { | 356 } else { |
357 #ifdef LIBJPEG_TURBO_VERSION | 357 #ifdef LIBJPEG_TURBO_VERSION |
358 // Check the byte ordering of the RGBA color space for the | |
359 // current platform | |
360 #ifdef SK_PMCOLOR_IS_RGBA | |
361 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA; | 358 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_RGBA; |
362 #else | |
363 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_BGRA; | |
364 #endif | |
365 #else | 359 #else |
366 fDecoderMgr->dinfo()->out_color_space = JCS_RGB; | 360 fDecoderMgr->dinfo()->out_color_space = JCS_RGB; |
367 #endif | 361 #endif |
| 362 } |
| 363 return true; |
| 364 case kBGRA_8888_SkColorType: |
| 365 if (isCMYK) { |
| 366 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; |
| 367 } else { |
| 368 #ifdef LIBJPEG_TURBO_VERSION |
| 369 fDecoderMgr->dinfo()->out_color_space = JCS_EXT_BGRA; |
| 370 #else |
| 371 fDecoderMgr->dinfo()->out_color_space = JCS_RGB; |
| 372 #endif |
368 } | 373 } |
369 return true; | 374 return true; |
370 case kRGB_565_SkColorType: | 375 case kRGB_565_SkColorType: |
371 if (isCMYK) { | 376 if (isCMYK) { |
372 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; | 377 fDecoderMgr->dinfo()->out_color_space = JCS_CMYK; |
373 } else { | 378 } else { |
374 #ifdef TURBO_HAS_565 | 379 #ifdef TURBO_HAS_565 |
375 fDecoderMgr->dinfo()->dither_mode = JDITHER_NONE; | 380 fDecoderMgr->dinfo()->dither_mode = JDITHER_NONE; |
376 fDecoderMgr->dinfo()->out_color_space = JCS_RGB565; | 381 fDecoderMgr->dinfo()->out_color_space = JCS_RGB565; |
377 #else | 382 #else |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 | 887 |
883 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); | 888 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); |
884 if (linesRead < remainingRows) { | 889 if (linesRead < remainingRows) { |
885 // FIXME: Handle incomplete YUV decodes without signalling an error. | 890 // FIXME: Handle incomplete YUV decodes without signalling an error. |
886 return kInvalidInput; | 891 return kInvalidInput; |
887 } | 892 } |
888 } | 893 } |
889 | 894 |
890 return kSuccess; | 895 return kSuccess; |
891 } | 896 } |
OLD | NEW |