Switch float arrays to vecs for conical gradients
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1745613002 Review URL: https://codereview.chromium.org/1745613002
This commit is contained in:
parent
55f2d2d57f
commit
de11ee41b3
@ -227,9 +227,9 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
|
|||||||
const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>();
|
const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>();
|
||||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||||
this->emitUniforms(uniformHandler, ge);
|
this->emitUniforms(uniformHandler, ge);
|
||||||
fParamUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag,
|
fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||||
"Conical2FSParams", 3);
|
"Conical2FSParams");
|
||||||
|
|
||||||
SkString cName("c");
|
SkString cName("c");
|
||||||
SkString tName("t");
|
SkString tName("t");
|
||||||
@ -237,9 +237,10 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
|
|||||||
SkString p1; // start radius squared
|
SkString p1; // start radius squared
|
||||||
SkString p2; // difference in radii (r1 - r0)
|
SkString p2; // difference in radii (r1 - r0)
|
||||||
|
|
||||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
|
|
||||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
|
p0.appendf("%s.x", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
|
||||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(2, &p2);
|
p1.appendf("%s.y", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
|
||||||
|
p2.appendf("%s.z", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
|
||||||
|
|
||||||
// We interpolate the linear component in coords[1].
|
// We interpolate the linear component in coords[1].
|
||||||
SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType());
|
SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType());
|
||||||
@ -294,13 +295,8 @@ void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
|
|||||||
if (fCachedRadius != radius0 ||
|
if (fCachedRadius != radius0 ||
|
||||||
fCachedDiffRadius != diffRadius) {
|
fCachedDiffRadius != diffRadius) {
|
||||||
|
|
||||||
float values[3] = {
|
pdman.set3f(fParamUni, SkScalarToFloat(radius0),
|
||||||
SkScalarToFloat(radius0),
|
SkScalarToFloat(SkScalarMul(radius0, radius0)), SkScalarToFloat(diffRadius));
|
||||||
SkScalarToFloat(SkScalarMul(radius0, radius0)),
|
|
||||||
SkScalarToFloat(diffRadius)
|
|
||||||
};
|
|
||||||
|
|
||||||
pdman.set1fv(fParamUni, 3, values);
|
|
||||||
fCachedRadius = radius0;
|
fCachedRadius = radius0;
|
||||||
fCachedDiffRadius = diffRadius;
|
fCachedDiffRadius = diffRadius;
|
||||||
}
|
}
|
||||||
@ -510,15 +506,15 @@ void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
|
|||||||
const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConicalEffect>();
|
const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConicalEffect>();
|
||||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||||
this->emitUniforms(uniformHandler, ge);
|
this->emitUniforms(uniformHandler, ge);
|
||||||
fParamUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag,
|
fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
|
||||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||||
"Conical2FSParams", 2);
|
"Conical2FSParams");
|
||||||
SkString tName("t");
|
SkString tName("t");
|
||||||
SkString p0; // focalX
|
SkString p0; // focalX
|
||||||
SkString p1; // 1 - focalX * focalX
|
SkString p1; // 1 - focalX * focalX
|
||||||
|
|
||||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
|
p0.appendf("%s.x", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
|
||||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
|
p1.appendf("%s.y", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
|
||||||
|
|
||||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||||
@ -568,12 +564,7 @@ void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
|
|||||||
if (fCachedFocal != focal) {
|
if (fCachedFocal != focal) {
|
||||||
SkScalar oneMinus2F = 1.f - SkScalarMul(focal, focal);
|
SkScalar oneMinus2F = 1.f - SkScalarMul(focal, focal);
|
||||||
|
|
||||||
float values[2] = {
|
pdman.set2f(fParamUni, SkScalarToFloat(focal), SkScalarToFloat(oneMinus2F));
|
||||||
SkScalarToFloat(focal),
|
|
||||||
SkScalarToFloat(oneMinus2F),
|
|
||||||
};
|
|
||||||
|
|
||||||
pdman.set1fv(fParamUni, 2, values);
|
|
||||||
fCachedFocal = focal;
|
fCachedFocal = focal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user