| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 toggle = next_dither_toggle16(toggle); | 453 toggle = next_dither_toggle16(toggle); |
| 454 | 454 |
| 455 dstX += SK_Scalar1; | 455 dstX += SK_Scalar1; |
| 456 } while (--count != 0); | 456 } while (--count != 0); |
| 457 } | 457 } |
| 458 } | 458 } |
| 459 | 459 |
| 460 #if SK_SUPPORT_GPU | 460 #if SK_SUPPORT_GPU |
| 461 | 461 |
| 462 #include "GrTBackendEffectFactory.h" | 462 #include "GrTBackendEffectFactory.h" |
| 463 #include "gl/GrGLShaderBuilder.h" | 463 #include "gl/builders/GrGLProgramBuilder.h" |
| 464 #include "SkGr.h" | 464 #include "SkGr.h" |
| 465 | 465 |
| 466 ///////////////////////////////////////////////////////////////////// | 466 ///////////////////////////////////////////////////////////////////// |
| 467 | 467 |
| 468 class GrGLLinearGradient : public GrGLGradientEffect { | 468 class GrGLLinearGradient : public GrGLGradientEffect { |
| 469 public: | 469 public: |
| 470 | 470 |
| 471 GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrDrawEffect
&) | 471 GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrDrawEffect
&) |
| 472 : INHERITED (factory) { } | 472 : INHERITED (factory) { } |
| 473 | 473 |
| 474 virtual ~GrGLLinearGradient() { } | 474 virtual ~GrGLLinearGradient() { } |
| 475 | 475 |
| 476 virtual void emitCode(GrGLShaderBuilder*, | 476 virtual void emitCode(GrGLProgramBuilder*, |
| 477 const GrDrawEffect&, | 477 const GrDrawEffect&, |
| 478 const GrEffectKey&, | 478 const GrEffectKey&, |
| 479 const char* outputColor, | 479 const char* outputColor, |
| 480 const char* inputColor, | 480 const char* inputColor, |
| 481 const TransformedCoordsArray&, | 481 const TransformedCoordsArray&, |
| 482 const TextureSamplerArray&) SK_OVERRIDE; | 482 const TextureSamplerArray&) SK_OVERRIDE; |
| 483 | 483 |
| 484 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect
KeyBuilder* b) { | 484 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect
KeyBuilder* b) { |
| 485 b->add32(GenBaseGradientKey(drawEffect)); | 485 b->add32(GenBaseGradientKey(drawEffect)); |
| 486 } | 486 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 tm)); | 543 tm)); |
| 544 SkPaint paint; | 544 SkPaint paint; |
| 545 GrColor paintColor; | 545 GrColor paintColor; |
| 546 GrEffect* effect; | 546 GrEffect* effect; |
| 547 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec
t)); | 547 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec
t)); |
| 548 return effect; | 548 return effect; |
| 549 } | 549 } |
| 550 | 550 |
| 551 ///////////////////////////////////////////////////////////////////// | 551 ///////////////////////////////////////////////////////////////////// |
| 552 | 552 |
| 553 void GrGLLinearGradient::emitCode(GrGLShaderBuilder* builder, | 553 void GrGLLinearGradient::emitCode(GrGLProgramBuilder* builder, |
| 554 const GrDrawEffect&, | 554 const GrDrawEffect&, |
| 555 const GrEffectKey& key, | 555 const GrEffectKey& key, |
| 556 const char* outputColor, | 556 const char* outputColor, |
| 557 const char* inputColor, | 557 const char* inputColor, |
| 558 const TransformedCoordsArray& coords, | 558 const TransformedCoordsArray& coords, |
| 559 const TextureSamplerArray& samplers) { | 559 const TextureSamplerArray& samplers) { |
| 560 uint32_t baseKey = key.get32(0); | 560 uint32_t baseKey = key.get32(0); |
| 561 this->emitUniforms(builder, baseKey); | 561 this->emitUniforms(builder, baseKey); |
| 562 SkString t = builder->ensureFSCoords2D(coords, 0); | 562 SkString t = builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0
); |
| 563 t.append(".x"); | 563 t.append(".x"); |
| 564 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample
rs); | 564 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample
rs); |
| 565 } | 565 } |
| 566 | 566 |
| 567 ///////////////////////////////////////////////////////////////////// | 567 ///////////////////////////////////////////////////////////////////// |
| 568 | 568 |
| 569 bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint, | 569 bool SkLinearGradient::asNewEffect(GrContext* context, const SkPaint& paint, |
| 570 const SkMatrix* localMatrix, GrColor* paintCo
lor, | 570 const SkMatrix* localMatrix, GrColor* paintCo
lor, |
| 571 GrEffect** effect) const { | 571 GrEffect** effect) const { |
| 572 SkASSERT(NULL != context); | 572 SkASSERT(NULL != context); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 str->append("SkLinearGradient ("); | 606 str->append("SkLinearGradient ("); |
| 607 | 607 |
| 608 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); | 608 str->appendf("start: (%f, %f)", fStart.fX, fStart.fY); |
| 609 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); | 609 str->appendf(" end: (%f, %f) ", fEnd.fX, fEnd.fY); |
| 610 | 610 |
| 611 this->INHERITED::toString(str); | 611 this->INHERITED::toString(str); |
| 612 | 612 |
| 613 str->append(")"); | 613 str->append(")"); |
| 614 } | 614 } |
| 615 #endif | 615 #endif |
| OLD | NEW |