diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-12 12:26:08 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-12 12:26:08 +0000 |
commit | ff6ea2663f76aa85ec55ddd0f00ca7906f1bc4e3 (patch) | |
tree | 54941da56d3d90540bb21bfab8ca11f0504951e9 /src/gpu/gl/GrGLShaderBuilder.cpp | |
parent | 2e71f1619d9a2c51c1292e618f42a56ad2da1de8 (diff) |
Add GrEllipseEdgeEffect.
Adds the effect that replaces the old oval rendering code. Also hooks in code to set attribute names and indices for effects.
Author: jvanverth@google.com
Review URL: https://chromiumcodereview.appspot.com/12462008
git-svn-id: http://skia.googlecode.com/svn/trunk@8092 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGLShaderBuilder.cpp')
-rw-r--r-- | src/gpu/gl/GrGLShaderBuilder.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp index 5c3f5b3fe8..1a238ae04b 100644 --- a/src/gpu/gl/GrGLShaderBuilder.cpp +++ b/src/gpu/gl/GrGLShaderBuilder.cpp @@ -258,6 +258,22 @@ const GrGLShaderVar& GrGLShaderBuilder::getUniformVariable(UniformHandle u) cons return fUniforms[handle_to_index(u)].fVariable; } +bool GrGLShaderBuilder::addAttribute(GrSLType type, + const char* name) { + for (int i = 0; i < fVSAttrs.count(); ++i) { + const GrGLShaderVar& attr = fVSAttrs[i]; + // if attribute already added, don't add it again + if (attr.getName().equals(name)) { + GrAssert(attr.getType() == type); + return false; + } + } + fVSAttrs.push_back().set(type, + GrGLShaderVar::kAttribute_TypeModifier, + name); + return true; +} + void GrGLShaderBuilder::addVarying(GrSLType type, const char* name, const char** vsOutName, @@ -491,6 +507,18 @@ GrGLEffect* GrGLShaderBuilder::createAndEmitGLEffect( samplerHandles->push_back(textureSamplers[i].fSamplerUniform); } + int numAttributes = stage.getVertexAttribIndexCount(); + const int* attributeIndices = stage.getVertexAttribIndices(); + SkSTArray<GrEffect::kMaxVertexAttribs, SkString> attributeNames; + for (int i = 0; i < numAttributes; ++i) { + SkString attributeName("aAttr"); + attributeName.appendS32(attributeIndices[i]); + + if (this->addAttribute(effect->vertexAttribType(i), attributeName.c_str())) { + fEffectAttributes.push_back().set(attributeIndices[i], attributeName); + } + } + GrGLEffect* glEffect = effect->getFactory().createGLInstance(effect); // Enclose custom code in a block to avoid namespace conflicts @@ -508,3 +536,16 @@ GrGLEffect* GrGLShaderBuilder::createAndEmitGLEffect( return glEffect; } + +const SkString* GrGLShaderBuilder::getEffectAttributeName(int attributeIndex) const { + const AttributePair* attribEnd = this->getEffectAttributes().end(); + for (const AttributePair* attrib = this->getEffectAttributes().begin(); + attrib != attribEnd; + ++attrib) { + if (attrib->fIndex == attributeIndex) { + return &attrib->fName; + } + } + + return NULL; +} |