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

Side by Side Diff: src/gpu/effects/GrDistanceFieldGeoProc.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/gpu/effects/GrDisableColorXP.cpp ('k') | src/gpu/effects/GrDitherEffect.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 2013 Google Inc. 2 * Copyright 2013 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 "GrDistanceFieldGeoProc.h" 8 #include "GrDistanceFieldGeoProc.h"
9 #include "GrFontAtlasSizes.h" 9 #include "GrFontAtlasSizes.h"
10 #include "GrInvariantOutput.h" 10 #include "GrInvariantOutput.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 GrGLPrimitiveProcessor* 232 GrGLPrimitiveProcessor*
233 GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt, 233 GrDistanceFieldA8TextGeoProc::createGLInstance(const GrBatchTracker& bt,
234 const GrGLSLCaps&) const { 234 const GrGLSLCaps&) const {
235 return SkNEW_ARGS(GrGLDistanceFieldA8TextGeoProc, (*this, bt)); 235 return SkNEW_ARGS(GrGLDistanceFieldA8TextGeoProc, (*this, bt));
236 } 236 }
237 237
238 /////////////////////////////////////////////////////////////////////////////// 238 ///////////////////////////////////////////////////////////////////////////////
239 239
240 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc); 240 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldA8TextGeoProc);
241 241
242 GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(SkRandom* random, 242 GrGeometryProcessor* GrDistanceFieldA8TextGeoProc::TestCreate(GrProcessorTestDat a* d) {
243 GrContext*, 243 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
244 const GrCaps&, 244 GrProcessorUnitTest::kAlphaTextureIdx;
245 GrTexture* texture s[]) {
246 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
247 GrProcessorUnitTest::kAlphaTextureIdx;
248 static const SkShader::TileMode kTileModes[] = { 245 static const SkShader::TileMode kTileModes[] = {
249 SkShader::kClamp_TileMode, 246 SkShader::kClamp_TileMode,
250 SkShader::kRepeat_TileMode, 247 SkShader::kRepeat_TileMode,
251 SkShader::kMirror_TileMode, 248 SkShader::kMirror_TileMode,
252 }; 249 };
253 SkShader::TileMode tileModes[] = { 250 SkShader::TileMode tileModes[] = {
254 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 251 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
255 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 252 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
256 }; 253 };
257 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : 254 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams:: kBilerp_FilterMode :
258 GrTextureParams::kNon e_FilterMode); 255 GrTextureParams::kNon e_FilterMode);
259 256
260 return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(random), 257 return GrDistanceFieldA8TextGeoProc::Create(GrRandomColor(d->fRandom),
261 GrTest::TestMatrix(random), 258 GrTest::TestMatrix(d->fRandom),
262 textures[texIdx], params, 259 d->fTextures[texIdx], params,
263 #ifdef SK_GAMMA_APPLY_TO_A8 260 #ifdef SK_GAMMA_APPLY_TO_A8
264 random->nextF(), 261 d->fRandom->nextF(),
265 #endif 262 #endif
266 random->nextBool() ? 263 d->fRandom->nextBool() ?
267 kSimilarity_DistanceFieldEff ectFlag : 0, 264 kSimilarity_DistanceFieldEff ectFlag : 0,
268 random->nextBool()); 265 d->fRandom->nextBool());
269 } 266 }
270 267
271 /////////////////////////////////////////////////////////////////////////////// 268 ///////////////////////////////////////////////////////////////////////////////
272 269
273 class GrGLDistanceFieldPathGeoProc : public GrGLGeometryProcessor { 270 class GrGLDistanceFieldPathGeoProc : public GrGLGeometryProcessor {
274 public: 271 public:
275 GrGLDistanceFieldPathGeoProc(const GrGeometryProcessor&, 272 GrGLDistanceFieldPathGeoProc(const GrGeometryProcessor&,
276 const GrBatchTracker&) 273 const GrBatchTracker&)
277 : fViewMatrix(SkMatrix::InvalidMatrix()) 274 : fViewMatrix(SkMatrix::InvalidMatrix())
278 , fColor(GrColor_ILLEGAL) 275 , fColor(GrColor_ILLEGAL)
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 455
459 GrGLPrimitiveProcessor* 456 GrGLPrimitiveProcessor*
460 GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG LSLCaps&) const { 457 GrDistanceFieldPathGeoProc::createGLInstance(const GrBatchTracker& bt, const GrG LSLCaps&) const {
461 return SkNEW_ARGS(GrGLDistanceFieldPathGeoProc, (*this, bt)); 458 return SkNEW_ARGS(GrGLDistanceFieldPathGeoProc, (*this, bt));
462 } 459 }
463 460
464 /////////////////////////////////////////////////////////////////////////////// 461 ///////////////////////////////////////////////////////////////////////////////
465 462
466 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc); 463 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldPathGeoProc);
467 464
468 GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(SkRandom* random, 465 GrGeometryProcessor* GrDistanceFieldPathGeoProc::TestCreate(GrProcessorTestData* d) {
469 GrContext*, 466 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
470 const GrCaps&, 467 : GrProcessorUnitTest::kAlphaTextureIdx;
471 GrTexture* textures[ ]) {
472 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx
473 : GrProcessorUnitTest::kAlphaTextureIdx;
474 static const SkShader::TileMode kTileModes[] = { 468 static const SkShader::TileMode kTileModes[] = {
475 SkShader::kClamp_TileMode, 469 SkShader::kClamp_TileMode,
476 SkShader::kRepeat_TileMode, 470 SkShader::kRepeat_TileMode,
477 SkShader::kMirror_TileMode, 471 SkShader::kMirror_TileMode,
478 }; 472 };
479 SkShader::TileMode tileModes[] = { 473 SkShader::TileMode tileModes[] = {
480 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 474 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
481 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 475 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
482 }; 476 };
483 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode 477 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams:: kBilerp_FilterMode
484 : GrTextureParams::kNon e_FilterMode); 478 : GrTextureParams:: kNone_FilterMode);
485 479
486 return GrDistanceFieldPathGeoProc::Create(GrRandomColor(random), 480 return GrDistanceFieldPathGeoProc::Create(GrRandomColor(d->fRandom),
487 GrTest::TestMatrix(random), 481 GrTest::TestMatrix(d->fRandom),
488 textures[texIdx], 482 d->fTextures[texIdx],
489 params, 483 params,
490 random->nextBool() ? 484 d->fRandom->nextBool() ?
491 kSimilarity_DistanceFieldE ffectFlag : 0, 485 kSimilarity_DistanceFieldE ffectFlag : 0,
492 random->nextBool()); 486 d->fRandom->nextBool());
493 } 487 }
494 488
495 /////////////////////////////////////////////////////////////////////////////// 489 ///////////////////////////////////////////////////////////////////////////////
496 490
497 class GrGLDistanceFieldLCDTextGeoProc : public GrGLGeometryProcessor { 491 class GrGLDistanceFieldLCDTextGeoProc : public GrGLGeometryProcessor {
498 public: 492 public:
499 GrGLDistanceFieldLCDTextGeoProc(const GrGeometryProcessor&, const GrBatchTra cker&) 493 GrGLDistanceFieldLCDTextGeoProc(const GrGeometryProcessor&, const GrBatchTra cker&)
500 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) { 494 : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL) {
501 fDistanceAdjust = GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(1. 0f, 1.0f, 1.0f); 495 fDistanceAdjust = GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(1. 0f, 1.0f, 1.0f);
502 } 496 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 GrGLPrimitiveProcessor* 712 GrGLPrimitiveProcessor*
719 GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt, 713 GrDistanceFieldLCDTextGeoProc::createGLInstance(const GrBatchTracker& bt,
720 const GrGLSLCaps&) const { 714 const GrGLSLCaps&) const {
721 return SkNEW_ARGS(GrGLDistanceFieldLCDTextGeoProc, (*this, bt)); 715 return SkNEW_ARGS(GrGLDistanceFieldLCDTextGeoProc, (*this, bt));
722 } 716 }
723 717
724 /////////////////////////////////////////////////////////////////////////////// 718 ///////////////////////////////////////////////////////////////////////////////
725 719
726 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc); 720 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrDistanceFieldLCDTextGeoProc);
727 721
728 GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(SkRandom* random, 722 GrGeometryProcessor* GrDistanceFieldLCDTextGeoProc::TestCreate(GrProcessorTestDa ta* d) {
729 GrContext*, 723 int texIdx = d->fRandom->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
730 const GrCaps&, 724 GrProcessorUnitTest::kAlphaTextureIdx;
731 GrTexture* text ures[]) {
732 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
733 GrProcessorUnitTest::kAlphaTextureIdx;
734 static const SkShader::TileMode kTileModes[] = { 725 static const SkShader::TileMode kTileModes[] = {
735 SkShader::kClamp_TileMode, 726 SkShader::kClamp_TileMode,
736 SkShader::kRepeat_TileMode, 727 SkShader::kRepeat_TileMode,
737 SkShader::kMirror_TileMode, 728 SkShader::kMirror_TileMode,
738 }; 729 };
739 SkShader::TileMode tileModes[] = { 730 SkShader::TileMode tileModes[] = {
740 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 731 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
741 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 732 kTileModes[d->fRandom->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
742 }; 733 };
743 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : 734 GrTextureParams params(tileModes, d->fRandom->nextBool() ? GrTextureParams:: kBilerp_FilterMode :
744 GrTextureParams::kNone_FilterMode); 735 GrTextureParams::kNone_FilterMode);
745 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f }; 736 DistanceAdjust wa = { 0.0f, 0.1f, -0.1f };
746 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; 737 uint32_t flags = kUseLCD_DistanceFieldEffectFlag;
747 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; 738 flags |= d->fRandom->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0;
748 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; 739 flags |= d->fRandom->nextBool() ? kBGR_DistanceFieldEffectFlag : 0;
749 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(random), 740 return GrDistanceFieldLCDTextGeoProc::Create(GrRandomColor(d->fRandom),
750 GrTest::TestMatrix(random), 741 GrTest::TestMatrix(d->fRandom),
751 textures[texIdx], params, 742 d->fTextures[texIdx], params,
752 wa, 743 wa,
753 flags, 744 flags,
754 random->nextBool()); 745 d->fRandom->nextBool());
755 } 746 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDisableColorXP.cpp ('k') | src/gpu/effects/GrDitherEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698