aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-11-28 09:48:31 -0500
committerGravatar Mike Klein <mtklein@chromium.org>2016-11-28 16:46:39 +0000
commit5a130119186271c884fb580e8c0950749e18a4c0 (patch)
tree332e0b3e63f69d4ca108bc6e058edcc56a00f709 /src/opts
parentdd13c020793b0a7fb2ac1f22024e9fb91ea483ef (diff)
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>
Diffstat (limited to 'src/opts')
-rw-r--r--src/opts/SkRasterPipeline_opts.h7
1 files changed, 4 insertions, 3 deletions
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) {