Chromium Code Reviews| 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 "SkRadialGradient.h" | 9 #include "SkRadialGradient.h" |
| 10 #include "SkRadialGradient_Table.h" | 10 #include "SkRadialGradient_Table.h" |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 | 531 |
| 532 SkColor colors[kMaxRandomGradientColors]; | 532 SkColor colors[kMaxRandomGradientColors]; |
| 533 SkScalar stopsArray[kMaxRandomGradientColors]; | 533 SkScalar stopsArray[kMaxRandomGradientColors]; |
| 534 SkScalar* stops = stopsArray; | 534 SkScalar* stops = stopsArray; |
| 535 SkShader::TileMode tm; | 535 SkShader::TileMode tm; |
| 536 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 536 int colorCount = RandomGradientParams(random, colors, &stops, &tm); |
| 537 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius, | 537 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius, |
| 538 colors, stops, colorCount, | 538 colors, stops, colorCount, |
| 539 tm)); | 539 tm)); |
| 540 SkPaint paint; | 540 SkPaint paint; |
| 541 return shader->asNewEffect(context, paint, NULL); | 541 GrColor grColor; |
| 542 GrEffectRef* effect; | |
| 543 shader->asNewEffect(context, paint, &grColor, &effect, NULL); | |
| 544 return effect; | |
| 542 } | 545 } |
| 543 | 546 |
| 544 ///////////////////////////////////////////////////////////////////// | 547 ///////////////////////////////////////////////////////////////////// |
| 545 | 548 |
| 546 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder, | 549 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder, |
| 547 const GrDrawEffect&, | 550 const GrDrawEffect&, |
| 548 EffectKey key, | 551 EffectKey key, |
| 549 const char* outputColor, | 552 const char* outputColor, |
| 550 const char* inputColor, | 553 const char* inputColor, |
| 551 const TransformedCoordsArray& coords, | 554 const TransformedCoordsArray& coords, |
| 552 const TextureSamplerArray& samplers) { | 555 const TextureSamplerArray& samplers) { |
| 553 this->emitUniforms(builder, key); | 556 this->emitUniforms(builder, key); |
| 554 SkString t("length("); | 557 SkString t("length("); |
| 555 t.append(builder->ensureFSCoords2D(coords, 0)); | 558 t.append(builder->ensureFSCoords2D(coords, 0)); |
| 556 t.append(")"); | 559 t.append(")"); |
| 557 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); | 560 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); |
| 558 } | 561 } |
| 559 | 562 |
| 560 ///////////////////////////////////////////////////////////////////// | 563 ///////////////////////////////////////////////////////////////////// |
| 561 | 564 |
| 562 GrEffectRef* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&, | 565 bool SkRadialGradient::asNewEffect(GrContext* context, const SkPaint& paint, GrC olor* grColor, |
| 563 const SkMatrix* localMatrix) const { | 566 GrEffectRef** grEffect, const SkMatrix* local Matrix) const { |
|
jvanverth1
2014/06/05 17:36:31
grColor never gets set by this method
| |
| 564 SkASSERT(NULL != context); | 567 SkASSERT(NULL != context); |
| 565 | 568 |
| 566 SkMatrix matrix; | 569 SkMatrix matrix; |
| 567 if (!this->getLocalMatrix().invert(&matrix)) { | 570 if (!this->getLocalMatrix().invert(&matrix)) { |
| 568 return NULL; | 571 return false; |
| 569 } | 572 } |
| 570 if (localMatrix) { | 573 if (localMatrix) { |
| 571 SkMatrix inv; | 574 SkMatrix inv; |
| 572 if (!localMatrix->invert(&inv)) { | 575 if (!localMatrix->invert(&inv)) { |
| 573 return NULL; | 576 return false; |
| 574 } | 577 } |
| 575 matrix.postConcat(inv); | 578 matrix.postConcat(inv); |
| 576 } | 579 } |
| 577 matrix.postConcat(fPtsToUnit); | 580 matrix.postConcat(fPtsToUnit); |
| 578 return GrRadialGradient::Create(context, *this, matrix, fTileMode); | 581 *grEffect = GrRadialGradient::Create(context, *this, matrix, fTileMode); |
| 582 return true; | |
| 579 } | 583 } |
| 580 | 584 |
| 581 #else | 585 #else |
| 582 | 586 |
| 583 GrEffectRef* SkRadialGradient::asNewEffect(GrContext*, const SkPaint&, const SkM atrix*) const { | 587 GrEffectRef* SkRadialGradient::asNewEffect(GrContext*, const SkPaint&, const SkM atrix*) const { |
| 584 SkDEBUGFAIL("Should not call in GPU-less build"); | 588 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 585 return NULL; | 589 return NULL; |
| 586 } | 590 } |
| 587 | 591 |
| 588 #endif | 592 #endif |
| 589 | 593 |
| 590 #ifndef SK_IGNORE_TO_STRING | 594 #ifndef SK_IGNORE_TO_STRING |
| 591 void SkRadialGradient::toString(SkString* str) const { | 595 void SkRadialGradient::toString(SkString* str) const { |
| 592 str->append("SkRadialGradient: ("); | 596 str->append("SkRadialGradient: ("); |
| 593 | 597 |
| 594 str->append("center: ("); | 598 str->append("center: ("); |
| 595 str->appendScalar(fCenter.fX); | 599 str->appendScalar(fCenter.fX); |
| 596 str->append(", "); | 600 str->append(", "); |
| 597 str->appendScalar(fCenter.fY); | 601 str->appendScalar(fCenter.fY); |
| 598 str->append(") radius: "); | 602 str->append(") radius: "); |
| 599 str->appendScalar(fRadius); | 603 str->appendScalar(fRadius); |
| 600 str->append(" "); | 604 str->append(" "); |
| 601 | 605 |
| 602 this->INHERITED::toString(str); | 606 this->INHERITED::toString(str); |
| 603 | 607 |
| 604 str->append(")"); | 608 str->append(")"); |
| 605 } | 609 } |
| 606 #endif | 610 #endif |
| OLD | NEW |