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

Side by Side Diff: src/effects/gradients/SkLinearGradient.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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLinearGradient.h" 8 #include "SkLinearGradient.h"
9 9
10 static inline int repeat_bits(int x, const int bits) { 10 static inline int repeat_bits(int x, const int bits) {
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 class GrGLLinearGradient : public GrGLGradientEffect { 454 class GrGLLinearGradient : public GrGLGradientEffect {
455 public: 455 public:
456 456
457 GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrDrawEffect &) 457 GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrDrawEffect &)
458 : INHERITED (factory) { } 458 : INHERITED (factory) { }
459 459
460 virtual ~GrGLLinearGradient() { } 460 virtual ~GrGLLinearGradient() { }
461 461
462 virtual void emitCode(GrGLShaderBuilder*, 462 virtual void emitCode(GrGLShaderBuilder*,
463 const GrDrawEffect&, 463 const GrDrawEffect&,
464 EffectKey, 464 const GrEffectKey&,
465 const char* outputColor, 465 const char* outputColor,
466 const char* inputColor, 466 const char* inputColor,
467 const TransformedCoordsArray&, 467 const TransformedCoordsArray&,
468 const TextureSamplerArray&) SK_OVERRIDE; 468 const TextureSamplerArray&) SK_OVERRIDE;
469 469
470 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { 470 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect KeyBuilder* b) {
471 return GenBaseGradientKey(drawEffect); 471 b->add32(GenBaseGradientKey(drawEffect));
472 } 472 }
473 473
474 private: 474 private:
475 475
476 typedef GrGLGradientEffect INHERITED; 476 typedef GrGLGradientEffect INHERITED;
477 }; 477 };
478 478
479 ///////////////////////////////////////////////////////////////////// 479 /////////////////////////////////////////////////////////////////////
480 480
481 class GrLinearGradient : public GrGradientEffect { 481 class GrLinearGradient : public GrGradientEffect {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 GrColor paintColor; 531 GrColor paintColor;
532 GrEffect* effect; 532 GrEffect* effect;
533 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t)); 533 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec t));
534 return effect; 534 return effect;
535 } 535 }
536 536
537 ///////////////////////////////////////////////////////////////////// 537 /////////////////////////////////////////////////////////////////////
538 538
539 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder, 539 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder,
540 const GrDrawEffect&, 540 const GrDrawEffect&,
541 EffectKey key, 541 const GrEffectKey& key,
542 const char* outputColor, 542 const char* outputColor,
543 const char* inputColor, 543 const char* inputColor,
544 const TransformedCoordsArray& coords, 544 const TransformedCoordsArray& coords,
545 const TextureSamplerArray& samplers) { 545 const TextureSamplerArray& samplers) {
546 this->emitUniforms(builder, key); 546 uint32_t baseKey = key.get32(0);
547 this->emitUniforms(builder, baseKey);
547 SkString t = builder->ensureFSCoords2D(coords, 0); 548 SkString t = builder->ensureFSCoords2D(coords, 0);
548 t.append(".x"); 549 t.append(".x");
549 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); 550 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample rs);
550 } 551 }
551 552
552 ///////////////////////////////////////////////////////////////////// 553 /////////////////////////////////////////////////////////////////////
553 554
554 bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint, 555 bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint,
555 const SkMatrix* localMatrix, GrColor* paintCo lor, 556 const SkMatrix* localMatrix, GrColor* paintCo lor,
556 GrEffect** effect) const { 557 GrEffect** effect) const {
557 SkASSERT(NULL != context); 558 SkASSERT(NULL != context);
558 559
559 SkMatrix matrix; 560 SkMatrix matrix;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 str->append("SkLinearGradient ("); 592 str->append("SkLinearGradient (");
592 593
593 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); 594 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY);
594 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); 595 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY);
595 596
596 this->INHERITED::toString(str); 597 this->INHERITED::toString(str);
597 598
598 str->append(")"); 599 str->append(")");
599 } 600 }
600 #endif 601 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShaderPriv.h ('k') | src/effects/gradients/SkRadialGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698