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

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

Issue 2175563003: Bundle SkShader::asFragmentProcessor arguments in a struct (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix indentation to be less arbitrary Created 4 years, 5 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/SkLinearGradient.h ('k') | src/effects/gradients/SkRadialGradient.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 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Sk4fLinearGradient.h" 8 #include "Sk4fLinearGradient.h"
9 #include "SkLinearGradient.h" 9 #include "SkLinearGradient.h"
10 #include "SkRefCnt.h" 10 #include "SkRefCnt.h"
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d) { 411 sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d) {
412 SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()} , 412 SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()} ,
413 {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()} }; 413 {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()} };
414 414
415 SkColor colors[kMaxRandomGradientColors]; 415 SkColor colors[kMaxRandomGradientColors];
416 SkScalar stopsArray[kMaxRandomGradientColors]; 416 SkScalar stopsArray[kMaxRandomGradientColors];
417 SkScalar* stops = stopsArray; 417 SkScalar* stops = stopsArray;
418 SkShader::TileMode tm; 418 SkShader::TileMode tm;
419 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 419 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
420 auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount , tm); 420 auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount , tm);
421 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(d->fContext, 421 SkMatrix viewMatrix = GrTest::TestMatrix(d->fRandom);
422 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality, 422 sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(SkShader::AsFPAr gs(
423 SkSourceGammaTreatment::kRespect); 423 d->fContext, &viewMatrix, NULL, kNone_SkFilterQuality, SkSourceGammaTrea tment::kRespect));
424 GrAlwaysAssert(fp); 424 GrAlwaysAssert(fp);
425 return fp; 425 return fp;
426 } 426 }
427 427
428 ///////////////////////////////////////////////////////////////////// 428 /////////////////////////////////////////////////////////////////////
429 429
430 void GrGLLinearGradient::emitCode(EmitArgs& args) { 430 void GrGLLinearGradient::emitCode(EmitArgs& args) {
431 const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>(); 431 const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>();
432 this->emitUniforms(args.fUniformHandler, ge); 432 this->emitUniforms(args.fUniformHandler, ge);
433 SkString t = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0); 433 SkString t = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
434 t.append(".x"); 434 t.append(".x");
435 this->emitColor(args.fFragBuilder, 435 this->emitColor(args.fFragBuilder,
436 args.fUniformHandler, 436 args.fUniformHandler,
437 args.fGLSLCaps, 437 args.fGLSLCaps,
438 ge, t.c_str(), 438 ge, t.c_str(),
439 args.fOutputColor, 439 args.fOutputColor,
440 args.fInputColor, 440 args.fInputColor,
441 args.fTexSamplers); 441 args.fTexSamplers);
442 } 442 }
443 443
444 ///////////////////////////////////////////////////////////////////// 444 /////////////////////////////////////////////////////////////////////
445 445
446 sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor( 446 sk_sp<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(const AsFPArgs& args) const {
447 GrContext* context, 447 SkASSERT(args.fContext);
448 const SkMatrix& viewm,
449 const SkMatrix* localMatrix,
450 SkFilterQuality,
451 SkSourceGammaTreatment) const {
452 SkASSERT(context);
453 448
454 SkMatrix matrix; 449 SkMatrix matrix;
455 if (!this->getLocalMatrix().invert(&matrix)) { 450 if (!this->getLocalMatrix().invert(&matrix)) {
456 return nullptr; 451 return nullptr;
457 } 452 }
458 if (localMatrix) { 453 if (args.fLocalMatrix) {
459 SkMatrix inv; 454 SkMatrix inv;
460 if (!localMatrix->invert(&inv)) { 455 if (!args.fLocalMatrix->invert(&inv)) {
461 return nullptr; 456 return nullptr;
462 } 457 }
463 matrix.postConcat(inv); 458 matrix.postConcat(inv);
464 } 459 }
465 matrix.postConcat(fPtsToUnit); 460 matrix.postConcat(fPtsToUnit);
466 461
467 sk_sp<GrFragmentProcessor> inner(GrLinearGradient::Make(context, *this, matr ix, fTileMode)); 462 sk_sp<GrFragmentProcessor> inner(
463 GrLinearGradient::Make(args.fContext, *this, matrix, fTileMode));
468 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner)); 464 return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
469 } 465 }
470 466
471 467
472 #endif 468 #endif
473 469
474 #ifndef SK_IGNORE_TO_STRING 470 #ifndef SK_IGNORE_TO_STRING
475 void SkLinearGradient::toString(SkString* str) const { 471 void SkLinearGradient::toString(SkString* str) const {
476 str->append("SkLinearGradient ("); 472 str->append("SkLinearGradient (");
477 473
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r); 752 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r);
757 } 753 }
758 } else { 754 } else {
759 if (fApplyAlphaAfterInterp) { 755 if (fApplyAlphaAfterInterp) {
760 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r); 756 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r);
761 } else { 757 } else {
762 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er); 758 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er);
763 } 759 }
764 } 760 }
765 } 761 }
OLDNEW
« no previous file with comments | « src/effects/gradients/SkLinearGradient.h ('k') | src/effects/gradients/SkRadialGradient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698