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

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

Issue 385713005: Allow GrGLEffects to produce variable length keys. (Closed) Base URL: https://skia.googlesource.com/skia.git@key
Patch Set: rebase Created 6 years, 5 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
« no previous file with comments | « src/effects/gradients/SkLinearGradient.cpp ('k') | src/effects/gradients/SkSweepGradient.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 "SkRadialGradient.h" 9 #include "SkRadialGradient.h"
10 #include "SkRadialGradient_Table.h" 10 #include "SkRadialGradient_Table.h"
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 463
464 class GrGLRadialGradient : public GrGLGradientEffect { 464 class GrGLRadialGradient : public GrGLGradientEffect {
465 public: 465 public:
466 466
467 GrGLRadialGradient(const GrBackendEffectFactory& factory, 467 GrGLRadialGradient(const GrBackendEffectFactory& factory,
468 const GrDrawEffect&) : INHERITED (factory) { } 468 const GrDrawEffect&) : INHERITED (factory) { }
469 virtual ~GrGLRadialGradient() { } 469 virtual ~GrGLRadialGradient() { }
470 470
471 virtual void emitCode(GrGLShaderBuilder*, 471 virtual void emitCode(GrGLShaderBuilder*,
472 const GrDrawEffect&, 472 const GrDrawEffect&,
473 EffectKey, 473 const GrEffectKey&,
474 const char* outputColor, 474 const char* outputColor,
475 const char* inputColor, 475 const char* inputColor,
476 const TransformedCoordsArray&, 476 const TransformedCoordsArray&,
477 const TextureSamplerArray&) SK_OVERRIDE; 477 const TextureSamplerArray&) SK_OVERRIDE;
478 478
479 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { 479 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect KeyBuilder* b) {
480 return GenBaseGradientKey(drawEffect); 480 b->add32(GenBaseGradientKey(drawEffect));
481 } 481 }
482 482
483 private: 483 private:
484 484
485 typedef GrGLGradientEffect INHERITED; 485 typedef GrGLGradientEffect INHERITED;
486 486
487 }; 487 };
488 488
489 ///////////////////////////////////////////////////////////////////// 489 /////////////////////////////////////////////////////////////////////
490 490
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 GrColor paintColor; 542 GrColor paintColor;
543 GrEffect* effect; 543 GrEffect* effect;
544 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t)); 544 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t));
545 return effect; 545 return effect;
546 } 546 }
547 547
548 ///////////////////////////////////////////////////////////////////// 548 /////////////////////////////////////////////////////////////////////
549 549
550 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder, 550 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder,
551 const GrDrawEffect&, 551 const GrDrawEffect&,
552 EffectKey key, 552 const GrEffectKey& key,
553 const char* outputColor, 553 const char* outputColor,
554 const char* inputColor, 554 const char* inputColor,
555 const TransformedCoordsArray& coords, 555 const TransformedCoordsArray& coords,
556 const TextureSamplerArray& samplers) { 556 const TextureSamplerArray& samplers) {
557 this->emitUniforms(builder, key); 557 uint32_t baseKey = key.get32(0);
558 this->emitUniforms(builder, baseKey);
558 SkString t("length("); 559 SkString t("length(");
559 t.append(builder->ensureFSCoords2D(coords, 0)); 560 t.append(builder->ensureFSCoords2D(coords, 0));
560 t.append(")"); 561 t.append(")");
561 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); 562 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample rs);
562 } 563 }
563 564
564 ///////////////////////////////////////////////////////////////////// 565 /////////////////////////////////////////////////////////////////////
565 566
566 bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint, 567 bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint,
567 const SkMatrix* localMatrix, GrColor* paintCo lor, 568 const SkMatrix* localMatrix, GrColor* paintCo lor,
568 GrEffect** effect) const { 569 GrEffect** effect) const {
569 SkASSERT(NULL != context); 570 SkASSERT(NULL != context);
570 571
571 SkMatrix matrix; 572 SkMatrix matrix;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 str->appendScalar(fCenter.fY); 609 str->appendScalar(fCenter.fY);
609 str->append(") radius: "); 610 str->append(") radius: ");
610 str->appendScalar(fRadius); 611 str->appendScalar(fRadius);
611 str->append(" "); 612 str->append(" ");
612 613
613 this->INHERITED::toString(str); 614 this->INHERITED::toString(str);
614 615
615 str->append(")"); 616 str->append(")");
616 } 617 }
617 #endif 618 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkLinearGradient.cpp ('k') | src/effects/gradients/SkSweepGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698