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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 455 |
456 typedef GrGLGradientEffect INHERITED; | 456 typedef GrGLGradientEffect INHERITED; |
457 | 457 |
458 }; | 458 }; |
459 | 459 |
460 ///////////////////////////////////////////////////////////////////// | 460 ///////////////////////////////////////////////////////////////////// |
461 | 461 |
462 class GrRadialGradient : public GrGradientEffect { | 462 class GrRadialGradient : public GrGradientEffect { |
463 public: | 463 public: |
464 static GrFragmentProcessor* Create(GrContext* ctx, | 464 static GrFragmentProcessor* Create(GrContext* ctx, |
| 465 GrShaderDataManager* shaderDataManager, |
465 const SkRadialGradient& shader, | 466 const SkRadialGradient& shader, |
466 const SkMatrix& matrix, | 467 const SkMatrix& matrix, |
467 SkShader::TileMode tm) { | 468 SkShader::TileMode tm) { |
468 return SkNEW_ARGS(GrRadialGradient, (ctx, shader, matrix, tm)); | 469 return SkNEW_ARGS(GrRadialGradient, (ctx, shaderDataManager, shader, mat
rix, tm)); |
469 } | 470 } |
470 | 471 |
471 virtual ~GrRadialGradient() { } | 472 virtual ~GrRadialGradient() { } |
472 | 473 |
473 const char* name() const override { return "Radial Gradient"; } | 474 const char* name() const override { return "Radial Gradient"; } |
474 | 475 |
475 virtual void getGLProcessorKey(const GrGLSLCaps& caps, | 476 virtual void getGLProcessorKey(const GrGLSLCaps& caps, |
476 GrProcessorKeyBuilder* b) const override { | 477 GrProcessorKeyBuilder* b) const override { |
477 GrGLRadialGradient::GenKey(*this, caps, b); | 478 GrGLRadialGradient::GenKey(*this, caps, b); |
478 } | 479 } |
479 | 480 |
480 GrGLFragmentProcessor* createGLInstance() const override { | 481 GrGLFragmentProcessor* createGLInstance() const override { |
481 return SkNEW_ARGS(GrGLRadialGradient, (*this)); | 482 return SkNEW_ARGS(GrGLRadialGradient, (*this)); |
482 } | 483 } |
483 | 484 |
484 private: | 485 private: |
485 GrRadialGradient(GrContext* ctx, | 486 GrRadialGradient(GrContext* ctx, |
| 487 GrShaderDataManager* shaderDataManager, |
486 const SkRadialGradient& shader, | 488 const SkRadialGradient& shader, |
487 const SkMatrix& matrix, | 489 const SkMatrix& matrix, |
488 SkShader::TileMode tm) | 490 SkShader::TileMode tm) |
489 : INHERITED(ctx, shader, matrix, tm) { | 491 : INHERITED(ctx, shaderDataManager, shader, matrix, tm) { |
490 this->initClassID<GrRadialGradient>(); | 492 this->initClassID<GrRadialGradient>(); |
491 } | 493 } |
492 | 494 |
493 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 495 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
494 | 496 |
495 typedef GrGradientEffect INHERITED; | 497 typedef GrGradientEffect INHERITED; |
496 }; | 498 }; |
497 | 499 |
498 ///////////////////////////////////////////////////////////////////// | 500 ///////////////////////////////////////////////////////////////////// |
499 | 501 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 t.append(builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0)); | 540 t.append(builder->getFragmentShaderBuilder()->ensureFSCoords2D(coords, 0)); |
539 t.append(")"); | 541 t.append(")"); |
540 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); | 542 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); |
541 } | 543 } |
542 | 544 |
543 ///////////////////////////////////////////////////////////////////// | 545 ///////////////////////////////////////////////////////////////////// |
544 | 546 |
545 bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa
int, | 547 bool SkRadialGradient::asFragmentProcessor(GrContext* context, const SkPaint& pa
int, |
546 const SkMatrix& viewM, | 548 const SkMatrix& viewM, |
547 const SkMatrix* localMatrix, GrColor*
paintColor, | 549 const SkMatrix* localMatrix, GrColor*
paintColor, |
548 GrShaderDataManager*, GrFragmentProce
ssor** fp) const { | 550 GrShaderDataManager* shaderDataManage
r, |
| 551 GrFragmentProcessor** fp) const { |
549 SkASSERT(context); | 552 SkASSERT(context); |
550 | 553 |
551 SkMatrix matrix; | 554 SkMatrix matrix; |
552 if (!this->getLocalMatrix().invert(&matrix)) { | 555 if (!this->getLocalMatrix().invert(&matrix)) { |
553 return false; | 556 return false; |
554 } | 557 } |
555 if (localMatrix) { | 558 if (localMatrix) { |
556 SkMatrix inv; | 559 SkMatrix inv; |
557 if (!localMatrix->invert(&inv)) { | 560 if (!localMatrix->invert(&inv)) { |
558 return false; | 561 return false; |
559 } | 562 } |
560 matrix.postConcat(inv); | 563 matrix.postConcat(inv); |
561 } | 564 } |
562 matrix.postConcat(fPtsToUnit); | 565 matrix.postConcat(fPtsToUnit); |
563 | 566 |
564 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); | 567 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); |
565 *fp = GrRadialGradient::Create(context, *this, matrix, fTileMode); | 568 *fp = GrRadialGradient::Create(context, shaderDataManager, *this, matrix, fT
ileMode); |
566 | 569 |
567 return true; | 570 return true; |
568 } | 571 } |
569 | 572 |
570 #else | 573 #else |
571 | 574 |
572 bool SkRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM
atrix&, | 575 bool SkRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkM
atrix&, |
573 const SkMatrix*, GrColor*, GrShaderDa
taManager*, | 576 const SkMatrix*, GrColor*, GrShaderDa
taManager*, |
574 GrFragmentProcessor**) const { | 577 GrFragmentProcessor**) const { |
575 SkDEBUGFAIL("Should not call in GPU-less build"); | 578 SkDEBUGFAIL("Should not call in GPU-less build"); |
(...skipping 12 matching lines...) Expand all Loading... |
588 str->appendScalar(fCenter.fY); | 591 str->appendScalar(fCenter.fY); |
589 str->append(") radius: "); | 592 str->append(") radius: "); |
590 str->appendScalar(fRadius); | 593 str->appendScalar(fRadius); |
591 str->append(" "); | 594 str->append(" "); |
592 | 595 |
593 this->INHERITED::toString(str); | 596 this->INHERITED::toString(str); |
594 | 597 |
595 str->append(")"); | 598 str->append(")"); |
596 } | 599 } |
597 #endif | 600 #endif |
OLD | NEW |