8#ifndef GrProcessorUnitTest_DEFINED
9#define GrProcessorUnitTest_DEFINED
13#if defined(GR_TEST_UTILS)
26class GrProcessorTestData;
32namespace GrProcessorUnitTest {
38std::unique_ptr<GrFragmentProcessor>
MakeChildFP(GrProcessorTestData*);
39std::unique_ptr<GrFragmentProcessor> MakeOptionalChildFP(GrProcessorTestData*);
49class GrProcessorTestData {
51 using ViewInfo = std::tuple<GrSurfaceProxyView, GrColorType, SkAlphaType>;
54 int numViews,
const ViewInfo views[]);
56 int numViews,
const ViewInfo views[],
57 std::unique_ptr<GrFragmentProcessor> inputFP);
58 GrProcessorTestData(
const GrProcessorTestData&) =
delete;
59 ~GrProcessorTestData();
65 std::unique_ptr<GrFragmentProcessor> inputFP();
67 ViewInfo randomView();
68 ViewInfo randomAlphaOnlyView();
71 int fCurrentTreeDepth = 0;
72 int fMaxTreeDepth = 1;
77 std::unique_ptr<SkArenaAlloc> fArena;
78 std::unique_ptr<GrFragmentProcessor> fInputFP;
84template <
class ProcessorSmartPtr>
87 using MakeProc = ProcessorSmartPtr (*)(GrProcessorTestData*);
89 GrProcessorTestFactory(MakeProc makeProc,
const char*
name);
92 static ProcessorSmartPtr
Make(GrProcessorTestData*
data);
95 static ProcessorSmartPtr MakeIdx(
int idx, GrProcessorTestData*
data);
102 static void VerifyFactoryCount();
109using GrFragmentProcessorTestFactory = GrProcessorTestFactory<std::unique_ptr<GrFragmentProcessor>>;
110using GrGeometryProcessorTestFactory = GrProcessorTestFactory<GrGeometryProcessor*>;
114 using GetFn =
const GrXPFactory*(GrProcessorTestData*);
116 GrXPFactoryTestFactory(GetFn* getProc);
122 static void VerifyFactoryCount();
128#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
133#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
134 [[maybe_unused]] static GrGeometryProcessorTestFactory* gTestFactory; \
135 static GrGeometryProcessor* TestCreate(GrProcessorTestData*);
137#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
138 [[maybe_unused]] static GrFragmentProcessorTestFactory* gTestFactory; \
139 static std::unique_ptr<GrFragmentProcessor> TestCreate(GrProcessorTestData*);
141#define GR_DECLARE_XP_FACTORY_TEST \
142 [[maybe_unused]] static GrXPFactoryTestFactory* gTestFactory; \
143 static const GrXPFactory* TestGet(GrProcessorTestData*);
149#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Effect) \
150 GrFragmentProcessorTestFactory* Effect::gTestFactory = \
151 new GrFragmentProcessorTestFactory(Effect::TestCreate, #Effect);
153#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(Effect) \
154 GrGeometryProcessorTestFactory* Effect::gTestFactory = \
155 new GrGeometryProcessorTestFactory(Effect::TestCreate, #Effect);
157#define GR_DEFINE_XP_FACTORY_TEST(Factory) \
158 GrXPFactoryTestFactory* Factory::gTestFactory = new GrXPFactoryTestFactory(Factory::TestGet);
164#define GR_DECLARE_FRAGMENT_PROCESSOR_TEST \
165 static std::unique_ptr<GrFragmentProcessor> TestCreate(GrProcessorTestData*);
166#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(X)
170#define GR_DECLARE_GEOMETRY_PROCESSOR_TEST \
171 static GrGeometryProcessor* TestCreate(GrProcessorTestData*);
172#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(X)
176#define GR_DECLARE_XP_FACTORY_TEST \
177 const GrXPFactory* TestGet(GrProcessorTestData*);
178#define GR_DEFINE_XP_FACTORY_TEST(X)
182 #define GR_DECLARE_GEOMETRY_PROCESSOR_TEST
183 #define GR_DECLARE_FRAGMENT_PROCESSOR_TEST
184 #define GR_DECLARE_XP_FACTORY_TEST
185 #define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(...)
186 #define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(...)
187 #define GR_DEFINE_XP_FACTORY_TEST(...)
188 #define GR_DECLARE_FRAGMENT_PROCESSOR_TEST
189 #define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(...)
190 #define GR_DECLARE_GEOMETRY_PROCESSOR_TEST
191 #define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(...)
192 #define GR_DECLARE_XP_FACTORY_TEST
193 #define GR_DEFINE_XP_FACTORY_TEST(...)
const GrXPFactory * Get(SkBlendMode mode)
GrFPResult MakeChildFP(const SkRuntimeEffect::ChildPtr &child, const GrFPArgs &childArgs)
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
DEF_SWITCHES_START aot vmservice shared library name
std::shared_ptr< const fml::Mapping > data