Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: src/effects/gradients/SkRadialGradient.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/gradients/SkRadialGradient.h ('k') | src/effects/gradients/SkSweepGradient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 435
436 }; 436 };
437 437
438 ///////////////////////////////////////////////////////////////////// 438 /////////////////////////////////////////////////////////////////////
439 439
440 class GrRadialGradient : public GrGradientEffect { 440 class GrRadialGradient : public GrGradientEffect {
441 public: 441 public:
442 static GrFragmentProcessor* Create(GrContext* ctx, 442 static GrFragmentProcessor* Create(GrContext* ctx,
443 const SkRadialGradient& shader, 443 const SkRadialGradient& shader,
444 const SkMatrix& matrix, 444 const SkMatrix& matrix,
445 SkShader::TileMode tm) { 445 SkShader::TileMode tm, GrRenderTarget* ds t) {
446 return new GrRadialGradient(ctx, shader, matrix, tm); 446 return new GrRadialGradient(ctx, shader, matrix, tm, dst);
447 } 447 }
448 448
449 virtual ~GrRadialGradient() { } 449 virtual ~GrRadialGradient() { }
450 450
451 const char* name() const override { return "Radial Gradient"; } 451 const char* name() const override { return "Radial Gradient"; }
452 452
453 private: 453 private:
454 GrRadialGradient(GrContext* ctx, 454 GrRadialGradient(GrContext* ctx,
455 const SkRadialGradient& shader, 455 const SkRadialGradient& shader,
456 const SkMatrix& matrix, 456 const SkMatrix& matrix,
457 SkShader::TileMode tm) 457 SkShader::TileMode tm, GrRenderTarget* dst)
458 : INHERITED(ctx, shader, matrix, tm) { 458 : INHERITED(ctx, shader, matrix, tm, dst) {
459 this->initClassID<GrRadialGradient>(); 459 this->initClassID<GrRadialGradient>();
460 } 460 }
461 461
462 GrGLFragmentProcessor* onCreateGLInstance() const override { 462 GrGLFragmentProcessor* onCreateGLInstance() const override {
463 return new GrGLRadialGradient(*this); 463 return new GrGLRadialGradient(*this);
464 } 464 }
465 465
466 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, 466 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
467 GrProcessorKeyBuilder* b) const override { 467 GrProcessorKeyBuilder* b) const override {
468 GrGLRadialGradient::GenKey(*this, caps, b); 468 GrGLRadialGradient::GenKey(*this, caps, b);
(...skipping 14 matching lines...) Expand all
483 483
484 SkColor colors[kMaxRandomGradientColors]; 484 SkColor colors[kMaxRandomGradientColors];
485 SkScalar stopsArray[kMaxRandomGradientColors]; 485 SkScalar stopsArray[kMaxRandomGradientColors];
486 SkScalar* stops = stopsArray; 486 SkScalar* stops = stopsArray;
487 SkShader::TileMode tm; 487 SkShader::TileMode tm;
488 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 488 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
489 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius, 489 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateRadial(center, radius,
490 colors, stops, colorCount, 490 colors, stops, colorCount,
491 tm)); 491 tm));
492 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 492 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
493 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 493 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, NULL);
494 GrAlwaysAssert(fp); 494 GrAlwaysAssert(fp);
495 return fp; 495 return fp;
496 } 496 }
497 497
498 ///////////////////////////////////////////////////////////////////// 498 /////////////////////////////////////////////////////////////////////
499 499
500 void GrGLRadialGradient::emitCode(EmitArgs& args) { 500 void GrGLRadialGradient::emitCode(EmitArgs& args) {
501 const GrRadialGradient& ge = args.fFp.cast<GrRadialGradient>(); 501 const GrRadialGradient& ge = args.fFp.cast<GrRadialGradient>();
502 this->emitUniforms(args.fBuilder, ge); 502 this->emitUniforms(args.fBuilder, ge);
503 SkString t("length("); 503 SkString t("length(");
504 t.append(args.fBuilder->getFragmentShaderBuilder()->ensureFSCoords2D(args.fC oords, 0)); 504 t.append(args.fBuilder->getFragmentShaderBuilder()->ensureFSCoords2D(args.fC oords, 0));
505 t.append(")"); 505 t.append(")");
506 this->emitColor(args.fBuilder, ge, t.c_str(), args.fOutputColor, args.fInput Color, 506 this->emitColor(args.fBuilder, ge, t.c_str(), args.fOutputColor, args.fInput Color,
507 args.fSamplers); 507 args.fSamplers);
508 } 508 }
509 509
510 ///////////////////////////////////////////////////////////////////// 510 /////////////////////////////////////////////////////////////////////
511 511
512 const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor( 512 const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor(
513 GrContext* context, 513 GrContext* context,
514 const SkMatrix& viewM, 514 const SkMatrix& viewM,
515 const SkMatrix* localMatrix, 515 const SkMatrix* localMatrix,
516 SkFilterQuality) const { 516 SkFilterQuality,
517 GrRenderTarget* dst) const {
517 SkASSERT(context); 518 SkASSERT(context);
518 519
519 SkMatrix matrix; 520 SkMatrix matrix;
520 if (!this->getLocalMatrix().invert(&matrix)) { 521 if (!this->getLocalMatrix().invert(&matrix)) {
521 return nullptr; 522 return nullptr;
522 } 523 }
523 if (localMatrix) { 524 if (localMatrix) {
524 SkMatrix inv; 525 SkMatrix inv;
525 if (!localMatrix->invert(&inv)) { 526 if (!localMatrix->invert(&inv)) {
526 return nullptr; 527 return nullptr;
527 } 528 }
528 matrix.postConcat(inv); 529 matrix.postConcat(inv);
529 } 530 }
530 matrix.postConcat(fPtsToUnit); 531 matrix.postConcat(fPtsToUnit);
531 SkAutoTUnref<const GrFragmentProcessor> inner( 532 SkAutoTUnref<const GrFragmentProcessor> inner(
532 GrRadialGradient::Create(context, *this, matrix, fTileMode)); 533 GrRadialGradient::Create(context, *this, matrix, fTileMode, dst));
533 return GrFragmentProcessor::MulOutputByInputAlpha(inner); 534 return GrFragmentProcessor::MulOutputByInputAlpha(inner);
534 } 535 }
535 536
536 #endif 537 #endif
537 538
538 #ifndef SK_IGNORE_TO_STRING 539 #ifndef SK_IGNORE_TO_STRING
539 void SkRadialGradient::toString(SkString* str) const { 540 void SkRadialGradient::toString(SkString* str) const {
540 str->append("SkRadialGradient: ("); 541 str->append("SkRadialGradient: (");
541 542
542 str->append("center: ("); 543 str->append("center: (");
543 str->appendScalar(fCenter.fX); 544 str->appendScalar(fCenter.fX);
544 str->append(", "); 545 str->append(", ");
545 str->appendScalar(fCenter.fY); 546 str->appendScalar(fCenter.fY);
546 str->append(") radius: "); 547 str->append(") radius: ");
547 str->appendScalar(fRadius); 548 str->appendScalar(fRadius);
548 str->append(" "); 549 str->append(" ");
549 550
550 this->INHERITED::toString(str); 551 this->INHERITED::toString(str);
551 552
552 str->append(")"); 553 str->append(")");
553 } 554 }
554 #endif 555 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkRadialGradient.h ('k') | src/effects/gradients/SkSweepGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698