Remove SK_ALLOW_STATIC_GLOBAL_INITIALIZERS from tests.

The tests themselves should run fine if no factories were actually
registered. This isolates the last uses of this flag to the gpu code
which is actually depending on it.

Change-Id: Ief9c01abfc37c4e071d946d70ef85f13f94ae0f6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/213301
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/src/gpu/GrProcessorUnitTest.h b/src/gpu/GrProcessorUnitTest.h
index 2a763b7..8ed5297 100644
--- a/src/gpu/GrProcessorUnitTest.h
+++ b/src/gpu/GrProcessorUnitTest.h
@@ -73,8 +73,6 @@
     sk_sp<GrTextureProxy> fProxies[2];
 };
 
-#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
-
 class GrProcessor;
 class GrTexture;
 
@@ -92,7 +90,9 @@
     /** Pick a random factory function and create a processor.  */
     static ProcessorSmartPtr Make(GrProcessorTestData* data) {
         VerifyFactoryCount();
-        SkASSERT(GetFactories()->count());
+        if (GetFactories()->count() == 0) {
+            return nullptr;
+        }
         uint32_t idx = data->fRandom->nextRangeU(0, GetFactories()->count() - 1);
         return MakeIdx(idx, data);
     }
@@ -102,6 +102,7 @@
 
     /** Use factory function at Index idx to create a processor. */
     static ProcessorSmartPtr MakeIdx(int idx, GrProcessorTestData* data) {
+        SkASSERT(idx < GetFactories()->count());
         GrProcessorTestFactory<ProcessorSmartPtr>* factory = (*GetFactories())[idx];
         ProcessorSmartPtr processor = factory->fMakeProc(data);
         SkASSERT(processor);
@@ -130,7 +131,9 @@
 
     static const GrXPFactory* Get(GrProcessorTestData* data) {
         VerifyFactoryCount();
-        SkASSERT(GetFactories()->count());
+        if (GetFactories()->count() == 0) {
+            return nullptr;
+        }
         uint32_t idx = data->fRandom->nextRangeU(0, GetFactories()->count() - 1);
         const GrXPFactory* xpf = (*GetFactories())[idx]->fGetProc(data);
         SkASSERT(xpf);
@@ -144,6 +147,8 @@
     static SkTArray<GrXPFactoryTestFactory*, true>* GetFactories();
 };
 
+#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
+
 /** GrProcessor subclasses should insert this macro in their declaration to be included in the
  *  program generation unit test.
  */