aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/gradients/Sk4fLinearGradient.cpp
Commit message (Collapse)AuthorAge
* [Reland] Relocate shaders to own dirGravatar Florin Malita2017-05-30
| | | | | | | | | | | Consolidate all shader impls under src/shaders/. (reland of https://skia-review.googlesource.com/c/17927/) Change-Id: I7918bdc1aafe842ed194412ba95b9ae53a2ec1d7 Reviewed-on: https://skia-review.googlesource.com/18146 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Delete onChooseBlitProcs() and related codeGravatar Florin Malita2017-05-26
| | | | | | | | | | | | All dead code now. Change-Id: I3d88103fef90d9e2ceee8b13db143ac9704689f5 Reviewed-on: https://skia-review.googlesource.com/18034 Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Klein <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Revert "Relocate shaders to own dir"Gravatar Stan Iliev2017-05-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit fabe0b26d05624ce7374f6ca89bd66df6142534e. Reason for revert: Last android roll failed with "external/skia/src/effects/SkGaussianEdgeShader.h:11:10: fatal error: 'SkShaderBase.h' file not found" Original change's description: > Relocate shaders to own dir > > Consolidate all shader impls under src/shaders/. > > Change-Id: I450e37541214704c1ad9e379d9d753b7cc62fac3 > Reviewed-on: https://skia-review.googlesource.com/17927 > Commit-Queue: Florin Malita <fmalita@chromium.org> > Reviewed-by: Herb Derby <herb@google.com> > TBR=mtklein@google.com,herb@google.com,fmalita@chromium.org,reed@google.com No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Idbb2b75053969df1dad9d8ce0217cd39189b9ddb Reviewed-on: https://skia-review.googlesource.com/18020 Reviewed-by: Stan Iliev <stani@google.com> Commit-Queue: Stan Iliev <stani@google.com>
* Relocate shaders to own dirGravatar Florin Malita2017-05-25
| | | | | | | | | Consolidate all shader impls under src/shaders/. Change-Id: I450e37541214704c1ad9e379d9d753b7cc62fac3 Reviewed-on: https://skia-review.googlesource.com/17927 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Herb Derby <herb@google.com>
* Remove Sk4fGradientInterval::fZeroRampGravatar Florin Malita2017-05-08
| | | | | | | | | | It's cheap enough to compute when needed, and we don't need it in hot loops anyway. Change-Id: Ib0242f98f8bee31bff939cfdc7356d51525092e4 Reviewed-on: https://skia-review.googlesource.com/15764 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Convert Sk4fGradientInterval to (bias, factor) formatGravatar Florin Malita2017-04-07
| | | | | | | | | | | | And rename some fileds: * p0, p1 -> t0, t1 * fC0, fDc -> fCb, fCg Change-Id: I94b520f83d8f21d62c9c24740b6d3e2dbc3a9ff7 Reviewed-on: https://skia-review.googlesource.com/11799 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Extract 4f gradient interval functionalityGravatar Florin Malita2017-03-23
| | | | | | | | | ... into structures usable outside Sk4fGradient classes. Change-Id: Ifffdbe8bafa4f027f2016ce71eefede6034dd3ae Reviewed-on: https://skia-review.googlesource.com/10060 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* [4fGradient] Relax interval checksGravatar Florin Malita2017-02-09
| | | | | | | | | | | | | | | | | | | We're currently considering intervals open at one extremity, in order to ensure that a given value is always contained in a single interval. This creates problems with synthetic clamp intervals [1, +inf), for t == +inf (no interval can contain it). Treat intervals as closed at both extremities instead. This introduces some ambiguitiy for overlapping values (contained in both adjacent intervals), but solves the more serious problem above. BUG=skia:6213 Change-Id: I33064f762fa9c2b914615e27977115d6654b12f4 Reviewed-on: https://skia-review.googlesource.com/8270 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* [4fLinearGradient] Avoid NaNs for degenerate perspectivesGravatar Florin Malita2017-02-09
| | | | | | | | | BUG=skia:6211 Change-Id: I92148497b29860b3844fe35c2985070a197e4085 Reviewed-on: https://skia-review.googlesource.com/8229 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Reed <reed@google.com>
* [4fGradient] Fix degenerate vertical gradient assertGravatar Florin Malita2017-02-08
| | | | | | | | | | | | | | | | | | For vertical gradients, we rely on LinearIntervalProcessor to yield a fAdvX == +inf, thanks to division by dx (== +/-0). But certain degenerate values may cause the numerator to also collapse to 0, resulting in fAdvX == NaN. Instead or relying on float semantics, pin fAdvX to +inf explicitly for vertical gradients. BUG=skia:5912 Change-Id: Ia8007b99802a6b1e0b22f5618a0ca8959b0cfbb2 Reviewed-on: https://skia-review.googlesource.com/8223 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Revert "Revert "make it illegal to include SkXfermode.h""Gravatar Mike Reed2016-11-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit e9d1b299ccbf8017ba57040986ded638f954684a. Reason for revert: <INSERT REASONING HERE> Original change's description: > Revert "make it illegal to include SkXfermode.h" > > This reverts commit 07764cefbb18041a77897df3453903b0a2016583. > > Reason for revert: breaking google3 > > Original change's description: > > make it illegal to include SkXfermode.h > > > > BUG=skia: > > > > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5133 > > > > Change-Id: I6e8596dcb17cd7e8efa67859bb682bf9bfcac4db > > Reviewed-on: https://skia-review.googlesource.com/5133 > > Reviewed-by: Mike Reed <reed@google.com> > > Commit-Queue: Mike Reed <reed@google.com> > > > > TBR=reed@google.com,reviews@skia.org > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Change-Id: I136f9e533eb60633c49dffa19b5747d50b6d98a8 > Reviewed-on: https://skia-review.googlesource.com/5196 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > TBR=egdaniel@google.com,reviews@skia.org,reed@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I0b767ce778a4ade83c2f07d5ece486bb46d7712c Reviewed-on: https://skia-review.googlesource.com/5223 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Mike Reed <reed@google.com>
* Revert "make it illegal to include SkXfermode.h"Gravatar Greg Daniel2016-11-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 07764cefbb18041a77897df3453903b0a2016583. Reason for revert: breaking google3 Original change's description: > make it illegal to include SkXfermode.h > > BUG=skia: > > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5133 > > Change-Id: I6e8596dcb17cd7e8efa67859bb682bf9bfcac4db > Reviewed-on: https://skia-review.googlesource.com/5133 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Mike Reed <reed@google.com> > TBR=reed@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I136f9e533eb60633c49dffa19b5747d50b6d98a8 Reviewed-on: https://skia-review.googlesource.com/5196 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
* make it illegal to include SkXfermode.hGravatar Mike Reed2016-11-23
| | | | | | | | | | | BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5133 Change-Id: I6e8596dcb17cd7e8efa67859bb682bf9bfcac4db Reviewed-on: https://skia-review.googlesource.com/5133 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Fix Sk4fLinearGradient initial interval pinningGravatar Florin Malita2016-11-14
| | | | | | | | | | | | | | | | | For repeat/mirror mode, fx tiling needs to ensure the value doesn't collapse to the open interval value due to float arithmetic. Clamp to the next lower representable value. BUG=skia:5955 R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4784 Change-Id: I635394d15a80276e88c18a499f93f3047464f190 Reviewed-on: https://skia-review.googlesource.com/4784 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Include what you use with signbit.Gravatar Ben Wagner2016-11-09
| | | | | | | | | | | | | | Include cmath in a few source files which use signbit and a relying on magic to happen to use it. Also Fix nuttiness in SampleClip. No need to #define single character identifiers. Change-Id: Iae3352d0cab9aaa6c37d6424f064b3d86fa2e011 Reviewed-on: https://skia-review.googlesource.com/4626 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Ben Wagner <bungeman@google.com> Commit-Queue: Herb Derby <herb@google.com>
* remove use of xfermode* in procsGravatar Mike Reed2016-11-09
| | | | | | | | | | | BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4592 Change-Id: I99f35924ff5325dfac527bb573a86d2d0366e0b3 Reviewed-on: https://skia-review.googlesource.com/4592 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Sk4fLinearGradient fuzzer fixesGravatar fmalita2016-11-01
| | | | | | | | | | | | | | 1) update in_range() to actually follow the documented rules regarding interval open/close endpoints 2) detect cases where the intervals provide negligible advance and fall back to using a color average BUG=skia:5647 R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2472483002 Review-Url: https://codereview.chromium.org/2472483002
* [Sk4fGradient] Use infinity floats for clamp-mode extreme positionsGravatar fmalita2016-10-21
| | | | | | | | | | | | | | | In clamp mode, we use a couple of synthetic edges that are supposed to extend to +/- infinity (-inf .. P0 and Pn .. inf). Currently we use SK_ScalarMin/Max, but these can be overrun with large/malicious inputs. Use SK_ScalarInfinity/SK_ScalarNegativeInfinity instead, and tweak compute_interval_props() to handle inf values gracefully. BUG=skia:5835 R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2441733002 Review-Url: https://chromiumcodereview.appspot.com/2441733002
* Faster 4f gradient premul pathGravatar fmalita2016-10-14
| | | | | | | | | | | | | | Similar to https://codereview.chromium.org/2409583003/, perform the premul in 4f. It turns out it's even faster to avoid the 255 load multiplication in this case. Also includes some template plumbing because DstTraits<>::load now needs to be premul-aware (previously it wasn't). R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2416233002 Review-Url: https://codereview.chromium.org/2416233002
* Harden LinearGradient4fContextGravatar fmalita2016-09-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | Three distinct issues exposed by Fuzzer: 1) truncating the flags to 8 bits may trip the assert in SkToU8 Since clients can pass in any garbage, we cannot assume it fits in 8 bits. Just static_cast<> instead. 2) vertical gradients with dx == -0.0 don't trigger interval inversion. For dx < 0 we want reversed intervals. But, alas, -0.0 < 0 == false (thanks, Ob^WIEEE 754!). Use signbit() instead. 3) half closed range checking needs to be inverted for reversed intervals. Normally we check for [p0, p1), but for reversed intervals (p1 < p0) we want to check for [p1, p0), and not (p1, p0]. Adjust the logic accordingly. BUG=skia:5647 R=reed@google.com,kjlubick@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2349153004 Review-Url: https://codereview.chromium.org/2349153004
* Correct sRGB <-> linear everywhere.Gravatar mtklein2016-07-20
| | | | | | | | | | | | | | | | | | | | | | This trims the SkPM4fPriv methods down to just foolproof methods. (Anything trying to build these itself is probably wrong.) Things like Sk4f srgb_to_linear(Sk4f) can't really exist anymore, at least not efficiently, so this refactor is somewhat more invasive than you might think. Generally this means things using to_4f() are also making a misstep... that's gone too. It also does not make sense to try to play games with linear floats with 255 bias any more. That hack can't work with real sRGB coding. Rather than update them, I've removed a couple of L32 xfermode fast paths. I'd even rather drop it entirely... BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2163683002 CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Review-Url: https://codereview.chromium.org/2163683002
* update callers to not use SkColorProfileTypeGravatar reed2016-06-21
| | | | | | | | | Requires https://codereview.chromium.org/2087833002/ to land first. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2086583002 Review-Url: https://codereview.chromium.org/2086583002
* linear -> sRGB: use fast approximate sqrt()Gravatar mtklein2016-06-07
| | | | | | | | | | | | | | | | Since we're already approximating the sRGB gamma curve with a sqrt(), we might as well approximate with it a faster approximate sqrt(). On Intel, this .rsqrt().invert() version is 2-3x faster than .sqrt() (~3x faster on older machines, ~2x faster on newer machines). This should provide ~11 bits of precision, suspiciously exactly enough. Running dm --config srgb, there are diffs, but none perceptible. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2046063002 Review-Url: https://codereview.chromium.org/2046063002
* [4fGradient] Veto blitters for non-opaque paintsGravatar fmalita2016-04-07
| | | | | | | | | | | | | | The current blitters don't support SrcOver, so we must ensure the colors are opaque. Checking shader.colorsAreOpaque() is not enough as it doesn't reflect the paint alpha. Instead we should check for context flags & kOpaqueAlpha_Flag, which is only set when both the color stops AND the paint are opaque. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1870773002 Review URL: https://codereview.chromium.org/1870773002
* Planar ramp() for S32 linear gradientsGravatar fmalita2016-03-23
| | | | | | | R=mtklein@google.com,reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1825333003 Review URL: https://codereview.chromium.org/1825333003
* Refactor 4f gradients using trait templatesGravatar fmalita2016-03-21
| | | | | | | | | | | | | | | | Some 4f gradient housekeeping. 1) replace <DstPtrType, ColorProfile> specialization tuples with an enum covering all dest types (L32, S32, F16, F32) 2) group various template helpers into dest trait classes, specialized for each dest type (2a - conflate current dst_swizzle and scale_for_dest ops into one load op) R=reed@google.com,mtklein@google.com,herb@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1816883002 Review URL: https://codereview.chromium.org/1816883002
* allow more options for shader blitprocsGravatar reed2016-03-18
| | | | | | | BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1810383004 Review URL: https://codereview.chromium.org/1810383004
* 4f linear gradient shader blittersGravatar fmalita2016-03-18
| | | | | | | | | | | | Add F16 specializations to support writing to half-float dests. Add color profile template arg across the board to support writing to sRGB dests. R=reed@google.com,mtklein@google.com,herb@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1808963005 Review URL: https://codereview.chromium.org/1808963005
* Generic 4f gradient T sampler fallbackGravatar fmalita2016-03-10
| | | | | | | | | | | | | | | | | | | Add a generic T sampler fallback impl which uses T series produced by subclasses mapTs() overrides. The fallback path uses the same interval structures as the current optimized linear4f impl, but always sorted in stop order (never inverted to match dx/increasing x order). Enable the new mechanism for 4f linear w/ perspective. Other boring changes: * relocate the interval builder (back) to the base class * add a private header for shared templates BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1783823002 Review URL: https://codereview.chromium.org/1783823002
* Fix 4f gradient swizzle post http://crrev.com/1774523002Gravatar fmalita2016-03-08
| | | | | | | | | | | | * store interval colors in pm4f-natural/RGBA order * swizzle to dst order during interval advance Also remove an unused Interval ctor. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1770153002 Review URL: https://codereview.chromium.org/1770153002
* Relocate the specialized linear gradient interval builderGravatar fmalita2016-03-04
| | | | | | | | | | | | | The specialized interval setup works really well for (4f) linear gradients, but it seems unlikely to benefit other gradient subclasses. Since it gets in the way of a general/fallback gradient impl, let's move this code to Sk4fLinearGradient. R=reed@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1764183002 Review URL: https://codereview.chromium.org/1764183002
* Initial linear gradient 4f implGravatar fmalita2016-02-22
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1688543002 Review URL: https://codereview.chromium.org/1688543002