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

Side by Side Diff: src/effects/gradients/SkTwoPointRadialGradient.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/SkTwoPointConicalGradient.cpp ('k') | src/gpu/GrAAConvexPathRenderer.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 "SkTwoPointRadialGradient.h" 9 #include "SkTwoPointRadialGradient.h"
10 10
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // 2 copies of uniform array, 1 for each of vertex & fragment shader, 541 // 2 copies of uniform array, 1 for each of vertex & fragment shader,
542 // to work around Xoom bug. Doesn't seem to cause performance decrease 542 // to work around Xoom bug. Doesn't seem to cause performance decrease
543 // in test apps, but need to keep an eye on it. 543 // in test apps, but need to keep an eye on it.
544 fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_Visibility , 544 fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_Visibility ,
545 kFloat_GrSLType, "Radial2VSParams", 6 ); 545 kFloat_GrSLType, "Radial2VSParams", 6 );
546 fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibili ty, 546 fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibili ty,
547 kFloat_GrSLType, "Radial2FSParams", 6 ); 547 kFloat_GrSLType, "Radial2FSParams", 6 );
548 548
549 // For radial gradients without perspective we can pass the linear 549 // For radial gradients without perspective we can pass the linear
550 // part of the quadratic as a varying. 550 // part of the quadratic as a varying.
551 if (kVec2f_GrSLType == coordsVaryingType) { 551 GrGLShaderBuilder::VertexBuilder* vertexBuilder =
552 builder->addVarying(kFloat_GrSLType, "Radial2BCoeff", &fVSVaryingName, & fFSVaryingName); 552 (kVec2f_GrSLType == coordsVaryingType) ? builder->getVertexBuilder() : N ULL;
553 if (NULL != vertexBuilder) {
554 vertexBuilder->addVarying(kFloat_GrSLType, "Radial2BCoeff",
555 &fVSVaryingName, &fFSVaryingName);
553 } 556 }
554 557
555 // VS 558 // VS
556 { 559 {
557 SkString p2; 560 SkString p2;
558 SkString p3; 561 SkString p3;
559 builder->getUniformVariable(fVSParamUni).appendArrayAccess(2, &p2); 562 builder->getUniformVariable(fVSParamUni).appendArrayAccess(2, &p2);
560 builder->getUniformVariable(fVSParamUni).appendArrayAccess(3, &p3); 563 builder->getUniformVariable(fVSParamUni).appendArrayAccess(3, &p3);
561 564
562 // For radial gradients without perspective we can pass the linear 565 // For radial gradients without perspective we can pass the linear
563 // part of the quadratic as a varying. 566 // part of the quadratic as a varying.
564 if (kVec2f_GrSLType == coordsVaryingType) { 567 if (NULL != vertexBuilder) {
565 // r2Var = 2 * (r2Parm[2] * varCoord.x - r2Param[3]) 568 // r2Var = 2 * (r2Parm[2] * varCoord.x - r2Param[3])
566 builder->vsCodeAppendf("\t%s = 2.0 *(%s * %s.x - %s);\n", 569 vertexBuilder->vsCodeAppendf("\t%s = 2.0 *(%s * %s.x - %s);\n",
567 fVSVaryingName, p2.c_str(), 570 fVSVaryingName, p2.c_str(),
568 vsCoordsVarying.c_str(), p3.c_str()); 571 vsCoordsVarying.c_str(), p3.c_str());
569 } 572 }
570 } 573 }
571 574
572 // FS 575 // FS
573 { 576 {
574 SkString cName("c"); 577 SkString cName("c");
575 SkString ac4Name("ac4"); 578 SkString ac4Name("ac4");
576 SkString rootName("root"); 579 SkString rootName("root");
577 SkString t; 580 SkString t;
578 SkString p0; 581 SkString p0;
579 SkString p1; 582 SkString p1;
580 SkString p2; 583 SkString p2;
581 SkString p3; 584 SkString p3;
582 SkString p4; 585 SkString p4;
583 SkString p5; 586 SkString p5;
584 builder->getUniformVariable(fFSParamUni).appendArrayAccess(0, &p0); 587 builder->getUniformVariable(fFSParamUni).appendArrayAccess(0, &p0);
585 builder->getUniformVariable(fFSParamUni).appendArrayAccess(1, &p1); 588 builder->getUniformVariable(fFSParamUni).appendArrayAccess(1, &p1);
586 builder->getUniformVariable(fFSParamUni).appendArrayAccess(2, &p2); 589 builder->getUniformVariable(fFSParamUni).appendArrayAccess(2, &p2);
587 builder->getUniformVariable(fFSParamUni).appendArrayAccess(3, &p3); 590 builder->getUniformVariable(fFSParamUni).appendArrayAccess(3, &p3);
588 builder->getUniformVariable(fFSParamUni).appendArrayAccess(4, &p4); 591 builder->getUniformVariable(fFSParamUni).appendArrayAccess(4, &p4);
589 builder->getUniformVariable(fFSParamUni).appendArrayAccess(5, &p5); 592 builder->getUniformVariable(fFSParamUni).appendArrayAccess(5, &p5);
590 593
591 // If we we're able to interpolate the linear component, 594 // If we we're able to interpolate the linear component,
592 // bVar is the varying; otherwise compute it 595 // bVar is the varying; otherwise compute it
593 SkString bVar; 596 SkString bVar;
594 if (kVec2f_GrSLType == coordsVaryingType) { 597 if (NULL != vertexBuilder) {
595 bVar = fFSVaryingName; 598 bVar = fFSVaryingName;
596 } else { 599 } else {
597 bVar = "b"; 600 bVar = "b";
598 builder->fsCodeAppendf("\tfloat %s = 2.0 * (%s * %s.x - %s);\n", 601 builder->fsCodeAppendf("\tfloat %s = 2.0 * (%s * %s.x - %s);\n",
599 bVar.c_str(), p2.c_str(), fsCoords.c_str(), p 3.c_str()); 602 bVar.c_str(), p2.c_str(), fsCoords.c_str(), p 3.c_str());
600 } 603 }
601 604
602 // c = (x^2)+(y^2) - params[4] 605 // c = (x^2)+(y^2) - params[4]
603 builder->fsCodeAppendf("\tfloat %s = dot(%s, %s) - %s;\n", 606 builder->fsCodeAppendf("\tfloat %s = dot(%s, %s) - %s;\n",
604 cName.c_str(), 607 cName.c_str(),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 708 }
706 709
707 #else 710 #else
708 711
709 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c onst { 712 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c onst {
710 SkDEBUGFAIL("Should not call in GPU-less build"); 713 SkDEBUGFAIL("Should not call in GPU-less build");
711 return NULL; 714 return NULL;
712 } 715 }
713 716
714 #endif 717 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698