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

Side by Side Diff: src/gpu/effects/GrRRectEffect.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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "GrRRectEffect.h" 8 #include "GrRRectEffect.h"
9 9
10 #include "GrConvexPolyEffect.h" 10 #include "GrConvexPolyEffect.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 bool CircularRRectEffect::onIsEqual(const GrFragmentProcessor& other) const { 100 bool CircularRRectEffect::onIsEqual(const GrFragmentProcessor& other) const {
101 const CircularRRectEffect& crre = other.cast<CircularRRectEffect>(); 101 const CircularRRectEffect& crre = other.cast<CircularRRectEffect>();
102 // The corner flags are derived from fRRect, so no need to check them. 102 // The corner flags are derived from fRRect, so no need to check them.
103 return fEdgeType == crre.fEdgeType && fRRect == crre.fRRect; 103 return fEdgeType == crre.fEdgeType && fRRect == crre.fRRect;
104 } 104 }
105 105
106 ////////////////////////////////////////////////////////////////////////////// 106 //////////////////////////////////////////////////////////////////////////////
107 107
108 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircularRRectEffect); 108 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircularRRectEffect);
109 109
110 GrFragmentProcessor* CircularRRectEffect::TestCreate(SkRandom* random, 110 GrFragmentProcessor* CircularRRectEffect::TestCreate(GrProcessorTestData* d) {
111 GrContext*, 111 SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
112 const GrCaps& caps, 112 SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
113 GrTexture*[]) { 113 SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f);
114 SkScalar w = random->nextRangeScalar(20.f, 1000.f);
115 SkScalar h = random->nextRangeScalar(20.f, 1000.f);
116 SkScalar r = random->nextRangeF(kRadiusMin, 9.f);
117 SkRRect rrect; 114 SkRRect rrect;
118 rrect.setRectXY(SkRect::MakeWH(w, h), r, r); 115 rrect.setRectXY(SkRect::MakeWH(w, h), r, r);
119 GrFragmentProcessor* fp; 116 GrFragmentProcessor* fp;
120 do { 117 do {
121 GrPrimitiveEdgeType et = 118 GrPrimitiveEdgeType et =
122 (GrPrimitiveEdgeType)random->nextULessThan(kGrProcessorEdgeTypeC nt); 119 (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeT ypeCnt);
123 fp = GrRRectEffect::Create(et, rrect); 120 fp = GrRRectEffect::Create(et, rrect);
124 } while (NULL == fp); 121 } while (NULL == fp);
125 return fp; 122 return fp;
126 } 123 }
127 124
128 ////////////////////////////////////////////////////////////////////////////// 125 //////////////////////////////////////////////////////////////////////////////
129 126
130 class GLCircularRRectEffect : public GrGLFragmentProcessor { 127 class GLCircularRRectEffect : public GrGLFragmentProcessor {
131 public: 128 public:
132 GLCircularRRectEffect(const GrProcessor&); 129 GLCircularRRectEffect(const GrProcessor&);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 434
438 bool EllipticalRRectEffect::onIsEqual(const GrFragmentProcessor& other) const { 435 bool EllipticalRRectEffect::onIsEqual(const GrFragmentProcessor& other) const {
439 const EllipticalRRectEffect& erre = other.cast<EllipticalRRectEffect>(); 436 const EllipticalRRectEffect& erre = other.cast<EllipticalRRectEffect>();
440 return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect; 437 return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect;
441 } 438 }
442 439
443 ////////////////////////////////////////////////////////////////////////////// 440 //////////////////////////////////////////////////////////////////////////////
444 441
445 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect); 442 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect);
446 443
447 GrFragmentProcessor* EllipticalRRectEffect::TestCreate(SkRandom* random, 444 GrFragmentProcessor* EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) {
448 GrContext*, 445 SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f);
449 const GrCaps& caps, 446 SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f);
450 GrTexture*[]) {
451 SkScalar w = random->nextRangeScalar(20.f, 1000.f);
452 SkScalar h = random->nextRangeScalar(20.f, 1000.f);
453 SkVector r[4]; 447 SkVector r[4];
454 r[SkRRect::kUpperLeft_Corner].fX = random->nextRangeF(kRadiusMin, 9.f); 448 r[SkRRect::kUpperLeft_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9.f);
455 // ensure at least one corner really is elliptical 449 // ensure at least one corner really is elliptical
456 do { 450 do {
457 r[SkRRect::kUpperLeft_Corner].fY = random->nextRangeF(kRadiusMin, 9.f); 451 r[SkRRect::kUpperLeft_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9. f);
458 } while (r[SkRRect::kUpperLeft_Corner].fY == r[SkRRect::kUpperLeft_Corner].f X); 452 } while (r[SkRRect::kUpperLeft_Corner].fY == r[SkRRect::kUpperLeft_Corner].f X);
459 453
460 SkRRect rrect; 454 SkRRect rrect;
461 if (random->nextBool()) { 455 if (d->fRandom->nextBool()) {
462 // half the time create a four-radii rrect. 456 // half the time create a four-radii rrect.
463 r[SkRRect::kLowerRight_Corner].fX = random->nextRangeF(kRadiusMin, 9.f); 457 r[SkRRect::kLowerRight_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9 .f);
464 r[SkRRect::kLowerRight_Corner].fY = random->nextRangeF(kRadiusMin, 9.f); 458 r[SkRRect::kLowerRight_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9 .f);
465 459
466 r[SkRRect::kUpperRight_Corner].fX = r[SkRRect::kLowerRight_Corner].fX; 460 r[SkRRect::kUpperRight_Corner].fX = r[SkRRect::kLowerRight_Corner].fX;
467 r[SkRRect::kUpperRight_Corner].fY = r[SkRRect::kUpperLeft_Corner].fY; 461 r[SkRRect::kUpperRight_Corner].fY = r[SkRRect::kUpperLeft_Corner].fY;
468 462
469 r[SkRRect::kLowerLeft_Corner].fX = r[SkRRect::kUpperLeft_Corner].fX; 463 r[SkRRect::kLowerLeft_Corner].fX = r[SkRRect::kUpperLeft_Corner].fX;
470 r[SkRRect::kLowerLeft_Corner].fY = r[SkRRect::kLowerRight_Corner].fY; 464 r[SkRRect::kLowerLeft_Corner].fY = r[SkRRect::kLowerRight_Corner].fY;
471 465
472 rrect.setRectRadii(SkRect::MakeWH(w, h), r); 466 rrect.setRectRadii(SkRect::MakeWH(w, h), r);
473 } else { 467 } else {
474 rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX, 468 rrect.setRectXY(SkRect::MakeWH(w, h), r[SkRRect::kUpperLeft_Corner].fX,
475 r[SkRRect::kUpperLeft_Corner].fY); 469 r[SkRRect::kUpperLeft_Corner].fY);
476 } 470 }
477 GrFragmentProcessor* fp; 471 GrFragmentProcessor* fp;
478 do { 472 do {
479 GrPrimitiveEdgeType et = (GrPrimitiveEdgeType)random->nextULessThan(kGrP rocessorEdgeTypeCnt); 473 GrPrimitiveEdgeType et =
474 (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeT ypeCnt);
480 fp = GrRRectEffect::Create(et, rrect); 475 fp = GrRRectEffect::Create(et, rrect);
481 } while (NULL == fp); 476 } while (NULL == fp);
482 return fp; 477 return fp;
483 } 478 }
484 479
485 ////////////////////////////////////////////////////////////////////////////// 480 //////////////////////////////////////////////////////////////////////////////
486 481
487 class GLEllipticalRRectEffect : public GrGLFragmentProcessor { 482 class GLEllipticalRRectEffect : public GrGLFragmentProcessor {
488 public: 483 public:
489 GLEllipticalRRectEffect(const GrProcessor&); 484 GLEllipticalRRectEffect(const GrProcessor&);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 if (rrect.isNinePatch()) { 727 if (rrect.isNinePatch()) {
733 return EllipticalRRectEffect::Create(edgeType, rrect); 728 return EllipticalRRectEffect::Create(edgeType, rrect);
734 } 729 }
735 return NULL; 730 return NULL;
736 } 731 }
737 } 732 }
738 } 733 }
739 734
740 return NULL; 735 return NULL;
741 } 736 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrPorterDuffXferProcessor.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698