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

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

Issue 671023002: Added varying struct (Closed) Base URL: https://skia.googlesource.com/skia.git@gp_emit_struct
Patch Set: cleanup Created 6 years, 1 month 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
« no previous file with comments | « include/gpu/GrGeometryProcessor.h ('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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR IDE { 522 virtual const GrBackendGeometryProcessorFactory& getFactory() const SK_OVERR IDE {
523 return GrTBackendGeometryProcessorFactory<QuadEdgeEffect>::getInstance() ; 523 return GrTBackendGeometryProcessorFactory<QuadEdgeEffect>::getInstance() ;
524 } 524 }
525 525
526 class GLProcessor : public GrGLGeometryProcessor { 526 class GLProcessor : public GrGLGeometryProcessor {
527 public: 527 public:
528 GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor& ) 528 GLProcessor(const GrBackendProcessorFactory& factory, const GrProcessor& )
529 : INHERITED (factory) {} 529 : INHERITED (factory) {}
530 530
531 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { 531 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE {
532 const char *vsName, *fsName; 532 GrGLVertToFrag v(kVec4f_GrSLType);
533 args.fPB->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName); 533 args.fPB->addVarying("QuadEdge", &v);
534 534
535 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde r(); 535 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde r();
536 536
537 SkAssertResult(fsBuilder->enableFeature( 537 SkAssertResult(fsBuilder->enableFeature(
538 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); 538 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) );
539 fsBuilder->codeAppendf("\t\tfloat edgeAlpha;\n"); 539 fsBuilder->codeAppendf("float edgeAlpha;");
540 540
541 // keep the derivative instructions outside the conditional 541 // keep the derivative instructions outside the conditional
542 fsBuilder->codeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName); 542 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn());
543 fsBuilder->codeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName); 543 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn());
544 fsBuilder->codeAppendf("\t\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsNa me, fsName); 544 fsBuilder->codeAppendf("if (%s.z > 0.0 && %s.w > 0.0) {", v.fsIn(), v.fsIn());
545 // today we know z and w are in device space. We could use derivativ es 545 // today we know z and w are in device space. We could use derivativ es
546 fsBuilder->codeAppendf("\t\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);\n", fsName, 546 fsBuilder->codeAppendf("edgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0); ", v.fsIn(),
547 fsName); 547 v.fsIn());
548 fsBuilder->codeAppendf ("\t\t} else {\n"); 548 fsBuilder->codeAppendf ("} else {");
549 fsBuilder->codeAppendf("\t\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvd x.y,\n" 549 fsBuilder->codeAppendf("vec2 gF = vec2(2.0*%s.x*duvdx.x - duvdx.y,"
550 "\t\t\t 2.0*%s.x*duvdy.x - duvd y.y);\n", 550 " 2.0*%s.x*duvdy.x - duvdy.y);" ,
551 fsName, fsName); 551 v.fsIn(), v.fsIn());
552 fsBuilder->codeAppendf("\t\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fs Name, fsName, 552 fsBuilder->codeAppendf("edgeAlpha = (%s.x*%s.x - %s.y);", v.fsIn(), v.fsIn(),
553 fsName); 553 v.fsIn());
554 fsBuilder->codeAppendf("\t\t\tedgeAlpha = " 554 fsBuilder->codeAppendf("edgeAlpha = "
555 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0 );\n\t\t}\n"); 555 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0 );}");
556 556
557 557
558 fsBuilder->codeAppendf("\t%s = %s;\n", args.fOutput, 558 fsBuilder->codeAppendf("%s = %s;", args.fOutput,
559 (GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edge Alpha")).c_str()); 559 (GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edge Alpha")).c_str());
560 560
561 const GrShaderVar& inQuadEdge = args.fGP.cast<QuadEdgeEffect>().inQu adEdge(); 561 const GrShaderVar& inQuadEdge = args.fGP.cast<QuadEdgeEffect>().inQu adEdge();
562 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); 562 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder();
563 vsBuilder->codeAppendf("\t%s = %s;\n", vsName, inQuadEdge.c_str()); 563 vsBuilder->codeAppendf("\t%s = %s;\n", v.vsOut(), inQuadEdge.c_str() );
564 } 564 }
565 565
566 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcess orKeyBuilder*) {} 566 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcess orKeyBuilder*) {}
567 567
568 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {} 568 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
569 569
570 private: 570 private:
571 typedef GrGLGeometryProcessor INHERITED; 571 typedef GrGLGeometryProcessor INHERITED;
572 }; 572 };
573 573
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 vOffset, // start vertex 706 vOffset, // start vertex
707 0, // start index 707 0, // start index
708 draw.fVertexCnt, 708 draw.fVertexCnt,
709 draw.fIndexCnt, 709 draw.fIndexCnt,
710 &devBounds); 710 &devBounds);
711 vOffset += draw.fVertexCnt; 711 vOffset += draw.fVertexCnt;
712 } 712 }
713 713
714 return true; 714 return true;
715 } 715 }
OLDNEW
« no previous file with comments | « include/gpu/GrGeometryProcessor.h ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698