Commit Graph

72 Commits

Author SHA1 Message Date
Ethan Nicholas
842d31b141 fixed Metal matrix constructors
Bug: skia:8544
Change-Id: Ie1e96ab1ef6e8c032fa510be36c035f91a1f6851
Reviewed-on: https://skia-review.googlesource.com/c/185687
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2019-01-25 18:37:34 +00:00
Ethan Nicholas
eace935298 Revert "converted AARectEffect to new FP system"
This reverts commit 222e275b0a.

Reason for revert: perf regression

Original change's description:
> converted AARectEffect to new FP system
> 
> Bug: skia:
> Change-Id: I0e4141c7f547bab92c65a6abff120ed04d5c2c66
> Reviewed-on: https://skia-review.googlesource.com/c/153550
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

TBR=bsalomon@google.com,ethannicholas@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: skia:
Change-Id: I3d7036a78d8582d6790c77b20a60e6e5257d1881
Reviewed-on: https://skia-review.googlesource.com/c/162283
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-10-15 20:43:26 +00:00
Ethan Nicholas
222e275b0a converted AARectEffect to new FP system
Bug: skia:
Change-Id: I0e4141c7f547bab92c65a6abff120ed04d5c2c66
Reviewed-on: https://skia-review.googlesource.com/c/153550
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-10-12 18:54:54 +00:00
Robert Phillips
94ade75219 Make GrYUVtoRGBEffect more flexible
This makes GL & Vulkan render the wacky_yuv_formats GM correctly (transparency and all).

Bug: skia:7903
Change-Id: I09cf872beae3fd0fc1c5109b03ca1714ed51ae85
Reviewed-on: https://skia-review.googlesource.com/c/160162
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2018-10-10 13:57:57 +00:00
Michael Ludwig
72535fb55a Reland "Reland "Implement an explicit binary search-based analytic gradient colorizer""
This is a reland of f065907ccc

3rd time's the charm:

The new analytic gradient shader was sporadically triggering violations of the coverage as alpha
compatibility optimization. Unfortunately, even when using the same device and random seed for the
test, the bots did not always reproduce the error. However, we identified the likely cause of the
violation.

The test requires that all output channels are less than the input alpha, which it uses to validate
whether or not the shader is modulating its values by the input alpha. This test does not pass if
the RGB values are greater than 1. The original version of the analytic gradient shader used half4s
for its scale and bias values. Given the threshold limit for hardstops of 0.00024 (SkNearlyZero),
a very small interval that is not treated as a hardstop can create a scale or bias of over 4000.
This moves into the very imprecise region of 16-bit floats, making it plausible that the gradient
outputs colors greater than 1, due to rounding. The kicker is that the random test generation for
stop locations does not use a uniform distribution, but is instead biased towards the remaining
interval, which increases the likelihood of generating a small interval that is not treated as a
hard stop. We are keeping this behavior since ill-conditioned gradients are useful in testing.

Original change's description:
> Reland "Implement an explicit binary search-based analytic gradient colorizer"
>
> This reverts commit 9461dcf130.
>
> Reason for revert: Fixes for ANGLE's incorrect shader behavior
>
> Original change's description:
> > Revert "Implement an explicit binary search-based analytic gradient colorizer"
> >
> > This reverts commit dcc85fc610.
> >
> > Reason for revert: ANGLE is frequently corrupted, particularly radial_gradient4 and mixershader
> >
> > Original change's description:
> > > Implement an explicit binary search-based analytic gradient colorizer
> > >
> > > Provides a reasonably flexible fragment processor that defines another
> > > colorizer implementation for gradients. It can support up to 8
> > > interpolation intervals (which is 16 colors if every stop is a hard stop
> > > or 9 colors if every stop is a smooth transition). It
> > > supports mixtures of hard and smooth stops. It is conditionally compiled
> > > into versions specific to the interval count (so it can produce up to
> > > 8 shader variants).
> > >
> > > The GrGradientShader controller does not remove the single and dual
> > > interval colorizers, which are useful specializations of this explicit
> > > binary search colorizer. Similarly, since it can only handle up to 8
> > > intervals, the texture colorizer is still used as a fallback.
> > >
> > > Currently it does not employ capabilities detection to determine if the
> > > hardware can support the number of required uniforms, which can become
> > > substantial for the larger gradient configurations.
> > >
> > > Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
> > > Change-Id: Ia1f735a5019766ae4796cc22964b2913db34b95b
> > > Reviewed-on: https://skia-review.googlesource.com/155080
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > Reviewed-by: Brian Osman <brianosman@google.com>
> >
> > TBR=bsalomon@google.com,brianosman@google.com,michaelludwig@google.com
> >
> > Change-Id: I351a387f0528e4c2db2d47ab2e5d6b336991fb98
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
> > Reviewed-on: https://skia-review.googlesource.com/156541
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,brianosman@google.com,michaelludwig@google.com
>
> Change-Id: I2aca36307d88c26905d860ec29417ec68c6037cc
> Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
> Reviewed-on: https://skia-review.googlesource.com/156542
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
Change-Id: I2d050624781c77cdd160291cadbadac602b48bde
Reviewed-on: https://skia-review.googlesource.com/c/157569
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2018-10-04 13:10:29 +00:00
Brian Osman
5ea96bf76e Remove unused premul/unpremul FP code
Bug: skia:
Change-Id: I911ee066ce4d0175cee3ee3868a86955d486687c
Reviewed-on: https://skia-review.googlesource.com/159060
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
2018-10-02 19:46:37 +00:00
Brian Osman
e2a801ddaa Revert "Reland "Implement an explicit binary search-based analytic gradient colorizer""
This reverts commit f065907ccc.

Reason for revert: Processor test failing (inconsistently) on several bots.

Original change's description:
> Reland "Implement an explicit binary search-based analytic gradient colorizer"
> 
> This reverts commit 9461dcf130.
> 
> Reason for revert: Fixes for ANGLE's incorrect shader behavior
> 
> Original change's description:
> > Revert "Implement an explicit binary search-based analytic gradient colorizer"
> >
> > This reverts commit dcc85fc610.
> >
> > Reason for revert: ANGLE is frequently corrupted, particularly radial_gradient4 and mixershader
> >
> > Original change's description:
> > > Implement an explicit binary search-based analytic gradient colorizer
> > >
> > > Provides a reasonably flexible fragment processor that defines another
> > > colorizer implementation for gradients. It can support up to 8
> > > interpolation intervals (which is 16 colors if every stop is a hard stop
> > > or 9 colors if every stop is a smooth transition). It
> > > supports mixtures of hard and smooth stops. It is conditionally compiled
> > > into versions specific to the interval count (so it can produce up to
> > > 8 shader variants).
> > >
> > > The GrGradientShader controller does not remove the single and dual
> > > interval colorizers, which are useful specializations of this explicit
> > > binary search colorizer. Similarly, since it can only handle up to 8
> > > intervals, the texture colorizer is still used as a fallback.
> > >
> > > Currently it does not employ capabilities detection to determine if the
> > > hardware can support the number of required uniforms, which can become
> > > substantial for the larger gradient configurations.
> > >
> > > Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
> > > Change-Id: Ia1f735a5019766ae4796cc22964b2913db34b95b
> > > Reviewed-on: https://skia-review.googlesource.com/155080
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > Reviewed-by: Brian Osman <brianosman@google.com>
> >
> > TBR=bsalomon@google.com,brianosman@google.com,michaelludwig@google.com
> >
> > Change-Id: I351a387f0528e4c2db2d47ab2e5d6b336991fb98
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
> > Reviewed-on: https://skia-review.googlesource.com/156541
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> 
> TBR=bsalomon@google.com,brianosman@google.com,michaelludwig@google.com
> 
> Change-Id: I2aca36307d88c26905d860ec29417ec68c6037cc
> Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
> Reviewed-on: https://skia-review.googlesource.com/156542
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=bsalomon@google.com,brianosman@google.com,michaelludwig@google.com

Change-Id: Icd925d568d8cdffdc3020c07a9c50a4aa9cf0bb9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
Reviewed-on: https://skia-review.googlesource.com/157429
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2018-09-27 16:50:52 +00:00
Michael Ludwig
f065907ccc Reland "Implement an explicit binary search-based analytic gradient colorizer"
This reverts commit 9461dcf130.

Reason for revert: Fixes for ANGLE's incorrect shader behavior

Original change's description:
> Revert "Implement an explicit binary search-based analytic gradient colorizer"
>
> This reverts commit dcc85fc610.
>
> Reason for revert: ANGLE is frequently corrupted, particularly radial_gradient4 and mixershader
>
> Original change's description:
> > Implement an explicit binary search-based analytic gradient colorizer
> >
> > Provides a reasonably flexible fragment processor that defines another
> > colorizer implementation for gradients. It can support up to 8
> > interpolation intervals (which is 16 colors if every stop is a hard stop
> > or 9 colors if every stop is a smooth transition). It
> > supports mixtures of hard and smooth stops. It is conditionally compiled
> > into versions specific to the interval count (so it can produce up to
> > 8 shader variants).
> >
> > The GrGradientShader controller does not remove the single and dual
> > interval colorizers, which are useful specializations of this explicit
> > binary search colorizer. Similarly, since it can only handle up to 8
> > intervals, the texture colorizer is still used as a fallback.
> >
> > Currently it does not employ capabilities detection to determine if the
> > hardware can support the number of required uniforms, which can become
> > substantial for the larger gradient configurations.
> >
> > Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
> > Change-Id: Ia1f735a5019766ae4796cc22964b2913db34b95b
> > Reviewed-on: https://skia-review.googlesource.com/155080
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> TBR=bsalomon@google.com,brianosman@google.com,michaelludwig@google.com
>
> Change-Id: I351a387f0528e4c2db2d47ab2e5d6b336991fb98
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
> Reviewed-on: https://skia-review.googlesource.com/156541
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=bsalomon@google.com,brianosman@google.com,michaelludwig@google.com

Change-Id: I2aca36307d88c26905d860ec29417ec68c6037cc
Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
Reviewed-on: https://skia-review.googlesource.com/156542
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2018-09-27 16:02:30 +00:00
Michael Ludwig
9461dcf130 Revert "Implement an explicit binary search-based analytic gradient colorizer"
This reverts commit dcc85fc610.

Reason for revert: ANGLE is frequently corrupted, particularly radial_gradient4 and mixershader

Original change's description:
> Implement an explicit binary search-based analytic gradient colorizer
> 
> Provides a reasonably flexible fragment processor that defines another
> colorizer implementation for gradients. It can support up to 8
> interpolation intervals (which is 16 colors if every stop is a hard stop
> or 9 colors if every stop is a smooth transition). It
> supports mixtures of hard and smooth stops. It is conditionally compiled
> into versions specific to the interval count (so it can produce up to
> 8 shader variants).
> 
> The GrGradientShader controller does not remove the single and dual
> interval colorizers, which are useful specializations of this explicit
> binary search colorizer. Similarly, since it can only handle up to 8
> intervals, the texture colorizer is still used as a fallback.
> 
> Currently it does not employ capabilities detection to determine if the
> hardware can support the number of required uniforms, which can become
> substantial for the larger gradient configurations.
> 
> Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
> Change-Id: Ia1f735a5019766ae4796cc22964b2913db34b95b
> Reviewed-on: https://skia-review.googlesource.com/155080
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

TBR=bsalomon@google.com,brianosman@google.com,michaelludwig@google.com

Change-Id: I351a387f0528e4c2db2d47ab2e5d6b336991fb98
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
Reviewed-on: https://skia-review.googlesource.com/156541
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2018-09-24 19:40:54 +00:00
Michael Ludwig
dcc85fc610 Implement an explicit binary search-based analytic gradient colorizer
Provides a reasonably flexible fragment processor that defines another
colorizer implementation for gradients. It can support up to 8
interpolation intervals (which is 16 colors if every stop is a hard stop
or 9 colors if every stop is a smooth transition). It
supports mixtures of hard and smooth stops. It is conditionally compiled
into versions specific to the interval count (so it can produce up to
8 shader variants).

The GrGradientShader controller does not remove the single and dual
interval colorizers, which are useful specializations of this explicit
binary search colorizer. Similarly, since it can only handle up to 8
intervals, the texture colorizer is still used as a fallback.

Currently it does not employ capabilities detection to determine if the
hardware can support the number of required uniforms, which can become
substantial for the larger gradient configurations.

Bug: chromium:796479, chromium:729727, chromium:696603, chromium:543625, chromium:414254
Change-Id: Ia1f735a5019766ae4796cc22964b2913db34b95b
Reviewed-on: https://skia-review.googlesource.com/155080
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2018-09-24 16:40:36 +00:00
Michael Ludwig
a7914d3a8e Implement textured gradients
Also clones SkGradientBitmapCache into GrGradientBitmapCache in the
gpu/gradients folder. But after cleaning up the old gradient code,
SkGradientBitmapCache will go away and SkGradientShader will have no
reference to the bitmap cache or support for building bitmaps.

The "new" GrGradientBitmapCache has been updated to hide the thread
safety responsibilities and gradient bitmap generation code that had
originally been a part of SkGradientShader.

Bug: skia:
Change-Id: Ida134c6437c866439fac44fa453d09a6a11549e7
Reviewed-on: https://skia-review.googlesource.com/150917
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-09-14 17:31:53 +00:00
Michael Ludwig
0495f7aec3 Implement dual interval gradients
Adds a new colorizer implementation that supports gradients with two
interpolation intervals. The two intervals can share a middle color
to represent the usual 3-color gradient, or can have different colors
to represent a hard stop at an arbitrary point.

Bug: skia:
Change-Id: I8c73705e83b99e28ad5c834230ced4e3b7b9d1c4
Reviewed-on: https://skia-review.googlesource.com/150700
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-09-14 13:12:52 +00:00
Michael Ludwig
8f685085af Implement 2-pt conical gradient layout
Add an FP that provides the two-point conical gradient effect. The
majority of the new FP's shader code is a straight forward port from
SkTwoPointConicalGradient_gpu.cpp. This FP is bulkier because of the
extensive calculations that go on in its overridden Make function.

To support 2-pt conical gradient's behavior of writing transparent
black in invalid areas of the conical interpolation, the contract of
gradient layout FPs has been updated to provide a flag in the y
component as to whether or not the fragment should be rejected.

A separate channel was used since negative values and large values are
perfectly reasonable for the untiled gradient layout to return (before
the value is then constrained into [0, 1]). It also seemed better to
avoid returning a problematic value like infinity or NaN.

Bug: skia:
Change-Id: I37373bb5aebd89cac8905602e699ad19f0f5ac82
Reviewed-on: https://skia-review.googlesource.com/148988
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-09-13 20:04:16 +00:00
Michael Ludwig
24d438b393 Implement sweep gradient layout
Add an FP that implements the sweep gradient effect and updates
SkSweepGradient to use the new system if possible.

Bug: skia:
Change-Id: I3f65da01afafae54c45848a6a78fd758f65eb4a6
Reviewed-on: https://skia-review.googlesource.com/148806
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-09-13 18:45:26 +00:00
Michael Ludwig
4089df8690 Implement radial gradient layout
Adds a radial gradient FP in the same vein as the prior linear gradient
FP. It updates SkRadialGradient to try and use the new system before
falling back to the original GPU gradient code.

Bug: skia:
Change-Id: I0739832beeae18d0a7178ada44014d7885478031
Reviewed-on: https://skia-review.googlesource.com/148803
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-09-13 16:58:25 +00:00
Michael Ludwig
4f94ef6cbd Reland "Base Gradient FP Refactor"
This reverts commit 1ea5656a28.

Reason for revert: Fixed google3 build failure

Original change's description:
> Revert "Base Gradient FP Refactor"
> 
> This reverts commit 10f7a1e075.
> 
> Reason for revert: broke google3 roll
> Original change's description:
> > Base Gradient FP Refactor
> > 
> > --
> > 
> > Redefines how gradients will be written in the GPU back-end:
> > 
> > They are split into three fragment processor components: master, layout, and colorizer.
> > The layout FP is responsible for converting the fragment position into an interpolant value, t.
> > Each high-level gradient--such as linear, radial, etc.--are implemented solely in a layout FP.
> > The colorizer FP is responsible for converting t into a color.
> > The master FP invokes the layout, clamps t into the proper domain, and then invokes the colorizer.
> > GrGradientShader provides factory functions to create FP graphs from SkGradientShader instances.
> > This pattern is documented in gpu/gradients/README.md.
> > 
> > Goals for current CL
> > ====================
> > 
> > Outline the FP components by providing .fp implementations for the simplest gradients.
> > Defines a two-color single interval colorizer and a linear gradient layout, and the master effect.
> > A MakeLinear() factory function is provided that can convert SkGradientShaders that fit these constraints.
> > SkLinearGradient first attempts to use the new system, falling back to the original GrGradientEffect.
> > 
> > Future CLs
> > ==========
> > 
> > To keep the CL reviews manageable, additional dependent CLs will be added that gradually replace past functionality.
> > A CL for each layout will be defined.
> > CLs for the different analytic colorizer cases and the textured gradient case will be defined.
> > Once the new system supports all current layouts and colorizer capabilities, all old GPU gradient code will be removed.
> > After this clean-up, analytic colorization can hopefully be expanded to reduce the usage of textured gradients.
> > 
> > Bug: skia:
> > Change-Id: Iafe7b8b4071491a71c473babcd7bedda659150c1
> > Reviewed-on: https://skia-review.googlesource.com/148120
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> 
> TBR=bsalomon@google.com,michaelludwig@google.com
> 
> Change-Id: Ib735e323795ac8874cb00b007a915786b50517a6
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/153600
> Reviewed-by: Cary Clark <caryclark@google.com>
> Commit-Queue: Cary Clark <caryclark@google.com>

TBR=bsalomon@google.com,caryclark@google.com,michaelludwig@google.com

Change-Id: Ibf6ffbcb1af0dfbdac7317151aeb08f18f84c7fd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/153887
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2018-09-12 20:20:32 +00:00
Cary Clark
1ea5656a28 Revert "Base Gradient FP Refactor"
This reverts commit 10f7a1e075.

Reason for revert: broke google3 roll
Original change's description:
> Base Gradient FP Refactor
> 
> --
> 
> Redefines how gradients will be written in the GPU back-end:
> 
> They are split into three fragment processor components: master, layout, and colorizer.
> The layout FP is responsible for converting the fragment position into an interpolant value, t.
> Each high-level gradient--such as linear, radial, etc.--are implemented solely in a layout FP.
> The colorizer FP is responsible for converting t into a color.
> The master FP invokes the layout, clamps t into the proper domain, and then invokes the colorizer.
> GrGradientShader provides factory functions to create FP graphs from SkGradientShader instances.
> This pattern is documented in gpu/gradients/README.md.
> 
> Goals for current CL
> ====================
> 
> Outline the FP components by providing .fp implementations for the simplest gradients.
> Defines a two-color single interval colorizer and a linear gradient layout, and the master effect.
> A MakeLinear() factory function is provided that can convert SkGradientShaders that fit these constraints.
> SkLinearGradient first attempts to use the new system, falling back to the original GrGradientEffect.
> 
> Future CLs
> ==========
> 
> To keep the CL reviews manageable, additional dependent CLs will be added that gradually replace past functionality.
> A CL for each layout will be defined.
> CLs for the different analytic colorizer cases and the textured gradient case will be defined.
> Once the new system supports all current layouts and colorizer capabilities, all old GPU gradient code will be removed.
> After this clean-up, analytic colorization can hopefully be expanded to reduce the usage of textured gradients.
> 
> Bug: skia:
> Change-Id: Iafe7b8b4071491a71c473babcd7bedda659150c1
> Reviewed-on: https://skia-review.googlesource.com/148120
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=bsalomon@google.com,michaelludwig@google.com

Change-Id: Ib735e323795ac8874cb00b007a915786b50517a6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/153600
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
2018-09-11 15:51:56 +00:00
Michael Ludwig
10f7a1e075 Base Gradient FP Refactor
--

Redefines how gradients will be written in the GPU back-end:

They are split into three fragment processor components: master, layout, and colorizer.
The layout FP is responsible for converting the fragment position into an interpolant value, t.
Each high-level gradient--such as linear, radial, etc.--are implemented solely in a layout FP.
The colorizer FP is responsible for converting t into a color.
The master FP invokes the layout, clamps t into the proper domain, and then invokes the colorizer.
GrGradientShader provides factory functions to create FP graphs from SkGradientShader instances.
This pattern is documented in gpu/gradients/README.md.

Goals for current CL
====================

Outline the FP components by providing .fp implementations for the simplest gradients.
Defines a two-color single interval colorizer and a linear gradient layout, and the master effect.
A MakeLinear() factory function is provided that can convert SkGradientShaders that fit these constraints.
SkLinearGradient first attempts to use the new system, falling back to the original GrGradientEffect.

Future CLs
==========

To keep the CL reviews manageable, additional dependent CLs will be added that gradually replace past functionality.
A CL for each layout will be defined.
CLs for the different analytic colorizer cases and the textured gradient case will be defined.
Once the new system supports all current layouts and colorizer capabilities, all old GPU gradient code will be removed.
After this clean-up, analytic colorization can hopefully be expanded to reduce the usage of textured gradients.

Bug: skia:
Change-Id: Iafe7b8b4071491a71c473babcd7bedda659150c1
Reviewed-on: https://skia-review.googlesource.com/148120
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-09-11 14:52:55 +00:00
Ethan Nicholas
78aceb2f87 converted overdraw effect to new FP system
Bug: skia:
Change-Id: I4cff0ecdf3fc61f584012af519730f08bfd78264
Reviewed-on: https://skia-review.googlesource.com/150484
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-09-04 13:37:25 +00:00
Michael Ludwig
a427559c13 Refactor 'in uniform' CPP code generation
Easily supports mapping ctypes to sksl types with templates that
specify how to send data to the GPU and how to track state changes.
The template logic and type mappings are defined in
SkSLCPPUniformCTypes.* while SkSLCPPCodeGenerator is updated to
utilize it.

It also updates the supported ctypes to properly generate code for
SkPoint, SkIPoint, SkIRect, and GrColor4f. The code generated for
'in uniforms' now also correctly supports conditional uniforms.


Bug: skia:
Change-Id: Ib7c0a873bdd68a966b6a00871f33102dfa2c432d
Reviewed-on: https://skia-review.googlesource.com/150129
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2018-08-31 15:19:58 +00:00
Ethan Nicholas
ce008119dc converted arithmetic FP to new FP structure
Bug: skia:
Change-Id: I5492b378fa0f2ab7b453b2b1b18e4aef898370d2
Reviewed-on: https://skia-review.googlesource.com/148910
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-08-30 17:41:11 +00:00
Ethan Nicholas
0054311bf3 Re-re-land "added GrSkSLFP and converted DitherEffect to use it"
This reverts commit 6c48e4d11c.

Bug: skia:
Change-Id: I7ee78990fc30eec545d1856e59eb6e0573089426
Reviewed-on: https://skia-review.googlesource.com/144348
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-07-31 15:18:03 +00:00
Ethan Nicholas
b93af7ec90 Revert "Revert "removed SkSLLayoutLexer""
This reverts commit 734b2a8597.

Bug: skia:
Change-Id: I1b8f49ab9d2ec1976f82f4feb70a8d0c5015b654
Reviewed-on: https://skia-review.googlesource.com/143109
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-07-24 15:55:15 +00:00
Ethan Nicholas
734b2a8597 Revert "removed SkSLLayoutLexer"
This reverts commit 804f817861.

Reason for revert: breaking chrome roll: https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8940111858576531488/+/steps/compile__with_patch_/0/stdout

Original change's description:
> removed SkSLLayoutLexer
> 
> Bug: skia:
> Change-Id: Iad4c89fbde8bc1f6c3d022af9aec2ec5faa8a4ef
> Reviewed-on: https://skia-review.googlesource.com/142583
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

TBR=mtklein@google.com,ethannicholas@google.com

Change-Id: Ie07065ac43c5b8356665a7170adbe97ae8fd9f90
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/143120
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-07-24 14:59:16 +00:00
Ethan Nicholas
804f817861 removed SkSLLayoutLexer
Bug: skia:
Change-Id: Iad4c89fbde8bc1f6c3d022af9aec2ec5faa8a4ef
Reviewed-on: https://skia-review.googlesource.com/142583
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-07-24 13:53:15 +00:00
Ethan Nicholas
6c48e4d11c Reland "Revert "added GrSkSLFP and converted DitherEffect to use it""
This reverts commit 97ae0c8902.

Reason for revert: Breaking ANGLE.

Original change's description:
> Revert "Revert "added GrSkSLFP and converted DitherEffect to use it""
> 
> This reverts commit f203078309.
> 
> Bug: skia:
> Change-Id: Icaaa8b3ea652a8f126bfbcc788a360493a7ebe3e
> Reviewed-on: https://skia-review.googlesource.com/137391
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=bsalomon@google.com,robertphillips@google.com,ethannicholas@google.com

Change-Id: I65d6d2707fceab0a99121c528d1b848d23e34bfa
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/142588
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-07-19 20:10:46 +00:00
Ethan Nicholas
97ae0c8902 Revert "Revert "added GrSkSLFP and converted DitherEffect to use it""
This reverts commit f203078309.

Bug: skia:
Change-Id: Icaaa8b3ea652a8f126bfbcc788a360493a7ebe3e
Reviewed-on: https://skia-review.googlesource.com/137391
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-07-19 19:00:55 +00:00
Kevin Lubick
f203078309 Revert "added GrSkSLFP and converted DitherEffect to use it"
This reverts commit dfbfc738a9.

Reason for revert: Seems to be breaking DDL/ASAN bots

Original change's description:
> added GrSkSLFP and converted DitherEffect to use it
>
> Bug: skia:
> Change-Id: I84b71165eab1712355f3c7669cee2d33d259f3df
> Reviewed-on: https://skia-review.googlesource.com/124504
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=bsalomon@google.com,ethannicholas@google.com

Change-Id: Ic4c3978aaba0391f2f8bb1316a456e3821a3a2f2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/135700
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2018-06-19 12:23:21 +00:00
Ethan Nicholas
dfbfc738a9 added GrSkSLFP and converted DitherEffect to use it
Bug: skia:
Change-Id: I84b71165eab1712355f3c7669cee2d33d259f3df
Reviewed-on: https://skia-review.googlesource.com/124504
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2018-06-18 18:40:58 +00:00
Greg Daniel
3e8c3458f0 Make generated effects from sksl fp files not need SK_SUPPORT_GPU
Bug: skia:
Change-Id: I42a5c7fe7dc35a23290c8daa754c9fcce07f76fb
Reviewed-on: https://skia-review.googlesource.com/119010
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2018-04-06 18:27:53 +00:00
Ethan Nicholas
26a9aad63b initial SkSLJIT checkin
Docs-Preview: https://skia.org/?cl=112204
Bug: skia:
Change-Id: I10042a0200db00bd8ff8078467c409b1cf191f50
Reviewed-on: https://skia-review.googlesource.com/112204
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
2018-03-27 18:39:13 +00:00
Ethan Nicholas
8f7e28f3ae added frexp support to SkSL
This includes an optimizer fix for the situation:

int i;
float f = frexp(foo, i);

If we don't read the variable i, it is considered dead and eliminated -
which then causes an error when we try to write the expression
frexmp(foo, i).

Bug: skia:
Change-Id: Iac385e38e215455346fab62e1f4ec46fa65b3c21
Reviewed-on: https://skia-review.googlesource.com/116521
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2018-03-26 19:03:44 +00:00
Mike Reed
18e7556371 move blur impl into core
Ever since we added drawShadow to the public api, blurs have necessarily
part of the core. This CL just formalizes that.

This should also allow us to have builds that exclude all of /effects (for code size)
and still be valid.

Will follow-up with a change to deprecate SkBlurMaskFilter and SkBlurQuality (both no longer needed).

Bug: skia:
Change-Id: Ifbbd8b47a30a0386d215726b67bcf1e8b84fb8f5
Reviewed-on: https://skia-review.googlesource.com/113713
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2018-03-12 18:48:18 +00:00
Ethan Nicholas
7461a4abe0 converted YUVEffect to SkSL
Bug: skia:
Change-Id: I1875e44417a0a583c4f35ee4d46856a34ba55245
Reviewed-on: https://skia-review.googlesource.com/88580
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-12-22 14:06:45 +00:00
Ethan Nicholas
297d6efe85 converted GrRRectBlurEffect to SkSL
Bug: skia:
Change-Id: Ifd192db07e02d69d445277a361760ce4a452f603
Reviewed-on: https://skia-review.googlesource.com/87441
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-12-20 19:56:36 +00:00
Ethan Nicholas
2d5f9b3d58 converted GrMagnifierEffect to SkSL
Bug: skia:
Change-Id: I6dc14ac66d5b911117e71fa23fef49a897082781
Reviewed-on: https://skia-review.googlesource.com/71342
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-12-13 20:01:40 +00:00
Ethan Nicholas
e9d172af84 converted ConstColorProcessor to SkSL
Bug: skia:
Change-Id: Ic3b18f82c1ab940637fb26dec1cf376dd859b35d
Reviewed-on: https://skia-review.googlesource.com/73720
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-11-20 20:34:38 +00:00
Ethan Nicholas
be0a042dcf converted Premul / Unpremul to SkSL
Bug: skia:
Change-Id: I4944badbb530e17b9ff7cca389f943e0b5982e01
Reviewed-on: https://skia-review.googlesource.com/72983
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-11-17 20:11:36 +00:00
Ethan Nicholas
8dca18ac7b converted GrAARectEffect to SkSL
Bug: skia:
Change-Id: I08254806fe7cb97dab21c5625aa16dd34aea9468
Reviewed-on: https://skia-review.googlesource.com/72120
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-11-16 21:54:38 +00:00
Ethan Nicholas
14efcbf349 converted LumaColorFilterEffect to sksl
Bug: skia:
Change-Id: I208984ec9ad357249ee1b2fe28477f1450b4b69d
Reviewed-on: https://skia-review.googlesource.com/67848
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2017-11-07 14:55:18 +00:00
Ethan Nicholas
d608c09ac5 Re-land "converted OverdrawColorFilter to SkSL"
This reverts commit 2d3cac58fc.

Bug: skia:
Change-Id: I6607d419f6b30c3e17b52ec5ce67d489bd1ad1dc
Reviewed-on: https://skia-review.googlesource.com/64080
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-10-26 14:58:27 +00:00
Ethan Nicholas
2d3cac58fc Revert "converted OverdrawColorFilter to SkSL"
This reverts commit 8aa4dc9052.

Reason for revert: strncmp getting mad

Original change's description:
> converted OverdrawColorFilter to SkSL
> 
> Bug: skia:
> Change-Id: Idcc0502758df1e60ed131a168b5c9a65a4d834a1
> Reviewed-on: https://skia-review.googlesource.com/63840
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=bsalomon@google.com,ethannicholas@google.com

Change-Id: Ib78d7c878c4597918d059bddb4d61f6a7f59a511
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/63561
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-10-25 21:05:05 +00:00
Ethan Nicholas
8aa4dc9052 converted OverdrawColorFilter to SkSL
Bug: skia:
Change-Id: Idcc0502758df1e60ed131a168b5c9a65a4d834a1
Reviewed-on: https://skia-review.googlesource.com/63840
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2017-10-25 20:19:18 +00:00
Ethan Nicholas
cc3057784b preliminary SkSL Metal backend
Bug: skia:
Change-Id: I03e839fb4f1061bc6d1b1b72d54fd39ca7bd7b84
Reviewed-on: https://skia-review.googlesource.com/51245
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2017-10-24 14:47:01 +00:00
Ethan Nicholas
823994624a converted GrRectBlurEffect to SkSL
Bug: skia:
Change-Id: I3a8e16fd2792e6fb5711815d8aad46ae30c2872e
Reviewed-on: https://skia-review.googlesource.com/59163
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2017-10-16 16:58:41 +00:00
Ethan Nicholas
c9472af858 SkSL FPs now support child processors, converted ArithmeticFP to SkSL
Bug: skia:
Change-Id: I34ed3480073d05762a7d4692aeee4b87e454ce52
Reviewed-on: https://skia-review.googlesource.com/57961
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-10-11 18:05:07 +00:00
Ethan Nicholas
839872c235 converted GrConfigConversionEffect to SkSL
Bug: skia:
Change-Id: If17cf0fc8b857d22f33a462a39a02bcddd15deda
Reviewed-on: https://skia-review.googlesource.com/55741
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-10-05 16:58:44 +00:00
Ethan Nicholas
5b5f096a03 Revert "Revert "Switch to the new SkSL lexer.""
This reverts commit 358515491a.

Bug: skia:
Change-Id: I013fac0ed83774d8ae7c6ee6819045cab37f5e97
Reviewed-on: https://skia-review.googlesource.com/45180
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-09-11 21:45:20 +00:00
Ethan Nicholas
358515491a Revert "Switch to the new SkSL lexer."
This reverts commit c576e93d17.

Reason for revert: ASAN failures

Original change's description:
> Switch to the new SkSL lexer.
> 
> This completely replaces flex with a new in-house lexical analyzer generator,
> which we have done for performance and memory usage reasons. Flex requires us
> to copy strings every time we need the text of a token, whereas this new lexer
> allows us to handle strings as a (non-null-terminated) pointer and length
> everywhere, eliminating most string copies.
> 
> Bug: skia:
> Change-Id: I2add26efc9e20cb699520e82abcf713af3968aca
> Reviewed-on: https://skia-review.googlesource.com/39780
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>

TBR=bsalomon@google.com,ethannicholas@google.com

Change-Id: If27b750a5f696d06a6bcffed12fe9f0598e084a6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/44881
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-09-11 16:34:02 +00:00
Ethan Nicholas
c576e93d17 Switch to the new SkSL lexer.
This completely replaces flex with a new in-house lexical analyzer generator,
which we have done for performance and memory usage reasons. Flex requires us
to copy strings every time we need the text of a token, whereas this new lexer
allows us to handle strings as a (non-null-terminated) pointer and length
everywhere, eliminating most string copies.

Bug: skia:
Change-Id: I2add26efc9e20cb699520e82abcf713af3968aca
Reviewed-on: https://skia-review.googlesource.com/39780
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2017-09-11 16:17:00 +00:00