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>
diff --git a/src/gpu/GrProcessorUnitTest.cpp b/src/gpu/GrProcessorUnitTest.cpp
index 5336b5b..186901d 100644
--- a/src/gpu/GrProcessorUnitTest.cpp
+++ b/src/gpu/GrProcessorUnitTest.cpp
@@ -58,8 +58,9 @@
}
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 @@
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;
}
diff --git a/src/gpu/GrProcessorUnitTest.h b/src/gpu/GrProcessorUnitTest.h
index 341acaf..044f20f 100644
--- a/src/gpu/GrProcessorUnitTest.h
+++ b/src/gpu/GrProcessorUnitTest.h
@@ -87,7 +87,7 @@
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 @@
static SkTArray<GrProcessorTestFactory<ProcessorSmartPtr>*, true>* GetFactories();
MakeProc fMakeProc;
+ SkString fName;
};
using GrFragmentProcessorTestFactory = GrProcessorTestFactory<std::unique_ptr<GrFragmentProcessor>>;
@@ -147,10 +148,10 @@
* 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)