diff options
author | Matt Sarett <msarett@google.com> | 2017-02-01 15:34:22 -0800 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-02 05:23:40 +0000 |
commit | 09a1c088b407b2cb04b7f41d71b227e7da4757a8 (patch) | |
tree | 842ef5091bf54075470a6c9d97e539b0ee82fae3 /src | |
parent | 0bd699e497819344083df4715928a54a597cd630 (diff) |
Prepare to test all image decode modes to F16
I've only been running F16 tests in "colorImage" mode.
We really should be running our "image" tests to F16 as well - so
they can be tested with scaling, subsets, etc.
This CL fixes bugs so that we can enable those tests.
BUG=skia:
Change-Id: I8137eb4fce7ea12f2c9d233a029d946d4a63e6b0
Reviewed-on: https://skia-review.googlesource.com/7801
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/codec/SkBmpStandardCodec.cpp | 22 | ||||
-rw-r--r-- | src/codec/SkJpegCodec.cpp | 11 |
2 files changed, 25 insertions, 8 deletions
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp index eeb3a1bbe5..7e39d610c4 100644 --- a/src/codec/SkBmpStandardCodec.cpp +++ b/src/codec/SkBmpStandardCodec.cpp @@ -307,7 +307,8 @@ void SkBmpStandardCodec::decodeIcoMask(SkStream* stream, const SkImageInfo& dstI // prevents us from using kIndex8. The below code depends on the output // being an SkPMColor. SkASSERT(kRGBA_8888_SkColorType == dstInfo.colorType() || - kBGRA_8888_SkColorType == dstInfo.colorType()); + kBGRA_8888_SkColorType == dstInfo.colorType() || + kRGBA_F16_SkColorType == dstInfo.colorType()); // If we are sampling, make sure that we only mask the sampled pixels. // We do not need to worry about sampling in the y-dimension because that @@ -325,10 +326,19 @@ void SkBmpStandardCodec::decodeIcoMask(SkStream* stream, const SkImageInfo& dstI return; } + auto applyMask = [dstInfo](void* dstRow, int x, uint64_t bit) { + if (kRGBA_F16_SkColorType == dstInfo.colorType()) { + uint64_t* dst64 = (uint64_t*) dstRow; + dst64[x] &= bit - 1; + } else { + uint32_t* dst32 = (uint32_t*) dstRow; + dst32[x] &= bit - 1; + } + }; + int row = this->getDstRow(y, dstInfo.height()); - SkPMColor* dstRow = - SkTAddOffset<SkPMColor>(dstPtr, row * dstRowBytes); + void* dstRow = SkTAddOffset<SkPMColor>(dstPtr, row * dstRowBytes); int srcX = srcStartX; for (int dstX = 0; dstX < sampledWidth; dstX++) { @@ -336,8 +346,8 @@ void SkBmpStandardCodec::decodeIcoMask(SkStream* stream, const SkImageInfo& dstI int modulus; SkTDivMod(srcX, 8, "ient, &modulus); uint32_t shift = 7 - modulus; - uint32_t alphaBit = (fSrcBuffer.get()[quotient] >> shift) & 0x1; - dstRow[dstX] &= alphaBit - 1; + uint64_t alphaBit = (fSrcBuffer.get()[quotient] >> shift) & 0x1; + applyMask(dstRow, dstX, alphaBit); srcX += sampleX; } } @@ -347,7 +357,7 @@ uint64_t SkBmpStandardCodec::onGetFillValue(const SkImageInfo& dstInfo) const { const SkPMColor* colorPtr = get_color_ptr(fColorTable.get()); if (colorPtr) { return get_color_table_fill_value(dstInfo.colorType(), dstInfo.alphaType(), colorPtr, 0, - nullptr); + this->colorXform()); } return INHERITED::onGetFillValue(dstInfo); } diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index ce36073b9a..03a901bed0 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -648,8 +648,15 @@ void SkJpegCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& fSwizzlerSubset.width() == options.fSubset->width()); swizzlerOptions.fSubset = &fSwizzlerSubset; } - fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, nullptr, dstInfo, swizzlerOptions, - nullptr, skipFormatConversion)); + + SkImageInfo swizzlerDstInfo = dstInfo; + if (kRGBA_F16_SkColorType == dstInfo.colorType()) { + // The color xform will handle conversion to F16. It will be expecting RGBA 8888 input. + swizzlerDstInfo = swizzlerDstInfo.makeColorType(kRGBA_8888_SkColorType); + } + + fSwizzler.reset(SkSwizzler::CreateSwizzler(swizzlerInfo, nullptr, swizzlerDstInfo, + swizzlerOptions, nullptr, skipFormatConversion)); SkASSERT(fSwizzler); } |