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 "SkBmpMaskCodec.h" | 8 #include "SkBmpMaskCodec.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 default: | 33 default: |
34 return false; | 34 return false; |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 /* | 39 /* |
40 * Creates an instance of the decoder | 40 * Creates an instance of the decoder |
41 */ | 41 */ |
42 SkBmpMaskCodec::SkBmpMaskCodec(const SkImageInfo& info, SkStream* stream, | 42 SkBmpMaskCodec::SkBmpMaskCodec(const SkImageInfo& info, SkStream* stream, |
43 SkBmpCodec::BmpInputFormat inputFormat, | |
43 uint16_t bitsPerPixel, SkMasks* masks, | 44 uint16_t bitsPerPixel, SkMasks* masks, |
44 SkBmpCodec::RowOrder rowOrder) | 45 SkBmpCodec::RowOrder rowOrder) |
45 : INHERITED(info, stream, bitsPerPixel, rowOrder) | 46 : INHERITED(info, stream, inputFormat, bitsPerPixel, rowOrder) |
46 , fMasks(masks) | 47 , fMasks(masks) |
47 , fMaskSwizzler(NULL) | 48 , fMaskSwizzler(NULL) |
48 , fSrcBuffer(NULL) | 49 , fSrcBuffer(NULL) |
49 {} | 50 {} |
50 | 51 |
51 /* | 52 /* |
52 * Initiates the bitmap decode | 53 * Initiates the bitmap decode |
53 */ | 54 */ |
54 SkCodec::Result SkBmpMaskCodec::onGetPixels(const SkImageInfo& dstInfo, | 55 SkCodec::Result SkBmpMaskCodec::onGetPixels(const SkImageInfo& dstInfo, |
55 void* dst, size_t dstRowBytes, | 56 void* dst, size_t dstRowBytes, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 | 129 |
129 // Decode the row in destination format | 130 // Decode the row in destination format |
130 int row = SkBmpCodec::kBottomUp_RowOrder == this->rowOrder() ? height - 1 - y : y; | 131 int row = SkBmpCodec::kBottomUp_RowOrder == this->rowOrder() ? height - 1 - y : y; |
131 void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes); | 132 void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes); |
132 fMaskSwizzler->swizzle(dstRow, srcRow); | 133 fMaskSwizzler->swizzle(dstRow, srcRow); |
133 } | 134 } |
134 | 135 |
135 // Finished decoding the entire image | 136 // Finished decoding the entire image |
136 return kSuccess; | 137 return kSuccess; |
137 } | 138 } |
139 | |
140 SkBmpMaskScanlineDecoder::SkBmpMaskScanlineDecoder(SkBmpMaskCodec* codec) | |
141 : INHERITED(codec->getInfo()) | |
142 , fCodec(codec) | |
143 {} | |
144 | |
145 SkCodec::Result SkBmpMaskScanlineDecoder::onStart(const SkImageInfo& dstInfo, | |
146 const SkCodec::Options& options, SkPMColor inputColorPtr[], int* inputCo lorCount) { | |
147 if (!fCodec->rewindIfNeeded()) { | |
148 return SkCodec::kCouldNotRewind; | |
149 } | |
150 if (options.fSubset) { | |
151 // Subsets are not supported. | |
152 return SkCodec::kUnimplemented; | |
153 } | |
154 if (dstInfo.dimensions() != fCodec->getInfo().dimensions()) { | |
155 SkCodecPrintf("Error: scaling not supported.\n"); | |
156 return SkCodec::kInvalidScale; | |
157 } | |
158 | |
159 if (!conversion_possible(dstInfo, fCodec->getInfo())) { | |
160 SkCodecPrintf("Error: cannot convert input type to output type.\n"); | |
161 return SkCodec::kInvalidConversion; | |
162 } | |
163 | |
164 // Initialize a the mask swizzler | |
165 if (!fCodec->initializeSwizzler(dstInfo)) { | |
166 SkCodecPrintf("Error: cannot initialize swizzler.\n"); | |
167 return SkCodec::kInvalidConversion; | |
168 } | |
169 | |
170 fDstInfo = dstInfo; | |
scroggo
2015/08/13 21:25:36
Can you get this from the base class, which also s
msarett
2015/08/14 15:44:48
Done.
| |
171 fOpts = options; | |
scroggo
2015/08/13 21:25:36
Maybe this should be stored in the base class as w
msarett
2015/08/14 15:44:48
fOptions is now stored in the base class.
| |
172 | |
173 return SkCodec::kSuccess; | |
174 } | |
175 | |
176 SkCodec::Result SkBmpMaskScanlineDecoder::onGetScanlines(void* dst, | |
177 int count, size_t rowBytes) { | |
178 // Create a new image info representing the portion of the image to decode | |
179 SkImageInfo rowInfo = fDstInfo.makeWH(dstInfo().width(), count); | |
scroggo
2015/08/13 21:25:35
nit: this->dstInfo()...
msarett
2015/08/14 15:44:48
Done.
| |
180 | |
181 // Decode the requested rows | |
182 SkCodec::Result r = fCodec->decode(rowInfo, dst, rowBytes, fOpts); | |
183 } | |
OLD | NEW |