| 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 "GrTestUtils.h" | 11 #include "GrTestUtils.h" |
| 12 #include "SkTArray.h" | 12 #include "SkTArray.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 struct GrProcessorTestData; | 19 struct GrProcessorTestData; |
| 19 | 20 |
| 20 namespace GrProcessorUnitTest { | 21 namespace GrProcessorUnitTest { |
| 21 | 22 |
| 22 // Used to access the dummy textures in TestCreate procs. | 23 // Used to access the dummy textures in TestCreate procs. |
| 23 enum { | 24 enum { |
| 24 kSkiaPMTextureIdx = 0, | 25 kSkiaPMTextureIdx = 0, |
| 25 kAlphaTextureIdx = 1, | 26 kAlphaTextureIdx = 1, |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 /** 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 |
| 29 creating an unbounded FP tree which may overflow various shader limits. */ | 30 creating an unbounded FP tree which may overflow various shader limits. */ |
| 30 const GrFragmentProcessor* CreateChildFP(GrProcessorTestData*); | 31 const GrFragmentProcessor* CreateChildFP(GrProcessorTestData*); |
| 31 | 32 |
| 32 } | 33 } |
| 33 | 34 |
| 34 /* | 35 /* |
| 35 * GrProcessorTestData is an argument struct to TestCreate functions | 36 * GrProcessorTestData is an argument struct to TestCreate functions |
| 36 * fTextures are valid textures that can optionally be used to construct | 37 * fTextures are valid textures that can optionally be used to construct |
| 37 * 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 |
| 38 * 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 |
| 39 * the GrContext. | 40 * the GrContext. |
| 40 */ | 41 */ |
| 41 struct GrProcessorTestData { | 42 struct GrProcessorTestData { |
| 42 GrProcessorTestData(SkRandom* random, | 43 GrProcessorTestData(SkRandom* random, |
| 43 GrContext* context, | 44 GrContext* context, |
| 44 const GrCaps* caps, | 45 const GrCaps* caps, |
| 46 const GrRenderTarget* rt, |
| 45 GrTexture* textures[2]) | 47 GrTexture* textures[2]) |
| 46 : fRandom(random) | 48 : fRandom(random) |
| 47 , fContext(context) | 49 , fContext(context) |
| 48 , fCaps(caps) { | 50 , fCaps(caps) |
| 51 , fRenderTarget(rt) { |
| 49 fTextures[0] = textures[0]; | 52 fTextures[0] = textures[0]; |
| 50 fTextures[1] = textures[1]; | 53 fTextures[1] = textures[1]; |
| 51 } | 54 } |
| 52 SkRandom* fRandom; | 55 SkRandom* fRandom; |
| 53 GrContext* fContext; | 56 GrContext* fContext; |
| 54 const GrCaps* fCaps; | 57 const GrCaps* fCaps; |
| 58 const GrRenderTarget* fRenderTarget; |
| 55 GrTexture* fTextures[2]; | 59 GrTexture* fTextures[2]; |
| 56 }; | 60 }; |
| 57 | 61 |
| 58 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 62 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 59 | 63 |
| 60 class GrProcessor; | 64 class GrProcessor; |
| 61 class GrTexture; | 65 class GrTexture; |
| 62 | 66 |
| 63 template <class Processor> class GrProcessorTestFactory : SkNoncopyable { | 67 template <class Processor> class GrProcessorTestFactory : SkNoncopyable { |
| 64 public: | 68 public: |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 #define GR_DEFINE_XP_FACTORY_TEST(X) | 144 #define GR_DEFINE_XP_FACTORY_TEST(X) |
| 141 | 145 |
| 142 // 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 |
| 143 // its definitions will compile. | 147 // its definitions will compile. |
| 144 #define GR_DECLARE_GEOMETRY_PROCESSOR_TEST
\ | 148 #define GR_DECLARE_GEOMETRY_PROCESSOR_TEST
\ |
| 145 static const GrGeometryProcessor* TestCreate(GrProcessorTestData*) | 149 static const GrGeometryProcessor* TestCreate(GrProcessorTestData*) |
| 146 #define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X) | 150 #define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X) |
| 147 | 151 |
| 148 #endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS | 152 #endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS |
| 149 #endif | 153 #endif |
| OLD | NEW |