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

Unified Diff: include/gpu/GrProcessorUnitTest.h

Issue 1213623022: fix up test create functions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment updated 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/effects/SkAlphaThresholdFilter.cpp » ('j') | src/effects/SkAlphaThresholdFilter.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrProcessorUnitTest.h
diff --git a/include/gpu/GrProcessorUnitTest.h b/include/gpu/GrProcessorUnitTest.h
index 13b6fc07564295019950f1bfb7c8d762edebf36d..d8675484369964d62c0f96983c9b20586a9999f9 100644
--- a/include/gpu/GrProcessorUnitTest.h
+++ b/include/gpu/GrProcessorUnitTest.h
@@ -30,29 +30,48 @@ class GrContext;
class GrProcessor;
class GrTexture;
+/*
+ * GrProcessorTestData is an argument struct to TestCreate functions
+ * GrTexture* fTextures[2] are valid textures that can optionally be used to construct
+ * GrTextureAccesses. The first texture has config kSkia8888_GrPixelConfig and the second has
+ * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create additional textures using
+ * the GrContext.
+ */
+struct GrProcessorTestData {
+ GrProcessorTestData(SkRandom* random,
+ GrContext* context,
+ GrShaderDataManager* shaderDataManager,
+ const GrCaps* caps,
+ GrTexture** textures)
+ : fRandom(random)
+ , fContext(context)
+ , fShaderDataManager(shaderDataManager)
+ , fCaps(caps)
+ , fTextures(textures) {}
+ SkRandom* fRandom;
+ GrContext* fContext;
+ GrShaderDataManager* fShaderDataManager;
+ const GrCaps* fCaps;
robertphillips 2015/07/08 20:51:32 GrTexture* fTextures[2]; ?
+ GrTexture** fTextures;
+};
+
template <class Processor>
class GrProcessorTestFactory : SkNoncopyable {
public:
- typedef Processor* (*CreateProc)(SkRandom*,
- GrContext*,
- const GrCaps& caps,
- GrTexture* dummyTextures[]);
+ typedef Processor* (*CreateProc)(GrProcessorTestData*);
GrProcessorTestFactory(CreateProc createProc) {
fCreateProc = createProc;
GetFactories()->push_back(this);
}
- static Processor* CreateStage(SkRandom* random,
- GrContext* context,
- const GrCaps& caps,
- GrTexture* dummyTextures[]) {
+ static Processor* CreateStage(GrProcessorTestData* data) {
VerifyFactoryCount();
SkASSERT(GetFactories()->count());
- uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1);
+ uint32_t idx = data->fRandom->nextRangeU(0, GetFactories()->count() - 1);
GrProcessorTestFactory<Processor>* factory = (*GetFactories())[idx];
- return factory->fCreateProc(random, context, caps, dummyTextures);
+ return factory->fCreateProc(data);
}
/*
@@ -71,36 +90,20 @@ private:
*/
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
static GrProcessorTestFactory<GrGeometryProcessor> gTestFactory SK_UNUSED; \
- static GrGeometryProcessor* TestCreate(SkRandom*, \
- GrContext*, \
- const GrCaps&, \
- GrTexture* dummyTextures[2])
+ static GrGeometryProcessor* TestCreate(GrProcessorTestData*)
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
static GrProcessorTestFactory<GrFragmentProcessor> gTestFactory SK_UNUSED; \
- static GrFragmentProcessor* TestCreate(SkRandom*, \
- GrContext*, \
- const GrCaps&, \
- GrTexture* dummyTextures[2])
+ static GrFragmentProcessor* TestCreate(GrProcessorTestData*)
#define GR_DECLARE_XP_FACTORY_TEST \
static GrProcessorTestFactory<GrXPFactory> gTestFactory SK_UNUSED; \
- static GrXPFactory* TestCreate(SkRandom*, \
- GrContext*, \
- const GrCaps&, \
- GrTexture* dummyTextures[2])
+ static GrXPFactory* TestCreate(GrProcessorTestData*)
/** GrProcessor subclasses should insert this macro in their implementation file. They must then
* also implement this static function:
- * GrProcessor* TestCreate(SkRandom*,
- * GrContext*,
- * const GrCaps&,
- * GrTexture* dummyTextures[2]);
- * dummyTextures[] are valid textures that can optionally be used to construct GrTextureAccesses.
- * The first texture has config kSkia8888_GrPixelConfig and the second has
- * kAlpha_8_GrPixelConfig. TestCreate functions are also free to create additional textures using
- * the GrContext.
+ * GrProcessor* TestCreate(GrProcessorTestData*);
*/
#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Effect) \
GrProcessorTestFactory<GrFragmentProcessor> Effect :: gTestFactory(Effect :: TestCreate)
@@ -116,28 +119,19 @@ private:
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
- static GrFragmentProcessor* TestCreate(SkRandom*, \
- GrContext*, \
- const GrCaps&, \
- GrTexture* dummyTextures[2])
+ static GrFragmentProcessor* TestCreate(GrProcessorTestData*)
#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(X)
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_XP_FACTORY_TEST \
- static GrXPFactory* TestCreate(SkRandom*, \
- GrContext*, \
- const GrCaps&, \
- GrTexture* dummyTextures[2])
+ static GrXPFactory* TestCreate(GrProcessorTestData*)
#define GR_DEFINE_XP_FACTORY_TEST(X)
// The unit test relies on static initializers. Just declare the TestCreate function so that
// its definitions will compile.
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
- static GrGeometryProcessor* TestCreate(SkRandom*, \
- GrContext*, \
- const GrCaps&, \
- GrTexture* dummyTextures[2])
+ static GrGeometryProcessor* TestCreate(GrProcessorTestData*)
#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X)
#endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
« no previous file with comments | « no previous file | src/effects/SkAlphaThresholdFilter.cpp » ('j') | src/effects/SkAlphaThresholdFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698