diff options
author | mtklein <mtklein@chromium.org> | 2015-12-14 11:25:18 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-14 11:25:18 -0800 |
commit | 6f37b4a4757ea3eb00c76162cc37f8a56c3b8bdb (patch) | |
tree | 1cf540ae66132e8ba6e59ce5d6f859cd096c1bf3 /src/effects | |
parent | 4e4155df100b77d11bd14591c7716743369fde9b (diff) |
Unify some SkNx code
- one base case and one N=1 case instead of two each (or three with doubles)
- use SkNx_cast instead of FromBytes/toBytes
- 4-at-a-time Sk4f::ToBytes becomes a special standalone Sk4f_ToBytes
If I did everything right, this'll be perf- and pixel- neutral.
https://gold.skia.org/search2?issue=1526523003&unt=true&query=source_type%3Dgm&master=false
BUG=skia:
CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Review URL: https://codereview.chromium.org/1526523003
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkColorMatrixFilter.cpp | 4 | ||||
-rw-r--r-- | src/effects/gradients/SkLinearGradient.cpp | 8 | ||||
-rw-r--r-- | src/effects/gradients/SkRadialGradient.cpp | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp index 3f0f12f2d8..a7b2b7a2f7 100644 --- a/src/effects/SkColorMatrixFilter.cpp +++ b/src/effects/SkColorMatrixFilter.cpp @@ -258,7 +258,7 @@ static Sk4f clamp_0_1(const Sk4f& x) { static SkPMColor round(const Sk4f& x) { SkPMColor c; - (x * Sk4f(255) + Sk4f(0.5f)).toBytes((uint8_t*)&c); + SkNx_cast<uint8_t>(x * Sk4f(255) + Sk4f(0.5f)).store((uint8_t*)&c); return c; } @@ -296,7 +296,7 @@ void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, SkPMColor continue; } - Sk4f srcf = Sk4f::FromBytes((const uint8_t*)&src_c) * Sk4f(1.0f/255); + Sk4f srcf = SkNx_cast<float>(Sk4b::Load((const uint8_t*)&src_c)) * Sk4f(1.0f/255); if (0xFF != SkGetPackedA32(src_c)) { srcf = unpremul(srcf); diff --git a/src/effects/gradients/SkLinearGradient.cpp b/src/effects/gradients/SkLinearGradient.cpp index 53264e4d8c..8760029795 100644 --- a/src/effects/gradients/SkLinearGradient.cpp +++ b/src/effects/gradients/SkLinearGradient.cpp @@ -150,7 +150,7 @@ SkLinearGradient::LinearGradientContext::LinearGradientContext( const Sk4f scale(1, 1, 1, paintAlpha); for (int i = 0; i < count; ++i) { uint32_t c = SkSwizzle_Color_to_PMColor(shader.fOrigColors[i]); - rec[i].fColor = Sk4f::FromBytes((const uint8_t*)&c) * scale; + rec[i].fColor = SkNx_cast<float>(Sk4b::Load((const uint8_t*)&c)) * scale; if (i > 0) { SkASSERT(rec[i - 1].fPos <= rec[i].fPos); } @@ -162,7 +162,7 @@ SkLinearGradient::LinearGradientContext::LinearGradientContext( for (int i = 0; i < count; ++i) { SkPMColor pmc = SkPreMultiplyColor(shader.fOrigColors[i]); pmc = SkAlphaMulQ(pmc, alphaScale); - rec[i].fColor = Sk4f::FromBytes((const uint8_t*)&pmc); + rec[i].fColor = SkNx_cast<float>(Sk4b::Load((const uint8_t*)&pmc)); if (i > 0) { SkASSERT(rec[i - 1].fPos <= rec[i].fPos); } @@ -699,7 +699,7 @@ find_backward(const SkLinearGradient::LinearGradientContext::Rec rec[], float ti template <bool apply_alpha> SkPMColor trunc_from_255(const Sk4f& x) { SkPMColor c; - x.toBytes((uint8_t*)&c); + SkNx_cast<uint8_t>(x).store((uint8_t*)&c); if (apply_alpha) { c = SkPreMultiplyARGB(SkGetPackedA32(c), SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c)); @@ -751,7 +751,7 @@ template <bool apply_alpha> void ramp(SkPMColor dstC[], int n, const Sk4f& c, co Sk4f cd3 = cd1 + dc2; while (n >= 4) { if (!apply_alpha) { - Sk4f::ToBytes((uint8_t*)dstC, cd0, cd1, cd2, cd3); + Sk4f_ToBytes((uint8_t*)dstC, cd0, cd1, cd2, cd3); dstC += 4; } else { *dstC++ = trunc_from_255<apply_alpha>(cd0); diff --git a/src/effects/gradients/SkRadialGradient.cpp b/src/effects/gradients/SkRadialGradient.cpp index 52d06392e1..d734aa056a 100644 --- a/src/effects/gradients/SkRadialGradient.cpp +++ b/src/effects/gradients/SkRadialGradient.cpp @@ -307,7 +307,7 @@ void shadeSpan_radial_clamp2(SkScalar sfx, SkScalar sdx, SkScalar sfy, SkScalar dR = dR + ddR; uint8_t fi[4]; - dist.toBytes(fi); + SkNx_cast<uint8_t>(dist).store(fi); for (int i = 0; i < 4; i++) { *dstC++ = cache[toggle + fi[i]]; @@ -319,7 +319,7 @@ void shadeSpan_radial_clamp2(SkScalar sfx, SkScalar sdx, SkScalar sfy, SkScalar Sk4f dist = Sk4f::Min(fast_sqrt(R), max); uint8_t fi[4]; - dist.toBytes(fi); + SkNx_cast<uint8_t>(dist).store(fi); for (int i = 0; i < count; i++) { *dstC++ = cache[toggle + fi[i]]; toggle = next_dither_toggle(toggle); |