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/effects/gradients/SkTwoPointConicalGradient.cpp

Issue 23754003: Isolate VertexBuilder from GrGLShaderBuilder (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: comment fix 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
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 "SkTwoPointConicalGradient.h" 9 #include "SkTwoPointConicalGradient.h"
10 10
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // 2 copies of uniform array, 1 for each of vertex & fragment shader, 499 // 2 copies of uniform array, 1 for each of vertex & fragment shader,
500 // to work around Xoom bug. Doesn't seem to cause performance decrease 500 // to work around Xoom bug. Doesn't seem to cause performance decrease
501 // in test apps, but need to keep an eye on it. 501 // in test apps, but need to keep an eye on it.
502 fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_Visibility , 502 fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_Visibility ,
503 kFloat_GrSLType, "Conical2VSParams", 6); 503 kFloat_GrSLType, "Conical2VSParams", 6);
504 fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibili ty, 504 fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibili ty,
505 kFloat_GrSLType, "Conical2FSParams", 6); 505 kFloat_GrSLType, "Conical2FSParams", 6);
506 506
507 // For radial gradients without perspective we can pass the linear 507 // For radial gradients without perspective we can pass the linear
508 // part of the quadratic as a varying. 508 // part of the quadratic as a varying.
509 if (kVec2f_GrSLType == coordsVaryingType) { 509 GrGLShaderBuilder::VertexBuilder* conical2BBuilder =
bsalomon 2013/08/30 17:59:17 Could we call this vsBuilder, vertexBuilder, or vB
Chris Dalton 2013/08/30 19:10:30 Done.
510 builder->addVarying(kFloat_GrSLType, "Conical2BCoeff", 510 (kVec2f_GrSLType == coordsVaryingType) ? builder->getVertexBuilder() : N ULL;
511 &fVSVaryingName, &fFSVaryingName); 511 if (conical2BBuilder) {
bsalomon 2013/08/30 17:59:17 Not really my pref, but at least in Gr code we ten
Chris Dalton 2013/08/30 19:10:30 Done.
512 conical2BBuilder->addVarying(kFloat_GrSLType, "Conical2BCoeff",
513 &fVSVaryingName, &fFSVaryingName);
512 } 514 }
513 515
514 // VS 516 // VS
515 { 517 {
516 SkString p2; // distance between centers 518 SkString p2; // distance between centers
517 SkString p3; // start radius 519 SkString p3; // start radius
518 SkString p5; // difference in radii (r1 - r0) 520 SkString p5; // difference in radii (r1 - r0)
519 builder->getUniformVariable(fVSParamUni).appendArrayAccess(2, &p2); 521 builder->getUniformVariable(fVSParamUni).appendArrayAccess(2, &p2);
520 builder->getUniformVariable(fVSParamUni).appendArrayAccess(3, &p3); 522 builder->getUniformVariable(fVSParamUni).appendArrayAccess(3, &p3);
521 builder->getUniformVariable(fVSParamUni).appendArrayAccess(5, &p5); 523 builder->getUniformVariable(fVSParamUni).appendArrayAccess(5, &p5);
522 524
523 // For radial gradients without perspective we can pass the linear 525 // For radial gradients without perspective we can pass the linear
524 // part of the quadratic as a varying. 526 // part of the quadratic as a varying.
525 if (kVec2f_GrSLType == coordsVaryingType) { 527 if (conical2BBuilder) {
526 // r2Var = -2 * (r2Parm[2] * varCoord.x - r2Param[3] * r2Param[5]) 528 // r2Var = -2 * (r2Parm[2] * varCoord.x - r2Param[3] * r2Param[5])
527 builder->vsCodeAppendf("\t%s = -2.0 * (%s * %s.x + %s * %s);\n", 529 conical2BBuilder->vsCodeAppendf("\t%s = -2.0 * (%s * %s.x + %s * %s) ;\n",
528 fVSVaryingName, p2.c_str(), 530 fVSVaryingName, p2.c_str(),
529 vsCoordsVarying.c_str(), p3.c_str(), p5.c_str ()); 531 vsCoordsVarying.c_str(), p3.c_str(), p5.c_str());
530 } 532 }
531 } 533 }
532 534
533 // FS 535 // FS
534 { 536 {
535 537
536 SkString cName("c"); 538 SkString cName("c");
537 SkString ac4Name("ac4"); 539 SkString ac4Name("ac4");
538 SkString dName("d"); 540 SkString dName("d");
539 SkString qName("q"); 541 SkString qName("q");
(...skipping 10 matching lines...) Expand all
550 builder->getUniformVariable(fFSParamUni).appendArrayAccess(0, &p0); 552 builder->getUniformVariable(fFSParamUni).appendArrayAccess(0, &p0);
551 builder->getUniformVariable(fFSParamUni).appendArrayAccess(1, &p1); 553 builder->getUniformVariable(fFSParamUni).appendArrayAccess(1, &p1);
552 builder->getUniformVariable(fFSParamUni).appendArrayAccess(2, &p2); 554 builder->getUniformVariable(fFSParamUni).appendArrayAccess(2, &p2);
553 builder->getUniformVariable(fFSParamUni).appendArrayAccess(3, &p3); 555 builder->getUniformVariable(fFSParamUni).appendArrayAccess(3, &p3);
554 builder->getUniformVariable(fFSParamUni).appendArrayAccess(4, &p4); 556 builder->getUniformVariable(fFSParamUni).appendArrayAccess(4, &p4);
555 builder->getUniformVariable(fFSParamUni).appendArrayAccess(5, &p5); 557 builder->getUniformVariable(fFSParamUni).appendArrayAccess(5, &p5);
556 558
557 // If we we're able to interpolate the linear component, 559 // If we we're able to interpolate the linear component,
558 // bVar is the varying; otherwise compute it 560 // bVar is the varying; otherwise compute it
559 SkString bVar; 561 SkString bVar;
560 if (kVec2f_GrSLType == coordsVaryingType) { 562 if (conical2BBuilder) {
561 bVar = fFSVaryingName; 563 bVar = fFSVaryingName;
562 } else { 564 } else {
563 bVar = "b"; 565 bVar = "b";
564 builder->fsCodeAppendf("\tfloat %s = -2.0 * (%s * %s.x + %s * %s);\n ", 566 builder->fsCodeAppendf("\tfloat %s = -2.0 * (%s * %s.x + %s * %s);\n ",
565 bVar.c_str(), p2.c_str(), fsCoords.c_str(), 567 bVar.c_str(), p2.c_str(), fsCoords.c_str(),
566 p3.c_str(), p5.c_str()); 568 p3.c_str(), p5.c_str());
567 } 569 }
568 570
569 // output will default to transparent black (we simply won't write anyth ing 571 // output will default to transparent black (we simply won't write anyth ing
570 // else to it if invalid, instead of discarding or returning prematurely ) 572 // else to it if invalid, instead of discarding or returning prematurely )
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 str->appendScalar(fCenter2.fY); 755 str->appendScalar(fCenter2.fY);
754 str->append(") radius2: "); 756 str->append(") radius2: ");
755 str->appendScalar(fRadius2); 757 str->appendScalar(fRadius2);
756 str->append(" "); 758 str->append(" ");
757 759
758 this->INHERITED::toString(str); 760 this->INHERITED::toString(str);
759 761
760 str->append(")"); 762 str->append(")");
761 } 763 }
762 #endif 764 #endif
OLDNEW
« no previous file with comments | « no previous file | src/effects/gradients/SkTwoPointRadialGradient.cpp » ('j') | src/gpu/gl/GrGLShaderBuilder.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698