aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrProcessorUnitTest.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-01-09 16:00:33 +0000
committerGravatar Brian Salomon <bsalomon@google.com>2017-01-09 16:08:13 +0000
commit003312a211e65f35e402d6fe80a32e23d4c94ac4 (patch)
tree61635d3df8e7bf873c0ea08b211da03521b8a477 /include/gpu/GrProcessorUnitTest.h
parenta8f80de2bc17672b4b6f26d3cf6b38123ac850c9 (diff)
Revert "Removing ref counting from GrXPFactory."
This reverts commit a8f80de2bc17672b4b6f26d3cf6b38123ac850c9. Reason for revert: nanobench failing on windows bots, possibly others Change-Id: Iacb8c650064a28654c165665be057377ffb02ba5 Reviewed-on: https://skia-review.googlesource.com/6802 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include/gpu/GrProcessorUnitTest.h')
-rw-r--r--include/gpu/GrProcessorUnitTest.h59
1 files changed, 17 insertions, 42 deletions
diff --git a/include/gpu/GrProcessorUnitTest.h b/include/gpu/GrProcessorUnitTest.h
index 0826e3d653..d398aae9e4 100644
--- a/include/gpu/GrProcessorUnitTest.h
+++ b/include/gpu/GrProcessorUnitTest.h
@@ -18,7 +18,6 @@ class GrContext;
class GrRenderTargetContext;
struct GrProcessorTestData;
class GrTexture;
-class GrXPFactory;
namespace GrProcessorUnitTest {
@@ -66,7 +65,7 @@ struct GrProcessorTestData {
class GrProcessor;
class GrTexture;
-template <class Processor> class GrProcessorTestFactory : private SkNoncopyable {
+template <class Processor> class GrProcessorTestFactory : SkNoncopyable {
public:
typedef sk_sp<Processor> (*MakeProc)(GrProcessorTestData*);
@@ -89,44 +88,20 @@ public:
/** Use factory function at Index idx to create a processor. */
static sk_sp<Processor> MakeIdx(int idx, GrProcessorTestData* data) {
GrProcessorTestFactory<Processor>* factory = (*GetFactories())[idx];
- sk_sp<Processor> processor = factory->fMakeProc(data);
- SkASSERT(processor);
- return processor;
+ return factory->fMakeProc(data);
}
-private:
- /**
+ /*
* A test function which verifies the count of factories.
*/
static void VerifyFactoryCount();
+private:
MakeProc fMakeProc;
static SkTArray<GrProcessorTestFactory<Processor>*, true>* GetFactories();
};
-class GrXPFactoryTestFactory : private SkNoncopyable {
-public:
- using GetFn = const GrXPFactory*(GrProcessorTestData*);
-
- GrXPFactoryTestFactory(GetFn* getProc) : fGetProc(getProc) { GetFactories()->push_back(this); }
-
- static const GrXPFactory* Get(GrProcessorTestData* data) {
- VerifyFactoryCount();
- SkASSERT(GetFactories()->count());
- uint32_t idx = data->fRandom->nextRangeU(0, GetFactories()->count() - 1);
- const GrXPFactory* xpf = (*GetFactories())[idx]->fGetProc(data);
- SkASSERT(xpf);
- return xpf;
- }
-
-private:
- static void VerifyFactoryCount();
-
- GetFn* fGetProc;
- static SkTArray<GrXPFactoryTestFactory*, true>* GetFactories();
-};
-
/** GrProcessor subclasses should insert this macro in their declaration to be included in the
* program generation unit test.
*/
@@ -139,21 +114,21 @@ private:
static sk_sp<GrFragmentProcessor> TestCreate(GrProcessorTestData*)
#define GR_DECLARE_XP_FACTORY_TEST \
- static GrXPFactoryTestFactory gTestFactory SK_UNUSED; \
- static const GrXPFactory* TestGet(GrProcessorTestData*)
+ static GrProcessorTestFactory<GrXPFactory> gTestFactory SK_UNUSED; \
+ static sk_sp<GrXPFactory> TestCreate(GrProcessorTestData*)
/** GrProcessor subclasses should insert this macro in their implementation file. They must then
* also implement this static function:
* GrProcessor* TestCreate(GrProcessorTestData*);
*/
#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Effect) \
- GrProcessorTestFactory<GrFragmentProcessor> Effect::gTestFactory(Effect::TestCreate)
-
-#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(Effect) \
- GrProcessorTestFactory<GrGeometryProcessor> Effect::gTestFactory(Effect::TestCreate)
+ GrProcessorTestFactory<GrFragmentProcessor> Effect :: gTestFactory(Effect :: TestCreate)
#define GR_DEFINE_XP_FACTORY_TEST(Factory) \
- GrXPFactoryTestFactory Factory::gTestFactory(Factory::TestGet)
+ GrProcessorTestFactory<GrXPFactory> Factory :: gTestFactory(Factory :: TestCreate)
+
+#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(Effect) \
+ GrProcessorTestFactory<GrGeometryProcessor> Effect :: gTestFactory(Effect :: TestCreate)
#else // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
@@ -165,15 +140,15 @@ private:
// 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 sk_sp<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 sk_sp<GrGeometryProcessor> TestCreate(GrProcessorTestData*)
#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X)
-// The unit test relies on static initializers. Just declare the TestGet function so that
-// its definitions will compile.
-#define GR_DECLARE_XP_FACTORY_TEST \
- const GrXPFactory* TestGet(GrProcessorTestData*)
-#define GR_DEFINE_XP_FACTORY_TEST(X)
-
#endif // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
#endif