From 5a130119186271c884fb580e8c0950749e18a4c0 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Mon, 28 Nov 2016 09:48:31 -0500 Subject: 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 --- src/opts/SkRasterPipeline_opts.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/opts') diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h index 6033952ea8..3b4cc2151b 100644 --- a/src/opts/SkRasterPipeline_opts.h +++ b/src/opts/SkRasterPipeline_opts.h @@ -262,9 +262,10 @@ STAGE(clamp_1, true) { } STAGE(unpremul, true) { - r *= a.invert(); - g *= a.invert(); - b *= a.invert(); + auto scale = (a == 0.0f).thenElse(0.0f, 1.0f/a); + r *= scale; + g *= scale; + b *= scale; } STAGE(premul, true) { -- cgit v1.2.3