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 "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 return kCouldNotRewind; | 121 return kCouldNotRewind; |
122 } | 122 } |
123 if (options.fSubset) { | 123 if (options.fSubset) { |
124 // Subsets are not supported. | 124 // Subsets are not supported. |
125 return kUnimplemented; | 125 return kUnimplemented; |
126 } | 126 } |
127 if (info.dimensions() != this->getInfo().dimensions()) { | 127 if (info.dimensions() != this->getInfo().dimensions()) { |
128 return kInvalidScale; | 128 return kInvalidScale; |
129 } | 129 } |
130 | 130 |
| 131 if (!valid_alpha(info.alphaType(), this->getInfo().alphaType())) { |
| 132 return SkCodec::kInvalidConversion; |
| 133 } |
| 134 |
131 // Prepare a color table if necessary | 135 // Prepare a color table if necessary |
132 setup_color_table(info.colorType(), ctable, ctableCount); | 136 setup_color_table(info.colorType(), ctable, ctableCount); |
133 | 137 |
134 | 138 |
135 // Initialize the swizzler | 139 // Initialize the swizzler |
136 SkAutoTDelete<SkSwizzler> swizzler(this->initializeSwizzler(info, ctable, op
tions)); | 140 SkAutoTDelete<SkSwizzler> swizzler(this->initializeSwizzler(info, ctable, op
tions)); |
137 if (NULL == swizzler.get()) { | 141 if (NULL == swizzler.get()) { |
138 return kInvalidConversion; | 142 return kInvalidConversion; |
139 } | 143 } |
140 | 144 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 return SkCodec::kCouldNotRewind; | 205 return SkCodec::kCouldNotRewind; |
202 } | 206 } |
203 if (options.fSubset) { | 207 if (options.fSubset) { |
204 // Subsets are not supported. | 208 // Subsets are not supported. |
205 return SkCodec::kUnimplemented; | 209 return SkCodec::kUnimplemented; |
206 } | 210 } |
207 if (dstInfo.dimensions() != this->getInfo().dimensions()) { | 211 if (dstInfo.dimensions() != this->getInfo().dimensions()) { |
208 return SkCodec::kInvalidScale; | 212 return SkCodec::kInvalidScale; |
209 } | 213 } |
210 | 214 |
| 215 if (!valid_alpha(dstInfo.alphaType(), this->getInfo().alphaType())) { |
| 216 return SkCodec::kInvalidConversion; |
| 217 } |
| 218 |
211 // Fill in the color table | 219 // Fill in the color table |
212 setup_color_table(dstInfo.colorType(), inputColorTable, inputColorCount)
; | 220 setup_color_table(dstInfo.colorType(), inputColorTable, inputColorCount)
; |
213 | 221 |
214 // Copy the color table to a pointer that can be owned by the scanline d
ecoder | 222 // Copy the color table to a pointer that can be owned by the scanline d
ecoder |
215 if (kIndex_8_SkColorType == dstInfo.colorType()) { | 223 if (kIndex_8_SkColorType == dstInfo.colorType()) { |
216 fColorTable.reset(SkNEW_ARGS(SkColorTable, (inputColorTable, 2))); | 224 fColorTable.reset(SkNEW_ARGS(SkColorTable, (inputColorTable, 2))); |
217 } | 225 } |
218 | 226 |
219 // Initialize the swizzler | 227 // Initialize the swizzler |
220 fSwizzler.reset(fCodec->initializeSwizzler(dstInfo, | 228 fSwizzler.reset(fCodec->initializeSwizzler(dstInfo, |
(...skipping 17 matching lines...) Expand all Loading... |
238 SkScanlineDecoder* SkWbmpCodec::NewSDFromStream(SkStream* stream) { | 246 SkScanlineDecoder* SkWbmpCodec::NewSDFromStream(SkStream* stream) { |
239 SkAutoTDelete<SkWbmpCodec> codec(static_cast<SkWbmpCodec*>( | 247 SkAutoTDelete<SkWbmpCodec> codec(static_cast<SkWbmpCodec*>( |
240 SkWbmpCodec::NewFromStream(stream))); | 248 SkWbmpCodec::NewFromStream(stream))); |
241 if (!codec) { | 249 if (!codec) { |
242 return NULL; | 250 return NULL; |
243 } | 251 } |
244 | 252 |
245 // Return the new scanline decoder | 253 // Return the new scanline decoder |
246 return SkNEW_ARGS(SkWbmpScanlineDecoder, (codec.detach())); | 254 return SkNEW_ARGS(SkWbmpScanlineDecoder, (codec.detach())); |
247 } | 255 } |
OLD | NEW |