diff options
author | Leon Scroggins III <scroggo@google.com> | 2017-09-05 14:17:19 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-05 18:36:25 +0000 |
commit | 1f1aa2dddb105b8fe309624ca001d86377183f11 (patch) | |
tree | 02a159780b4aca26e323a9344d445e4c9815469c | |
parent | 171fa47c6ac0a23c09063d4bd01a01b0acddd7fa (diff) |
Stop using SkRasterPipeline inside GIF
SkRasterPipeline was overkill, since blending is just comparing to 0.
(Each pixel is either opaque or 0.)
Bug: 760935
Change-Id: I082045010709c07cc2558988ef509816b9d4bc65
Reviewed-on: https://skia-review.googlesource.com/42440
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
-rw-r--r-- | src/codec/SkGifCodec.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp index d812930d1d..c41d826940 100644 --- a/src/codec/SkGifCodec.cpp +++ b/src/codec/SkGifCodec.cpp @@ -36,10 +36,8 @@ #include "SkColorTable.h" #include "SkGifCodec.h" #include "SkMakeUnique.h" -#include "SkRasterPipeline.h" #include "SkStream.h" #include "SkSwizzler.h" -#include "../jumper/SkJumper.h" #include <algorithm> @@ -417,6 +415,19 @@ void SkGifCodec::applyXformRow(const SkImageInfo& dstInfo, void* dst, const uint } } +template <typename T> +static void blend_line(void* dstAsVoid, const void* srcAsVoid, int width) { + T* dst = reinterpret_cast<T*>(dstAsVoid); + const T* src = reinterpret_cast<const T*>(srcAsVoid); + while (width --> 0) { + if (*src != 0) { // GIF pixels are either transparent (== 0) or opaque (!= 0). + *dst = *src; + } + src++; + dst++; + } +} + void SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin, int rowNumber, int repeatCount, bool writeTransparentPixels) { @@ -511,32 +522,21 @@ void SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin, // which is twice as wide. offsetBytes *= 2; } - SkRasterPipeline_<256> p; - SkRasterPipeline::StockStage storeDst; - void* src = SkTAddOffset<void>(fTmpBuffer.get(), offsetBytes); - void* dst = SkTAddOffset<void>(dstLine, offsetBytes); + const void* src = SkTAddOffset<void>(fTmpBuffer.get(), offsetBytes); + void* dst = SkTAddOffset<void>(dstLine, offsetBytes); - SkJumper_MemoryCtx src_ctx = { src, 0 }, - dst_ctx = { dst, 0 }; switch (dstInfo.colorType()) { case kBGRA_8888_SkColorType: case kRGBA_8888_SkColorType: - p.append(SkRasterPipeline::load_8888_dst, &dst_ctx); - p.append(SkRasterPipeline::load_8888, &src_ctx); - storeDst = SkRasterPipeline::store_8888; + blend_line<uint32_t>(dst, src, fSwizzler->swizzleWidth()); break; case kRGBA_F16_SkColorType: - p.append(SkRasterPipeline::load_f16_dst, &dst_ctx); - p.append(SkRasterPipeline::load_f16, &src_ctx); - storeDst = SkRasterPipeline::store_f16; + blend_line<uint64_t>(dst, src, fSwizzler->swizzleWidth()); break; default: SkASSERT(false); return; } - p.append(SkRasterPipeline::srcover); - p.append(storeDst, &dst); - p.run(0,0, fSwizzler->swizzleWidth(),1); } // Tell the frame to copy the row data if need be. |