OLD | NEW |
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 GrProcessorUnitTest_DEFINED | 8 #ifndef GrProcessorUnitTest_DEFINED |
9 #define GrProcessorUnitTest_DEFINED | 9 #define GrProcessorUnitTest_DEFINED |
10 | 10 |
11 #include "../private/SkTArray.h" | 11 #include "../private/SkTArray.h" |
12 #include "GrTestUtils.h" | 12 #include "GrTestUtils.h" |
13 #include "SkTypes.h" | 13 #include "SkTypes.h" |
14 | 14 |
15 class SkMatrix; | 15 class SkMatrix; |
16 class GrCaps; | 16 class GrCaps; |
17 class GrContext; | 17 class GrContext; |
18 class GrRenderTarget; | 18 class GrDrawContext; |
19 struct GrProcessorTestData; | 19 struct GrProcessorTestData; |
20 | 20 |
21 namespace GrProcessorUnitTest { | 21 namespace GrProcessorUnitTest { |
22 | 22 |
23 // Used to access the dummy textures in TestCreate procs. | 23 // Used to access the dummy textures in TestCreate procs. |
24 enum { | 24 enum { |
25 kSkiaPMTextureIdx = 0, | 25 kSkiaPMTextureIdx = 0, |
26 kAlphaTextureIdx = 1, | 26 kAlphaTextureIdx = 1, |
27 }; | 27 }; |
28 | 28 |
29 /** This allows parent FPs to implement a test create with known leaf children i
n order to avoid | 29 /** This allows parent FPs to implement a test create with known leaf children i
n order to avoid |
30 creating an unbounded FP tree which may overflow various shader limits. */ | 30 creating an unbounded FP tree which may overflow various shader limits. */ |
31 const GrFragmentProcessor* CreateChildFP(GrProcessorTestData*); | 31 const GrFragmentProcessor* CreateChildFP(GrProcessorTestData*); |
32 | 32 |
33 } | 33 } |
34 | 34 |
35 /* | 35 /* |
36 * GrProcessorTestData is an argument struct to TestCreate functions | 36 * GrProcessorTestData is an argument struct to TestCreate functions |
37 * fTextures are valid textures that can optionally be used to construct | 37 * fTextures are valid textures that can optionally be used to construct |
38 * GrTextureAccesses. The first texture has config kSkia8888_GrPixelConfig and t
he second has | 38 * GrTextureAccesses. The first texture has config kSkia8888_GrPixelConfig and t
he second has |
39 * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create addition
al textures using | 39 * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create addition
al textures using |
40 * the GrContext. | 40 * the GrContext. |
41 */ | 41 */ |
42 struct GrProcessorTestData { | 42 struct GrProcessorTestData { |
43 GrProcessorTestData(SkRandom* random, | 43 GrProcessorTestData(SkRandom* random, |
44 GrContext* context, | 44 GrContext* context, |
45 const GrCaps* caps, | 45 const GrCaps* caps, |
46 const GrRenderTarget* rt, | 46 const GrDrawContext* drawContext, |
47 GrTexture* textures[2]) | 47 GrTexture* textures[2]) |
48 : fRandom(random) | 48 : fRandom(random) |
49 , fContext(context) | 49 , fContext(context) |
50 , fCaps(caps) | 50 , fCaps(caps) |
51 , fRenderTarget(rt) { | 51 , fDrawContext(drawContext) { |
52 fTextures[0] = textures[0]; | 52 fTextures[0] = textures[0]; |
53 fTextures[1] = textures[1]; | 53 fTextures[1] = textures[1]; |
54 } | 54 } |
55 SkRandom* fRandom; | 55 SkRandom* fRandom; |
56 GrContext* fContext; | 56 GrContext* fContext; |
57 const GrCaps* fCaps; | 57 const GrCaps* fCaps; |
58 const GrRenderTarget* fRenderTarget; | 58 const GrDrawContext* fDrawContext; |
59 GrTexture* fTextures[2]; | 59 GrTexture* fTextures[2]; |
60 }; | 60 }; |
61 | 61 |
62 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 62 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
63 | 63 |
64 class GrProcessor; | 64 class GrProcessor; |
65 class GrTexture; | 65 class GrTexture; |
66 | 66 |
67 template <class Processor> class GrProcessorTestFactory : SkNoncopyable { | 67 template <class Processor> class GrProcessorTestFactory : SkNoncopyable { |
68 public: | 68 public: |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 #define GR_DEFINE_XP_FACTORY_TEST(X) | 144 #define GR_DEFINE_XP_FACTORY_TEST(X) |
145 | 145 |
146 // The unit test relies on static initializers. Just declare the TestCreate func
tion so that | 146 // The unit test relies on static initializers. Just declare the TestCreate func
tion so that |
147 // its definitions will compile. | 147 // its definitions will compile. |
148 #define GR_DECLARE_GEOMETRY_PROCESSOR_TEST
\ | 148 #define GR_DECLARE_GEOMETRY_PROCESSOR_TEST
\ |
149 static const GrGeometryProcessor* TestCreate(GrProcessorTestData*) | 149 static const GrGeometryProcessor* TestCreate(GrProcessorTestData*) |
150 #define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X) | 150 #define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X) |
151 | 151 |
152 #endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 152 #endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
153 #endif | 153 #endif |
OLD | NEW |