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

Side by Side Diff: include/gpu/GrEffectUnitTest.h

Issue 23576015: Change old PRG to be SkLCGRandom; change new one to SkRandom (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix some spurious SkMWCRandoms Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « gm/strokes.cpp ('k') | include/utils/SkRandom.h » ('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 2012 Google Inc. 2 * Copyright 2012 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 #ifndef GrEffectUnitTest_DEFINED 8 #ifndef GrEffectUnitTest_DEFINED
9 #define GrEffectUnitTest_DEFINED 9 #define GrEffectUnitTest_DEFINED
10 10
11 #include "GrNoncopyable.h" 11 #include "GrNoncopyable.h"
12 #include "SkRandom.h" 12 #include "SkRandom.h"
13 #include "SkTArray.h" 13 #include "SkTArray.h"
14 14
15 class SkMatrix; 15 class SkMatrix;
16 class GrDrawTargetCaps; 16 class GrDrawTargetCaps;
17 17
18 namespace GrEffectUnitTest { 18 namespace GrEffectUnitTest {
19 // Used to access the dummy textures in TestCreate procs. 19 // Used to access the dummy textures in TestCreate procs.
20 enum { 20 enum {
21 kSkiaPMTextureIdx = 0, 21 kSkiaPMTextureIdx = 0,
22 kAlphaTextureIdx = 1, 22 kAlphaTextureIdx = 1,
23 }; 23 };
24 24
25 /** 25 /**
26 * A helper for use in GrEffect::TestCreate functions. 26 * A helper for use in GrEffect::TestCreate functions.
27 */ 27 */
28 const SkMatrix& TestMatrix(SkMWCRandom*); 28 const SkMatrix& TestMatrix(SkRandom*);
29 29
30 } 30 }
31 31
32 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 32 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
33 33
34 class GrContext; 34 class GrContext;
35 class GrEffectRef; 35 class GrEffectRef;
36 class GrTexture; 36 class GrTexture;
37 37
38 class GrEffectTestFactory : GrNoncopyable { 38 class GrEffectTestFactory : GrNoncopyable {
39 public: 39 public:
40 40
41 typedef GrEffectRef* (*CreateProc)(SkMWCRandom*, 41 typedef GrEffectRef* (*CreateProc)(SkRandom*,
42 GrContext*, 42 GrContext*,
43 const GrDrawTargetCaps& caps, 43 const GrDrawTargetCaps& caps,
44 GrTexture* dummyTextures[]); 44 GrTexture* dummyTextures[]);
45 45
46 GrEffectTestFactory(CreateProc createProc) { 46 GrEffectTestFactory(CreateProc createProc) {
47 fCreateProc = createProc; 47 fCreateProc = createProc;
48 GetFactories()->push_back(this); 48 GetFactories()->push_back(this);
49 } 49 }
50 50
51 static GrEffectRef* CreateStage(SkMWCRandom* random, 51 static GrEffectRef* CreateStage(SkRandom* random,
52 GrContext* context, 52 GrContext* context,
53 const GrDrawTargetCaps& caps, 53 const GrDrawTargetCaps& caps,
54 GrTexture* dummyTextures[]) { 54 GrTexture* dummyTextures[]) {
55 uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1); 55 uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1);
56 GrEffectTestFactory* factory = (*GetFactories())[idx]; 56 GrEffectTestFactory* factory = (*GetFactories())[idx];
57 return factory->fCreateProc(random, context, caps, dummyTextures); 57 return factory->fCreateProc(random, context, caps, dummyTextures);
58 } 58 }
59 59
60 private: 60 private:
61 CreateProc fCreateProc; 61 CreateProc fCreateProc;
62 static SkTArray<GrEffectTestFactory*, true>* GetFactories(); 62 static SkTArray<GrEffectTestFactory*, true>* GetFactories();
63 }; 63 };
64 64
65 /** GrEffect subclasses should insert this macro in their declaration to be incl uded in the 65 /** GrEffect subclasses should insert this macro in their declaration to be incl uded in the
66 * program generation unit test. 66 * program generation unit test.
67 */ 67 */
68 #define GR_DECLARE_EFFECT_TEST \ 68 #define GR_DECLARE_EFFECT_TEST \
69 static GrEffectTestFactory gTestFactory; \ 69 static GrEffectTestFactory gTestFactory; \
70 static GrEffectRef* TestCreate(SkMWCRandom*, \ 70 static GrEffectRef* TestCreate(SkRandom*, \
71 GrContext*, \ 71 GrContext*, \
72 const GrDrawTargetCaps&, \ 72 const GrDrawTargetCaps&, \
73 GrTexture* dummyTextures[2]) 73 GrTexture* dummyTextures[2])
74 74
75 /** GrEffect subclasses should insert this macro in their implementation file. T hey must then 75 /** GrEffect subclasses should insert this macro in their implementation file. T hey must then
76 * also implement this static function: 76 * also implement this static function:
77 * GrEffect* TestCreate(SkMWCRandom*, 77 * GrEffect* TestCreate(SkRandom*,
78 * GrContext*, 78 * GrContext*,
79 * const GrDrawTargetCaps&, 79 * const GrDrawTargetCaps&,
80 * GrTexture* dummyTextures[2]); 80 * GrTexture* dummyTextures[2]);
81 * dummyTextures[] are valid textures that can optionally be used to construct G rTextureAccesses. 81 * dummyTextures[] are valid textures that can optionally be used to construct G rTextureAccesses.
82 * The first texture has config kSkia8888_GrPixelConfig and the second has 82 * The first texture has config kSkia8888_GrPixelConfig and the second has
83 * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create addition al textures using 83 * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create addition al textures using
84 * the GrContext. 84 * the GrContext.
85 */ 85 */
86 #define GR_DEFINE_EFFECT_TEST(Effect) \ 86 #define GR_DEFINE_EFFECT_TEST(Effect) \
87 GrEffectTestFactory Effect :: gTestFactory(Effect :: TestCreate) 87 GrEffectTestFactory Effect :: gTestFactory(Effect :: TestCreate)
88 88
89 #else // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 89 #else // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
90 90
91 // The unit test relies on static initializers. Just declare the TestCreate func tion so that 91 // The unit test relies on static initializers. Just declare the TestCreate func tion so that
92 // its definitions will compile. 92 // its definitions will compile.
93 #define GR_DECLARE_EFFECT_TEST \ 93 #define GR_DECLARE_EFFECT_TEST \
94 static GrEffectRef* TestCreate(SkMWCRandom*, \ 94 static GrEffectRef* TestCreate(SkRandom*, \
95 GrContext*, \ 95 GrContext*, \
96 const GrDrawTargetCaps&, \ 96 const GrDrawTargetCaps&, \
97 GrTexture* dummyTextures[2]) 97 GrTexture* dummyTextures[2])
98 #define GR_DEFINE_EFFECT_TEST(X) 98 #define GR_DEFINE_EFFECT_TEST(X)
99 99
100 #endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 100 #endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
101 #endif 101 #endif
OLDNEW
« no previous file with comments | « gm/strokes.cpp ('k') | include/utils/SkRandom.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698