31 SetTransform(pdman, shaderCaps, fViewMatrixUniform, ce.fViewMatrix, &fViewMatrix);
32 SetTransform(pdman, shaderCaps, fLocalMatrixUniform, ce.fLocalMatrix, &fLocalMatrix);
34 if (fColor != ce.fColor) {
35 pdman.
set4fv(fColorUniform, 1, ce.fColor.
vec());
39 if (ce.fCoverageScale != 0xff && ce.fCoverageScale != fCoverageScale) {
41 fCoverageScale = ce.fCoverageScale;
46 void onEmitCode(EmitArgs&, GrGPArgs*)
override;
51 uint8_t fCoverageScale = 0xFF;
59void GrConicEffect::Impl::onEmitCode(EmitArgs&
args, GrGPArgs* gpArgs) {
66 varyingHandler->emitAttributes(gp);
69 varyingHandler->addVarying(
"ConicCoeffs", &v);
70 vertBuilder->
codeAppendf(
"%s = %s;", v.vsOut(), gp.inConicCoeffs().
name());
82 gp.inPosition().
name(),
85 if (gp.fUsesLocalCoords) {
92 &fLocalMatrixUniform);
117 fragBuilder->
codeAppendf(
"%s = dFdx(%s.xyz);", dklmdx.c_str(), v.fsIn());
118 fragBuilder->
codeAppendf(
"%s = dFdy(%s.xyz);", dklmdy.c_str(), v.fsIn());
119 fragBuilder->
codeAppendf(
"%s = 2.0 * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;",
121 v.fsIn(), dklmdx.c_str(),
122 v.fsIn(), dklmdx.c_str(),
123 v.fsIn(), dklmdx.c_str());
124 fragBuilder->
codeAppendf(
"%s = 2.0 * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;",
126 v.fsIn(), dklmdy.c_str(),
127 v.fsIn(), dklmdy.c_str(),
128 v.fsIn(), dklmdy.c_str());
129 fragBuilder->
codeAppendf(
"%s = float2(%s, %s);", gF.c_str(), dfdx.c_str(),
131 fragBuilder->
codeAppendf(
"%s = sqrt(dot(%s, %s));",
132 gFM.c_str(), gF.c_str(), gF.c_str());
133 fragBuilder->
codeAppendf(
"%s = %s.x*%s.x - %s.y*%s.z;",
134 func.c_str(), v.fsIn(), v.fsIn(), v.fsIn(), v.fsIn());
135 fragBuilder->
codeAppendf(
"%s = abs(%s);", func.c_str(), func.c_str());
137 edgeAlpha.c_str(), func.c_str(), gFM.c_str());
138 fragBuilder->
codeAppendf(
"%s = max(1.0 - %s, 0.0);",
139 edgeAlpha.c_str(), edgeAlpha.c_str());
144 if (gp.fCoverageScale != 0xff) {
145 const char* coverageScale;
146 fCoverageScaleUniform = uniformHandler->
addUniform(
nullptr,
151 fragBuilder->
codeAppendf(
"half4 %s = half4(half(%s) * %s);",
152 args.fOutputCoverage, coverageScale, edgeAlpha.c_str());
154 fragBuilder->
codeAppendf(
"half4 %s = half4(%s);",
args.fOutputCoverage, edgeAlpha.c_str());
164 key |= fCoverageScale == 0xff ? 0x8 : 0x0;
165 key |= fUsesLocalCoords ? 0x10 : 0x0;
175 return std::make_unique<Impl>();
179 const SkMatrix& localMatrix,
bool usesLocalCoords)
182 , fViewMatrix(viewMatrix)
183 , fLocalMatrix(viewMatrix)
184 , fUsesLocalCoords(usesLocalCoords)
193#if defined(GR_TEST_UTILS)
196 SkMatrix viewMatrix = GrTest::TestMatrix(
d->fRandom);
197 SkMatrix localMatrix = GrTest::TestMatrix(
d->fRandom);
198 bool usesLocalCoords =
d->fRandom->nextBool();
219 SetTransform(pdman, shaderCaps, fViewMatrixUniform, qe.fViewMatrix, &fViewMatrix);
220 SetTransform(pdman, shaderCaps, fLocalMatrixUniform, qe.fLocalMatrix, &fLocalMatrix);
222 if (qe.fColor != fColor) {
223 pdman.
set4fv(fColorUniform, 1, qe.fColor.
vec());
227 if (qe.fCoverageScale != 0xff && qe.fCoverageScale != fCoverageScale) {
229 fCoverageScale = qe.fCoverageScale;
234 void onEmitCode(EmitArgs&, GrGPArgs*)
override;
239 uint8_t fCoverageScale = 0xFF;
247void GrQuadEffect::Impl::onEmitCode(EmitArgs&
args, GrGPArgs* gpArgs) {
254 varyingHandler->emitAttributes(gp);
257 varyingHandler->addVarying(
"HairQuadEdge", &v);
258 vertBuilder->
codeAppendf(
"%s = %s;", v.vsOut(), gp.inHairQuadEdge().
name());
270 gp.inPosition().
name(),
272 &fViewMatrixUniform);
273 if (gp.fUsesLocalCoords) {
280 &fLocalMatrixUniform);
285 fragBuilder->
codeAppendf(
"half2 duvdx = half2(dFdx(%s.xy));", v.fsIn());
286 fragBuilder->
codeAppendf(
"half2 duvdy = half2(dFdy(%s.xy));", v.fsIn());
287 fragBuilder->
codeAppendf(
"half2 gF = half2(2.0 * %s.x * duvdx.x - duvdx.y,"
288 " 2.0 * %s.x * duvdy.x - duvdy.y);",
290 fragBuilder->
codeAppendf(
"edgeAlpha = half(%s.x * %s.x - %s.y);",
291 v.fsIn(), v.fsIn(), v.fsIn());
292 fragBuilder->
codeAppend(
"edgeAlpha = sqrt(edgeAlpha * edgeAlpha / dot(gF, gF));");
293 fragBuilder->
codeAppend(
"edgeAlpha = max(1.0 - edgeAlpha, 0.0);");
297 if (gp.fCoverageScale != 0xFF) {
298 const char* coverageScale;
299 fCoverageScaleUniform = uniformHandler->
addUniform(
nullptr,
304 fragBuilder->
codeAppendf(
"half4 %s = half4(%s * edgeAlpha);",
args.fOutputCoverage,
307 fragBuilder->
codeAppendf(
"half4 %s = half4(edgeAlpha);",
args.fOutputCoverage);
317 key |= fCoverageScale != 0xff ? 0x8 : 0x0;
318 key |= fUsesLocalCoords ? 0x10 : 0x0;
328 return std::make_unique<Impl>();
332 const SkMatrix& localMatrix,
bool usesLocalCoords)
335 , fViewMatrix(viewMatrix)
336 , fLocalMatrix(localMatrix)
337 , fUsesLocalCoords(usesLocalCoords)
346#if defined(GR_TEST_UTILS)
349 SkMatrix viewMatrix = GrTest::TestMatrix(
d->fRandom);
350 SkMatrix localMatrix = GrTest::TestMatrix(
d->fRandom);
351 bool usesLocalCoords =
d->fRandom->nextBool();
static float GrNormalizeByteToFloat(uint8_t value)
#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(...)
constexpr SkPMColor4f SK_PMColor4fILLEGAL
void setData(const GrGLSLProgramDataManager &pdman, const GrShaderCaps &shaderCaps, const GrGeometryProcessor &geomProc) override
~GrConicEffect() override
static GrGeometryProcessor * Make(SkArenaAlloc *arena, const SkPMColor4f &color, const SkMatrix &viewMatrix, const GrCaps &caps, const SkMatrix &localMatrix, bool usesLocalCoords, uint8_t coverage=0xff)
void addToKey(const GrShaderCaps &caps, skgpu::KeyBuilder *b) const override
std::unique_ptr< ProgramImpl > makeProgramImpl(const GrShaderCaps &) const override
virtual void set4fv(UniformHandle, int arrayCount, const float v[]) const =0
virtual void set1f(UniformHandle, float v0) const =0
void declAppend(const GrShaderVar &var)
void codeAppend(const char *str)
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
GrShaderVar asShaderVar() const
constexpr const char * name() const
void setupUniformColor(GrGLSLFPFragmentBuilder *fragBuilder, GrGLSLUniformHandler *uniformHandler, const char *outputName, UniformHandle *colorUniform)
GrGLSLProgramDataManager::UniformHandle UniformHandle
static uint32_t AddMatrixKeys(const GrShaderCaps &shaderCaps, uint32_t flags, const SkMatrix &viewMatrix, const SkMatrix &localMatrix)
static void WriteOutputPosition(GrGLSLVertexBuilder *, GrGPArgs *, const char *posName)
static void WriteLocalCoord(GrGLSLVertexBuilder *, GrGLSLUniformHandler *, const GrShaderCaps &, GrGPArgs *, GrShaderVar localVar, const SkMatrix &localMatrix, UniformHandle *localMatrixUniform)
static void SetTransform(const GrGLSLProgramDataManager &, const GrShaderCaps &, const UniformHandle &uniform, const SkMatrix &matrix, SkMatrix *state=nullptr)
void setVertexAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
void setData(const GrGLSLProgramDataManager &pdman, const GrShaderCaps &shaderCaps, const GrGeometryProcessor &geomProc) override
static GrGeometryProcessor * Make(SkArenaAlloc *arena, const SkPMColor4f &color, const SkMatrix &viewMatrix, const GrCaps &caps, const SkMatrix &localMatrix, bool usesLocalCoords, uint8_t coverage=0xff)
void addToKey(const GrShaderCaps &caps, skgpu::KeyBuilder *b) const override
std::unique_ptr< ProgramImpl > makeProgramImpl(const GrShaderCaps &) const override
static const SkMatrix & I()
static const SkMatrix & InvalidMatrix()
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
const float * vec() const
static SkRGBA4f FromBytes_RGBA(uint32_t color)