Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Unified Diff: src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp

Issue 1745613002: Switch float arrays to vecs for conical gradients (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
index 83d5af86145294f54b93a6823267da020b1f6a2c..5b0855ab7c71e0ee0c48299d2b7801e4ac66d8f1 100644
--- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
+++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
@@ -227,9 +227,9 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
this->emitUniforms(uniformHandler, ge);
- fParamUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "Conical2FSParams", 3);
+ fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec3f_GrSLType, kDefault_GrSLPrecision,
+ "Conical2FSParams");
SkString cName("c");
SkString tName("t");
@@ -237,9 +237,10 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
SkString p1; // start radius squared
SkString p2; // difference in radii (r1 - r0)
- uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
- uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
- uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(2, &p2);
+
+ p0.appendf("%s.x", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
+ 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].
SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType());
@@ -294,13 +295,8 @@ void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman,
if (fCachedRadius != radius0 ||
fCachedDiffRadius != diffRadius) {
- float values[3] = {
- SkScalarToFloat(radius0),
- SkScalarToFloat(SkScalarMul(radius0, radius0)),
- SkScalarToFloat(diffRadius)
- };
-
- pdman.set1fv(fParamUni, 3, values);
+ pdman.set3f(fParamUni, SkScalarToFloat(radius0),
+ SkScalarToFloat(SkScalarMul(radius0, radius0)), SkScalarToFloat(diffRadius));
fCachedRadius = radius0;
fCachedDiffRadius = diffRadius;
}
@@ -510,15 +506,15 @@ void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConicalEffect>();
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
this->emitUniforms(uniformHandler, ge);
- fParamUni = uniformHandler->addUniformArray(kFragment_GrShaderFlag,
- kFloat_GrSLType, kDefault_GrSLPrecision,
- "Conical2FSParams", 2);
+ fParamUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
+ kVec2f_GrSLType, kDefault_GrSLPrecision,
+ "Conical2FSParams");
SkString tName("t");
SkString p0; // focalX
SkString p1; // 1 - focalX * focalX
- uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
- uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
+ p0.appendf("%s.x", uniformHandler->getUniformVariable(fParamUni).getName().c_str());
+ 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
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
@@ -568,12 +564,7 @@ void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
if (fCachedFocal != focal) {
SkScalar oneMinus2F = 1.f - SkScalarMul(focal, focal);
- float values[2] = {
- SkScalarToFloat(focal),
- SkScalarToFloat(oneMinus2F),
- };
-
- pdman.set1fv(fParamUni, 2, values);
+ pdman.set2f(fParamUni, SkScalarToFloat(focal), SkScalarToFloat(oneMinus2F));
fCachedFocal = focal;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698