Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: include/gpu/GrProcessorUnitTest.h

Issue 1037123003: Implement support for KHR_blend_equation_advanced (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_zzz2_barriers
Patch Set: Properly track the previous patch Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
/*

Powered by Google App Engine
This is Rietveld 408576698