aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkModeColorFilter.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-10-27 11:29:36 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-27 20:00:21 +0000
commit130863ef51a2a94e5bdf87f344c0e892b2403985 (patch)
tree4c25fab02c00819fbda547e711630ba3fdd6abc8 /src/core/SkModeColorFilter.cpp
parent6fe16d3f58937957351fb347a7b1dffa0e0768bc (diff)
Only clamp when we think our math requires it.
If we require our inputs are sound, in-gamut, premul colors (a in [0,1], r,g,b in [0,a]) then we should only need to clamp when the math we perform requires it. The safety clamps before each store are paranoia. The main thing this pipeline handles right now that needs clamping is the plus transfermode. This is either used to blend, where the clamp must come after the coverage lerp, or used via a mode color filter, where we have no choice but to clamp right at the end of the color filer. This changes how the mode color filter draws with the plus transfermode. It didn't used to clamp at all. I think this is a bug fix. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4034 Change-Id: I3cbaade2127cc88c8782596f45749c4fe4b0e953 Reviewed-on: https://skia-review.googlesource.com/4034 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkModeColorFilter.cpp')
-rw-r--r--src/core/SkModeColorFilter.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/core/SkModeColorFilter.cpp b/src/core/SkModeColorFilter.cpp
index 98cb3b2ae6..f000e7c55e 100644
--- a/src/core/SkModeColorFilter.cpp
+++ b/src/core/SkModeColorFilter.cpp
@@ -90,7 +90,12 @@ bool SkModeColorFilter::onAppendStages(SkRasterPipeline* p) const {
// and applying the opposite xfermode, e.g. dst-in instead of src-in.
p->append(SkRasterPipeline::swap_src_dst);
p->append(SkRasterPipeline::constant_color, &fPM4f);
- return SkBlendMode_AppendStages((SkBlendMode)fMode, p);
+ auto mode = (SkBlendMode)fMode;
+ if (!SkBlendMode_AppendStages(mode, p)) {
+ return false;
+ }
+ if (SkBlendMode_CanOverflow(mode)) { p->append(SkRasterPipeline::clamp_1); }
+ return true;
}
///////////////////////////////////////////////////////////////////////////////