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 "SkJpegDecoderMgr.h" | 8 #include "SkJpegDecoderMgr.h" |
9 #include "SkJpegUtility_codec.h" | 9 #include "SkJpegUtility_codec.h" |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 bool JpegDecoderMgr::returnFalse(const char caller[]) { | 27 bool JpegDecoderMgr::returnFalse(const char caller[]) { |
28 print_message((j_common_ptr) &fDInfo, caller); | 28 print_message((j_common_ptr) &fDInfo, caller); |
29 return false; | 29 return false; |
30 } | 30 } |
31 | 31 |
32 SkCodec::Result JpegDecoderMgr::returnFailure(const char caller[], SkCodec::Resu
lt result) { | 32 SkCodec::Result JpegDecoderMgr::returnFailure(const char caller[], SkCodec::Resu
lt result) { |
33 print_message((j_common_ptr) &fDInfo, caller); | 33 print_message((j_common_ptr) &fDInfo, caller); |
34 return result; | 34 return result; |
35 } | 35 } |
36 | 36 |
37 SkColorType JpegDecoderMgr::getColorType() { | 37 bool JpegDecoderMgr::getEncodedColor(SkEncodedInfo::Color* color) { |
38 switch (fDInfo.jpeg_color_space) { | 38 switch (fDInfo.jpeg_color_space) { |
39 case JCS_GRAYSCALE: | 39 case JCS_GRAYSCALE: |
40 return kGray_8_SkColorType; | 40 *color = SkEncodedInfo::kGray_Color; |
| 41 return true; |
| 42 case JCS_YCbCr: |
| 43 *color = SkEncodedInfo::kYUV_Color; |
| 44 return true; |
| 45 case JCS_RGB: |
| 46 *color = SkEncodedInfo::kRGB_Color; |
| 47 return true; |
| 48 case JCS_YCCK: |
| 49 *color = SkEncodedInfo::kYCCK_Color; |
| 50 return true; |
| 51 case JCS_CMYK: |
| 52 *color = SkEncodedInfo::kInvertedCMYK_Color; |
| 53 return true; |
41 default: | 54 default: |
42 return kN32_SkColorType; | 55 return false; |
43 } | 56 } |
44 } | 57 } |
45 | 58 |
46 JpegDecoderMgr::JpegDecoderMgr(SkStream* stream) | 59 JpegDecoderMgr::JpegDecoderMgr(SkStream* stream) |
47 : fSrcMgr(stream) | 60 : fSrcMgr(stream) |
48 , fInit(false) | 61 , fInit(false) |
49 { | 62 { |
50 // Error manager must be set before any calls to libjeg in order to handle f
ailures | 63 // Error manager must be set before any calls to libjeg in order to handle f
ailures |
51 fDInfo.err = jpeg_std_error(&fErrorMgr); | 64 fDInfo.err = jpeg_std_error(&fErrorMgr); |
52 fErrorMgr.error_exit = skjpeg_err_exit; | 65 fErrorMgr.error_exit = skjpeg_err_exit; |
(...skipping 12 matching lines...) Expand all Loading... |
65 } | 78 } |
66 } | 79 } |
67 | 80 |
68 jmp_buf& JpegDecoderMgr::getJmpBuf() { | 81 jmp_buf& JpegDecoderMgr::getJmpBuf() { |
69 return fErrorMgr.fJmpBuf; | 82 return fErrorMgr.fJmpBuf; |
70 } | 83 } |
71 | 84 |
72 jpeg_decompress_struct* JpegDecoderMgr::dinfo() { | 85 jpeg_decompress_struct* JpegDecoderMgr::dinfo() { |
73 return &fDInfo; | 86 return &fDInfo; |
74 } | 87 } |
OLD | NEW |