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

Side by Side Diff: src/gpu/effects/GrConvexPolyEffect.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/GrConstColorProcessor.cpp ('k') | src/gpu/effects/GrConvolutionEffect.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 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
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
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 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConstColorProcessor.cpp ('k') | src/gpu/effects/GrConvolutionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698