aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkBmpStandardCodec.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-02-01 15:34:22 -0800
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-02-02 05:23:40 +0000
commit09a1c088b407b2cb04b7f41d71b227e7da4757a8 (patch)
tree842ef5091bf54075470a6c9d97e539b0ee82fae3 /src/codec/SkBmpStandardCodec.cpp
parent0bd699e497819344083df4715928a54a597cd630 (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/codec/SkBmpStandardCodec.cpp')
-rw-r--r--src/codec/SkBmpStandardCodec.cpp22
1 files changed, 16 insertions, 6 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, &quotient, &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);
}