Report the effect type when TestCreate returns null.

This is a quality-of-life improvement when debugging processor
unit tests.

Change-Id: I6eba2ea17710e224852e4688c5cc491ed09461ce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/305690
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2020-07-24 17:03:04 -04:00 committed by Skia Commit-Bot
parent 1bf2b4f587
commit 7c7a7e5da9
2 changed files with 10 additions and 6 deletions

View File

@ -58,8 +58,9 @@ GrProcessorTestData::ViewInfo GrProcessorTestData::randomAlphaOnlyView() {
}
template <class ProcessorSmartPtr>
GrProcessorTestFactory<ProcessorSmartPtr>::GrProcessorTestFactory(MakeProc makeProc) {
fMakeProc = makeProc;
GrProcessorTestFactory<ProcessorSmartPtr>::GrProcessorTestFactory(MakeProc makeProc,
const char* name)
: fMakeProc(makeProc), fName(name) {
GetFactories()->push_back(this);
}
@ -79,7 +80,9 @@ ProcessorSmartPtr GrProcessorTestFactory<ProcessorSmartPtr>::MakeIdx(int idx,
SkASSERT(idx < GetFactories()->count());
GrProcessorTestFactory<ProcessorSmartPtr>* factory = (*GetFactories())[idx];
ProcessorSmartPtr processor = factory->fMakeProc(data);
SkASSERT(processor);
if (processor == nullptr) {
SK_ABORT("%s: TestCreate returned null", factory->fName.c_str());
}
return processor;
}

View File

@ -87,7 +87,7 @@ class GrProcessorTestFactory : private SkNoncopyable {
public:
using MakeProc = ProcessorSmartPtr (*)(GrProcessorTestData*);
GrProcessorTestFactory(MakeProc makeProc);
GrProcessorTestFactory(MakeProc makeProc, const char* name);
/** Pick a random factory function and create a processor. */
static ProcessorSmartPtr Make(GrProcessorTestData* data);
@ -104,6 +104,7 @@ private:
static SkTArray<GrProcessorTestFactory<ProcessorSmartPtr>*, true>* GetFactories();
MakeProc fMakeProc;
SkString fName;
};
using GrFragmentProcessorTestFactory = GrProcessorTestFactory<std::unique_ptr<GrFragmentProcessor>>;
@ -147,10 +148,10 @@ private:
* GrProcessor* TestCreate(GrProcessorTestData*);
*/
#define GR_DEFINE_FRAGMENT_PROCESSOR_TEST(Effect) \
GrFragmentProcessorTestFactory Effect::gTestFactory(Effect::TestCreate)
GrFragmentProcessorTestFactory Effect::gTestFactory(Effect::TestCreate, #Effect)
#define GR_DEFINE_GEOMETRY_PROCESSOR_TEST(Effect) \
GrGeometryProcessorTestFactory Effect::gTestFactory(Effect::TestCreate)
GrGeometryProcessorTestFactory Effect::gTestFactory(Effect::TestCreate, #Effect)
#define GR_DEFINE_XP_FACTORY_TEST(Factory) \
GrXPFactoryTestFactory Factory::gTestFactory(Factory::TestGet)