From 003312a211e65f35e402d6fe80a32e23d4c94ac4 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Mon, 9 Jan 2017 16:00:33 +0000 Subject: 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 Reviewed-by: Brian Salomon --- include/gpu/GrProcessorUnitTest.h | 59 +++++++++++---------------------------- 1 file changed, 17 insertions(+), 42 deletions(-) (limited to 'include/gpu/GrProcessorUnitTest.h') 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 GrProcessorTestFactory : private SkNoncopyable { +template class GrProcessorTestFactory : SkNoncopyable { public: typedef sk_sp (*MakeProc)(GrProcessorTestData*); @@ -89,44 +88,20 @@ public: /** Use factory function at Index idx to create a processor. */ static sk_sp MakeIdx(int idx, GrProcessorTestData* data) { GrProcessorTestFactory* factory = (*GetFactories())[idx]; - sk_sp 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*, 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* 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 TestCreate(GrProcessorTestData*) #define GR_DECLARE_XP_FACTORY_TEST \ - static GrXPFactoryTestFactory gTestFactory SK_UNUSED; \ - static const GrXPFactory* TestGet(GrProcessorTestData*) + static GrProcessorTestFactory gTestFactory SK_UNUSED; \ + static sk_sp 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 Effect::gTestFactory(Effect::TestCreate) - -#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(Effect) \ - GrProcessorTestFactory Effect::gTestFactory(Effect::TestCreate) + GrProcessorTestFactory Effect :: gTestFactory(Effect :: TestCreate) #define GR_DEFINE_XP_FACTORY_TEST(Factory) \ - GrXPFactoryTestFactory Factory::gTestFactory(Factory::TestGet) + GrProcessorTestFactory Factory :: gTestFactory(Factory :: TestCreate) + +#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(Effect) \ + GrProcessorTestFactory Effect :: gTestFactory(Effect :: TestCreate) #else // !SK_ALLOW_STATIC_GLOBAL_INITIALIZERS @@ -163,17 +138,17 @@ private: static sk_sp 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 sk_sp 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 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 -- cgit v1.2.3