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); | 541 return shader->asNewEffect(context, paint, NULL); |
542 } | 542 } |
543 | 543 |
544 ///////////////////////////////////////////////////////////////////// | 544 ///////////////////////////////////////////////////////////////////// |
545 | 545 |
546 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder, | 546 void GrGLRadialGradient::emitCode(GrGLShaderBuilder* builder, |
547 const GrDrawEffect&, | 547 const GrDrawEffect&, |
548 EffectKey key, | 548 EffectKey key, |
549 const char* outputColor, | 549 const char* outputColor, |
550 const char* inputColor, | 550 const char* inputColor, |
551 const TransformedCoordsArray& coords, | 551 const TransformedCoordsArray& coords, |
552 const TextureSamplerArray& samplers) { | 552 const TextureSamplerArray& samplers) { |
553 this->emitUniforms(builder, key); | 553 this->emitUniforms(builder, key); |
554 SkString t("length("); | 554 SkString t("length("); |
555 t.append(builder->ensureFSCoords2D(coords, 0)); | 555 t.append(builder->ensureFSCoords2D(coords, 0)); |
556 t.append(")"); | 556 t.append(")"); |
557 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); | 557 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, samplers); |
558 } | 558 } |
559 | 559 |
560 ///////////////////////////////////////////////////////////////////// | 560 ///////////////////////////////////////////////////////////////////// |
561 | 561 |
562 GrEffectRef* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&) c
onst { | 562 GrEffectRef* SkRadialGradient::asNewEffect(GrContext* context, const SkPaint&, |
| 563 const SkMatrix* localMatrix) const { |
563 SkASSERT(NULL != context); | 564 SkASSERT(NULL != context); |
564 | 565 |
565 SkMatrix matrix; | 566 SkMatrix matrix; |
566 if (!this->getLocalMatrix().invert(&matrix)) { | 567 if (!this->getLocalMatrix().invert(&matrix)) { |
567 return NULL; | 568 return NULL; |
568 } | 569 } |
| 570 if (localMatrix) { |
| 571 SkMatrix inv; |
| 572 if (!localMatrix->invert(&inv)) { |
| 573 return NULL; |
| 574 } |
| 575 matrix.postConcat(inv); |
| 576 } |
569 matrix.postConcat(fPtsToUnit); | 577 matrix.postConcat(fPtsToUnit); |
570 return GrRadialGradient::Create(context, *this, matrix, fTileMode); | 578 return GrRadialGradient::Create(context, *this, matrix, fTileMode); |
571 } | 579 } |
572 | 580 |
573 #else | 581 #else |
574 | 582 |
575 GrEffectRef* SkRadialGradient::asNewEffect(GrContext*, const SkPaint&) const { | 583 GrEffectRef* SkRadialGradient::asNewEffect(GrContext*, const SkPaint&) const { |
576 SkDEBUGFAIL("Should not call in GPU-less build"); | 584 SkDEBUGFAIL("Should not call in GPU-less build"); |
577 return NULL; | 585 return NULL; |
578 } | 586 } |
(...skipping 10 matching lines...) Expand all Loading... |
589 str->appendScalar(fCenter.fY); | 597 str->appendScalar(fCenter.fY); |
590 str->append(") radius: "); | 598 str->append(") radius: "); |
591 str->appendScalar(fRadius); | 599 str->appendScalar(fRadius); |
592 str->append(" "); | 600 str->append(" "); |
593 | 601 |
594 this->INHERITED::toString(str); | 602 this->INHERITED::toString(str); |
595 | 603 |
596 str->append(")"); | 604 str->append(")"); |
597 } | 605 } |
598 #endif | 606 #endif |
OLD | NEW |