aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkCodec.cpp
diff options
context:
space:
mode:
authorGravatar msarett <msarett@google.com>2016-09-13 09:04:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-13 09:04:11 -0700
commitf7eb6fc71abd7649d65a877e7a10d1060afc0c88 (patch)
tree873bfaad147f112a8963a016c0cf640faeafde4c /src/codec/SkCodec.cpp
parentf06e5183004fb3c43b6cc4cb3b4140443d99b8e6 (diff)
Implement Fill() for incomplete decodes to RGBA_F16
Before this patch, we would hit an SkASSERT(false). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2335203002 Review-Url: https://codereview.chromium.org/2335203002
Diffstat (limited to 'src/codec/SkCodec.cpp')
-rw-r--r--src/codec/SkCodec.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index b076954adc..6f298700b7 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -11,6 +11,7 @@
#include "SkColorSpace.h"
#include "SkData.h"
#include "SkGifCodec.h"
+#include "SkHalf.h"
#include "SkIcoCodec.h"
#include "SkJpegCodec.h"
#ifdef SK_HAS_PNG_LIBRARY
@@ -353,8 +354,24 @@ int SkCodec::onOutputScanline(int inputScanline) const {
}
}
+uint64_t SkCodec::onGetFillValue(const SkImageInfo& dstInfo) const {
+ switch (dstInfo.colorType()) {
+ case kRGBA_F16_SkColorType: {
+ static constexpr uint64_t transparentColor = 0;
+ static constexpr uint64_t opaqueColor = ((uint64_t) SK_Half1) << 48;
+ return (kOpaque_SkAlphaType == fSrcInfo.alphaType()) ? opaqueColor : transparentColor;
+ }
+ default: {
+ // This not only handles the kN32 case, but also k565, kGray8, kIndex8, since
+ // the low bits are zeros.
+ return (kOpaque_SkAlphaType == fSrcInfo.alphaType()) ?
+ SK_ColorBLACK : SK_ColorTRANSPARENT;
+ }
+ }
+}
+
static void fill_proc(const SkImageInfo& info, void* dst, size_t rowBytes,
- uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit, SkSampler* sampler) {
+ uint64_t colorOrIndex, SkCodec::ZeroInitialized zeroInit, SkSampler* sampler) {
if (sampler) {
sampler->fill(info, dst, rowBytes, colorOrIndex, zeroInit);
} else {
@@ -366,7 +383,7 @@ void SkCodec::fillIncompleteImage(const SkImageInfo& info, void* dst, size_t row
ZeroInitialized zeroInit, int linesRequested, int linesDecoded) {
void* fillDst;
- const uint32_t fillValue = this->getFillValue(info.colorType());
+ const uint64_t fillValue = this->getFillValue(info);
const int linesRemaining = linesRequested - linesDecoded;
SkSampler* sampler = this->getSampler(false);