diff options
author | Mike Klein <mtklein@chromium.org> | 2017-09-15 14:57:02 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-16 02:25:23 +0000 |
commit | f757ae6aa74df9028ec1c9e14fed2b710c32ac23 (patch) | |
tree | c9e97b7f90472993402c07c463e1ba583a9a5710 /src/core | |
parent | 98c5d92ee60f6d395f9591891922aa9852a497ee (diff) |
Retry, Bump stored lowp uniform color to 16-bit storage.
This makes loading into 16-bit channels more natural in _lowp.cpp.
Update a unit test to stop using out-of-range "colors".
Change-Id: I494687aac87948b60a40de447aa1527cf7167b2d
Cq-Include-Trybots: skia.primary:Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Release-UBSAN_float_cast_overflow
Reviewed-on: https://skia-review.googlesource.com/47580
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkRasterPipeline.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/SkRasterPipeline.cpp b/src/core/SkRasterPipeline.cpp index a8c4c0de73..0e56fc4810 100644 --- a/src/core/SkRasterPipeline.cpp +++ b/src/core/SkRasterPipeline.cpp @@ -82,6 +82,11 @@ void SkRasterPipeline::dump() const { #endif void SkRasterPipeline::append_constant_color(SkArenaAlloc* alloc, const float rgba[4]) { + SkASSERT(0 <= rgba[0] && rgba[0] <= 1); + SkASSERT(0 <= rgba[1] && rgba[1] <= 1); + SkASSERT(0 <= rgba[2] && rgba[2] <= 1); + SkASSERT(0 <= rgba[3] && rgba[3] <= 1); + if (rgba[0] == 0 && rgba[1] == 0 && rgba[2] == 0 && rgba[3] == 1) { this->append(black_color); INC_BLACK; @@ -92,7 +97,13 @@ void SkRasterPipeline::append_constant_color(SkArenaAlloc* alloc, const float rg auto ctx = alloc->make<SkJumper_UniformColorCtx>(); Sk4f color = Sk4f::Load(rgba); color.store(&ctx->r); - ctx->rgba = Sk4f_toL32(color); + + // To make loads more direct, we store 8-bit values in 16-bit slots. + color = color * 255.0f + 0.5f; + ctx->rgba[0] = (uint16_t)color[0]; + ctx->rgba[1] = (uint16_t)color[1]; + ctx->rgba[2] = (uint16_t)color[2]; + ctx->rgba[3] = (uint16_t)color[3]; this->unchecked_append(uniform_color, ctx); INC_COLOR; |