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

Side by Side Diff: src/effects/gradients/SkTwoPointRadialGradient.cpp

Issue 22854005: GPU Gradients (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: reverted defer flag to true Created 7 years, 4 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 "SkTwoPointRadialGradient.h" 9 #include "SkTwoPointRadialGradient.h"
10 10
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 fIsDegenerate = data.isDegenerate(); 525 fIsDegenerate = data.isDegenerate();
526 } 526 }
527 527
528 void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder, 528 void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
529 const GrDrawEffect& drawEffect, 529 const GrDrawEffect& drawEffect,
530 EffectKey key, 530 EffectKey key,
531 const char* outputColor, 531 const char* outputColor,
532 const char* inputColor, 532 const char* inputColor,
533 const TextureSamplerArray& samplers) { 533 const TextureSamplerArray& samplers) {
534 534
535 this->emitYCoordUniform(builder); 535 this->emitUniforms(builder, key);
536 const char* fsCoords; 536 const char* fsCoords;
537 const char* vsCoordsVarying; 537 const char* vsCoordsVarying;
538 GrSLType coordsVaryingType; 538 GrSLType coordsVaryingType;
539 this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingT ype); 539 this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingT ype);
540 540
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_ShaderType , 544 fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_ShaderType ,
545 kFloat_GrSLType, "Radial2VSParams", 6 ); 545 kFloat_GrSLType, "Radial2VSParams", 6 );
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 ac4Name.c_str()); 622 ac4Name.c_str());
623 623
624 // t is: (-b + params[5] * sqrt(b^2-4ac)) * params[1] 624 // t is: (-b + params[5] * sqrt(b^2-4ac)) * params[1]
625 t.printf("(-%s + %s * %s) * %s", bVar.c_str(), p5.c_str(), 625 t.printf("(-%s + %s * %s) * %s", bVar.c_str(), p5.c_str(),
626 rootName.c_str(), p1.c_str()); 626 rootName.c_str(), p1.c_str());
627 } else { 627 } else {
628 // t is: -c/b 628 // t is: -c/b
629 t.printf("-%s / %s", cName.c_str(), bVar.c_str()); 629 t.printf("-%s / %s", cName.c_str(), bVar.c_str());
630 } 630 }
631 631
632 this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, sampl ers[0]); 632 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, sample rs);
633 } 633 }
634 } 634 }
635 635
636 void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, 636 void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman,
637 const GrDrawEffect& drawEffect) { 637 const GrDrawEffect& drawEffect) {
638 INHERITED::setData(uman, drawEffect); 638 INHERITED::setData(uman, drawEffect);
639 const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>(); 639 const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>();
640 SkASSERT(data.isDegenerate() == fIsDegenerate); 640 SkASSERT(data.isDegenerate() == fIsDegenerate);
641 SkScalar centerX1 = data.center(); 641 SkScalar centerX1 = data.center();
642 SkScalar radius0 = data.radius(); 642 SkScalar radius0 = data.radius();
(...skipping 24 matching lines...) Expand all
667 fCachedPosRoot = data.isPosRoot(); 667 fCachedPosRoot = data.isPosRoot();
668 } 668 }
669 } 669 }
670 670
671 GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect , 671 GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect ,
672 const GrGLCaps&) { 672 const GrGLCaps&) {
673 enum { 673 enum {
674 kIsDegenerate = 1 << kMatrixKeyBitCnt, 674 kIsDegenerate = 1 << kMatrixKeyBitCnt,
675 }; 675 };
676 676
677 EffectKey key = GenMatrixKey(drawEffect); 677 EffectKey key = GenBaseGradientKey(drawEffect);
678 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) { 678 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) {
679 key |= kIsDegenerate; 679 key |= kIsDegenerate;
680 } 680 }
681 return key; 681 return key;
682 } 682 }
683 683
684 ///////////////////////////////////////////////////////////////////// 684 /////////////////////////////////////////////////////////////////////
685 685
686 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP aint&) const { 686 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP aint&) const {
687 SkASSERT(NULL != context); 687 SkASSERT(NULL != context);
(...skipping 17 matching lines...) Expand all
705 } 705 }
706 706
707 #else 707 #else
708 708
709 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c onst { 709 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c onst {
710 SkDEBUGFAIL("Should not call in GPU-less build"); 710 SkDEBUGFAIL("Should not call in GPU-less build");
711 return NULL; 711 return NULL;
712 } 712 }
713 713
714 #endif 714 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698