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

Side by Side Diff: src/effects/gradients/SkRadialGradient.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/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 * 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 "SkRadialGradient.h" 8 #include "SkRadialGradient.h"
9 #include "SkNx.h" 9 #include "SkNx.h"
10 10
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()}; 306 SkPoint center = {d->fRandom->nextUScalar1(), d->fRandom->nextUScalar1()};
307 SkScalar radius = d->fRandom->nextUScalar1(); 307 SkScalar radius = d->fRandom->nextUScalar1();
308 308
309 SkColor colors[kMaxRandomGradientColors]; 309 SkColor colors[kMaxRandomGradientColors];
310 SkScalar stopsArray[kMaxRandomGradientColors]; 310 SkScalar stopsArray[kMaxRandomGradientColors];
311 SkScalar* stops = stopsArray; 311 SkScalar* stops = stopsArray;
312 SkShader::TileMode tm; 312 SkShader::TileMode tm;
313 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm); 313 int colorCount = RandomGradientParams(d->fRandom, colors, &stops, &tm);
314 auto shader = SkGradientShader::MakeRadial(center, radius, colors, stops, co lorCount, tm); 314 auto shader = SkGradientShader::MakeRadial(center, radius, colors, stops, co lorCount, tm);
315 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext, 315 const GrFragmentProcessor* fp = shader->asFragmentProcessor(d->fContext,
316 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality); 316 GrTest::TestMatrix(d->fRandom), NULL, kNone_SkFilterQuality,
317 SkSourceGammaTreatment::kRespect);
317 GrAlwaysAssert(fp); 318 GrAlwaysAssert(fp);
318 return fp; 319 return fp;
319 } 320 }
320 321
321 ///////////////////////////////////////////////////////////////////// 322 /////////////////////////////////////////////////////////////////////
322 323
323 void GrGLRadialGradient::emitCode(EmitArgs& args) { 324 void GrGLRadialGradient::emitCode(EmitArgs& args) {
324 const GrRadialGradient& ge = args.fFp.cast<GrRadialGradient>(); 325 const GrRadialGradient& ge = args.fFp.cast<GrRadialGradient>();
325 this->emitUniforms(args.fUniformHandler, ge); 326 this->emitUniforms(args.fUniformHandler, ge);
326 SkString t("length("); 327 SkString t("length(");
327 t.append(args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0)); 328 t.append(args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0));
328 t.append(")"); 329 t.append(")");
329 this->emitColor(args.fFragBuilder, 330 this->emitColor(args.fFragBuilder,
330 args.fUniformHandler, 331 args.fUniformHandler,
331 args.fGLSLCaps, 332 args.fGLSLCaps,
332 ge, t.c_str(), 333 ge, t.c_str(),
333 args.fOutputColor, 334 args.fOutputColor,
334 args.fInputColor, 335 args.fInputColor,
335 args.fTexSamplers); 336 args.fTexSamplers);
336 } 337 }
337 338
338 ///////////////////////////////////////////////////////////////////// 339 /////////////////////////////////////////////////////////////////////
339 340
340 const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor( 341 const GrFragmentProcessor* SkRadialGradient::asFragmentProcessor(
341 GrContext* context, 342 GrContext* context,
342 const SkMatrix& viewM, 343 const SkMatrix& viewM,
343 const SkMatrix* localMatrix, 344 const SkMatrix* localMatrix,
344 SkFilterQuality) const { 345 SkFilterQuality,
346 SkSourceGammaTreatment) const {
345 SkASSERT(context); 347 SkASSERT(context);
346 348
347 SkMatrix matrix; 349 SkMatrix matrix;
348 if (!this->getLocalMatrix().invert(&matrix)) { 350 if (!this->getLocalMatrix().invert(&matrix)) {
349 return nullptr; 351 return nullptr;
350 } 352 }
351 if (localMatrix) { 353 if (localMatrix) {
352 SkMatrix inv; 354 SkMatrix inv;
353 if (!localMatrix->invert(&inv)) { 355 if (!localMatrix->invert(&inv)) {
354 return nullptr; 356 return nullptr;
(...skipping 18 matching lines...) Expand all
373 str->appendScalar(fCenter.fY); 375 str->appendScalar(fCenter.fY);
374 str->append(") radius: "); 376 str->append(") radius: ");
375 str->appendScalar(fRadius); 377 str->appendScalar(fRadius);
376 str->append(" "); 378 str->append(" ");
377 379
378 this->INHERITED::toString(str); 380 this->INHERITED::toString(str);
379 381
380 str->append(")"); 382 str->append(")");
381 } 383 }
382 #endif 384 #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