| Index: include/gpu/GrProcessorUnitTest.h
|
| diff --git a/include/gpu/GrProcessorUnitTest.h b/include/gpu/GrProcessorUnitTest.h
|
| index 4b97483c0fa438f017c2c6728ed04c2b5084bd44..f417c7dd94dfbf130506fda0b6365efee4658cc8 100644
|
| --- a/include/gpu/GrProcessorUnitTest.h
|
| +++ b/include/gpu/GrProcessorUnitTest.h
|
| @@ -115,10 +115,21 @@ public:
|
| const GrDrawTargetCaps& caps,
|
| GrTexture* dummyTextures[]) {
|
| VerifyFactoryCount();
|
| - SkASSERT(GetFactories()->count());
|
| - uint32_t idx = random->nextRangeU(0, GetFactories()->count() - 1);
|
| - GrProcessorTestFactory<Processor>* factory = (*GetFactories())[idx];
|
| - return factory->fCreateProc(random, context, caps, dummyTextures);
|
| + int count = GetFactories()->count();
|
| + SkASSERT(count);
|
| + uint32_t idx = random->nextRangeU(0, count - 1);
|
| + Processor* p = (*GetFactories())[idx]->fCreateProc(random, context, caps, dummyTextures);
|
| + if (!p) {
|
| + // Factory at idx was not supported on this GrContext. Find one that is.
|
| + SkSTArray<8, GrProcessorTestFactory<Processor>*, true> localFactories(*GetFactories());
|
| + do {
|
| + count--;
|
| + SkASSERT(count);
|
| + SkTSwap(localFactories[idx], localFactories[count]);
|
| + idx = random->nextRangeU(0, count - 1);
|
| + } while (!(p = localFactories[idx]->fCreateProc(random, context, caps, dummyTextures)));
|
| + }
|
| + return p;
|
| }
|
|
|
| /*
|
|
|