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

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

Issue 12531015: Adds local coords to GrEffect system. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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
« 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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 ///////////////////////////////////////////////////////////////////// 467 /////////////////////////////////////////////////////////////////////
468 468
469 #if SK_SUPPORT_GPU 469 #if SK_SUPPORT_GPU
470 470
471 #include "GrTBackendEffectFactory.h" 471 #include "GrTBackendEffectFactory.h"
472 472
473 class GrGLRadialGradient : public GrGLGradientEffect { 473 class GrGLRadialGradient : public GrGLGradientEffect {
474 public: 474 public:
475 475
476 GrGLRadialGradient(const GrBackendEffectFactory& factory, 476 GrGLRadialGradient(const GrBackendEffectFactory& factory,
477 const GrEffectRef&) : INHERITED (factory) { } 477 const GrDrawEffect&) : INHERITED (factory) { }
478 virtual ~GrGLRadialGradient() { } 478 virtual ~GrGLRadialGradient() { }
479 479
480 virtual void emitCode(GrGLShaderBuilder*, 480 virtual void emitCode(GrGLShaderBuilder*,
481 const GrEffectStage&, 481 const GrDrawEffect&,
482 EffectKey, 482 EffectKey,
483 const char* vertexCoords,
484 const char* outputColor, 483 const char* outputColor,
485 const char* inputColor, 484 const char* inputColor,
486 const TextureSamplerArray&) SK_OVERRIDE; 485 const TextureSamplerArray&) SK_OVERRIDE;
487 486
488 static EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) { 487 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
489 return GenMatrixKey(stage); 488 return GenMatrixKey(drawEffect);
490 } 489 }
491 490
492 private: 491 private:
493 492
494 typedef GrGLGradientEffect INHERITED; 493 typedef GrGLGradientEffect INHERITED;
495 494
496 }; 495 };
497 496
498 ///////////////////////////////////////////////////////////////////// 497 /////////////////////////////////////////////////////////////////////
499 498
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius, 546 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius,
548 colors, stops, colorCount, 547 colors, stops, colorCount,
549 tm)); 548 tm));
550 SkPaint paint; 549 SkPaint paint;
551 return shader->asNewEffect(context, paint); 550 return shader->asNewEffect(context, paint);
552 } 551 }
553 552
554 ///////////////////////////////////////////////////////////////////// 553 /////////////////////////////////////////////////////////////////////
555 554
556 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder, 555 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder,
557 const GrEffectStage&, 556 const GrDrawEffect&,
558 EffectKey key, 557 EffectKey key,
559 const char* vertexCoords,
560 const char* outputColor, 558 const char* outputColor,
561 const char* inputColor, 559 const char* inputColor,
562 const TextureSamplerArray& samplers) { 560 const TextureSamplerArray& samplers) {
563 this->emitYCoordUniform(builder); 561 this->emitYCoordUniform(builder);
564 const char* coords; 562 const char* coords;
565 this->setupMatrix(builder, key, vertexCoords, &coords); 563 this->setupMatrix(builder, key, &coords);
566 SkString t("length("); 564 SkString t("length(");
567 t.append(coords); 565 t.append(coords);
568 t.append(")"); 566 t.append(")");
569 this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[ 0]); 567 this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[ 0]);
570 } 568 }
571 569
572 ///////////////////////////////////////////////////////////////////// 570 /////////////////////////////////////////////////////////////////////
573 571
574 GrEffectRef* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&) c onst { 572 GrEffectRef* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&) c onst {
575 SkASSERT(NULL != context); 573 SkASSERT(NULL != context);
(...skipping 25 matching lines...) Expand all
601 str->appendScalar(fCenter.fY); 599 str->appendScalar(fCenter.fY);
602 str->append(") radius: "); 600 str->append(") radius: ");
603 str->appendScalar(fRadius); 601 str->appendScalar(fRadius);
604 str->append(" "); 602 str->append(" ");
605 603
606 this->INHERITED::toString(str); 604 this->INHERITED::toString(str);
607 605
608 str->append(")"); 606 str->append(")");
609 } 607 }
610 #endif 608 #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