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

Side by Side Diff: src/gpu/effects/GrBezierEffect.cpp

Issue 1462123003: Create GrGLSLVaryingHandler class for program building (Closed) Base URL: https://skia.googlesource.com/skia.git@putCapsOnArgs
Patch Set: fix release builder Created 5 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 | « src/gpu/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/effects/GrBitmapTextGeoProc.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 2013 Google Inc. 2 * Copyright 2013 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 "GrBezierEffect.h" 8 #include "GrBezierEffect.h"
9 9
10 #include "glsl/GrGLSLGeometryProcessor.h" 10 #include "glsl/GrGLSLGeometryProcessor.h"
11 #include "glsl/GrGLSLProgramBuilder.h" 11 #include "glsl/GrGLSLProgramBuilder.h"
12 #include "glsl/GrGLSLProgramDataManager.h" 12 #include "glsl/GrGLSLProgramDataManager.h"
13 #include "glsl/GrGLSLUtil.h" 13 #include "glsl/GrGLSLUtil.h"
14 #include "glsl/GrGLSLVarying.h"
14 15
15 class GrGLConicEffect : public GrGLSLGeometryProcessor { 16 class GrGLConicEffect : public GrGLSLGeometryProcessor {
16 public: 17 public:
17 GrGLConicEffect(const GrGeometryProcessor&); 18 GrGLConicEffect(const GrGeometryProcessor&);
18 19
19 void onEmitCode(EmitArgs&, GrGPArgs*) override; 20 void onEmitCode(EmitArgs&, GrGPArgs*) override;
20 21
21 static inline void GenKey(const GrGeometryProcessor&, 22 static inline void GenKey(const GrGeometryProcessor&,
22 const GrGLSLCaps&, 23 const GrGLSLCaps&,
23 GrProcessorKeyBuilder*); 24 GrProcessorKeyBuilder*);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor) 69 GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor)
69 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage Scale(0xff) { 70 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage Scale(0xff) {
70 const GrConicEffect& ce = processor.cast<GrConicEffect>(); 71 const GrConicEffect& ce = processor.cast<GrConicEffect>();
71 fEdgeType = ce.getEdgeType(); 72 fEdgeType = ce.getEdgeType();
72 } 73 }
73 74
74 void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { 75 void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
75 GrGLSLGPBuilder* pb = args.fPB; 76 GrGLSLGPBuilder* pb = args.fPB;
76 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; 77 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
77 const GrConicEffect& gp = args.fGP.cast<GrConicEffect>(); 78 const GrConicEffect& gp = args.fGP.cast<GrConicEffect>();
79 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
78 80
79 // emit attributes 81 // emit attributes
80 vertBuilder->emitAttributes(gp); 82 varyingHandler->emitAttributes(gp);
81 83
82 GrGLSLVertToFrag v(kVec4f_GrSLType); 84 GrGLSLVertToFrag v(kVec4f_GrSLType);
83 args.fPB->addVarying("ConicCoeffs", &v); 85 varyingHandler->addVarying("ConicCoeffs", &v);
84 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName); 86 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName);
85 87
86 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 88 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
87 // Setup pass through color 89 // Setup pass through color
88 if (!gp.colorIgnored()) { 90 if (!gp.colorIgnored()) {
89 this->setupUniformColor(args.fPB, fragBuilder, args.fOutputColor, &fColo rUniform); 91 this->setupUniformColor(args.fPB, fragBuilder, args.fOutputColor, &fColo rUniform);
90 } 92 }
91 93
92 // Setup position 94 // Setup position
93 this->setupPosition(pb, 95 this->setupPosition(pb,
94 vertBuilder, 96 vertBuilder,
95 gpArgs, 97 gpArgs,
96 gp.inPosition()->fName, 98 gp.inPosition()->fName,
97 gp.viewMatrix(), 99 gp.viewMatrix(),
98 &fViewMatrixUniform); 100 &fViewMatrixUniform);
99 101
100 // emit transforms with position 102 // emit transforms with position
101 this->emitTransforms(pb, 103 this->emitTransforms(pb,
102 vertBuilder, 104 vertBuilder,
105 varyingHandler,
103 gpArgs->fPositionVar, 106 gpArgs->fPositionVar,
104 gp.inPosition()->fName, 107 gp.inPosition()->fName,
105 gp.localMatrix(), 108 gp.localMatrix(),
106 args.fTransformsIn, 109 args.fTransformsIn,
107 args.fTransformsOut); 110 args.fTransformsOut);
108 111
109 fragBuilder->codeAppend("float edgeAlpha;"); 112 fragBuilder->codeAppend("float edgeAlpha;");
110 113
111 switch (fEdgeType) { 114 switch (fEdgeType) {
112 case kHairlineAA_GrProcessorEdgeType: { 115 case kHairlineAA_GrProcessorEdgeType: {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor) 297 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor)
295 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage Scale(0xff) { 298 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverage Scale(0xff) {
296 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); 299 const GrQuadEffect& ce = processor.cast<GrQuadEffect>();
297 fEdgeType = ce.getEdgeType(); 300 fEdgeType = ce.getEdgeType();
298 } 301 }
299 302
300 void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { 303 void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
301 GrGLSLGPBuilder* pb = args.fPB; 304 GrGLSLGPBuilder* pb = args.fPB;
302 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; 305 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
303 const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>(); 306 const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>();
307 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
304 308
305 // emit attributes 309 // emit attributes
306 vertBuilder->emitAttributes(gp); 310 varyingHandler->emitAttributes(gp);
307 311
308 GrGLSLVertToFrag v(kVec4f_GrSLType); 312 GrGLSLVertToFrag v(kVec4f_GrSLType);
309 args.fPB->addVarying("HairQuadEdge", &v); 313 varyingHandler->addVarying("HairQuadEdge", &v);
310 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName); 314 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName);
311 315
312 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 316 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
313 // Setup pass through color 317 // Setup pass through color
314 if (!gp.colorIgnored()) { 318 if (!gp.colorIgnored()) {
315 this->setupUniformColor(args.fPB, fragBuilder, args.fOutputColor, &fColo rUniform); 319 this->setupUniformColor(args.fPB, fragBuilder, args.fOutputColor, &fColo rUniform);
316 } 320 }
317 321
318 // Setup position 322 // Setup position
319 this->setupPosition(pb, 323 this->setupPosition(pb,
320 vertBuilder, 324 vertBuilder,
321 gpArgs, 325 gpArgs,
322 gp.inPosition()->fName, 326 gp.inPosition()->fName,
323 gp.viewMatrix(), 327 gp.viewMatrix(),
324 &fViewMatrixUniform); 328 &fViewMatrixUniform);
325 329
326 // emit transforms with position 330 // emit transforms with position
327 this->emitTransforms(pb, 331 this->emitTransforms(pb,
328 vertBuilder, 332 vertBuilder,
333 varyingHandler,
329 gpArgs->fPositionVar, 334 gpArgs->fPositionVar,
330 gp.inPosition()->fName, 335 gp.inPosition()->fName,
331 gp.localMatrix(), 336 gp.localMatrix(),
332 args.fTransformsIn, 337 args.fTransformsIn,
333 args.fTransformsOut); 338 args.fTransformsOut);
334 339
335 fragBuilder->codeAppendf("float edgeAlpha;"); 340 fragBuilder->codeAppendf("float edgeAlpha;");
336 341
337 switch (fEdgeType) { 342 switch (fEdgeType) {
338 case kHairlineAA_GrProcessorEdgeType: { 343 case kHairlineAA_GrProcessorEdgeType: {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 499
495 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor) 500 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor)
496 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) { 501 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) {
497 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); 502 const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
498 fEdgeType = ce.getEdgeType(); 503 fEdgeType = ce.getEdgeType();
499 } 504 }
500 505
501 void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { 506 void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
502 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; 507 GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
503 const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>(); 508 const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>();
509 GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
504 510
505 // emit attributes 511 // emit attributes
506 vertBuilder->emitAttributes(gp); 512 varyingHandler->emitAttributes(gp);
507 513
508 GrGLSLVertToFrag v(kVec4f_GrSLType); 514 GrGLSLVertToFrag v(kVec4f_GrSLType);
509 args.fPB->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision); 515 varyingHandler->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision);
510 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); 516 vertBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName);
511 517
512 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; 518 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
513 // Setup pass through color 519 // Setup pass through color
514 if (!gp.colorIgnored()) { 520 if (!gp.colorIgnored()) {
515 this->setupUniformColor(args.fPB, fragBuilder, args.fOutputColor, &fColo rUniform); 521 this->setupUniformColor(args.fPB, fragBuilder, args.fOutputColor, &fColo rUniform);
516 } 522 }
517 523
518 // Setup position 524 // Setup position
519 this->setupPosition(args.fPB, 525 this->setupPosition(args.fPB,
520 vertBuilder, 526 vertBuilder,
521 gpArgs, 527 gpArgs,
522 gp.inPosition()->fName, 528 gp.inPosition()->fName,
523 gp.viewMatrix(), 529 gp.viewMatrix(),
524 &fViewMatrixUniform); 530 &fViewMatrixUniform);
525 531
526 // emit transforms with position 532 // emit transforms with position
527 this->emitTransforms(args.fPB, 533 this->emitTransforms(args.fPB,
528 vertBuilder, 534 vertBuilder,
535 varyingHandler,
529 gpArgs->fPositionVar, 536 gpArgs->fPositionVar,
530 gp.inPosition()->fName, 537 gp.inPosition()->fName,
531 args.fTransformsIn, 538 args.fTransformsIn,
532 args.fTransformsOut); 539 args.fTransformsOut);
533 540
534 541
535 GrGLSLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecisi on); 542 GrGLSLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecisi on);
536 GrGLSLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); 543 GrGLSLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
537 GrGLSLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); 544 GrGLSLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision);
538 GrGLSLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision); 545 GrGLSLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 do { 672 do {
666 GrPrimitiveEdgeType edgeType = 673 GrPrimitiveEdgeType edgeType =
667 static_cast<GrPrimitiveEdgeType>( 674 static_cast<GrPrimitiveEdgeType>(
668 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); 675 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt));
669 gp = GrCubicEffect::Create(GrRandomColor(d->fRandom), 676 gp = GrCubicEffect::Create(GrRandomColor(d->fRandom),
670 GrTest::TestMatrix(d->fRandom), edgeType, *d- >fCaps); 677 GrTest::TestMatrix(d->fRandom), edgeType, *d- >fCaps);
671 } while (nullptr == gp); 678 } while (nullptr == gp);
672 return gp; 679 return gp;
673 } 680 }
674 681
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAConvexPathRenderer.cpp ('k') | src/gpu/effects/GrBitmapTextGeoProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698