| OLD | NEW |
| 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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrDrawEffect
&) | 441 GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrDrawEffect
&) |
| 442 : INHERITED (factory) { } | 442 : INHERITED (factory) { } |
| 443 | 443 |
| 444 virtual ~GrGLLinearGradient() { } | 444 virtual ~GrGLLinearGradient() { } |
| 445 | 445 |
| 446 virtual void emitCode(GrGLShaderBuilder*, | 446 virtual void emitCode(GrGLShaderBuilder*, |
| 447 const GrDrawEffect&, | 447 const GrDrawEffect&, |
| 448 EffectKey, | 448 EffectKey, |
| 449 const char* outputColor, | 449 const char* outputColor, |
| 450 const char* inputColor, | 450 const char* inputColor, |
| 451 const TransformedCoordsArray&, |
| 451 const TextureSamplerArray&) SK_OVERRIDE; | 452 const TextureSamplerArray&) SK_OVERRIDE; |
| 452 | 453 |
| 453 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { | 454 static EffectKey GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { |
| 454 return GenBaseGradientKey(drawEffect); | 455 return GenBaseGradientKey(drawEffect); |
| 455 } | 456 } |
| 456 | 457 |
| 457 private: | 458 private: |
| 458 | 459 |
| 459 typedef GrGLGradientEffect INHERITED; | 460 typedef GrGLGradientEffect INHERITED; |
| 460 }; | 461 }; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 return shader->asNewEffect(context, paint); | 516 return shader->asNewEffect(context, paint); |
| 516 } | 517 } |
| 517 | 518 |
| 518 ///////////////////////////////////////////////////////////////////// | 519 ///////////////////////////////////////////////////////////////////// |
| 519 | 520 |
| 520 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder, | 521 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder, |
| 521 const GrDrawEffect&, | 522 const GrDrawEffect&, |
| 522 EffectKey key, | 523 EffectKey key, |
| 523 const char* outputColor, | 524 const char* outputColor, |
| 524 const char* inputColor, | 525 const char* inputColor, |
| 526 const TransformedCoordsArray& coords, |
| 525 const TextureSamplerArray& samplers) { | 527 const TextureSamplerArray& samplers) { |
| 526 this->emitUniforms(builder, key); | 528 this->emitUniforms(builder, key); |
| 527 SkString coords; | 529 SkString t = builder->ensureFSCoords2D(coords, 0); |
| 528 this->setupMatrix(builder, key, &coords); | |
| 529 SkString t; | |
| 530 t.append(coords); | |
| 531 t.append(".x"); | 530 t.append(".x"); |
| 532 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); | 531 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); |
| 533 } | 532 } |
| 534 | 533 |
| 535 ///////////////////////////////////////////////////////////////////// | 534 ///////////////////////////////////////////////////////////////////// |
| 536 | 535 |
| 537 GrEffectRef* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&) c
onst { | 536 GrEffectRef* SkLinearGradient::asNewEffect(GrContext* context, const SkPaint&) c
onst { |
| 538 SkASSERT(NULL != context); | 537 SkASSERT(NULL != context); |
| 539 SkMatrix matrix; | 538 SkMatrix matrix; |
| 540 if (!this->getLocalMatrix().invert(&matrix)) { | 539 if (!this->getLocalMatrix().invert(&matrix)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 558 str->append("SkLinearGradient ("); | 557 str->append("SkLinearGradient ("); |
| 559 | 558 |
| 560 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 559 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); |
| 561 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 560 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); |
| 562 | 561 |
| 563 this->INHERITED::toString(str); | 562 this->INHERITED::toString(str); |
| 564 | 563 |
| 565 str->append(")"); | 564 str->append(")"); |
| 566 } | 565 } |
| 567 #endif | 566 #endif |
| OLD | NEW |