| 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 toggle = next_dither_toggle16(toggle); | 439 toggle = next_dither_toggle16(toggle); |
| 440 | 440 |
| 441 dstX += SK_Scalar1; | 441 dstX += SK_Scalar1; |
| 442 } while (--count != 0); | 442 } while (--count != 0); |
| 443 } | 443 } |
| 444 } | 444 } |
| 445 | 445 |
| 446 #if SK_SUPPORT_GPU | 446 #if SK_SUPPORT_GPU |
| 447 | 447 |
| 448 #include "GrTBackendEffectFactory.h" | 448 #include "GrTBackendEffectFactory.h" |
| 449 #include "gl/GrGLShaderBuilder.h" | 449 #include "gl/builders/GrGLProgramBuilder.h" |
| 450 #include "SkGr.h" | 450 #include "SkGr.h" |
| 451 | 451 |
| 452 ///////////////////////////////////////////////////////////////////// | 452 ///////////////////////////////////////////////////////////////////// |
| 453 | 453 |
| 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(GrGLProgramBuilder*, |
| 463 const GrDrawEffect&, | 463 const GrDrawEffect&, |
| 464 const GrEffectKey&, | 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 void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect
KeyBuilder* b) { | 470 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect
KeyBuilder* b) { |
| 471 b->add32(GenBaseGradientKey(drawEffect)); | 471 b->add32(GenBaseGradientKey(drawEffect)); |
| 472 } | 472 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 tm)); | 529 tm)); |
| 530 SkPaint paint; | 530 SkPaint paint; |
| 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(GrGLProgramBuilder* builder, |
| 540 const GrDrawEffect&, | 540 const GrDrawEffect&, |
| 541 const GrEffectKey& 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 uint32_t baseKey = key.get32(0); | 546 uint32_t baseKey = key.get32(0); |
| 547 this->emitUniforms(builder, baseKey); | 547 this->emitUniforms(builder, baseKey); |
| 548 SkString t = builder->ensureFSCoords2D(coords, 0); | 548 SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0
); |
| 549 t.append(".x"); | 549 t.append(".x"); |
| 550 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample
rs); | 550 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample
rs); |
| 551 } | 551 } |
| 552 | 552 |
| 553 ///////////////////////////////////////////////////////////////////// | 553 ///////////////////////////////////////////////////////////////////// |
| 554 | 554 |
| 555 bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint, | 555 bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint, |
| 556 const SkMatrix* localMatrix, GrColor* paintCo
lor, | 556 const SkMatrix* localMatrix, GrColor* paintCo
lor, |
| 557 GrEffect** effect) const { | 557 GrEffect** effect) const { |
| 558 SkASSERT(NULL != context); | 558 SkASSERT(NULL != context); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 str->append("SkLinearGradient ("); | 592 str->append("SkLinearGradient ("); |
| 593 | 593 |
| 594 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 594 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); |
| 595 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 595 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); |
| 596 | 596 |
| 597 this->INHERITED::toString(str); | 597 this->INHERITED::toString(str); |
| 598 | 598 |
| 599 str->append(")"); | 599 str->append(")"); |
| 600 } | 600 } |
| 601 #endif | 601 #endif |
| OLD | NEW |