Fix unpremul stage.
authorMike Klein <mtklein@chromium.org>
Mon, 28 Nov 2016 14:48:31 +0000 (09:48 -0500)
committerMike Klein <mtklein@chromium.org>
Mon, 28 Nov 2016 16:46:39 +0000 (16:46 +0000)
commit5a130119186271c884fb580e8c0950749e18a4c0
tree332e0b3e63f69d4ca108bc6e058edcc56a00f709
parentdd13c020793b0a7fb2ac1f22024e9fb91ea483ef
Fix unpremul stage.

The existing invert() logic explodes when a == 0.

Less terribly, invert() also does not turn 1.0f into 1.0f, so we now use a float divide.  This will cause a small diff in the matrix color filter GM due to increased unpremul precision.

There's an alternative to try if this stage turns out to be speed critical:
   auto scale = (a == 0.0f).thenElse(0.0f,
                                     a.invert() * (1.0f / SkNf(1.0f).invert()));

The (1.0f / SkNf(1.0f).invert()) bit there is a constant, scaling a bit to make 1.0f produce 1.0f.

CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD

Change-Id: I9db72eda108d3d28583a4357f90a0dcd7e4d8a6f
Reviewed-on: https://skia-review.googlesource.com/5227
Reviewed-by: Mike Reed <reed@google.com>
src/opts/SkRasterPipeline_opts.h