| OLD | NEW |
| 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 Loading... |
| 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 const GrFragmentProcessor* CircularRRectEffect::TestCreate(GrProcessorTestData*
d) { | 110 GrFragmentProcessor* CircularRRectEffect::TestCreate(GrProcessorTestData* d) { |
| 111 SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f); | 111 SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f); |
| 112 SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f); | 112 SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f); |
| 113 SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f); | 113 SkScalar r = d->fRandom->nextRangeF(kRadiusMin, 9.f); |
| 114 SkRRect rrect; | 114 SkRRect rrect; |
| 115 rrect.setRectXY(SkRect::MakeWH(w, h), r, r); | 115 rrect.setRectXY(SkRect::MakeWH(w, h), r, r); |
| 116 GrFragmentProcessor* fp; | 116 GrFragmentProcessor* fp; |
| 117 do { | 117 do { |
| 118 GrPrimitiveEdgeType et = | 118 GrPrimitiveEdgeType et = |
| 119 (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeT
ypeCnt); | 119 (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeT
ypeCnt); |
| 120 fp = GrRRectEffect::Create(et, rrect); | 120 fp = GrRRectEffect::Create(et, rrect); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 425 |
| 426 bool EllipticalRRectEffect::onIsEqual(const GrFragmentProcessor& other) const { | 426 bool EllipticalRRectEffect::onIsEqual(const GrFragmentProcessor& other) const { |
| 427 const EllipticalRRectEffect& erre = other.cast<EllipticalRRectEffect>(); | 427 const EllipticalRRectEffect& erre = other.cast<EllipticalRRectEffect>(); |
| 428 return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect; | 428 return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect; |
| 429 } | 429 } |
| 430 | 430 |
| 431 ////////////////////////////////////////////////////////////////////////////// | 431 ////////////////////////////////////////////////////////////////////////////// |
| 432 | 432 |
| 433 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect); | 433 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipticalRRectEffect); |
| 434 | 434 |
| 435 const GrFragmentProcessor* EllipticalRRectEffect::TestCreate(GrProcessorTestData
* d) { | 435 GrFragmentProcessor* EllipticalRRectEffect::TestCreate(GrProcessorTestData* d) { |
| 436 SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f); | 436 SkScalar w = d->fRandom->nextRangeScalar(20.f, 1000.f); |
| 437 SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f); | 437 SkScalar h = d->fRandom->nextRangeScalar(20.f, 1000.f); |
| 438 SkVector r[4]; | 438 SkVector r[4]; |
| 439 r[SkRRect::kUpperLeft_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9.f); | 439 r[SkRRect::kUpperLeft_Corner].fX = d->fRandom->nextRangeF(kRadiusMin, 9.f); |
| 440 // ensure at least one corner really is elliptical | 440 // ensure at least one corner really is elliptical |
| 441 do { | 441 do { |
| 442 r[SkRRect::kUpperLeft_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9.
f); | 442 r[SkRRect::kUpperLeft_Corner].fY = d->fRandom->nextRangeF(kRadiusMin, 9.
f); |
| 443 } while (r[SkRRect::kUpperLeft_Corner].fY == r[SkRRect::kUpperLeft_Corner].f
X); | 443 } while (r[SkRRect::kUpperLeft_Corner].fY == r[SkRRect::kUpperLeft_Corner].f
X); |
| 444 | 444 |
| 445 SkRRect rrect; | 445 SkRRect rrect; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 if (rrect.isNinePatch()) { | 711 if (rrect.isNinePatch()) { |
| 712 return EllipticalRRectEffect::Create(edgeType, rrect); | 712 return EllipticalRRectEffect::Create(edgeType, rrect); |
| 713 } | 713 } |
| 714 return nullptr; | 714 return nullptr; |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 } | 717 } |
| 718 | 718 |
| 719 return nullptr; | 719 return nullptr; |
| 720 } | 720 } |
| OLD | NEW |