aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders/gradients/SkGradientShaderPriv.h
Commit message (Collapse)AuthorAge
* Remove array of TextureSampler pointers from GrIOResourceProcessor.Gravatar Brian Salomon2018-07-30
| | | | | | | | | | Instead store sampler count on base class and subclasses implement a virtual to get the ith sampler. Change-Id: I13e2447a6467a09761d8615acb4aa360b87b1476 Reviewed-on: https://skia-review.googlesource.com/141563 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
* Switch gradients to as-encoded blendingGravatar Brian Osman2018-07-06
| | | | | | | | | | | | | | Stops are now always transformed all the way to destination color space, using a new helper struct. Even textured gradients on GPU pre-transform the stops, for simplicity and consistency. We plumb the destination config in to drive the choice of texture format - this is simpler and more correct. Bug: skia: Change-Id: Ie3aea9d29a8a5973a72551d9efeaf247ce29606b Reviewed-on: https://skia-review.googlesource.com/139173 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Remove GrPixelConfig argument to GrColorSpaceXform[Effect]::MakeGravatar Brian Osman2018-06-14
| | | | | | | | | | | This was for sRGB configs, which are no longer treated special. Pulling this out of https://skia-review.googlesource.com/c/skia/+/132090 to land separately. Change-Id: Id04c4e82ad4ffe375cfd384490839b0488e54d44 Reviewed-on: https://skia-review.googlesource.com/134843 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* rebaseGravatar Cary Clark2018-06-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 32a4910e57b1fdd3c8671de1ee85e05ca21d079f. Reason for revert: SkMatrix::toString use has been removed from flutter and has been picked up in fuchsia Additionally some bookmaker changes take into account recent additions of typedef comments and the generated header comment. Original change's description: > Revert "remove toString" > > This reverts commit 5191880cbf3ee4d122b0d11b4945fbab0784fda7. > > Reason for revert: broke flutter > > Original change's description: > > remove toString > > > > toString may have been used by obsolete debugger only > > find out if that is so > > > > R=​brianosman@google.com,bsalomon@google.com > > > > Docs-Preview: https://skia.org/?cl=119894 > > Bug:830651 > > Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd > > Reviewed-on: https://skia-review.googlesource.com/119894 > > Commit-Queue: Cary Clark <caryclark@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org > > Change-Id: I9f81de6c3615ee0608bcea9081b77239b4b8816c TBR=bsalomon@google.com,brianosman@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Reviewed-on: https://skia-review.googlesource.com/129623 Reviewed-by: Cary Clark <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@google.com> Docs-Preview: https://skia.org/?cl=133583 Bug: 830651 Change-Id: If8499e796be63580ad419e150e94d43e8b89de1b Reviewed-on: https://skia-review.googlesource.com/133583 Commit-Queue: Cary Clark <caryclark@skia.org> Auto-Submit: Cary Clark <caryclark@skia.org>
* Revert "Reland "remove toString""Gravatar Cary Clark2018-05-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 92e37b6d79f12ccfaaf7671413316952d182267d. Reason for revert: toString still used by flutter Original change's description: > Reland "remove toString" > > This reverts commit 32a4910e57b1fdd3c8671de1ee85e05ca21d079f. > > Reason for revert: SkMatrix::toString use has been removed from flutter and has been picked up in fuchsia > > Original change's description: > > Revert "remove toString" > > > > This reverts commit 5191880cbf3ee4d122b0d11b4945fbab0784fda7. > > > > Reason for revert: broke flutter > > > > Original change's description: > > > remove toString > > > > > > toString may have been used by obsolete debugger only > > > find out if that is so > > > > > > R=​brianosman@google.com,bsalomon@google.com > > > > > > Docs-Preview: https://skia.org/?cl=119894 > > > Bug:830651 > > > Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd > > > Reviewed-on: https://skia-review.googlesource.com/119894 > > > Commit-Queue: Cary Clark <caryclark@google.com> > > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > > > TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org > > > > Change-Id: I9f81de6c3615ee0608bcea9081b77239b4b8816c > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: 830651 > > Reviewed-on: https://skia-review.googlesource.com/129340 > > Reviewed-by: Cary Clark <caryclark@google.com> > > Commit-Queue: Cary Clark <caryclark@google.com> > > TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: 830651 > Change-Id: Ida8725b6051132d8c46faf99358a8fcc1bcabf34 > Reviewed-on: https://skia-review.googlesource.com/129623 > Reviewed-by: Cary Clark <caryclark@skia.org> > Reviewed-by: Cary Clark <caryclark@google.com> > Commit-Queue: Cary Clark <caryclark@google.com> TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org Change-Id: Iafc59ffc1b3db67c520ba31bf12d68e1b46c0ea2 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 830651 Reviewed-on: https://skia-review.googlesource.com/131082 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
* Reland "remove toString"Gravatar Cary Clark2018-05-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 32a4910e57b1fdd3c8671de1ee85e05ca21d079f. Reason for revert: SkMatrix::toString use has been removed from flutter and has been picked up in fuchsia Original change's description: > Revert "remove toString" > > This reverts commit 5191880cbf3ee4d122b0d11b4945fbab0784fda7. > > Reason for revert: broke flutter > > Original change's description: > > remove toString > > > > toString may have been used by obsolete debugger only > > find out if that is so > > > > R=​brianosman@google.com,bsalomon@google.com > > > > Docs-Preview: https://skia.org/?cl=119894 > > Bug:830651 > > Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd > > Reviewed-on: https://skia-review.googlesource.com/119894 > > Commit-Queue: Cary Clark <caryclark@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org > > Change-Id: I9f81de6c3615ee0608bcea9081b77239b4b8816c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: 830651 > Reviewed-on: https://skia-review.googlesource.com/129340 > Reviewed-by: Cary Clark <caryclark@google.com> > Commit-Queue: Cary Clark <caryclark@google.com> TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 830651 Change-Id: Ida8725b6051132d8c46faf99358a8fcc1bcabf34 Reviewed-on: https://skia-review.googlesource.com/129623 Reviewed-by: Cary Clark <caryclark@skia.org> Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
* Revert "remove toString"Gravatar Cary Clark2018-05-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5191880cbf3ee4d122b0d11b4945fbab0784fda7. Reason for revert: broke flutter Original change's description: > remove toString > > toString may have been used by obsolete debugger only > find out if that is so > > R=​brianosman@google.com,bsalomon@google.com > > Docs-Preview: https://skia.org/?cl=119894 > Bug:830651 > Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd > Reviewed-on: https://skia-review.googlesource.com/119894 > Commit-Queue: Cary Clark <caryclark@google.com> > Reviewed-by: Brian Salomon <bsalomon@google.com> TBR=bsalomon@google.com,brianosman@google.com,caryclark@google.com,caryclark@skia.org Change-Id: I9f81de6c3615ee0608bcea9081b77239b4b8816c No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 830651 Reviewed-on: https://skia-review.googlesource.com/129340 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
* remove toStringGravatar Cary Clark2018-05-20
| | | | | | | | | | | | | | toString may have been used by obsolete debugger only find out if that is so R=brianosman@google.com,bsalomon@google.com Docs-Preview: https://skia.org/?cl=119894 Bug:830651 Change-Id: I737f19b7d3fbc869bea2f443fa3b5ed7c1393ffd Reviewed-on: https://skia-review.googlesource.com/119894 Commit-Queue: Cary Clark <caryclark@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
* Validate gradient DescriptorScope size during deserializationGravatar Florin Malita2018-05-10
| | | | | | | | | | Check that the reader has sufficient data before allocating buffers. Bug: skia:7937 Change-Id: I2352d9a5cbace77b77c150a3a6439e8ac18b0dc5 Reviewed-on: https://skia-review.googlesource.com/127132 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Kevin Lubick <kjlubick@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>
* Banish SkShaderBase::isRasterPipelineOnly()Gravatar Florin Malita2018-04-04
| | | | | | | | | | | | | | | | | Keeping related heuristics in sync with actual shader capabilities is somewhat tricky, and overall fragile. So how about this: instead of an explicit opt-in mechanism, try to instantiate a legacy shader context and fall back to raster pipeline on failure (null Context => implicit opt-in for raster pipeline). Shaders can still choose not to draw by returning both a null Context and failing appendStages(). BUG=skia:7772 Change-Id: I2e76f51af7064853a6cb851b4c30c82eba3ee828 Reviewed-on: https://skia-review.googlesource.com/118383 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Mike Reed <reed@google.com>
* Fix GrTextureStripAtlasManager cleanup order bugGravatar Robert Phillips2018-03-19
| | | | | | | | Bug: 820703 Change-Id: I6f1a895ceb213d38361bc03a472cf2a48e4720a5 Reviewed-on: https://skia-review.googlesource.com/115001 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
* add decal tilemode to shadersGravatar Mike Reed2018-02-16
| | | | | | | | | | | | | Plenty more to follow-up: - gradients - gpu impl Bug: skia:7638 Change-Id: I8e54fd0e24921f040f178c793b36c7fb855b136e Reviewed-on: https://skia-review.googlesource.com/107420 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* add gpu impl for shadermaskfilterGravatar Mike Reed2018-02-01
| | | | | | | | | | | adds MulChildAlphaByInput renames MulOutputByInputAlpha --> MulChildByInputAlpha Bug: skia:7500 Change-Id: Ic0615d4d23a887fbee510901ed77a36f98a1b11d Reviewed-on: https://skia-review.googlesource.com/102440 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Remove DumpHelper as the bug is fixedGravatar Yuqian Li2018-01-09
| | | | | | | | Bug: skia:7436 Change-Id: I1dd09eb2b2d07f13b1ace01259791d8e0ce26ae8 Reviewed-on: https://skia-review.googlesource.com/92702 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
* Debug random 2pt conical shadersGravatar Yuqian Li2017-12-21
| | | | | | | | Bug: skia:7436 Change-Id: I5131c7f1208f04e6145c0bc11454ef0c39ce8e2f Reviewed-on: https://skia-review.googlesource.com/88426 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Yuqian Li <liyuqian@google.com>
* Guard the sqrt(temp) where temp < 0 in 2pt conical gradientGravatar Yuqian Li2017-12-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although Linux and Android will return NAN, iOS and some some Win10 devices would return undefined values. This relands 82161 (with the fix mentioned above). The speedup is a little less due to the additional temp < 0 check. 4.08% faster in gradient_conicalOutZero_clamp 6.83% faster in gradient_conical_clamp_shallow_dither 9.43% faster in gradient_conicalOutZero_clamp_3color 12.66% faster in gradient_conicalOut_clamp_hicolor 16.67% faster in gradient_conicalOut_clamp_3color 17.83% faster in gradient_conicalOut_clamp and the speedup is further reduced because we break up the if with two conditions into two ifs with single condition: 7.32% faster in gradient_conical_clamp_shallow_dither 8.00% faster in gradient_conicalOut_clamp_hicolor 8.57% faster in gradient_conicalOut_clamp 8.73% faster in gradient_conicalOut_clamp_3color CQ_INCLUDE_TRYBOTS=skia.primary:Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-All-Android,Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Debug-All-Android,Test-Mac-Clang-MacMini7.1-GPU-IntelIris5100-x86_64-Debug-All-CommandBuffer Change-Id: I41fb8d97e31c577b52a200f0b883591c9bdc4d1c Reviewed-on: https://skia-review.googlesource.com/84963 Commit-Queue: Yuqian Li <liyuqian@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
* Revert "Reimplement TwoPointConicalGradient_gpu"Gravatar Yuqian Li2017-12-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 84f18c422ae98085c452d3f721ec32228e92f531. Reason for revert: GMs are incorrect on some mobile devices Original change's description: > Reimplement TwoPointConicalGradient_gpu > > 4.24% faster in gradient_conical_clamp_shallow_dither > 6.43% faster in gradient_conicalOutZero_clamp_hicolor > 10.41% faster in gradient_conicalOut_clamp_hicolor > 14.85% faster in gradient_conicalOutZero_clamp_3color > 16.72% faster in gradient_conicalOut_clamp > 24.30% faster in gradient_conicalOut_clamp_3color > > CQ_INCLUDE_TRYBOTS=skia.primary:Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-All-Android,Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Debug-All-Android > > Bug: skia: > Change-Id: I6bc1f24c9463fc9c2acbcba7bd4d55b37ade1613 > Reviewed-on: https://skia-review.googlesource.com/82161 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Yuqian Li <liyuqian@google.com> TBR=egdaniel@google.com,fmalita@google.com,liyuqian@google.com Change-Id: Ieb20cce12a958abb8293218b89baf3d5a2aad0a8 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Cq-Include-Trybots: skia.primary:Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-All-Android, Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Debug-All-Android Reviewed-on: https://skia-review.googlesource.com/84801 Reviewed-by: Yuqian Li <liyuqian@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
* Reimplement TwoPointConicalGradient_gpuGravatar Yuqian Li2017-12-13
| | | | | | | | | | | | | | | | | 4.24% faster in gradient_conical_clamp_shallow_dither 6.43% faster in gradient_conicalOutZero_clamp_hicolor 10.41% faster in gradient_conicalOut_clamp_hicolor 14.85% faster in gradient_conicalOutZero_clamp_3color 16.72% faster in gradient_conicalOut_clamp 24.30% faster in gradient_conicalOut_clamp_3color CQ_INCLUDE_TRYBOTS=skia.primary:Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Release-All-Android,Test-Android-Clang-Nexus7-GPU-Tegra3-arm-Debug-All-Android Bug: skia: Change-Id: I6bc1f24c9463fc9c2acbcba7bd4d55b37ade1613 Reviewed-on: https://skia-review.googlesource.com/82161 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
* Simplify analytical GPU gradient implsGravatar Florin Malita2017-11-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1) reformulate the gradient data as a series of interpolation intervals, defined as tuples of (color_scale, color_bias) such that color(t) = t * color_scale + color_bias (this allows us to skip the relative_t computation and simply feed tiled_t into a fast MAD) 2) then, the existing specializations can be generalized as a) select an interpolation interval (possibly based on a threshold) b) compute the interpolated color using the method in #1 3) simplify the hard-edge cases by using clamp intervals (color_scale == 0) and relaxing the clamping step (allowing tiled_t < 0 or tiled_t > 1, in order to hit the clamping intervals during the selection step) The existing specializations are converted as follows: * kTwo_ColorType -> single interpolation interval, normal clamping * kThree_ColorType -> two interpolation intervals, normal clamping, threshold == pos[1] * kSingleHardStop_ColorType -> two interpolation intervals, normal clamping, threshold == pos[1/2] * kHardStopLeftEdged_ColorType -> two interpolation intervals, clamping (-inf, 1], threshold == 0 * kHardStopRightEdged_ColorType -> two interpolation intervals, clamping [0, +inf), threshold == 1 This reduces the SkSL overhead in a couple of ways: * the clamp stage is sometimes reduced to min/max vs. full clamp() * the color interpolation stage is just a MAD vs. full mix() Change-Id: I65be84d131d56136ec5e946c2b3dba149a4473cf Reviewed-on: https://skia-review.googlesource.com/68218 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Remove gradient onGetGLSLProcessorKey() overridesGravatar Florin Malita2017-11-03
| | | | | | | | | | | None of the gradient processor subclassess contributes anything to the base class key. Relocate the key logic to GrGradientEffect, and remove unneeded builerplate. Change-Id: I6b33ad359212579adedf95c0c3d481373c83d4c4 Reviewed-on: https://skia-review.googlesource.com/67721 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Gradient cleanup passGravatar Florin Malita2017-11-01
| | | | | | | | | | | 1) replace manual storage management with SkAutoSTMalloc 2) simplify explicit positions processing (remove redundant branch) Change-Id: I7841e2018ac421768ed1d61c4e3ef6a1d28f6244 Reviewed-on: https://skia-review.googlesource.com/66146 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: 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>
* Add support for transfer functions to GrColorSpaceXformGravatar Brian Osman2017-10-31
| | | | | | | | | | | | | | | | | | | With this change, untagged sources (eg N32) are treated as sRGB data, which causes a huge number of GMs to render more correctly in GPU sRGB/F16/etc... configs. Also, because the sources are treated as having a color space, we actually do gamut conversion for wide or narrow gamut outputs. This change also applies the transfer function math to individual colors in the case of gradient stops and color shaders. (The CPU backend doesn't do this yet, but I think we've decided there's no reason not to support it). Bug: skia: Change-Id: If76e9e4a268f9f74110ff4bbe4fe189ba5d19d9f Reviewed-on: https://skia-review.googlesource.com/64100 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Remove gradient SkFixed position recordsGravatar Florin Malita2017-10-30
| | | | | | | | | | At this point they are only used to build a cache key. Replace with float positions and delete the supporting code. Change-Id: Ida12fd39ed3f612a807de4505c7398838e0693be Reviewed-on: https://skia-review.googlesource.com/64940 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Re-land: Stop using fixed point recs for gradient positioning infoGravatar Florin Malita2017-10-28
| | | | | | | | | | | | | The fixed point gradient records are historical relics. Instead of round-tripping through FP, just use the float positions directly. We can remove the recs completely in a follow-up. TBR= Change-Id: Ic3c8e58af6dfa76744799513c9e60af0462014d0 Reviewed-on: https://skia-review.googlesource.com/64680 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Revert "Stop using fixed point recs for gradient positioning info"Gravatar Florin Malita2017-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 97293503f50d01d7e5054d7a1f9d93644cce9964. Reason for revert: some wacky diffs Original change's description: > Stop using fixed point recs for gradient positioning info > > The fixed point gradient records are historical relics. Instead of > round-tripping through FP, just use the float positions directly. > > We can remove the recs completely in a follow-up, after rebaselining the > existing clients. > > Change-Id: I85d1e0f469006de320dbc842f50e69bcbb3aa668 > Reviewed-on: https://skia-review.googlesource.com/64102 > Reviewed-by: Brian Osman <brianosman@google.com> > Commit-Queue: Florin Malita <fmalita@chromium.org> TBR=brianosman@google.com,fmalita@chromium.org,reed@google.com Change-Id: I37bf9b6a358eb09d7d0cf737beb9c1bd994fd736 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/64103 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Stop using fixed point recs for gradient positioning infoGravatar Florin Malita2017-10-26
| | | | | | | | | | | | | The fixed point gradient records are historical relics. Instead of round-tripping through FP, just use the float positions directly. We can remove the recs completely in a follow-up, after rebaselining the existing clients. Change-Id: I85d1e0f469006de320dbc842f50e69bcbb3aa668 Reviewed-on: https://skia-review.googlesource.com/64102 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* 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>
* Stop using GradientShaderCache for gradient texturesGravatar Florin Malita2017-10-25
| | | | | | | | | | | | | | | | | Ganesh uses GradientShaderCache for generating legacy gradient textures, and a custom helper (initLinearBitmap) for all other cases. Now that GradientShaderCache no longer supports dithering, there is little difference between the two implementantions. And sice the result is also cached in a separate bitmap cache, we might as well consolidate the implementation and always use initLinearBitmap. This allows us to completely remove GradientShaderCache in a follow up. Change-Id: Ie05d15132a6116d2f139f066b81fcfbc9e22d7b6 Reviewed-on: https://skia-review.googlesource.com/63741 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 unused (?) gradient context classGravatar Brian Osman2017-10-25
| | | | | | | | Bug: skia: Change-Id: Id8a561e8d95fb0405cba2f2a5c3165667344579e Reviewed-on: https://skia-review.googlesource.com/63860 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: 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>
* Remove GradientShaderCache dither and paint alpha supportGravatar Florin Malita2017-10-25
| | | | | | | | | | | | The gradient cache is only used for complex GPU gradients, and is always initialized with no dithering and opaque alpha. Remove the (now-dead) code supporing ditherning and non-opaque alpha. Change-Id: Iad694fa760e9a236efadd4cf92fbc7f8bcacadbe Reviewed-on: https://skia-review.googlesource.com/63520 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Add clamped/unclamped xform to GrColorSpaceXformGravatar Brian Osman2017-10-20
| | | | | | | | | | | Use that in analytic gradient setup for future-proofing. Also fixed several out-of-date comments in gradient code. Bug: skia: Change-Id: I79726cad786c22f80e08cdc2b7a1e15ae27ecd5a Reviewed-on: https://skia-review.googlesource.com/62320 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com>
* make skmatrix getmapproc privateGravatar Cary Clark2017-10-20
| | | | | | | | | | | | | | Make SkMatrix MapXYProc MapPtsProc and friends private. Code search turned up no clients in chromium, google3, android. Fingers crossed. R:reed@google.com Bug: skia:6898 Change-Id: Iee20fe5150499215a09f67cc6f117b685f38f455 Reviewed-on: https://skia-review.googlesource.com/62140 Commit-Queue: Cary Clark <caryclark@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
* Simplify GrGradientEffect color handlingGravatar Brian Osman2017-10-19
| | | | | | | | | | | | | For analytic gradients, hoist the byte -> float, premultiplication, and color space transformation to creation time. Eliminates second array (only one was ever used), and four different onSetData helpers. Bug: skia: Change-Id: Ib5740b37ef2a5dcf2551e85b1e72f64d8cbcc5fa Reviewed-on: https://skia-review.googlesource.com/62120 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Brian Salomon <bsalomon@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>
* initClassID no longer auto-allocates idsGravatar Ethan Nicholas2017-10-09
| | | | | | | | | | | | | Auto-allocated IDs mean that the IDs depend upon the order in which classes happen to get initialized and are therefore not consistent from run to run. This change paves the way for a persistent shader cache by fixing the IDs in an enum. Bug: skia: Change-Id: I3e923c6c54f41b3b3eb616458abee83e0909c09f Reviewed-on: https://skia-review.googlesource.com/56401 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
* make most of SkColorPriv.h privateGravatar Cary Clark2017-09-15
| | | | | | | | | | | | | created new file src/core/SkColorData.h for internal consumption. Note that many of the functions there are unused as well. Bug: skia: 6898 R: reed@google.com Change-Id: I25bfd5a9c21f53558c4ca65a77eb5d322d897c6d Reviewed-on: https://skia-review.googlesource.com/46848 Commit-Queue: Cary Clark <caryclark@google.com> Reviewed-by: Mike Reed <reed@google.com>
* Remove symmetric three stop special caseGravatar Brian Osman2017-09-12
| | | | | | | | | | | | Just let the general three-stop shader handle all three-stop gradients. Also, pre-compute values derived from the middle stop to remove all division (and actually convert computation to FMA form). Bug: skia: Change-Id: I1aae069d929d1a942c38aa2e2f3fd5fb7d9b2f10 Reviewed-on: https://skia-review.googlesource.com/45800 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
* Add general three-stop analytic gradient shaderGravatar Brian Osman2017-09-11
| | | | | | | | | | | | | | | | This fixes an Android rendering bug where radial gradients were being used for "clipping" (via DstIn blend mode). The gradient stops were placed at (0, 0.999, 1), which caused our table quantization to drop the last stop. kThree_ColorType now means "0, any t, 1". The old (special-case) kThree_ColorType is now called kSymmetricThree_ColorType. Bug: skia: Change-Id: I96a0b9e679f2d537862a3e097f7e3446474914ea Reviewed-on: https://skia-review.googlesource.com/45260 Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
* Rework GrSamplerParams to be more compact and use its own wrap mode enum.Gravatar Brian Salomon2017-09-07
| | | | | | | | | The main change is to make GrSamplerParams smaller by making its enums have byte-sized underlying types. The rest is cosmetic. Change-Id: Ib71ea50612d24619a85e463826c6b8dfb9b445e3 Reviewed-on: https://skia-review.googlesource.com/43200 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
* fold params into StageRecGravatar Mike Reed2017-08-29
| | | | | | | | | | | | | pre-CL before trying to add a hint-rect field to allow shaders to "optimize" their stages for a given restriction in device space - e.g. if the shader's intrinsic domain is contained, it won't need to tile/clamp Bug: skia: Change-Id: Ia2da557691da25f31e4b9e3f53c3bc6709b89083 Reviewed-on: https://skia-review.googlesource.com/40224 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Reed <reed@google.com>
* Consolidate GrGradientEffect analytical implsGravatar Florin Malita2017-08-08
| | | | | | | | | There's a lot of commonality, we can share more code. Change-Id: I6528358763459c4e8af17fe5f6763752cfffdf39 Reviewed-on: https://skia-review.googlesource.com/31023 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Brian Salomon <bsalomon@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>
* Implement clone() for Gradient GrFragmentProcessorsGravatar Brian Salomon2017-07-27
| | | | | | | | | Also removes the hard stop gradient conditional compilation macro. Change-Id: Idd56b5f3061db063d650a0090406ec192acc0b53 Reviewed-on: https://skia-review.googlesource.com/27661 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
* Clarify adjustMatrixAndAppendStages semanticsGravatar Florin Malita2017-07-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A false return from adjustMatrixAndAppendStages() currently means we'll attempt to create a legacy context wrapper stage. Only two gradient impls can return false, and they don't really want the same thing: 1) linear returns false when the stops are compressed, to get the "nice" legacy blend color behavior 2) two-point radial returns false when it cannot map the center points (degenerate matrix); in this case we prolly don't want to draw at all This setup made sense while we were retrofitting gradients with stages, but now that all of them support RP, it is confusing to sometimes get a legacy context wrapper even when we are specifically asked for stages. I propose we align the semantics with SkShader::onAppendStages(), such that a false return means "don't draw" rather than "try to draw with a legacy context". This means we're giving up the compressed stop behavior for linear, but that's such an arbitrary corner case that I don't think we care at all. Change-Id: I01256c4acb81b16fb68e6c74cf8d91ea77b95a3b Reviewed-on: https://skia-review.googlesource.com/22541 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Herb Derby <herb@google.com>
* 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>
* Fix GrGradientEffect::isValid()Gravatar Brian Salomon2017-06-09
| | | | | | | | | | This was relying on TextureSampler::proxy() which crashes if the proxy is not valid. Bug: skia: Change-Id: I8452f5cea3a71b5ced15259aede52a44ab152cf2 Reviewed-on: https://skia-review.googlesource.com/19403 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>