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

Issue 22854005: GPU Gradients (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fixes from code reviews 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 fIsDegenerate = data.isDegenerate(); 528 fIsDegenerate = data.isDegenerate();
529 } 529 }
530 530
531 void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder, 531 void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder,
532 const GrDrawEffect& drawEffect, 532 const GrDrawEffect& drawEffect,
533 EffectKey key, 533 EffectKey key,
534 const char* outputColor, 534 const char* outputColor,
535 const char* inputColor, 535 const char* inputColor,
536 const TextureSamplerArray& samplers) { 536 const TextureSamplerArray& samplers) {
537 537
538 this->emitYCoordUniform(builder); 538 this->emitUniforms(builder, key);
539 const char* fsCoords; 539 const char* fsCoords;
540 const char* vsCoordsVarying; 540 const char* vsCoordsVarying;
541 GrSLType coordsVaryingType; 541 GrSLType coordsVaryingType;
542 this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingT ype); 542 this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingT ype);
543 543
544 // 2 copies of uniform array, 1 for each of vertex & fragment shader, 544 // 2 copies of uniform array, 1 for each of vertex & fragment shader,
545 // to work around Xoom bug. Doesn't seem to cause performance decrease 545 // to work around Xoom bug. Doesn't seem to cause performance decrease
546 // in test apps, but need to keep an eye on it. 546 // in test apps, but need to keep an eye on it.
547 fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_ShaderType , 547 fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_ShaderType ,
548 kFloat_GrSLType, "Radial2VSParams", 6 ); 548 kFloat_GrSLType, "Radial2VSParams", 6 );
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 ac4Name.c_str()); 625 ac4Name.c_str());
626 626
627 // t is: (-b + params[5] * sqrt(b^2-4ac)) * params[1] 627 // t is: (-b + params[5] * sqrt(b^2-4ac)) * params[1]
628 t.printf("(-%s + %s * %s) * %s", bVar.c_str(), p5.c_str(), 628 t.printf("(-%s + %s * %s) * %s", bVar.c_str(), p5.c_str(),
629 rootName.c_str(), p1.c_str()); 629 rootName.c_str(), p1.c_str());
630 } else { 630 } else {
631 // t is: -c/b 631 // t is: -c/b
632 t.printf("-%s / %s", cName.c_str(), bVar.c_str()); 632 t.printf("-%s / %s", cName.c_str(), bVar.c_str());
633 } 633 }
634 634
635 this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, sampl ers[0]); 635 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, sample rs);
636 } 636 }
637 } 637 }
638 638
639 void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, 639 void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman,
640 const GrDrawEffect& drawEffect) { 640 const GrDrawEffect& drawEffect) {
641 INHERITED::setData(uman, drawEffect); 641 INHERITED::setData(uman, drawEffect);
642 const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>(); 642 const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>();
643 GrAssert(data.isDegenerate() == fIsDegenerate); 643 GrAssert(data.isDegenerate() == fIsDegenerate);
644 SkScalar centerX1 = data.center(); 644 SkScalar centerX1 = data.center();
645 SkScalar radius0 = data.radius(); 645 SkScalar radius0 = data.radius();
(...skipping 24 matching lines...) Expand all
670 fCachedPosRoot = data.isPosRoot(); 670 fCachedPosRoot = data.isPosRoot();
671 } 671 }
672 } 672 }
673 673
674 GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect , 674 GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect ,
675 const GrGLCaps&) { 675 const GrGLCaps&) {
676 enum { 676 enum {
677 kIsDegenerate = 1 << kMatrixKeyBitCnt, 677 kIsDegenerate = 1 << kMatrixKeyBitCnt,
678 }; 678 };
679 679
680 EffectKey key = GenMatrixKey(drawEffect); 680 EffectKey key = GenBaseGradientKey(drawEffect);
681 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) { 681 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) {
682 key |= kIsDegenerate; 682 key |= kIsDegenerate;
683 } 683 }
684 return key; 684 return key;
685 } 685 }
686 686
687 ///////////////////////////////////////////////////////////////////// 687 /////////////////////////////////////////////////////////////////////
688 688
689 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP aint&) const { 689 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP aint&) const {
690 SkASSERT(NULL != context); 690 SkASSERT(NULL != context);
(...skipping 17 matching lines...) Expand all
708 } 708 }
709 709
710 #else 710 #else
711 711
712 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c onst { 712 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c onst {
713 SkDEBUGFAIL("Should not call in GPU-less build"); 713 SkDEBUGFAIL("Should not call in GPU-less build");
714 return NULL; 714 return NULL;
715 } 715 }
716 716
717 #endif 717 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698