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

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

Issue 2037413002: Add SkSourceGammaTreatment enum so we know how to create mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix DM compilation Created 4 years, 6 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 10
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()} , 411 SkPoint points[] = {{d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()} ,
412 {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()} }; 412 {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()} };
413 413
414 SkColor colors[kMaxRandomGradientColors]; 414 SkColor colors[kMaxRandomGradientColors];
415 SkScalar stopsArray[kMaxRandomGradientColors]; 415 SkScalar stopsArray[kMaxRandomGradientColors];
416 SkScalar* stops = stopsArray; 416 SkScalar* stops = stopsArray;
417 SkShader::TileMode tm; 417 SkShader::TileMode tm;
418 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 418 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
419 auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount , tm); 419 auto shader = SkGradientShader::MakeLinear(points, colors, stops, colorCount , tm);
420 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 420 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
421 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 421 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
422 SkSourceGammaTreatment::kRespect);
422 GrAlwaysAssert(fp); 423 GrAlwaysAssert(fp);
423 return fp; 424 return fp;
424 } 425 }
425 426
426 ///////////////////////////////////////////////////////////////////// 427 /////////////////////////////////////////////////////////////////////
427 428
428 void GrGLLinearGradient::emitCode(EmitArgs& args) { 429 void GrGLLinearGradient::emitCode(EmitArgs& args) {
429 const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>(); 430 const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>();
430 this->emitUniforms(args.fUniformHandler, ge); 431 this->emitUniforms(args.fUniformHandler, ge);
431 SkString t = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0); 432 SkString t = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
432 t.append(".x"); 433 t.append(".x");
433 this->emitColor(args.fFragBuilder, 434 this->emitColor(args.fFragBuilder,
434 args.fUniformHandler, 435 args.fUniformHandler,
435 args.fGLSLCaps, 436 args.fGLSLCaps,
436 ge, t.c_str(), 437 ge, t.c_str(),
437 args.fOutputColor, 438 args.fOutputColor,
438 args.fInputColor, 439 args.fInputColor,
439 args.fTexSamplers); 440 args.fTexSamplers);
440 } 441 }
441 442
442 ///////////////////////////////////////////////////////////////////// 443 /////////////////////////////////////////////////////////////////////
443 444
444 const GrFragmentProcessor* SkLinearGradient::asFragmentProcessor( 445 const GrFragmentProcessor* SkLinearGradient::asFragmentProcessor(
445 GrContext* context, 446 GrContext* context,
446 const SkMatrix& viewm, 447 const SkMatrix& viewm,
447 const SkMatrix* localMatrix, 448 const SkMatrix* localMatrix,
448 SkFilterQuality) const { 449 SkFilterQuality,
450 SkSourceGammaTreatment) const {
449 SkASSERT(context); 451 SkASSERT(context);
450 452
451 SkMatrix matrix; 453 SkMatrix matrix;
452 if (!this->getLocalMatrix().invert(&matrix)) { 454 if (!this->getLocalMatrix().invert(&matrix)) {
453 return nullptr; 455 return nullptr;
454 } 456 }
455 if (localMatrix) { 457 if (localMatrix) {
456 SkMatrix inv; 458 SkMatrix inv;
457 if (!localMatrix->invert(&inv)) { 459 if (!localMatrix->invert(&inv)) {
458 return nullptr; 460 return nullptr;
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r); 756 this->shade4_dx_clamp<false, true>(dstC, count, fx, dx, invDx, dithe r);
755 } 757 }
756 } else { 758 } else {
757 if (fApplyAlphaAfterInterp) { 759 if (fApplyAlphaAfterInterp) {
758 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r); 760 this->shade4_dx_clamp<true, false>(dstC, count, fx, dx, invDx, dithe r);
759 } else { 761 } else {
760 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er); 762 this->shade4_dx_clamp<false, false>(dstC, count, fx, dx, invDx, dith er);
761 } 763 }
762 } 764 }
763 } 765 }
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