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 "GrOvalEffect.h" | 8 #include "GrOvalEffect.h" |
9 | 9 |
10 #include "GrFragmentProcessor.h" | 10 #include "GrFragmentProcessor.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 bool CircleEffect::onIsEqual(const GrFragmentProcessor& other) const { | 69 bool CircleEffect::onIsEqual(const GrFragmentProcessor& other) const { |
70 const CircleEffect& ce = other.cast<CircleEffect>(); | 70 const CircleEffect& ce = other.cast<CircleEffect>(); |
71 return fEdgeType == ce.fEdgeType && fCenter == ce.fCenter && fRadius == ce.f
Radius; | 71 return fEdgeType == ce.fEdgeType && fCenter == ce.fCenter && fRadius == ce.f
Radius; |
72 } | 72 } |
73 | 73 |
74 ////////////////////////////////////////////////////////////////////////////// | 74 ////////////////////////////////////////////////////////////////////////////// |
75 | 75 |
76 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleEffect); | 76 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(CircleEffect); |
77 | 77 |
78 GrFragmentProcessor* CircleEffect::TestCreate(GrProcessorTestData* d) { | 78 const GrFragmentProcessor* CircleEffect::TestCreate(GrProcessorTestData* d) { |
79 SkPoint center; | 79 SkPoint center; |
80 center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f); | 80 center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f); |
81 center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f); | 81 center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f); |
82 SkScalar radius = d->fRandom->nextRangeF(0.f, 1000.f); | 82 SkScalar radius = d->fRandom->nextRangeF(0.f, 1000.f); |
83 GrPrimitiveEdgeType et; | 83 GrPrimitiveEdgeType et; |
84 do { | 84 do { |
85 et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeType
Cnt); | 85 et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeType
Cnt); |
86 } while (kHairlineAA_GrProcessorEdgeType == et); | 86 } while (kHairlineAA_GrProcessorEdgeType == et); |
87 return CircleEffect::Create(et, center, radius); | 87 return CircleEffect::Create(et, center, radius); |
88 } | 88 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 bool EllipseEffect::onIsEqual(const GrFragmentProcessor& other) const { | 239 bool EllipseEffect::onIsEqual(const GrFragmentProcessor& other) const { |
240 const EllipseEffect& ee = other.cast<EllipseEffect>(); | 240 const EllipseEffect& ee = other.cast<EllipseEffect>(); |
241 return fEdgeType == ee.fEdgeType && fCenter == ee.fCenter && fRadii == ee.fR
adii; | 241 return fEdgeType == ee.fEdgeType && fCenter == ee.fCenter && fRadii == ee.fR
adii; |
242 } | 242 } |
243 | 243 |
244 ////////////////////////////////////////////////////////////////////////////// | 244 ////////////////////////////////////////////////////////////////////////////// |
245 | 245 |
246 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipseEffect); | 246 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(EllipseEffect); |
247 | 247 |
248 GrFragmentProcessor* EllipseEffect::TestCreate(GrProcessorTestData* d) { | 248 const GrFragmentProcessor* EllipseEffect::TestCreate(GrProcessorTestData* d) { |
249 SkPoint center; | 249 SkPoint center; |
250 center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f); | 250 center.fX = d->fRandom->nextRangeScalar(0.f, 1000.f); |
251 center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f); | 251 center.fY = d->fRandom->nextRangeScalar(0.f, 1000.f); |
252 SkScalar rx = d->fRandom->nextRangeF(0.f, 1000.f); | 252 SkScalar rx = d->fRandom->nextRangeF(0.f, 1000.f); |
253 SkScalar ry = d->fRandom->nextRangeF(0.f, 1000.f); | 253 SkScalar ry = d->fRandom->nextRangeF(0.f, 1000.f); |
254 GrPrimitiveEdgeType et; | 254 GrPrimitiveEdgeType et; |
255 do { | 255 do { |
256 et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeType
Cnt); | 256 et = (GrPrimitiveEdgeType)d->fRandom->nextULessThan(kGrProcessorEdgeType
Cnt); |
257 } while (kHairlineAA_GrProcessorEdgeType == et); | 257 } while (kHairlineAA_GrProcessorEdgeType == et); |
258 return EllipseEffect::Create(et, center, rx, ry); | 258 return EllipseEffect::Create(et, center, rx, ry); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 w /= 2; | 368 w /= 2; |
369 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval
.fTop + w), w); | 369 return CircleEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, oval
.fTop + w), w); |
370 } else { | 370 } else { |
371 w /= 2; | 371 w /= 2; |
372 h /= 2; | 372 h /= 2; |
373 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova
l.fTop + h), w, h); | 373 return EllipseEffect::Create(edgeType, SkPoint::Make(oval.fLeft + w, ova
l.fTop + h), w, h); |
374 } | 374 } |
375 | 375 |
376 return nullptr; | 376 return nullptr; |
377 } | 377 } |
OLD | NEW |