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 "SkCodecPriv.h" | 10 #include "SkCodecPriv.h" |
11 #include "SkColorSpace.h" | 11 #include "SkColorSpace.h" |
12 #include "SkData.h" | 12 #include "SkData.h" |
13 #include "SkGifCodec.h" | 13 #include "SkGifCodec.h" |
| 14 #include "SkHalf.h" |
14 #include "SkIcoCodec.h" | 15 #include "SkIcoCodec.h" |
15 #include "SkJpegCodec.h" | 16 #include "SkJpegCodec.h" |
16 #ifdef SK_HAS_PNG_LIBRARY | 17 #ifdef SK_HAS_PNG_LIBRARY |
17 #include "SkPngCodec.h" | 18 #include "SkPngCodec.h" |
18 #endif | 19 #endif |
19 #include "SkRawCodec.h" | 20 #include "SkRawCodec.h" |
20 #include "SkStream.h" | 21 #include "SkStream.h" |
21 #include "SkWbmpCodec.h" | 22 #include "SkWbmpCodec.h" |
22 #include "SkWebpCodec.h" | 23 #include "SkWebpCodec.h" |
23 | 24 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 return inputScanline; | 347 return inputScanline; |
347 case kBottomUp_SkScanlineOrder: | 348 case kBottomUp_SkScanlineOrder: |
348 return this->getInfo().height() - inputScanline - 1; | 349 return this->getInfo().height() - inputScanline - 1; |
349 default: | 350 default: |
350 // This case indicates an interlaced gif and is implemented by SkGif
Codec. | 351 // This case indicates an interlaced gif and is implemented by SkGif
Codec. |
351 SkASSERT(false); | 352 SkASSERT(false); |
352 return 0; | 353 return 0; |
353 } | 354 } |
354 } | 355 } |
355 | 356 |
| 357 uint64_t SkCodec::onGetFillValue(const SkImageInfo& dstInfo) const { |
| 358 switch (dstInfo.colorType()) { |
| 359 case kRGBA_F16_SkColorType: { |
| 360 static constexpr uint64_t transparentColor = 0; |
| 361 static constexpr uint64_t opaqueColor = ((uint64_t) SK_Half1) << 48; |
| 362 return (kOpaque_SkAlphaType == fSrcInfo.alphaType()) ? opaqueColor :
transparentColor; |
| 363 } |
| 364 default: { |
| 365 // This not only handles the kN32 case, but also k565, kGray8, kInde
x8, since |
| 366 // the low bits are zeros. |
| 367 return (kOpaque_SkAlphaType == fSrcInfo.alphaType()) ? |
| 368 SK_ColorBLACK : SK_ColorTRANSPARENT; |
| 369 } |
| 370 } |
| 371 } |
| 372 |
356 static void fill_proc(const SkImageInfo& info, void* dst, size_t rowBytes, | 373 static void fill_proc(const SkImageInfo& info, void* dst, size_t rowBytes, |
357 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit, SkSampler* sam
pler) { | 374 uint64_t colorOrIndex, SkCodec::ZeroInitialized zeroInit, SkSampler* sam
pler) { |
358 if (sampler) { | 375 if (sampler) { |
359 sampler->fill(info, dst, rowBytes, colorOrIndex, zeroInit); | 376 sampler->fill(info, dst, rowBytes, colorOrIndex, zeroInit); |
360 } else { | 377 } else { |
361 SkSampler::Fill(info, dst, rowBytes, colorOrIndex, zeroInit); | 378 SkSampler::Fill(info, dst, rowBytes, colorOrIndex, zeroInit); |
362 } | 379 } |
363 } | 380 } |
364 | 381 |
365 void SkCodec::fillIncompleteImage(const SkImageInfo& info, void* dst, size_t row
Bytes, | 382 void SkCodec::fillIncompleteImage(const SkImageInfo& info, void* dst, size_t row
Bytes, |
366 ZeroInitialized zeroInit, int linesRequested, int linesDecoded) { | 383 ZeroInitialized zeroInit, int linesRequested, int linesDecoded) { |
367 | 384 |
368 void* fillDst; | 385 void* fillDst; |
369 const uint32_t fillValue = this->getFillValue(info.colorType()); | 386 const uint64_t fillValue = this->getFillValue(info); |
370 const int linesRemaining = linesRequested - linesDecoded; | 387 const int linesRemaining = linesRequested - linesDecoded; |
371 SkSampler* sampler = this->getSampler(false); | 388 SkSampler* sampler = this->getSampler(false); |
372 | 389 |
373 int fillWidth = info.width(); | 390 int fillWidth = info.width(); |
374 if (fOptions.fSubset) { | 391 if (fOptions.fSubset) { |
375 fillWidth = fOptions.fSubset->width(); | 392 fillWidth = fOptions.fSubset->width(); |
376 } | 393 } |
377 | 394 |
378 switch (this->getScanlineOrder()) { | 395 switch (this->getScanlineOrder()) { |
379 case kTopDown_SkScanlineOrder: | 396 case kTopDown_SkScanlineOrder: |
(...skipping 13 matching lines...) Expand all Loading... |
393 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq
uested); | 410 SkASSERT(1 == linesRequested || this->getInfo().height() == linesReq
uested); |
394 const SkImageInfo fillInfo = info.makeWH(fillWidth, 1); | 411 const SkImageInfo fillInfo = info.makeWH(fillWidth, 1); |
395 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { | 412 for (int srcY = linesDecoded; srcY < linesRequested; srcY++) { |
396 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r
owBytes); | 413 fillDst = SkTAddOffset<void>(dst, this->outputScanline(srcY) * r
owBytes); |
397 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp
ler); | 414 fill_proc(fillInfo, fillDst, rowBytes, fillValue, zeroInit, samp
ler); |
398 } | 415 } |
399 break; | 416 break; |
400 } | 417 } |
401 } | 418 } |
402 } | 419 } |
OLD | NEW |