OLD | NEW |
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 "SkLinearGradient.h" | 9 #include "SkLinearGradient.h" |
10 | 10 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 446 |
447 #if SK_SUPPORT_GPU | 447 #if SK_SUPPORT_GPU |
448 | 448 |
449 #include "GrTBackendEffectFactory.h" | 449 #include "GrTBackendEffectFactory.h" |
450 | 450 |
451 ///////////////////////////////////////////////////////////////////// | 451 ///////////////////////////////////////////////////////////////////// |
452 | 452 |
453 class GrGLLinearGradient : public GrGLGradientEffect { | 453 class GrGLLinearGradient : public GrGLGradientEffect { |
454 public: | 454 public: |
455 | 455 |
456 GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrEffectRef&
) | 456 GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrDrawEffect
&) |
457 : INHERITED (factory) { } | 457 : INHERITED (factory) { } |
458 | 458 |
459 virtual ~GrGLLinearGradient() { } | 459 virtual ~GrGLLinearGradient() { } |
460 | 460 |
461 virtual void emitCode(GrGLShaderBuilder*, | 461 virtual void emitCode(GrGLShaderBuilder*, |
462 const GrEffectStage&, | 462 const GrDrawEffect&, |
463 EffectKey, | 463 EffectKey, |
464 const char* vertexCoords, | |
465 const char* outputColor, | 464 const char* outputColor, |
466 const char* inputColor, | 465 const char* inputColor, |
467 const TextureSamplerArray&) SK_OVERRIDE; | 466 const TextureSamplerArray&) SK_OVERRIDE; |
468 | 467 |
469 static EffectKey GenKey(const GrEffectStage& stage, const GrGLCaps&) { | 468 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { |
470 return GenMatrixKey(stage); | 469 return GenMatrixKey(drawEffect); |
471 } | 470 } |
472 | 471 |
473 private: | 472 private: |
474 | 473 |
475 typedef GrGLGradientEffect INHERITED; | 474 typedef GrGLGradientEffect INHERITED; |
476 }; | 475 }; |
477 | 476 |
478 ///////////////////////////////////////////////////////////////////// | 477 ///////////////////////////////////////////////////////////////////// |
479 | 478 |
480 class GrLinearGradient : public GrGradientEffect { | 479 class GrLinearGradient : public GrGradientEffect { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, | 525 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, |
527 colors, stops,
colorCount, | 526 colors, stops,
colorCount, |
528 tm)); | 527 tm)); |
529 SkPaint paint; | 528 SkPaint paint; |
530 return shader->asNewEffect(context, paint); | 529 return shader->asNewEffect(context, paint); |
531 } | 530 } |
532 | 531 |
533 ///////////////////////////////////////////////////////////////////// | 532 ///////////////////////////////////////////////////////////////////// |
534 | 533 |
535 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder, | 534 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder, |
536 const GrEffectStage& stage, | 535 const GrDrawEffect&, |
537 EffectKey key, | 536 EffectKey key, |
538 const char* vertexCoords, | |
539 const char* outputColor, | 537 const char* outputColor, |
540 const char* inputColor, | 538 const char* inputColor, |
541 const TextureSamplerArray& samplers) { | 539 const TextureSamplerArray& samplers) { |
542 this->emitYCoordUniform(builder); | 540 this->emitYCoordUniform(builder); |
543 const char* coords; | 541 const char* coords; |
544 this->setupMatrix(builder, key, vertexCoords, &coords); | 542 this->setupMatrix(builder, key, &coords); |
545 SkString t; | 543 SkString t; |
546 t.append(coords); | 544 t.append(coords); |
547 t.append(".x"); | 545 t.append(".x"); |
548 this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[
0]); | 546 this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, samplers[
0]); |
549 } | 547 } |
550 | 548 |
551 ///////////////////////////////////////////////////////////////////// | 549 ///////////////////////////////////////////////////////////////////// |
552 | 550 |
553 GrEffectRef* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&) c
onst { | 551 GrEffectRef* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&) c
onst { |
554 SkASSERT(NULL != context); | 552 SkASSERT(NULL != context); |
(...skipping 19 matching lines...) Expand all Loading... |
574 str->append("SkLinearGradient ("); | 572 str->append("SkLinearGradient ("); |
575 | 573 |
576 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 574 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); |
577 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 575 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); |
578 | 576 |
579 this->INHERITED::toString(str); | 577 this->INHERITED::toString(str); |
580 | 578 |
581 str->append(")"); | 579 str->append(")"); |
582 } | 580 } |
583 #endif | 581 #endif |
OLD | NEW |