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

Unified Diff: dm/DM.cpp

Issue 1446453003: Generate list of GPU contexts outside SurfaceTest tests (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: msvc fixes Created 5 years, 1 month 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
« no previous file with comments | « no previous file | src/gpu/GrContextFactory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DM.cpp
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 8873dcabbe591792fec88dc10cc4feaacd330c11..7497161369b42788dac022dc8f9eedb534801135 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -1144,6 +1144,67 @@ int dm_main() {
return 0;
}
+// TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards.
+// Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0.
+namespace skiatest {
+namespace {
+typedef void(*TestWithGrContext)(skiatest::Reporter*, GrContext*);
+typedef void(*TestWithGrContextAndGLContext)(skiatest::Reporter*, GrContext*, SkGLContext*);
+#if SK_SUPPORT_GPU
+template<typename T>
+void call_test(T test, skiatest::Reporter* reporter, GrContextFactory::ContextInfo* context);
+template<>
+void call_test(TestWithGrContext test, skiatest::Reporter* reporter,
+ GrContextFactory::ContextInfo* context) {
+ test(reporter, context->fGrContext);
+}
+template<>
+void call_test(TestWithGrContextAndGLContext test, skiatest::Reporter* reporter,
+ GrContextFactory::ContextInfo* context) {
+ test(reporter, context->fGrContext, context->fGLContext);
+}
+#endif
+} // namespace
+
+
+template<typename T>
+void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* reporter,
+ GrContextFactory* factory) {
+#if SK_SUPPORT_GPU
+ for (int i = 0; i < GrContextFactory::kGLContextTypeCnt; ++i) {
+ GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType) i;
+ int contextSelector = kNone_GPUTestContexts;
+ if (GrContextFactory::IsRenderingGLContext(glCtxType)) {
+ contextSelector |= kAllRendering_GPUTestContexts;
+ }
+ if (glCtxType == GrContextFactory::kNative_GLContextType) {
+ contextSelector |= kNative_GPUTestContexts;
+ }
+ if (glCtxType == GrContextFactory::kNull_GLContextType) {
+ contextSelector |= kNull_GPUTestContexts;
+ }
+ if ((testContexts & contextSelector) == 0) {
+ continue;
+ }
+ if (GrContextFactory::ContextInfo* context = factory->getContextInfo(glCtxType)) {
+ call_test(test, reporter, context);
+ }
+ }
+#endif
+}
+
+template
+void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test,
+ GPUTestContexts testContexts,
+ Reporter* reporter,
+ GrContextFactory* factory);
+template
+void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndGLContext test,
+ GPUTestContexts testContexts,
+ Reporter* reporter,
+ GrContextFactory* factory);
+} // namespace skiatest
+
#if !defined(SK_BUILD_FOR_IOS)
int main(int argc, char** argv) {
SkCommandLineFlags::Parse(argc, argv);
« no previous file with comments | « no previous file | src/gpu/GrContextFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698