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

Unified Diff: include/gpu/GrProcessorUnitTest.h

Issue 614163002: Force linking of static member variables for GLPrograms (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 6 years, 2 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/gpu/GrProcessor.cpp » ('j') | no next file with comments »
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 04ab2d15eb4e574273979b513352973fe2dc7d8e..3e1601dc8e049e20c9c4110f9d917b5db4559e87 100644
--- a/include/gpu/GrProcessorUnitTest.h
+++ b/include/gpu/GrProcessorUnitTest.h
@@ -40,9 +40,9 @@ class GrProcessorTestFactory : SkNoncopyable {
public:
typedef Processor* (*CreateProc)(SkRandom*,
- GrContext*,
- const GrDrawTargetCaps& caps,
- GrTexture* dummyTextures[]);
+ GrContext*,
+ const GrDrawTargetCaps& caps,
+ GrTexture* dummyTextures[]);
GrProcessorTestFactory(CreateProc createProc) {
fCreateProc = createProc;
@@ -50,42 +50,43 @@ public:
}
static Processor* CreateStage(SkRandom* random,
- GrContext* context,
- const GrDrawTargetCaps& caps,
- GrTexture* dummyTextures[]) {
+ GrContext* context,
+ const GrDrawTargetCaps& caps,
+ GrTexture* dummyTextures[]) {
+ VerifyFactoryCount();
+ SkASSERT(GetFactories()->count());
uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1);
GrProcessorTestFactory<Processor>* factory = (*GetFactories())[idx];
return factory->fCreateProc(random, context, caps, dummyTextures);
}
+ /*
+ * A test function which verifies the count of factories.
+ */
+ static void VerifyFactoryCount();
+
private:
CreateProc fCreateProc;
- #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
- static SkTArray<GrProcessorTestFactory<Processor>*, true>* GetFactories() {
- static SkTArray<GrProcessorTestFactory<Processor>*, true> gFactories;
- return &gFactories;
- }
- #endif
+ static SkTArray<GrProcessorTestFactory<Processor>*, true>* GetFactories();
};
/** GrProcessor subclasses should insert this macro in their declaration to be included in the
* program generation unit test.
*/
-
#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
- static GrProcessorTestFactory<GrGeometryProcessor> gTestFactory; \
+ static GrProcessorTestFactory<GrGeometryProcessor> gTestFactory SK_UNUSED; \
static GrGeometryProcessor* TestCreate(SkRandom*, \
- GrContext*, \
- const GrDrawTargetCaps&, \
- GrTexture* dummyTextures[2])
+ GrContext*, \
+ const GrDrawTargetCaps&, \
+ GrTexture* dummyTextures[2])
#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
- static GrProcessorTestFactory<GrFragmentProcessor> gTestFactory; \
+ static GrProcessorTestFactory<GrFragmentProcessor> gTestFactory SK_UNUSED; \
static GrFragmentProcessor* TestCreate(SkRandom*, \
- GrContext*, \
- const GrDrawTargetCaps&, \
- GrTexture* dummyTextures[2])
+ GrContext*, \
+ const GrDrawTargetCaps&, \
+ GrTexture* dummyTextures[2])
/** GrProcessor subclasses should insert this macro in their implementation file. They must then
* also implement this static function:
« no previous file with comments | « no previous file | src/gpu/GrProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698