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 "SkBmpCodec.h" | 8 #include "SkBmpCodec.h" |
9 #include "SkCodec.h" | 9 #include "SkCodec.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 if (!this->rewindIfNeeded()) { | 214 if (!this->rewindIfNeeded()) { |
215 return kCouldNotRewind; | 215 return kCouldNotRewind; |
216 } | 216 } |
217 | 217 |
218 // Set options. | 218 // Set options. |
219 Options optsStorage; | 219 Options optsStorage; |
220 if (nullptr == options) { | 220 if (nullptr == options) { |
221 options = &optsStorage; | 221 options = &optsStorage; |
222 } else if (options->fSubset) { | 222 } else if (options->fSubset) { |
223 SkIRect subset(*options->fSubset); | 223 SkIRect size = SkIRect::MakeSize(dstInfo.dimensions()); |
224 if (!this->onGetValidSubset(&subset) || subset != *options->fSubset) { | 224 if (!size.contains(*options->fSubset)) { |
225 // FIXME: How to differentiate between not supporting subset at all | 225 return kInvalidInput; |
226 // and not supporting this particular subset? | 226 } |
227 return kUnimplemented; | 227 |
| 228 // We only support subsetting in the x-dimension for scanline decoder. |
| 229 // Subsetting in the y-dimension can be accomplished using skipScanlines
(). |
| 230 if (options->fSubset->top() != 0 || options->fSubset->height() != dstInf
o.height()) { |
| 231 return kInvalidInput; |
228 } | 232 } |
229 } | 233 } |
230 | 234 |
231 // FIXME: Support subsets somehow? | 235 // FIXME: Support subsets somehow? |
232 if (!this->dimensionsSupported(dstInfo.dimensions())) { | 236 if (!this->dimensionsSupported(dstInfo.dimensions())) { |
233 return kInvalidScale; | 237 return kInvalidScale; |
234 } | 238 } |
235 | 239 |
236 const Result result = this->onStartScanlineDecode(dstInfo, *options, ctable,
ctableCount); | 240 const Result result = this->onStartScanlineDecode(dstInfo, *options, ctable,
ctableCount); |
237 if (result != SkCodec::kSuccess) { | 241 if (result != SkCodec::kSuccess) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq
uested); | 343 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq
uested); |
340 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); | 344 const SkImageInfo fillInfo = info.makeWH(info.width(), 1); |
341 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { | 345 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { |
342 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r
owBytes); | 346 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r
owBytes); |
343 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp
ler); | 347 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp
ler); |
344 } | 348 } |
345 break; | 349 break; |
346 } | 350 } |
347 } | 351 } |
348 } | 352 } |
OLD | NEW |