diff options
author | Mike Klein <mtklein@chromium.org> | 2016-11-22 14:58:45 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-22 20:40:05 +0000 |
commit | cb5338cadcc7852026a5225f8cf825530f265fa2 (patch) | |
tree | 134454b8a11fbf5cd6d2e2dd67de9978e5e4d506 /src/opts | |
parent | 2cb6cb7218171b357bb5c934f032ba69c7b78401 (diff) |
Support sRGB 565.
It looks like I'm not going to be able to avoid supporting sRGB G8, I8, 565, 4444, 8888.
(A8 and F16 will always be linear.) This fixes 565, and lays out the rest of the accum_*.
I did a little reorganization to keep things in ascending bit depth, just for sanity.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5145
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Change-Id: Ib0508e5a4ee1bab2044a76bcabc367841d634cd2
Reviewed-on: https://skia-review.googlesource.com/5145
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/opts')
-rw-r--r-- | src/opts/SkRasterPipeline_opts.h | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h index f17d7ac3d9..ba8883a7fb 100644 --- a/src/opts/SkRasterPipeline_opts.h +++ b/src/opts/SkRasterPipeline_opts.h @@ -777,6 +777,13 @@ SI SkNi offset_and_ptr(T** ptr, const void* ctx, const SkNf& x, const SkNf& y) { return offset; } +STAGE(accum_a8, true) {} // TODO + +STAGE(accum_g8, true) {} // TODO +STAGE(accum_g8_srgb, true) {} // TODO +STAGE(accum_i8, true) {} // TODO +STAGE(accum_i8_srgb, true) {} // TODO + STAGE(accum_565, true) { const uint16_t* p; SkNi offset = offset_and_ptr(&p, ctx, r, g); @@ -798,30 +805,31 @@ STAGE(accum_565, true) { db += scale * B; da += scale; } - -STAGE(accum_f16, true) { - const uint64_t* p; +STAGE(accum_565_srgb, true) { + const uint16_t* p; SkNi offset = offset_and_ptr(&p, ctx, r, g); - uint16_t R[N], G[N], B[N], A[N]; + uint16_t px[N]; for (size_t i = 0; i < N; i++) { if (kIsTail && i >= tail) { - R[i] = G[i] = B[i] = A[i] = 0; + px[i] = 0; continue; } - uint64_t rgba = p[offset[i]]; - R[i] = rgba >> 0; - G[i] = rgba >> 16; - B[i] = rgba >> 32; - A[i] = rgba >> 48; + px[i] = p[offset[i]]; } + SkNf R,G,B; + from_565(SkNh::Load(px), &R, &G, &B); + SkNf scale = b; - dr += scale * SkHalfToFloat_finite_ftz(SkNh::Load(R)); - dg += scale * SkHalfToFloat_finite_ftz(SkNh::Load(G)); - db += scale * SkHalfToFloat_finite_ftz(SkNh::Load(B)); - da += scale * SkHalfToFloat_finite_ftz(SkNh::Load(A)); + dr += scale * sk_linear_from_srgb_math(R); + dg += scale * sk_linear_from_srgb_math(G); + db += scale * sk_linear_from_srgb_math(B); + da += scale; } +STAGE(accum_4444, true) {} // TODO +STAGE(accum_4444_srgb, true) {} // TODO + STAGE(accum_8888, true) { const uint32_t* p; SkNi offset = offset_and_ptr(&p, ctx, r, g); @@ -845,8 +853,7 @@ STAGE(accum_8888, true) { db += scale * SkNx_cast<float>(SkNb::Load(B)) * (1/255.0f); da += scale * SkNx_cast<float>(SkNb::Load(A)) * (1/255.0f); } - -STAGE(accum_srgb, true) { +STAGE(accum_8888_srgb, true) { const uint32_t* p; SkNi offset = offset_and_ptr(&p, ctx, r, g); @@ -870,6 +877,30 @@ STAGE(accum_srgb, true) { da += scale * SkNx_cast<float>(SkNb::Load(A)) * (1/255.0f); } +STAGE(accum_f16, true) { + const uint64_t* p; + SkNi offset = offset_and_ptr(&p, ctx, r, g); + + uint16_t R[N], G[N], B[N], A[N]; + for (size_t i = 0; i < N; i++) { + if (kIsTail && i >= tail) { + R[i] = G[i] = B[i] = A[i] = 0; + continue; + } + uint64_t rgba = p[offset[i]]; + R[i] = rgba >> 0; + G[i] = rgba >> 16; + B[i] = rgba >> 32; + A[i] = rgba >> 48; + } + SkNf scale = b; + dr += scale * SkHalfToFloat_finite_ftz(SkNh::Load(R)); + dg += scale * SkHalfToFloat_finite_ftz(SkNh::Load(G)); + db += scale * SkHalfToFloat_finite_ftz(SkNh::Load(B)); + da += scale * SkHalfToFloat_finite_ftz(SkNh::Load(A)); +} + + template <typename Fn> SI Fn enum_to_Fn(SkRasterPipeline::StockStage st) { switch (st) { |