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

Side by Side Diff: src/gpu/GrAAConvexPathRenderer.cpp

Issue 23754003: Isolate VertexBuilder from GrGLShaderBuilder (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 3 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/effects/gradients/SkTwoPointRadialGradient.cpp ('k') | src/gpu/GrAARectRenderer.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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAAConvexPathRenderer.h" 9 #include "GrAAConvexPathRenderer.h"
10 10
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 public: 510 public:
511 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) 511 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
512 : INHERITED (factory) {} 512 : INHERITED (factory) {}
513 513
514 virtual void emitCode(GrGLShaderBuilder* builder, 514 virtual void emitCode(GrGLShaderBuilder* builder,
515 const GrDrawEffect& drawEffect, 515 const GrDrawEffect& drawEffect,
516 EffectKey key, 516 EffectKey key,
517 const char* outputColor, 517 const char* outputColor,
518 const char* inputColor, 518 const char* inputColor,
519 const TextureSamplerArray& samplers) SK_OVERRIDE { 519 const TextureSamplerArray& samplers) SK_OVERRIDE {
520 GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder->getVertex Builder();
521 SkASSERT(NULL != vertexBuilder);
522
520 const char *vsName, *fsName; 523 const char *vsName, *fsName;
521 const SkString* attrName = 524 const SkString* attrName =
522 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice s()[0]); 525 vertexBuilder->getEffectAttributeName(drawEffect.getVertexAttrib Indices()[0]);
523 builder->fsCodeAppendf("\t\tfloat edgeAlpha;\n"); 526 builder->fsCodeAppendf("\t\tfloat edgeAlpha;\n");
524 527
525 SkAssertResult(builder->enableFeature( 528 SkAssertResult(builder->enableFeature(
526 GrGLShaderBuilder::kStandardDeriva tives_GLSLFeature)); 529 GrGLShaderBuilder::kStandardDeriva tives_GLSLFeature));
527 builder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName); 530 vertexBuilder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsN ame);
528 531
529 // keep the derivative instructions outside the conditional 532 // keep the derivative instructions outside the conditional
530 builder->fsCodeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName); 533 builder->fsCodeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
531 builder->fsCodeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName); 534 builder->fsCodeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
532 builder->fsCodeAppendf("\t\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsNa me, fsName); 535 builder->fsCodeAppendf("\t\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsNa me, fsName);
533 // today we know z and w are in device space. We could use derivativ es 536 // today we know z and w are in device space. We could use derivativ es
534 builder->fsCodeAppendf("\t\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);\n", fsName, 537 builder->fsCodeAppendf("\t\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);\n", fsName,
535 fsName); 538 fsName);
536 builder->fsCodeAppendf ("\t\t} else {\n"); 539 builder->fsCodeAppendf ("\t\t} else {\n");
537 builder->fsCodeAppendf("\t\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvd x.y,\n" 540 builder->fsCodeAppendf("\t\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvd x.y,\n"
538 "\t\t\t 2.0*%s.x*duvdy.x - duvd y.y);\n", 541 "\t\t\t 2.0*%s.x*duvdy.x - duvd y.y);\n",
539 fsName, fsName); 542 fsName, fsName);
540 builder->fsCodeAppendf("\t\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fs Name, fsName, 543 builder->fsCodeAppendf("\t\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fs Name, fsName,
541 fsName); 544 fsName);
542 builder->fsCodeAppendf("\t\t\tedgeAlpha = " 545 builder->fsCodeAppendf("\t\t\tedgeAlpha = "
543 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0 );\n\t\t}\n"); 546 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0 );\n\t\t}\n");
544 547
545 SkString modulate; 548 SkString modulate;
546 GrGLSLModulatef<4>(&modulate, inputColor, "edgeAlpha"); 549 GrGLSLModulatef<4>(&modulate, inputColor, "edgeAlpha");
547 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str() ); 550 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str() );
548 551
549 builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); 552 vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str ());
550 } 553 }
551 554
552 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 555 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) {
553 return 0x0; 556 return 0x0;
554 } 557 }
555 558
556 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {} 559 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {}
557 560
558 private: 561 private:
559 typedef GrGLEffect INHERITED; 562 typedef GrGLEffect INHERITED;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 vOffset, // start vertex 691 vOffset, // start vertex
689 0, // start index 692 0, // start index
690 draw.fVertexCnt, 693 draw.fVertexCnt,
691 draw.fIndexCnt, 694 draw.fIndexCnt,
692 &devBounds); 695 &devBounds);
693 vOffset += draw.fVertexCnt; 696 vOffset += draw.fVertexCnt;
694 } 697 }
695 698
696 return true; 699 return true;
697 } 700 }
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointRadialGradient.cpp ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698