| 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 "GrConvexPolyEffect.h" | 8 #include "GrConvexPolyEffect.h" |
| 9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
| 10 #include "SkPathPriv.h" | 10 #include "SkPathPriv.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 GrPrimitiveEdgeType fEdgeType; | 53 GrPrimitiveEdgeType fEdgeType; |
| 54 | 54 |
| 55 typedef GrFragmentProcessor INHERITED; | 55 typedef GrFragmentProcessor INHERITED; |
| 56 | 56 |
| 57 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 57 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 58 | 58 |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect); | 61 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AARectEffect); |
| 62 | 62 |
| 63 GrFragmentProcessor* AARectEffect::TestCreate(SkRandom* random, | 63 GrFragmentProcessor* AARectEffect::TestCreate(GrProcessorTestData* d) { |
| 64 GrContext*, | 64 SkRect rect = SkRect::MakeLTRB(d->fRandom->nextSScalar1(), |
| 65 const GrCaps& caps, | 65 d->fRandom->nextSScalar1(), |
| 66 GrTexture*[]) { | 66 d->fRandom->nextSScalar1(), |
| 67 SkRect rect = SkRect::MakeLTRB(random->nextSScalar1(), | 67 d->fRandom->nextSScalar1()); |
| 68 random->nextSScalar1(), | |
| 69 random->nextSScalar1(), | |
| 70 random->nextSScalar1()); | |
| 71 GrFragmentProcessor* fp; | 68 GrFragmentProcessor* fp; |
| 72 do { | 69 do { |
| 73 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>(random->
nextULessThan( | 70 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
| 74 kGrProcessor
EdgeTypeCnt)); | 71 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); |
| 75 | 72 |
| 76 fp = AARectEffect::Create(edgeType, rect); | 73 fp = AARectEffect::Create(edgeType, rect); |
| 77 } while (NULL == fp); | 74 } while (NULL == fp); |
| 78 return fp; | 75 return fp; |
| 79 } | 76 } |
| 80 | 77 |
| 81 ////////////////////////////////////////////////////////////////////////////// | 78 ////////////////////////////////////////////////////////////////////////////// |
| 82 | 79 |
| 83 class GLAARectEffect : public GrGLFragmentProcessor { | 80 class GLAARectEffect : public GrGLFragmentProcessor { |
| 84 public: | 81 public: |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 const GrConvexPolyEffect& cpe = other.cast<GrConvexPolyEffect>(); | 350 const GrConvexPolyEffect& cpe = other.cast<GrConvexPolyEffect>(); |
| 354 // ignore the fact that 0 == -0 and just use memcmp. | 351 // ignore the fact that 0 == -0 and just use memcmp. |
| 355 return (cpe.fEdgeType == fEdgeType && cpe.fEdgeCount == fEdgeCount && | 352 return (cpe.fEdgeType == fEdgeType && cpe.fEdgeCount == fEdgeCount && |
| 356 0 == memcmp(cpe.fEdges, fEdges, 3 * fEdgeCount * sizeof(SkScalar))); | 353 0 == memcmp(cpe.fEdges, fEdges, 3 * fEdgeCount * sizeof(SkScalar))); |
| 357 } | 354 } |
| 358 | 355 |
| 359 ////////////////////////////////////////////////////////////////////////////// | 356 ////////////////////////////////////////////////////////////////////////////// |
| 360 | 357 |
| 361 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect); | 358 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConvexPolyEffect); |
| 362 | 359 |
| 363 GrFragmentProcessor* GrConvexPolyEffect::TestCreate(SkRandom* random, | 360 GrFragmentProcessor* GrConvexPolyEffect::TestCreate(GrProcessorTestData* d) { |
| 364 GrContext*, | 361 int count = d->fRandom->nextULessThan(kMaxEdges) + 1; |
| 365 const GrCaps& caps, | |
| 366 GrTexture*[]) { | |
| 367 int count = random->nextULessThan(kMaxEdges) + 1; | |
| 368 SkScalar edges[kMaxEdges * 3]; | 362 SkScalar edges[kMaxEdges * 3]; |
| 369 for (int i = 0; i < 3 * count; ++i) { | 363 for (int i = 0; i < 3 * count; ++i) { |
| 370 edges[i] = random->nextSScalar1(); | 364 edges[i] = d->fRandom->nextSScalar1(); |
| 371 } | 365 } |
| 372 | 366 |
| 373 GrFragmentProcessor* fp; | 367 GrFragmentProcessor* fp; |
| 374 do { | 368 do { |
| 375 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 369 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
| 376 random->nextULessThan(kGrProcessorEdgeTy
peCnt)); | 370 d->fRandom->nextULessThan(kGrProcessorEdgeTypeCnt)); |
| 377 fp = GrConvexPolyEffect::Create(edgeType, count, edges); | 371 fp = GrConvexPolyEffect::Create(edgeType, count, edges); |
| 378 } while (NULL == fp); | 372 } while (NULL == fp); |
| 379 return fp; | 373 return fp; |
| 380 } | 374 } |
| OLD | NEW |