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 #ifndef SkJpegCodec_DEFINED | 8 #ifndef SkJpegCodec_DEFINED |
9 #define SkJpegCodec_DEFINED | 9 #define SkJpegCodec_DEFINED |
10 | 10 |
11 #include "SkCodec.h" | 11 #include "SkCodec.h" |
12 #include "SkColorSpace.h" | 12 #include "SkColorSpace.h" |
| 13 #include "SkColorSpaceXform.h" |
13 #include "SkImageInfo.h" | 14 #include "SkImageInfo.h" |
14 #include "SkSwizzler.h" | 15 #include "SkSwizzler.h" |
15 #include "SkStream.h" | 16 #include "SkStream.h" |
16 #include "SkTemplates.h" | 17 #include "SkTemplates.h" |
17 | 18 |
18 class JpegDecoderMgr; | 19 class JpegDecoderMgr; |
19 | 20 |
20 /* | 21 /* |
21 * | 22 * |
22 * This class implements the decoding for jpeg images | 23 * This class implements the decoding for jpeg images |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 * @param stream the encoded image data | 93 * @param stream the encoded image data |
93 * @param decoderMgr holds decompress struct, src manager, and error manager | 94 * @param decoderMgr holds decompress struct, src manager, and error manager |
94 * takes ownership | 95 * takes ownership |
95 */ | 96 */ |
96 SkJpegCodec(int width, int height, const SkEncodedInfo& info, SkStream* stre
am, | 97 SkJpegCodec(int width, int height, const SkEncodedInfo& info, SkStream* stre
am, |
97 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin o
rigin, | 98 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin o
rigin, |
98 sk_sp<SkData> iccData); | 99 sk_sp<SkData> iccData); |
99 | 100 |
100 /* | 101 /* |
101 * Checks if the conversion between the input image and the requested output | 102 * Checks if the conversion between the input image and the requested output |
102 * image has been implemented | 103 * image has been implemented. |
103 * Sets the output color space | 104 * |
| 105 * Sets the output color space. |
104 */ | 106 */ |
105 bool setOutputColorSpace(const SkImageInfo& dst); | 107 bool setOutputColorSpace(const SkImageInfo& dst, bool needsColorXform); |
106 | 108 |
107 // scanline decoding | |
108 void initializeSwizzler(const SkImageInfo& dstInfo, const Options& options); | 109 void initializeSwizzler(const SkImageInfo& dstInfo, const Options& options); |
| 110 bool initializeColorXform(const SkImageInfo& dstInfo, bool needsColorXform); |
| 111 void allocateStorage(const SkImageInfo& dstInfo); |
| 112 int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int cou
nt); |
| 113 |
| 114 /* |
| 115 * Scanline decoding. |
| 116 */ |
109 SkSampler* getSampler(bool createIfNecessary) override; | 117 SkSampler* getSampler(bool createIfNecessary) override; |
110 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti
ons, | 118 Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& opti
ons, |
111 SkPMColor ctable[], int* ctableCount) override; | 119 SkPMColor ctable[], int* ctableCount) override; |
112 int onGetScanlines(void* dst, int count, size_t rowBytes) override; | 120 int onGetScanlines(void* dst, int count, size_t rowBytes) override; |
113 bool onSkipScanlines(int count) override; | 121 bool onSkipScanlines(int count) override; |
114 | 122 |
115 SkAutoTDelete<JpegDecoderMgr> fDecoderMgr; | 123 SkAutoTDelete<JpegDecoderMgr> fDecoderMgr; |
| 124 |
116 // We will save the state of the decompress struct after reading the header. | 125 // We will save the state of the decompress struct after reading the header. |
117 // This allows us to safely call onGetScaledDimensions() at any time. | 126 // This allows us to safely call onGetScaledDimensions() at any time. |
118 const int fReadyState; | 127 const int fReadyState; |
119 | 128 |
120 // scanline decoding | 129 |
121 SkAutoTMalloc<uint8_t> fStorage; // Only used if sampling is needed | 130 SkAutoTMalloc<uint8_t> fStorage; |
122 uint8_t* fSrcRow; // Only used if sampling is needed | 131 uint8_t* fSwizzleSrcRow; |
| 132 uint32_t* fColorXformSrcRow; |
| 133 |
123 // libjpeg-turbo provides some subsetting. In the case that libjpeg-turbo | 134 // libjpeg-turbo provides some subsetting. In the case that libjpeg-turbo |
124 // cannot take the exact the subset that we need, we will use the swizzler | 135 // cannot take the exact the subset that we need, we will use the swizzler |
125 // to further subset the output from libjpeg-turbo. | 136 // to further subset the output from libjpeg-turbo. |
126 SkIRect fSwizzlerSubset; | 137 SkIRect fSwizzlerSubset; |
127 SkAutoTDelete<SkSwizzler> fSwizzler; | 138 |
| 139 SkAutoTDelete<SkSwizzler> fSwizzler; |
| 140 std::unique_ptr<SkColorSpaceXform> fColorXform; |
128 | 141 |
129 sk_sp<SkData> fICCData; | 142 sk_sp<SkData> fICCData; |
130 | 143 |
131 typedef SkCodec INHERITED; | 144 typedef SkCodec INHERITED; |
132 }; | 145 }; |
133 | 146 |
134 #endif | 147 #endif |
OLD | NEW |