diff options
author | Matt Sarett <msarett@google.com> | 2016-11-07 10:26:17 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-07 16:00:11 +0000 |
commit | a225e9be53001a8397344ce1e272a7df2fced499 (patch) | |
tree | bb99b48a9cccfa82e4da7dff98ac60fd63c58b45 /src/codec/SkSwizzler.cpp | |
parent | 84a812061f1d16aa6d349ca065bf67d06767bbc2 (diff) |
Finish color space support for SkCodec
Implements color space xforms and F16 for SkRawCodec and SkWbmpCodec.
BUG=skia:4895
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4459
Change-Id: I8c72918e46387350b49a9811ce654d26b1ab352a
Reviewed-on: https://skia-review.googlesource.com/4459
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/codec/SkSwizzler.cpp')
-rw-r--r-- | src/codec/SkSwizzler.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp index c9eb923053..0bbe824dc2 100644 --- a/src/codec/SkSwizzler.cpp +++ b/src/codec/SkSwizzler.cpp @@ -7,6 +7,7 @@ #include "SkCodecPriv.h" #include "SkColorPriv.h" +#include "SkHalf.h" #include "SkOpts.h" #include "SkSwizzler.h" #include "SkTemplates.h" @@ -150,6 +151,35 @@ static void swizzle_bit_to_565( #undef RGB565_BLACK #undef RGB565_WHITE +static void swizzle_bit_to_f16( + void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int dstWidth, + int bpp, int deltaSrc, int offset, const SkPMColor* /*ctable*/) { + static const uint64_t kWhite = (((uint64_t) SK_Half1) << 0) | + (((uint64_t) SK_Half1) << 16) | + (((uint64_t) SK_Half1) << 32) | + (((uint64_t) SK_Half1) << 48); + static const uint64_t kBlack = (((uint64_t) 0) << 0) | + (((uint64_t) 0) << 16) | + (((uint64_t) 0) << 32) | + (((uint64_t) SK_Half1) << 48); + + uint64_t* SK_RESTRICT dst = (uint64_t*) dstRow; + + // increment src by byte offset and bitIndex by bit offset + src += offset / 8; + int bitIndex = offset % 8; + uint8_t currByte = *src; + + dst[0] = ((currByte >> (7 - bitIndex)) & 1) ? kWhite : kBlack; + + for (int x = 1; x < dstWidth; x++) { + int bitOffset = bitIndex + deltaSrc; + bitIndex = bitOffset % 8; + currByte = *(src += bitOffset / 8); + dst[x] = ((currByte >> (7 - bitIndex)) & 1) ? kWhite : kBlack; + } +} + // kIndex1, kIndex2, kIndex4 static void swizzle_small_index_to_index( @@ -700,6 +730,9 @@ SkSwizzler* SkSwizzler::CreateSwizzler(const SkEncodedInfo& encodedInfo, case kGray_8_SkColorType: proc = &swizzle_bit_to_grayscale; break; + case kRGBA_F16_SkColorType: + proc = &swizzle_bit_to_f16; + break; default: return nullptr; } |