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

Side by Side Diff: src/gpu/gl/GrGLShaderBuilder.cpp

Issue 12462008: Add GrEllipseEdgeEffect (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: rebase again Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gl/GrGLShaderBuilder.h" 8 #include "gl/GrGLShaderBuilder.h"
9 #include "gl/GrGLProgram.h" 9 #include "gl/GrGLProgram.h"
10 #include "gl/GrGLUniformHandle.h" 10 #include "gl/GrGLUniformHandle.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 *outName = uni.fVariable.c_str(); 251 *outName = uni.fVariable.c_str();
252 } 252 }
253 253
254 return h; 254 return h;
255 } 255 }
256 256
257 const GrGLShaderVar& GrGLShaderBuilder::getUniformVariable(UniformHandle u) cons t { 257 const GrGLShaderVar& GrGLShaderBuilder::getUniformVariable(UniformHandle u) cons t {
258 return fUniforms[handle_to_index(u)].fVariable; 258 return fUniforms[handle_to_index(u)].fVariable;
259 } 259 }
260 260
261 bool GrGLShaderBuilder::addAttribute(GrSLType type,
262 const char* name) {
263 for (int i = 0; i < fVSAttrs.count(); ++i) {
264 const GrGLShaderVar& attr = fVSAttrs[i];
265 // if attribute already added, don't add it again
266 if (attr.getName().equals(name)) {
267 GrAssert(attr.getType() == type);
268 return false;
269 }
270 }
271 fVSAttrs.push_back().set(type,
272 GrGLShaderVar::kAttribute_TypeModifier,
273 name);
274 return true;
275 }
276
261 void GrGLShaderBuilder::addVarying(GrSLType type, 277 void GrGLShaderBuilder::addVarying(GrSLType type,
262 const char* name, 278 const char* name,
263 const char** vsOutName, 279 const char** vsOutName,
264 const char** fsInName) { 280 const char** fsInName) {
265 fVSOutputs.push_back(); 281 fVSOutputs.push_back();
266 fVSOutputs.back().setType(type); 282 fVSOutputs.back().setType(type);
267 fVSOutputs.back().setTypeModifier(GrGLShaderVar::kOut_TypeModifier); 283 fVSOutputs.back().setTypeModifier(GrGLShaderVar::kOut_TypeModifier);
268 if (kNonStageIdx == fCurrentStageIdx) { 284 if (kNonStageIdx == fCurrentStageIdx) {
269 fVSOutputs.back().accessName()->printf("v%s", name); 285 fVSOutputs.back().accessName()->printf("v%s", name);
270 } else { 286 } else {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 500
485 const GrEffectRef& effect = *stage.getEffect(); 501 const GrEffectRef& effect = *stage.getEffect();
486 int numTextures = effect->numTextures(); 502 int numTextures = effect->numTextures();
487 SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers; 503 SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers;
488 textureSamplers.push_back_n(numTextures); 504 textureSamplers.push_back_n(numTextures);
489 for (int i = 0; i < numTextures; ++i) { 505 for (int i = 0; i < numTextures; ++i) {
490 textureSamplers[i].init(this, &effect->textureAccess(i), i); 506 textureSamplers[i].init(this, &effect->textureAccess(i), i);
491 samplerHandles->push_back(textureSamplers[i].fSamplerUniform); 507 samplerHandles->push_back(textureSamplers[i].fSamplerUniform);
492 } 508 }
493 509
510 int numAttributes = stage.getVertexAttribIndexCount();
511 const int* attributeIndices = stage.getVertexAttribIndices();
512 SkSTArray<GrEffect::kMaxVertexAttribs, SkString> attributeNames;
513 for (int i = 0; i < numAttributes; ++i) {
514 SkString attributeName("aAttr");
515 attributeName.appendS32(attributeIndices[i]);
516
517 if (this->addAttribute(effect->vertexAttribType(i), attributeName.c_str( ))) {
518 fEffectAttributes.push_back().set(attributeIndices[i], attributeName );
519 }
520 }
521
494 GrGLEffect* glEffect = effect->getFactory().createGLInstance(effect); 522 GrGLEffect* glEffect = effect->getFactory().createGLInstance(effect);
495 523
496 // Enclose custom code in a block to avoid namespace conflicts 524 // Enclose custom code in a block to avoid namespace conflicts
497 this->fVSCode.appendf("\t{ // %s\n", glEffect->name()); 525 this->fVSCode.appendf("\t{ // %s\n", glEffect->name());
498 this->fFSCode.appendf("\t{ // %s \n", glEffect->name()); 526 this->fFSCode.appendf("\t{ // %s \n", glEffect->name());
499 glEffect->emitCode(this, 527 glEffect->emitCode(this,
500 stage, 528 stage,
501 key, 529 key,
502 vsInCoord, 530 vsInCoord,
503 fsOutColor, 531 fsOutColor,
504 fsInColor, 532 fsInColor,
505 textureSamplers); 533 textureSamplers);
506 this->fVSCode.appendf("\t}\n"); 534 this->fVSCode.appendf("\t}\n");
507 this->fFSCode.appendf("\t}\n"); 535 this->fFSCode.appendf("\t}\n");
508 536
509 return glEffect; 537 return glEffect;
510 } 538 }
539
540 const SkString* GrGLShaderBuilder::getEffectAttributeName(int attributeIndex) co nst {
541 const AttributePair* attribEnd = this->getEffectAttributes().end();
542 for (const AttributePair* attrib = this->getEffectAttributes().begin();
543 attrib != attribEnd;
544 ++attrib) {
545 if (attrib->fIndex == attributeIndex) {
546 return &attrib->fName;
547 }
548 }
549
550 return NULL;
551 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698