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

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

Issue 635533005: Revert of Cleanup of shader building system (Closed) Base URL: https://skia.googlesource.com/skia.git@solo_gp
Patch Set: Created 6 years, 2 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
« no previous file with comments | « include/gpu/GrTBackendProcessorFactory.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
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrDrawState.h" 12 #include "GrDrawState.h"
13 #include "GrDrawTargetCaps.h" 13 #include "GrDrawTargetCaps.h"
14 #include "GrProcessor.h" 14 #include "GrProcessor.h"
15 #include "GrPathUtils.h" 15 #include "GrPathUtils.h"
16 #include "GrTBackendProcessorFactory.h" 16 #include "GrTBackendProcessorFactory.h"
17 #include "SkString.h" 17 #include "SkString.h"
18 #include "SkStrokeRec.h" 18 #include "SkStrokeRec.h"
19 #include "SkTraceEvent.h" 19 #include "SkTraceEvent.h"
20 20
21 #include "gl/builders/GrGLProgramBuilder.h" 21 #include "gl/builders/GrGLFullProgramBuilder.h"
22 #include "gl/GrGLProcessor.h" 22 #include "gl/GrGLProcessor.h"
23 #include "gl/GrGLSL.h" 23 #include "gl/GrGLSL.h"
24 #include "gl/GrGLGeometryProcessor.h" 24 #include "gl/GrGLGeometryProcessor.h"
25 25
26 #include "GrGeometryProcessor.h" 26 #include "GrGeometryProcessor.h"
27 27
28 GrAAConvexPathRenderer::GrAAConvexPathRenderer() { 28 GrAAConvexPathRenderer::GrAAConvexPathRenderer() {
29 } 29 }
30 30
31 struct Segment { 31 struct Segment {
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 521
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(GrGLGPBuilder* builder, 531 virtual void emitCode(GrGLFullProgramBuilder* builder,
532 const GrGeometryProcessor& geometryProcessor, 532 const GrGeometryProcessor& geometryProcessor,
533 const GrProcessorKey& key, 533 const GrProcessorKey& key,
534 const char* outputColor, 534 const char* outputColor,
535 const char* inputColor, 535 const char* inputColor,
536 const TransformedCoordsArray&, 536 const TransformedCoordsArray&,
537 const TextureSamplerArray& samplers) SK_OVERRIDE { 537 const TextureSamplerArray& samplers) SK_OVERRIDE {
538 const char *vsName, *fsName; 538 const char *vsName, *fsName;
539 builder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName); 539 builder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName);
540 540
541 GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder (); 541 GrGLProcessorFragmentShaderBuilder* fsBuilder = builder->getFragment ShaderBuilder();
542 542
543 SkAssertResult(fsBuilder->enableFeature( 543 SkAssertResult(fsBuilder->enableFeature(
544 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); 544 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) );
545 fsBuilder->codeAppendf("\t\tfloat edgeAlpha;\n"); 545 fsBuilder->codeAppendf("\t\tfloat edgeAlpha;\n");
546 546
547 // keep the derivative instructions outside the conditional 547 // keep the derivative instructions outside the conditional
548 fsBuilder->codeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName); 548 fsBuilder->codeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName);
549 fsBuilder->codeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName); 549 fsBuilder->codeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName);
550 fsBuilder->codeAppendf("\t\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsNa me, fsName); 550 fsBuilder->codeAppendf("\t\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsNa me, fsName);
551 // today we know z and w are in device space. We could use derivativ es 551 // today we know z and w are in device space. We could use derivativ es
552 fsBuilder->codeAppendf("\t\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);\n", fsName, 552 fsBuilder->codeAppendf("\t\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5, 1.0);\n", fsName,
553 fsName); 553 fsName);
554 fsBuilder->codeAppendf ("\t\t} else {\n"); 554 fsBuilder->codeAppendf ("\t\t} else {\n");
555 fsBuilder->codeAppendf("\t\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvd x.y,\n" 555 fsBuilder->codeAppendf("\t\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvd x.y,\n"
556 "\t\t\t 2.0*%s.x*duvdy.x - duvd y.y);\n", 556 "\t\t\t 2.0*%s.x*duvdy.x - duvd y.y);\n",
557 fsName, fsName); 557 fsName, fsName);
558 fsBuilder->codeAppendf("\t\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fs Name, fsName, 558 fsBuilder->codeAppendf("\t\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fs Name, fsName,
559 fsName); 559 fsName);
560 fsBuilder->codeAppendf("\t\t\tedgeAlpha = " 560 fsBuilder->codeAppendf("\t\t\tedgeAlpha = "
561 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0 );\n\t\t}\n"); 561 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0 );\n\t\t}\n");
562 562
563 563
564 fsBuilder->codeAppendf("\t%s = %s;\n", outputColor, 564 fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
565 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeA lpha")).c_str()); 565 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeA lpha")).c_str());
566 566
567 const GrShaderVar& inQuadEdge = geometryProcessor.cast<QuadEdgeEffec t>().inQuadEdge(); 567 const GrShaderVar& inQuadEdge = geometryProcessor.cast<QuadEdgeEffec t>().inQuadEdge();
568 GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder(); 568 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder ();
569 vsBuilder->codeAppendf("\t%s = %s;\n", vsName, inQuadEdge.c_str()); 569 vsBuilder->codeAppendf("\t%s = %s;\n", vsName, inQuadEdge.c_str());
570 } 570 }
571 571
572 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcess orKeyBuilder*) {} 572 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcess orKeyBuilder*) {}
573 573
574 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {} 574 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}
575 575
576 private: 576 private:
577 typedef GrGLGeometryProcessor INHERITED; 577 typedef GrGLGeometryProcessor INHERITED;
578 }; 578 };
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 vOffset, // start vertex 713 vOffset, // start vertex
714 0, // start index 714 0, // start index
715 draw.fVertexCnt, 715 draw.fVertexCnt,
716 draw.fIndexCnt, 716 draw.fIndexCnt,
717 &devBounds); 717 &devBounds);
718 vOffset += draw.fVertexCnt; 718 vOffset += draw.fVertexCnt;
719 } 719 }
720 720
721 return true; 721 return true;
722 } 722 }
OLDNEW
« no previous file with comments | « include/gpu/GrTBackendProcessorFactory.h ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698