aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/shaders/gradients/SkGradientShader.cpp
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>
* add explicit accessor for sRGB singleton colorspacesGravatar Mike Klein2018-07-25
| | | | | | | | | | | | | | SkColorSpace::MakeSRGB().get() is scary, and causes more ref/unref pairs than strictly necessary for these singletons. This time the implementation is still in SkColorSpace.cpp, so these should really work as singletons. Change-Id: I40f2942c8dcde3040663a04c4f5330aca90868ae Reviewed-on: https://skia-review.googlesource.com/143305 Auto-Submit: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
* Fix fuzzer bug in SkGradientShader::MakeSweepGravatar Robert Phillips2018-07-09
| | | | | | | | | In this case, startAngle was NaN while endAngle was -NaN Change-Id: Ic3498a6f08700437590eb219e2baf535db912cc2 Reviewed-on: https://skia-review.googlesource.com/139980 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
* Support older SKPs drawing to legacy destinations correctlyGravatar Brian Osman2018-07-06
| | | | | | | | | | | | | We were ignoring the linear aspect of the serialized colors, and treating them as if they were sRGB-encoded. Now, always transform colors back to sRGB when drawing to legacy destinations. Change-Id: I980aae73a3e536cccb65b841967a01b6811aa863 Reviewed-on: https://skia-review.googlesource.com/139550 Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Auto-Submit: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@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>
* 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>
* Dest color space no longer impacts mipmaps or texture samplingGravatar Brian Osman2018-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PS5: Removes SkDestinationSurfaceColorMode, tracking of mipmap mode on GrTexture, sRGB decode state per-texture. Because we were often choosing sRGB configs for RGB color types, legacy rendering would then be incorrect (too dark). So... PS7: Stops ever using sRGB pixel configs when translating image info or color type. Also removes a bunch of GrCaps bits and a GrContextOption that are no longer relevant. PS9: Adjusts surface creation unit test expectations, and changes the raster rules accordingly. At this point, sRGB configs are (obviously) going to be broken. Locally, I ran 8888, gl, and the gbr- versions of both. Across all GMs x configs, there are 13 diffs. 12 are GMs that create surfaces with a color-space attached (and thus, the offscreen is no longer getting sRGB pixel config). The only remainder constructs an SkPictureImageGenerator, (with an attached color space) and renders it to the gbr-gl canvas, which triggers a a tagged surface inside the generator. Bug: skia: Change-Id: Ie5edfa157dd799f3121e8173fc4f97f6c8ed6789 Reviewed-on: https://skia-review.googlesource.com/131282 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
* 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>
* remove defines and add commasGravatar Cary Clark2018-05-21
| | | | | | | | | | | | | | | | | | | | | | | | Preparation for generating bookmaker files for all remaining interfaces Standardize enum and enum classes by including a comma after the last entry. Replace flatten-related #define in public interfaces with their equivalent. The motivation is to give documentation something to refer to. An alternative would be to move part or all of this out of the public interface; something I can work on in a follow-up CL. R=reed@google.com,bsalomon@google.com Bug: skia:6898 Change-Id: I4b865f6ec3d8f5d31e50448fef7d2714510302f0 Reviewed-on: https://skia-review.googlesource.com/129312 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Cary Clark <caryclark@skia.org>
* 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>
* Return nullptr when ReadBuffer becomes invalidGravatar Kevin Lubick2018-05-17
| | | | | | | | | | | | | | | | | This especially helps in SkDrawLooper because we can bail out early instead of looping for a potentially long time, e.g. when fuzzed input says count is a large number. This also cleans up validate in a few spots, and adds validateCanReadN as a helper function. Bug: skia:7937 Change-Id: Ic5eff357c8cadc91eeafc6e39c78c570ba74df2f Reviewed-on: https://skia-review.googlesource.com/128847 Commit-Queue: Kevin Lubick <kjlubick@google.com> Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Reviewed-by: Florin Malita <fmalita@chromium.org>
* Make GrCaps and GrShaderCaps private.Gravatar Brian Salomon2018-05-11
| | | | | | | | | Moves getCaps() from GrContext to GrContextPriv and removes unused refCaps(). Change-Id: Ic6a8951b656c0d1b2773eae73bff8e88af819866 Reviewed-on: https://skia-review.googlesource.com/127389 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
* Validate readByteArrayAsData sizeGravatar Florin Malita2018-05-10
| | | | | | | | | | | | Check that the reader has enough data before attempting to allocate the buffer. Also update to return nullptr on read failures. Change-Id: Ia1ea8f611bad95cf3a4493b12582ac3fa7c2b00f Reviewed-on: https://skia-review.googlesource.com/127129 Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* 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 stale gradient color space assertGravatar Florin Malita2018-04-26
| | | | | | | | | | | | | SkGradientShaderBase asserts gammaIsLinear() -- but we don't enforce this in factories. Based on comments, this may be a stale restriction. Can we drop it? Bug: chromium:798208 Change-Id: Id9639cb2bb87f112b26c05372f2a3181c139e5ec Reviewed-on: https://skia-review.googlesource.com/123860 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* 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>
* with no more offline codegen, seed_shader can be normalGravatar Mike Klein2018-03-11
| | | | | | | | | | | | | | We passed this iota array as an argument before because it was generating awkward code for our object file parser to handle (relocations, other weird things, can't quite remember). Now that we're compiling pipeline code normally, we can make seed_shader a normal stage again, with no special iota ctx pointer needed. Change-Id: I3929d61bfb6f914248f360c2c2326ce3d1f23163 Reviewed-on: https://skia-review.googlesource.com/113667 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
* Make GrTextureStripAtlas DDL friendlyGravatar Robert Phillips2018-03-09
| | | | | | | Change-Id: If8fdd7a1c027bc2b2791cfe1af13f99c2561d93d Reviewed-on: https://skia-review.googlesource.com/113268 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
* Simplify decal for gradientsGravatar Mike Reed2018-02-19
| | | | | | | | | | | | Previous change extended the stored array of colors/positions, and lost the information that the intent was decal. This variant just uses custom stages already developed for imageshader, keeping the intent of decal. Bug: skia:7638 Change-Id: Ie3f30b42f4c1793487f08039cd3cea8e31aafc40 Reviewed-on: https://skia-review.googlesource.com/108280 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Mike Reed <reed@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>
* Disable texture strip atlasing for DDLGravatar Robert Phillips2018-02-02
| | | | | | | | | | | | | Ultimately we will want to perform inline and ASAP uploads for the texture strip atlas. Unfortunately, that functionality relies on the existance of the flushState (which we don't have for the opList-based DDL implementation). For now we will punt and try storing the individual texture strips in their own image-based texture proxy for DDLs. Change-Id: Ic2ee0deb230172bda4a5d4b69cc802dbe84ad7ac Reviewed-on: https://skia-review.googlesource.com/102464 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
* Add GrProxyProviderGravatar Robert Phillips2018-01-08
| | | | | | | | | This pulls all the proxy tracking & creation functionality out of the GrResourceCache and GrResourceProvider and consolidates it in the GrProxyProvider. Change-Id: I7256f7c544319a70c1bd93dd5a9ccbe5fa0a544f Reviewed-on: https://skia-review.googlesource.com/91501 Commit-Queue: Robert Phillips <robertphillips@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
* Push much of the SkColorSpace_Base interface up to SkColorSpaceGravatar Brian Osman2017-12-12
| | | | | | | | | | | Some pieces still remain, but the next step looks less mechanical, so I wanted to land this piece independently. Bug: skia: Change-Id: Ie63afcfa08af2f6e4996911fa2225c43441dbfb2 Reviewed-on: https://skia-review.googlesource.com/84120 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Brian Osman <brianosman@google.com>
* Add cap on intel to avoid calling abs and floor on the same line in aGravatar Greg Daniel2017-12-02
| | | | | | | | | | | | | | | | | | | | shader. This fixes a bug on some intel devices where we are failing in the ProcessorOptimizationTest. I've tried other "no op" type things between the floor call and abs which also fixed the issue, as well as adding explicit checks to see if we are less than -1 or greater than 1 where the clamp is. Thus the clamp itself should be a no op and shouldn't secretly be fixing the problem outside of forcing the floor and abs lines to be separate. Bug: skia: Change-Id: I85bf82e0e02607b78470b7a5f8f918e9f53f0154 Reviewed-on: https://skia-review.googlesource.com/76820 Reviewed-by: Robert Phillips <robertphillips@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@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 SK_SUPPORT_LEGACY_UNIFORM_GRADIENTSGravatar Florin Malita2017-11-06
| | | | | | | | | | All clients are now switched over. Change-Id: Idfdb910241ab9f7c2caf5baf59e9c3277aef164f Reviewed-on: https://skia-review.googlesource.com/67846 Reviewed-by: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Detect explicit uniform gradient positionsGravatar Florin Malita2017-11-04
| | | | | | | | | | | | | | | | | | When the color stop positions are uniform, the client is allowed to not specify them (implicit positions, signaled by a null |pos| pointer). This enables some internal optiomizations and yields improved rasterization times. But if the client does pass explicit uniform positions, we currently treat them as general/non-uniform. Detect explicit uniform color stop positions at construction time, and drop them - to ensure optimal treatment downstream. Change-Id: I32ee86daa652622de2936a6f47acb68b64e0b70a Reviewed-on: https://skia-review.googlesource.com/67765 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org>
* Remove SK_SUPPORT_LEGACY_GRADIENT_COLOR_CONVERSIONGravatar Florin Malita2017-11-03
| | | | | | | | | | | | The original change didn't produce any diffs, so this flag is not useful. TBR= Change-Id: Ic4c8d6dcd7d03ace8624345fd624bc5840b99d27 Reviewed-on: https://skia-review.googlesource.com/67724 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Enforce gradient color stop monotonicity in ctorGravatar Florin Malita2017-11-03
| | | | | | | | | | | | | | From the SVG 1.1 spec: Each gradient offset value is required to be equal to or greater than the previous gradient stop's offset value. If a given gradient stop's offset value is not equal to or greater than all previous offset values, then the offset value is adjusted to be equal to the largest of all previous offset values. Change-Id: I797369a1e14dc776ceb6478ac9fcdd4792e65562 Reviewed-on: https://skia-review.googlesource.com/67761 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Mike Klein <mtklein@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>
* Streamline legacy gradient color conversionGravatar Florin Malita2017-11-01
| | | | | | | | | | | | | | | | To produce colors for interpolation in legacy mode, we currently do something like SkColor c = Sk4f_toS32(swizzle_rb(Sk4f::Load(c4f))); color4f = swizzle_rb(SkNx_cast<float>(Sk4b::Load(&c)) * (1/255.0f)); Let's see if we can streamline some of that. Change-Id: I423b5aa8c2df8d115cc236d5f0a2e79923a9c2cc Reviewed-on: https://skia-review.googlesource.com/66142 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com>
* 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>
* Tweak gradient shader code to avoid hangs on Tegra3Gravatar Brian Osman2017-10-26
| | | | | | | | | Bug: skia: Change-Id: I07d638d5f7b399d279f445c8f2b490ea55414e2f Reviewed-on: https://skia-review.googlesource.com/64101 Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: 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>
* 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>
* 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>
* Avoid double-dithering of legacy/gpu gradientsGravatar Florin Malita2017-10-24
| | | | | | | | | | | | The GPU backend is the only remaining user of getGradientTableBitmap(). But with Ganesh, dithering is applied as a separate GrPaint effect => we must not pre-dither the gradient texture also. Change-Id: Icc47c1e762c4913205b3715512894d3d2c3b7659 Reviewed-on: https://skia-review.googlesource.com/63261 Reviewed-by: Brian Salomon <bsalomon@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>