| 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 510     SkScalar stopsArray[kMaxRandomGradientColors]; | 510     SkScalar stopsArray[kMaxRandomGradientColors]; | 
| 511     SkScalar* stops = stopsArray; | 511     SkScalar* stops = stopsArray; | 
| 512     SkShader::TileMode tm; | 512     SkShader::TileMode tm; | 
| 513     int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 513     int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 
| 514     SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius, | 514     SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius, | 
| 515                                                                  colors, stops, 
     colorCount, | 515                                                                  colors, stops, 
     colorCount, | 
| 516                                                                  tm)); | 516                                                                  tm)); | 
| 517     SkPaint paint; | 517     SkPaint paint; | 
| 518     GrColor paintColor; | 518     GrColor paintColor; | 
| 519     GrFragmentProcessor* fp; | 519     GrFragmentProcessor* fp; | 
|  | 520     GrPaint grPaint; | 
| 520     SkAssertResult(shader->asFragmentProcessor(context, paint, | 521     SkAssertResult(shader->asFragmentProcessor(context, paint, | 
| 521                                                GrTest::TestMatrix(random), NULL, | 522                                                GrTest::TestMatrix(random), NULL, | 
| 522                                                &paintColor, &fp)); | 523                                                &paintColor, grPaint.getShaderDat
     aManager(), &fp)); | 
| 523     return fp; | 524     return fp; | 
| 524 } | 525 } | 
| 525 | 526 | 
| 526 ///////////////////////////////////////////////////////////////////// | 527 ///////////////////////////////////////////////////////////////////// | 
| 527 | 528 | 
| 528 void GrGLRadialGradient::emitCode(GrGLFPBuilder* builder, | 529 void GrGLRadialGradient::emitCode(GrGLFPBuilder* builder, | 
| 529                                   const GrFragmentProcessor& fp, | 530                                   const GrFragmentProcessor& fp, | 
| 530                                   const char* outputColor, | 531                                   const char* outputColor, | 
| 531                                   const char* inputColor, | 532                                   const char* inputColor, | 
| 532                                   const TransformedCoordsArray& coords, | 533                                   const TransformedCoordsArray& coords, | 
| 533                                   const TextureSamplerArray& samplers) { | 534                                   const TextureSamplerArray& samplers) { | 
| 534     const GrRadialGradient& ge = fp.cast<GrRadialGradient>(); | 535     const GrRadialGradient& ge = fp.cast<GrRadialGradient>(); | 
| 535     this->emitUniforms(builder, ge); | 536     this->emitUniforms(builder, ge); | 
| 536     SkString t("length("); | 537     SkString t("length("); | 
| 537     t.append(builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0)); | 538     t.append(builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0)); | 
| 538     t.append(")"); | 539     t.append(")"); | 
| 539     this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); | 540     this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); | 
| 540 } | 541 } | 
| 541 | 542 | 
| 542 ///////////////////////////////////////////////////////////////////// | 543 ///////////////////////////////////////////////////////////////////// | 
| 543 | 544 | 
| 544 bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa
     int, | 545 bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa
     int, | 
| 545                                            const SkMatrix& viewM, | 546                                            const SkMatrix& viewM, | 
| 546                                            const SkMatrix* localMatrix, GrColor*
      paintColor, | 547                                            const SkMatrix* localMatrix, GrColor*
      paintColor, | 
| 547                                            GrFragmentProcessor** fp) const { | 548                                            GrShaderDataManager*, GrFragmentProce
     ssor** fp) const { | 
| 548     SkASSERT(context); | 549     SkASSERT(context); | 
| 549 | 550 | 
| 550     SkMatrix matrix; | 551     SkMatrix matrix; | 
| 551     if (!this->getLocalMatrix().invert(&matrix)) { | 552     if (!this->getLocalMatrix().invert(&matrix)) { | 
| 552         return false; | 553         return false; | 
| 553     } | 554     } | 
| 554     if (localMatrix) { | 555     if (localMatrix) { | 
| 555         SkMatrix inv; | 556         SkMatrix inv; | 
| 556         if (!localMatrix->invert(&inv)) { | 557         if (!localMatrix->invert(&inv)) { | 
| 557             return false; | 558             return false; | 
| 558         } | 559         } | 
| 559         matrix.postConcat(inv); | 560         matrix.postConcat(inv); | 
| 560     } | 561     } | 
| 561     matrix.postConcat(fPtsToUnit); | 562     matrix.postConcat(fPtsToUnit); | 
| 562 | 563 | 
| 563     *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); | 564     *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); | 
| 564     *fp = GrRadialGradient::Create(context, *this, matrix, fTileMode); | 565     *fp = GrRadialGradient::Create(context, *this, matrix, fTileMode); | 
| 565 | 566 | 
| 566     return true; | 567     return true; | 
| 567 } | 568 } | 
| 568 | 569 | 
| 569 #else | 570 #else | 
| 570 | 571 | 
| 571 bool SkRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM
     atrix&, | 572 bool SkRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM
     atrix&, | 
| 572                                            const SkMatrix*, GrColor*, | 573                                            const SkMatrix*, GrColor*, GrShaderDa
     taManager*, | 
| 573                                            GrFragmentProcessor**) const { | 574                                            GrFragmentProcessor**) const { | 
| 574     SkDEBUGFAIL("Should not call in GPU-less build"); | 575     SkDEBUGFAIL("Should not call in GPU-less build"); | 
| 575     return false; | 576     return false; | 
| 576 } | 577 } | 
| 577 | 578 | 
| 578 #endif | 579 #endif | 
| 579 | 580 | 
| 580 #ifndef SK_IGNORE_TO_STRING | 581 #ifndef SK_IGNORE_TO_STRING | 
| 581 void SkRadialGradient::toString(SkString* str) const { | 582 void SkRadialGradient::toString(SkString* str) const { | 
| 582     str->append("SkRadialGradient: ("); | 583     str->append("SkRadialGradient: ("); | 
| 583 | 584 | 
| 584     str->append("center: ("); | 585     str->append("center: ("); | 
| 585     str->appendScalar(fCenter.fX); | 586     str->appendScalar(fCenter.fX); | 
| 586     str->append(", "); | 587     str->append(", "); | 
| 587     str->appendScalar(fCenter.fY); | 588     str->appendScalar(fCenter.fY); | 
| 588     str->append(") radius: "); | 589     str->append(") radius: "); | 
| 589     str->appendScalar(fRadius); | 590     str->appendScalar(fRadius); | 
| 590     str->append(" "); | 591     str->append(" "); | 
| 591 | 592 | 
| 592     this->INHERITED::toString(str); | 593     this->INHERITED::toString(str); | 
| 593 | 594 | 
| 594     str->append(")"); | 595     str->append(")"); | 
| 595 } | 596 } | 
| 596 #endif | 597 #endif | 
| OLD | NEW | 
|---|