• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

generated/H12-Nov-2020-2,0881,743

GrClampedGradientEffect.fpH A D07-Nov-20202.4 KiB5950

GrDualIntervalGradientColorizer.fpH A D07-Nov-20202.1 KiB6350

GrGradientBitmapCache.cppH A D07-Nov-20207.2 KiB250191

GrGradientBitmapCache.hH A D07-Nov-20201.7 KiB6340

GrGradientShader.cppH A D07-Nov-202014.3 KiB308201

GrGradientShader.hH A D07-Nov-20202.5 KiB6638

GrLinearGradientLayout.fpH A D07-Nov-20202.9 KiB7563

GrRadialGradientLayout.fpH A D07-Nov-20202.6 KiB7160

GrSingleIntervalGradientColorizer.fpH A D07-Nov-2020702 2217

GrSweepGradientLayout.fpH A D07-Nov-20203.1 KiB8470

GrTextureGradientColorizer.fpH A D07-Nov-2020413 1915

GrTiledGradientEffect.fpH A D07-Nov-20202 KiB6050

GrTwoPointConicalGradientLayout.fpH A D07-Nov-202011.4 KiB303256

GrUnrolledBinaryGradientColorizer.fpH A D07-Nov-20208.2 KiB189165

README.mdH A D07-Nov-20203.9 KiB7258

README.md

1Gradients on the GPU
2====================
3
4Gradients can be thought of, at a very high level, as three pieces:
5
61. A color interpolator that is one dimensional, returning a color for an input
7   within the range [0.0, 1.0]. This obfuscates the the definition of specific
8   color stops and how to wrap, tile, or clamp out of bound inputs. A color
9   interpolator will be named GrYGradientColorizer
102. A layout that converts from 2D geometry/position to the one dimensional
11   domain of the color interpolator. This is how a linear or radial gradient
12   distinguishes itself. When designing a new gradient, this is the component
13   that you have to implement. A layout will generally be named
14   GrXGradientLayout
153. A master effect that composes the layout and color interpolator together. It
16   is also responsible for implementing the clamping behavior that can be
17   abstracted away from both the layout and colorization.
18
19
20GrClampedGradientEffect handles clamped and decal tile modes, while
21GrTiledGradientEffect implements repeat and mirror tile modes. The
22GrClampedGradientEffect requires border colors to be specified outside of its
23colorizer child, but these border colors may be defined by the gradient color
24stops. Both of these master effects delegate calculating a t interpolant to a
25child process, perform their respective tile mode operations, and possibly
26convert the tiled t value (guaranteed to be within 0 and 1) into an output
27color using their child colorizer process.
28
29Because of how child processors are currently defined, where they have a single
30half4 input and a single half4 output, their is a type mismatch between the 1D
31t value and the 4D inputs/outputs of the layout and colorizer processes. For
32now, the master effect assumes an untiled t is output in sk_OutColor.x by the
33layout and it tiles solely off of that value.
34
35However, layouts can output a negative value in the y component to invalidate
36the gradient location (currently on the two point conical gradient does this).
37When invalidated, the master effect outputs transparent black and does not
38invoke the child processor. Other than this condition, any value in y, z, or w
39are passed into the colorizer unmodified. The colorizer should assume that the
40valid tiled t value is in sk_InColor.x and can safely ignore y, z, and w.
41
42Currently there are color interpolators (colorizers) for analytic color cases
43(evaluated directly on the GPU) and sampling a generated texture map.
44
45GrGradientShader provides static factory functions to create
46GrFragmentProcessor graphs that reproduce a particular SkGradientShader.
47
48Optimization Flags
49==================
50
51At an abstract level, gradient shaders are compatible with coverage as alpha
52and, under certain conditions, preserve opacity when the inputs are opaque. To
53reduce the amount of duplicate code and boilerplate, these optimization
54decisions are implemented in the master effects and not in the colorizers. It
55is assumed that all colorizer FPs will be compatible with coverage as alpha and
56will preserve opacity if input colors are opaque. Since this is assumed by the
57master effects, they do not need to report these optimizations or check input
58opacity (this does mean if the colorizers are used independently from the
59master effect shader that the reported flags might not be optimal, but since
60that is unlikely, this convention really simplifies the colorizer
61implementations).
62
63Unlike colorizers, which do not need to report any optimization flags, layout
64FPs should report opacity preserving optimizations because they can impact the
65opacity of a pixel outside of how the gradient would otherwise color it.
66Layouts that potentially reject pixels (i.e. could output a negative y value)
67must not report kPreservesOpaqueInput_OptimizationFlag. Layouts that never
68reject a pixel should report kPreservesOpaqueInput_OptimizationFlag since the
69master effects can optimize away checking if the layout rejects a pixel.
70
71
72