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

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

Issue 365853002: Rename GrGLUniformManager to GrGLProgramResourceManager (Closed) Base URL: https://skia.googlesource.com/skia.git@02-path-program-fragment
Patch Set: rebase Created 6 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
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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 380
381 ///////////////////////////////////////////////////////////////////// 381 /////////////////////////////////////////////////////////////////////
382 382
383 #if SK_SUPPORT_GPU 383 #if SK_SUPPORT_GPU
384 384
385 #include "GrTBackendEffectFactory.h" 385 #include "GrTBackendEffectFactory.h"
386 #include "gl/GrGLShaderBuilder.h" 386 #include "gl/GrGLShaderBuilder.h"
387 #include "SkGr.h" 387 #include "SkGr.h"
388 388
389 // For brevity 389 // For brevity
390 typedef GrGLUniformManager::UniformHandle UniformHandle; 390 typedef GrGLProgramDataManager::UniformHandle UniformHandle;
391 391
392 class GrGLRadial2Gradient : public GrGLGradientEffect { 392 class GrGLRadial2Gradient : public GrGLGradientEffect {
393 393
394 public: 394 public:
395 395
396 GrGLRadial2Gradient(const GrBackendEffectFactory& factory, const GrDrawEffec t&); 396 GrGLRadial2Gradient(const GrBackendEffectFactory& factory, const GrDrawEffec t&);
397 virtual ~GrGLRadial2Gradient() { } 397 virtual ~GrGLRadial2Gradient() { }
398 398
399 virtual void emitCode(GrGLShaderBuilder*, 399 virtual void emitCode(GrGLShaderBuilder*,
400 const GrDrawEffect&, 400 const GrDrawEffect&,
401 const GrEffectKey&, 401 const GrEffectKey&,
402 const char* outputColor, 402 const char* outputColor,
403 const char* inputColor, 403 const char* inputColor,
404 const TransformedCoordsArray&, 404 const TransformedCoordsArray&,
405 const TextureSamplerArray&) SK_OVERRIDE; 405 const TextureSamplerArray&) SK_OVERRIDE;
406 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE; 406 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_ OVERRIDE;
407 407
408 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui lder* b); 408 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui lder* b);
409 409
410 protected: 410 protected:
411 411
412 UniformHandle fParamUni; 412 UniformHandle fParamUni;
413 413
414 const char* fVSVaryingName; 414 const char* fVSVaryingName;
415 const char* fFSVaryingName; 415 const char* fFSVaryingName;
416 416
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 t.printf("(-%s + %s * %s) * %s", bVar.c_str(), p5.c_str(), 618 t.printf("(-%s + %s * %s) * %s", bVar.c_str(), p5.c_str(),
619 rootName.c_str(), p1.c_str()); 619 rootName.c_str(), p1.c_str());
620 } else { 620 } else {
621 // t is: -c/b 621 // t is: -c/b
622 t.printf("-%s / %s", cName.c_str(), bVar.c_str()); 622 t.printf("-%s / %s", cName.c_str(), bVar.c_str());
623 } 623 }
624 624
625 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample rs); 625 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample rs);
626 } 626 }
627 627
628 void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, 628 void GrGLRadial2Gradient::setData(const GrGLProgramDataManager& pdman,
629 const GrDrawEffect& drawEffect) { 629 const GrDrawEffect& drawEffect) {
630 INHERITED::setData(uman, drawEffect); 630 INHERITED::setData(pdman, drawEffect);
631 const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>(); 631 const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>();
632 SkASSERT(data.isDegenerate() == fIsDegenerate); 632 SkASSERT(data.isDegenerate() == fIsDegenerate);
633 SkScalar centerX1 = data.center(); 633 SkScalar centerX1 = data.center();
634 SkScalar radius0 = data.radius(); 634 SkScalar radius0 = data.radius();
635 if (fCachedCenter != centerX1 || 635 if (fCachedCenter != centerX1 ||
636 fCachedRadius != radius0 || 636 fCachedRadius != radius0 ||
637 fCachedPosRoot != data.isPosRoot()) { 637 fCachedPosRoot != data.isPosRoot()) {
638 638
639 SkScalar a = SkScalarMul(centerX1, centerX1) - SK_Scalar1; 639 SkScalar a = SkScalarMul(centerX1, centerX1) - SK_Scalar1;
640 640
641 // When we're in the degenerate (linear) case, the second 641 // When we're in the degenerate (linear) case, the second
642 // value will be INF but the program doesn't read it. (We 642 // value will be INF but the program doesn't read it. (We
643 // use the same 6 uniforms even though we don't need them 643 // use the same 6 uniforms even though we don't need them
644 // all in the linear case just to keep the code complexity 644 // all in the linear case just to keep the code complexity
645 // down). 645 // down).
646 float values[6] = { 646 float values[6] = {
647 SkScalarToFloat(a), 647 SkScalarToFloat(a),
648 1 / (2.f * SkScalarToFloat(a)), 648 1 / (2.f * SkScalarToFloat(a)),
649 SkScalarToFloat(centerX1), 649 SkScalarToFloat(centerX1),
650 SkScalarToFloat(radius0), 650 SkScalarToFloat(radius0),
651 SkScalarToFloat(SkScalarMul(radius0, radius0)), 651 SkScalarToFloat(SkScalarMul(radius0, radius0)),
652 data.isPosRoot() ? 1.f : -1.f 652 data.isPosRoot() ? 1.f : -1.f
653 }; 653 };
654 654
655 uman.set1fv(fParamUni, 6, values); 655 pdman.set1fv(fParamUni, 6, values);
656 fCachedCenter = centerX1; 656 fCachedCenter = centerX1;
657 fCachedRadius = radius0; 657 fCachedRadius = radius0;
658 fCachedPosRoot = data.isPosRoot(); 658 fCachedPosRoot = data.isPosRoot();
659 } 659 }
660 } 660 }
661 661
662 void GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect, 662 void GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect,
663 const GrGLCaps&, GrEffectKeyBuilder* b) { 663 const GrGLCaps&, GrEffectKeyBuilder* b) {
664 uint32_t* key = b->add32n(2); 664 uint32_t* key = b->add32n(2);
665 key[0] = GenBaseGradientKey(drawEffect); 665 key[0] = GenBaseGradientKey(drawEffect);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 #else 705 #else
706 706
707 bool SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint& pa int, 707 bool SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint& pa int,
708 const SkMatrix* localMatrix, GrColor* paintColor, 708 const SkMatrix* localMatrix, GrColor* paintColor,
709 GrEffect** effect) const { 709 GrEffect** effect) const {
710 SkDEBUGFAIL("Should not call in GPU-less build"); 710 SkDEBUGFAIL("Should not call in GPU-less build");
711 return false; 711 return false;
712 } 712 }
713 713
714 #endif 714 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp ('k') | src/gpu/GrAAConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698