Begin fixing GrShaderVar.
Remove as many setters as possible, make the constructors less
ambiguous, make it movable, remove USE_UNIFORM_FLOAT_ARRAYS.
Change-Id: I71397d04b5b5d6deb792d77cb98d629d42785f06
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279218
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/src/gpu/gl/GrGLUniformHandler.cpp b/src/gpu/gl/GrGLUniformHandler.cpp
index e9836af..4a3b564 100644
--- a/src/gpu/gl/GrGLUniformHandler.cpp
+++ b/src/gpu/gl/GrGLUniformHandler.cpp
@@ -35,23 +35,23 @@
SkASSERT(valid_name(name));
SkASSERT(0 != visibility);
- UniformInfo& uni = fUniforms.push_back();
- uni.fVariable.setType(type);
- uni.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
// TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
// the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
// exactly what name it wants to use for the uniform view matrix. If we prefix anythings, then
// the names will mismatch. I think the correct solution is to have all GPs which need the
// uniform view matrix, they should upload the view matrix in their setData along with regular
// uniforms.
+ SkString resolvedName;
char prefix = 'u';
if ('u' == name[0] || !strncmp(name, GR_NO_MANGLE_PREFIX, strlen(GR_NO_MANGLE_PREFIX))) {
prefix = '\0';
}
- fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName);
- uni.fVariable.setArrayCount(arrayCount);
- uni.fVisibility = visibility;
- uni.fLocation = -1;
+ fProgramBuilder->nameVariable(&resolvedName, prefix, name, mangleName);
+
+ UniformInfo& uni = fUniforms.push_back(GrGLProgramDataManager::UniformInfo{
+ GrShaderVar{std::move(resolvedName), type, GrShaderVar::TypeModifier::Uniform, arrayCount},
+ visibility, -1
+ });
if (outName) {
*outName = uni.fVariable.c_str();
@@ -70,12 +70,13 @@
GrTextureType type = backendFormat.textureType();
- UniformInfo& sampler = fSamplers.push_back();
- sampler.fVariable.setType(GrSLCombinedSamplerTypeForTextureType(type));
- sampler.fVariable.setTypeModifier(GrShaderVar::kUniform_TypeModifier);
- sampler.fVariable.setName(mangleName);
- sampler.fLocation = -1;
- sampler.fVisibility = kFragment_GrShaderFlag;
+ fSamplers.push_back(GrGLProgramDataManager::UniformInfo{
+ GrShaderVar{std::move(mangleName),
+ GrSLCombinedSamplerTypeForTextureType(type),
+ GrShaderVar::TypeModifier::Uniform},
+ kFragment_GrShaderFlag, -1
+ });
+
if (shaderCaps->textureSwizzleAppliedInShader()) {
fSamplerSwizzles.push_back(swizzle);
SkASSERT(fSamplers.count() == fSamplerSwizzles.count());