aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders/gradients/SkTwoPointConicalGradient.cpp
Commit message (Collapse)AuthorAge
* Revert "Fix handling of MaskFilter matrices"Gravatar Robert Phillips2018-04-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2097fd03ffea48bd904c48c93348b2350600870e. Reason for revert: This is breaking a lot of Windows bots (esp. on the shadermaskfilter_localmatrix) Original change's description: > Fix handling of MaskFilter matrices > > 1) extend GrFPArgs to track pre/post local matrices, add helpers for > creating pre/post wrapper args > > 2) add a SkShaderBase helper (totalLocalMatrix) to centralize the LM > sandwich logic. > > 3) update call sites to use the above > > 4) rename SkMatrixFilter::makeWithLocalMatrix -> makeWithMatrix, to > disambiguate vs. SkShader::makeWithLocalMatrix. > > BUG=skia:7744 > > Change-Id: Ib2b7b007e6924979b00649dde7c94ef4b34771f1 > Reviewed-on: https://skia-review.googlesource.com/119330 > Commit-Queue: Florin Malita <fmalita@chromium.org> > Reviewed-by: Brian Salomon <bsalomon@google.com> TBR=bsalomon@google.com,robertphillips@google.com,fmalita@chromium.org,reed@google.com Change-Id: I918dbb95bf00b3122e6699b84566ec82dbb5fc5c No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:7744 Reviewed-on: https://skia-review.googlesource.com/120340 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
* Fix handling of MaskFilter matricesGravatar Florin Malita2018-04-11
| | | | | | | | | | | | | | | | | | | | 1) extend GrFPArgs to track pre/post local matrices, add helpers for creating pre/post wrapper args 2) add a SkShaderBase helper (totalLocalMatrix) to centralize the LM sandwich logic. 3) update call sites to use the above 4) rename SkMatrixFilter::makeWithLocalMatrix -> makeWithMatrix, to disambiguate vs. SkShader::makeWithLocalMatrix. BUG=skia:7744 Change-Id: Ib2b7b007e6924979b00649dde7c94ef4b34771f1 Reviewed-on: https://skia-review.googlesource.com/119330 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Brian Salomon <bsalomon@google.com>
* remove SK_IGNORE_TO_STRINGGravatar Cary Clark2018-04-05
| | | | | | | | | | | | | | | | | | | SK_IGNORE_TO_STRING is not defined anywhere. The same effect can be had by using a modern linker. Removing it simplifies bookmaker and makes our includes easier to understand. R=robertphillips@google.com TBR=reed@google.com Bug: skia:6898 Change-Id: Ib716f5ef1b42a7fbda0df43ece212d1b7c40289f Reviewed-on: https://skia-review.googlesource.com/118963 Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@skia.org>
* rename inner AsFPArgs to stand-alone GrFPArgsGravatar Mike Reed2018-01-19
| | | | | | | | | | This prepares us to share this with other effects (most notably maskfilters) Bug: skia: Change-Id: I12530fdf10c4e5f2a9ab6d394bf9e87c54ea60c4 Reviewed-on: https://skia-review.googlesource.com/97062 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
* Remove legacy 2pt conical gradientGravatar Yuqian Li2018-01-16
| | | | | | | | Bug: skia:7459 Change-Id: Iccc2588f80e22b13ed5d23656b8c75d7b7058a36 Reviewed-on: https://skia-review.googlesource.com/92700 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Yuqian Li <liyuqian@google.com>
* Update 2pt conical gradient in raster pipelineGravatar Yuqian Li2018-01-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | The updated algorithm matches our new GPU algorithm (https://skia.org/dev/design/conical) and it brings about 7%-26% speedup. In the next CL, I'll simplify the GPU code by reusing the CPU code in this CL. 7.20% faster in gradient_conical_clamp_hicolor 8.94% faster in gradient_conicalZero_clamp_hicolor 10.00% faster in gradient_conicalOut_clamp_hicolor 11.72% faster in gradient_conicalOutZero_clamp_hicolor 13.62% faster in gradient_conical_clamp_3color 16.52% faster in gradient_conicalZero_clamp_3color 17.48% faster in gradient_conical_clamp 17.70% faster in gradient_conical_clamp_shallow 20.60% faster in gradient_conicalOut_clamp_3color 20.98% faster in gradient_conicalOutZero_clamp_3color 21.79% faster in gradient_conicalZero_clamp 22.48% faster in gradient_conicalOut_clamp 26.13% faster in gradient_conicalOutZero_clamp Bug: skia: Change-Id: Ia159495e1c77658cb28e48c9edf84938464e501c Reviewed-on: https://skia-review.googlesource.com/90262 Commit-Queue: Yuqian Li <liyuqian@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Use first/second instead of min/max in 2pt conical gradientGravatar Yuqian Li2017-12-11
| | | | | | | | | | | | | | | | | | | | | | | | | Here's the tiny performance gain: $python tools/calmbench/calmbench.py firstsecond --extraarg "-m conic" firstsecond (compared to master) is likely 4.23% faster in gradient_conicalOut_clamp_3color 4.23% faster in gradient_conicalOutZero_clamp_3color 4.79% faster in gradient_conical_clamp_shallow_dither 6.04% faster in gradient_conical_clamp_3color 6.04% faster in gradient_conicalZero_clamp_3color 6.42% faster in gradient_conicalOut_clamp 6.43% faster in gradient_conicalOutZero_clamp 6.74% faster in gradient_conical_clamp 6.98% faster in gradient_conical_clamp_shallow 6.98% faster in gradient_conicalZero_clamp Bug: skia: Change-Id: Id74866908b99753ed8b16a657d3f67c9255d0043 Reviewed-on: https://skia-review.googlesource.com/76561 Commit-Queue: Yuqian Li <liyuqian@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Florin Malita <fmalita@chromium.org>
* Don't store legacy colors in gradient shadersGravatar Florin Malita2017-10-31
| | | | | | | | | | | | We only pass linear/4f colors to the ctor, and then derive the legacy colors from them. Might as well just derive when needed. Change-Id: I82b3d159da91f6faa4a3e7d681763c0ec1cdab07 Reviewed-on: https://skia-review.googlesource.com/65680 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com>
* Delete GradientShaderCacheGravatar Florin Malita2017-10-26
| | | | | | | | | Dead code. Change-Id: If415e603b8e898da72ad95f32596445900794d23 Reviewed-on: https://skia-review.googlesource.com/63562 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Pass GrRenderTargetContext's GrColorSpaceInfo to SkShader and SkColorFilter.Gravatar Brian Salomon2017-10-25
| | | | | | | | | | | | | | Also to SkColorTo(Premul|Unpremul)GrColor4f. This can avoid cache lookups to find GrColorSpaceXforms as the xform pointer is stored in GrColorSpaceInfo after the first lookup. Also uses GrColorSpaceInfo to construct GrTextUtils::Paint. Bug: skia: Change-Id: Idf19d512a60d2269e6921c7fb54d93aee499a70d Reviewed-on: https://skia-review.googlesource.com/63660 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
* Remove GrColorSpaceXform from GrGradientEffectGravatar Brian Osman2017-10-25
| | | | | | | | | | | | | | Use a local xform to convert color stops for analytic gradients. For texture-based gradients, wrap the FP with an xform effect. To simplify this code, add a new AdjustFP helper to do the color xform, and also add the MulOutputByInputAlpha stage. Bug: skia: Change-Id: Icde19b5ec1c66aae76f894e9978c90a5f00c852e Reviewed-on: https://skia-review.googlesource.com/62500 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Avoid 2PtConical gradient flippingGravatar Florin Malita2017-10-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, when startRadius > endRadius conical gradients are inverting their data (start/end points and radii, colors and positions) to guarantee r0 < r1 at raster time. But the radii ordering is only mildly interesting to the impl: it controls which of the two quadratic solutions we select for the inside case, but doesn't fundamentally change the algorithm. Furthermore, for the "outside" case, inverting the order is already inconvenient and needs to be taken into account (both CPU/GPU impls are already tracking this bit of info). Instead of transforming the gradient definition, we can detect the inverted case and adjust the quadratic solution selector. In practice this means: * |edge| case - no change, the equation is linear * |inside| case - select the smaller root instead of largest * |outside| case - [gpu-only] invert the clamp/limiting function Change-Id: Ie3106464e39a4dd3848dc43671d973f7e1958e63 Reviewed-on: https://skia-review.googlesource.com/61660 Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Make GrFragmentProcessor be non-refcounted and use std::unique_ptr.Gravatar Brian Salomon2017-08-11
| | | | | | | Change-Id: I985e54a071338e99292a5aa2f42c92bc115b4008 Reviewed-on: https://skia-review.googlesource.com/32760 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
* Gradient stages cleanupGravatar Florin Malita2017-07-30
| | | | | | | | | | | | | Hoist the matrix setup into SkGradientShaderBase. Drop the bool return for adjustMatrixAndAppendStages(), and rename to appendGradientStages(). Change-Id: Iad412f638f86223e5af46a7d3dea6f768f52bcad Reviewed-on: https://skia-review.googlesource.com/26427 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
* Remove stale SkTwoPointConicalGradient assertGravatar Florin Malita2017-07-29
| | | | | | | | | Change-Id: If46426393e5151dad4f66ee5a54341024701e87e TBR= NOTRY=true Reviewed-on: https://skia-review.googlesource.com/28500 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Florin Malita <fmalita@chromium.org>
* Don't instantiate degenerate 2pt gradientsGravatar Florin Malita2017-07-29
| | | | | | | | | We can catch the condition at construction time, no need to defer. Change-Id: I973b9e1b79998e2b334e3a91694c793882dfd65a Reviewed-on: https://skia-review.googlesource.com/26564 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@google.com>
* Remove now-dead SK_SUPPORT_LEGACY_GRADIENT_MATRIX_MATH codeGravatar Florin Malita2017-07-29
| | | | | | | | Change-Id: I080942c44d2ce1a018ba127944c0a477af876158 TBR= Reviewed-on: https://skia-review.googlesource.com/28480 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Always postConcat() pipeline gradient matricesGravatar Florin Malita2017-07-25
| | | | | | | | | | | | | In order to unblock https://skia-review.googlesource.com/c/26564 & https://skia-review.googlesource.com/c/26427, switch all impls to use a single/atomic postConcat for the gradient matrix. This is much easier to guard than the changes above. Change-Id: Ib72dbc7b5a56a96390f4468fd12caf8b6a0e46ef Reviewed-on: https://skia-review.googlesource.com/26620 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* consolidate logic for matrix stageGravatar Mike Reed2017-07-04
| | | | | | | | Bug: skia: Change-Id: Id1559b31692a1aed9aa4d15620b2019ae9c7c22b Reviewed-on: https://skia-review.googlesource.com/21404 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
* Handle degenerate 2pt conical center values gracefullyGravatar Florin Malita2017-07-03
| | | | | | | | | | | | | SkMatrix::setPolyToPoly() may fail to map degenerate values. Handle this case explicitly, instead of assuming it never fails. BUG=chromium:738746 TBR= Change-Id: Ie1049b98f7e07ae5d6bdb706ba7b4a399388e5d8 Reviewed-on: https://skia-review.googlesource.com/21375 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Delete non-raster-pipeline SkTwoPointConicalGradient implGravatar Florin Malita2017-06-30
| | | | | | | | Change-Id: If39a2b01d6099fef14695a4ce05b57a3d5c3d99c Reviewed-on: https://skia-review.googlesource.com/21320 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Always use raster pipeline for SkTwoPointConicalGradientGravatar Florin Malita2017-06-29
| | | | | | | Change-Id: I14fc27c5ba8d6fd58df193a172148b7f5aca20bf Reviewed-on: https://skia-review.googlesource.com/21262 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* 2pt conical stage for focal-point-outside caseGravatar Florin Malita2017-06-29
| | | | | | | | | | | | | | | | | A couple of annoyances here: 1) the prev vector_scale stage is not usable for masking, as NaN values can propagate through => switch to actual masking 2) for the outside case, we must select the min root when the gradient is flipped => split into two templated stages (_min, _max) (I'm not convinced that we need to flip the gradient for RP at all; we can investigate later) Change-Id: I0283812d613a53124f2987d1aea1f26e4533655e Reviewed-on: https://skia-review.googlesource.com/21162 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* 2pt conical stage for focal-pt-on-edge caseGravatar Florin Malita2017-06-28
| | | | | | | | | | | | | | | | | | | When the focal point is on the edge of the end circle, the quadratic equation devolves to linear. Add a stage to handle this case. As a complication, this case can produce "degenerate" values: 1) t == NaN 2) R(t) < 0 For these, we're supposed to draw transparent black - which means overwriting the color from the gradient stage. To support this, build a 0/1 vector mask in the context, and apply it post-gradient-stage. Change-Id: Ice4e3243abfd8c784bb810f6c310aed7a4ac7dc8 Reviewed-on: https://skia-review.googlesource.com/21111 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@google.com>
* 2ptconical stageGravatar Florin Malita2017-06-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | Initial impl, for the well-behaved case (focal point inside). MBP numbers - Before: 3365.87 ! gradient_conical_clamp_shallow srgb 3590.88 ! gradient_conical_clamp_shallow_dither srgb 3376.91 ! gradient_conical_clamp_3color srgb 3351.64 ! gradient_conical_clamp_hicolor srgb 3379.35 ! gradient_conical_clamp srgb After: 648.93 ! gradient_conical_clamp_shallow srgb 665.12 ! gradient_conical_clamp_shallow_dither srgb 773.98 ! gradient_conical_clamp_3color srgb 1175.35 ! gradient_conical_clamp_hicolor srgb 619.17 ! gradient_conical_clamp srgb Change-Id: I07b22a758363e1f340a6041bca53bdef74229eb9 Reviewed-on: https://skia-review.googlesource.com/20906 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* 2pt conical stage for concentric caseGravatar Florin Malita2017-06-27
| | | | | | | | | | If the circles are concentric, we can use the radial stage and post-massage t with a 2x3 stage. Change-Id: I744bc889d509d5f9ff162c179e8ec7ca35410e3c Reviewed-on: https://skia-review.googlesource.com/20972 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Make gradient effect creation fail if texture LUT creation failsGravatar Brian Salomon2017-06-09
| | | | | | | | Bug: skia:6198 Change-Id: Ib8fb273564ca54ee9e6e045ac67e191af705a37a Reviewed-on: https://skia-review.googlesource.com/19260 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
* [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>
* 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>