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

Side by Side Diff: src/effects/SkColorFilters.cpp

Issue 1213623022: fix up test create functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more cleanup Created 5 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/SkBlurMaskFilter.cpp ('k') | src/effects/SkColorMatrixFilter.cpp » ('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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkBlitRow.h" 8 #include "SkBlitRow.h"
9 #include "SkColorFilter.h" 9 #include "SkColorFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 GrInvariantOutput::ReadInput readInput = GrInvariantOutput::kWill_ReadInput; 337 GrInvariantOutput::ReadInput readInput = GrInvariantOutput::kWill_ReadInput;
338 // These could be calculated from the blend equation with template trickery. . 338 // These could be calculated from the blend equation with template trickery. .
339 if (SkXfermode::kZero_Coeff == dstCoeff && 339 if (SkXfermode::kZero_Coeff == dstCoeff &&
340 !GrBlendCoeffRefsDst(sk_blend_to_grblend(srcCoeff))) { 340 !GrBlendCoeffRefsDst(sk_blend_to_grblend(srcCoeff))) {
341 readInput = GrInvariantOutput::kWillNot_ReadInput; 341 readInput = GrInvariantOutput::kWillNot_ReadInput;
342 } 342 }
343 inout->setToOther(result.getValidComponents(), result.getColor(), readInput) ; 343 inout->setToOther(result.getValidComponents(), result.getColor(), readInput) ;
344 } 344 }
345 345
346 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ModeColorFilterEffect); 346 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ModeColorFilterEffect);
347 GrFragmentProcessor* ModeColorFilterEffect::TestCreate(SkRandom* rand, 347 GrFragmentProcessor* ModeColorFilterEffect::TestCreate(GrProcessorTestData* d) {
348 GrContext*,
349 const GrCaps&,
350 GrTexture*[]) {
351 SkXfermode::Mode mode = SkXfermode::kDst_Mode; 348 SkXfermode::Mode mode = SkXfermode::kDst_Mode;
352 while (SkXfermode::kDst_Mode == mode) { 349 while (SkXfermode::kDst_Mode == mode) {
353 mode = static_cast<SkXfermode::Mode>(rand->nextRangeU(0, SkXfermode::kLa stCoeffMode)); 350 mode = static_cast<SkXfermode::Mode>(d->fRandom->nextRangeU(0, SkXfermod e::kLastCoeffMode));
354 } 351 }
355 352
356 // pick a random premul color 353 // pick a random premul color
357 uint8_t alpha = rand->nextULessThan(256); 354 uint8_t alpha = d->fRandom->nextULessThan(256);
358 GrColor color = GrColorPackRGBA(rand->nextRangeU(0, alpha), 355 GrColor color = GrColorPackRGBA(d->fRandom->nextRangeU(0, alpha),
359 rand->nextRangeU(0, alpha), 356 d->fRandom->nextRangeU(0, alpha),
360 rand->nextRangeU(0, alpha), 357 d->fRandom->nextRangeU(0, alpha),
361 alpha); 358 alpha);
362 return ModeColorFilterEffect::Create(color, mode); 359 return ModeColorFilterEffect::Create(color, mode);
363 } 360 }
364 361
365 bool SkModeColorFilter::asFragmentProcessors(GrContext*, GrShaderDataManager*, 362 bool SkModeColorFilter::asFragmentProcessors(GrContext*, GrShaderDataManager*,
366 SkTDArray<GrFragmentProcessor*>* ar ray) const { 363 SkTDArray<GrFragmentProcessor*>* ar ray) const {
367 if (SkXfermode::kDst_Mode != fMode) { 364 if (SkXfermode::kDst_Mode != fMode) {
368 GrFragmentProcessor* frag = ModeColorFilterEffect::Create(SkColor2GrColo r(fColor), fMode); 365 GrFragmentProcessor* frag = ModeColorFilterEffect::Create(SkColor2GrColo r(fColor), fMode);
369 if (frag) { 366 if (frag) {
370 if (array) { 367 if (array) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 byte_to_scale(SkColorGetG(mul)), 466 byte_to_scale(SkColorGetG(mul)),
470 byte_to_scale(SkColorGetB(mul)), 467 byte_to_scale(SkColorGetB(mul)),
471 1); 468 1);
472 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), 469 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
473 SkIntToScalar(SkColorGetG(add)), 470 SkIntToScalar(SkColorGetG(add)),
474 SkIntToScalar(SkColorGetB(add)), 471 SkIntToScalar(SkColorGetB(add)),
475 0); 472 0);
476 return SkColorMatrixFilter::Create(matrix); 473 return SkColorMatrixFilter::Create(matrix);
477 } 474 }
478 475
OLDNEW
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698