| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "CrashHandler.h" | 8 #include "CrashHandler.h" |
| 9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
| 10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 #endif // SK_PDF_IMAGE_STATS | 1408 #endif // SK_PDF_IMAGE_STATS |
| 1409 | 1409 |
| 1410 print_status(); | 1410 print_status(); |
| 1411 info("Finished!\n"); | 1411 info("Finished!\n"); |
| 1412 return 0; | 1412 return 0; |
| 1413 } | 1413 } |
| 1414 | 1414 |
| 1415 // TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards. | 1415 // TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards. |
| 1416 // Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0. | 1416 // Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0. |
| 1417 namespace skiatest { | 1417 namespace skiatest { |
| 1418 void RunWithGPUTestContexts(GrContextTestFn* test, GPUTestContexts testContexts, | 1418 |
| 1419 #if SK_SUPPORT_GPU |
| 1420 bool IsGLContextType(sk_gpu_test::GrContextFactory::ContextType type) { |
| 1421 return kOpenGL_GrBackend == GrContextFactory::ContextTypeBackend(type); |
| 1422 } |
| 1423 bool IsRenderingGLContextType(sk_gpu_test::GrContextFactory::ContextType type) { |
| 1424 return IsGLContextType(type) && GrContextFactory::IsRenderingContext(type); |
| 1425 } |
| 1426 bool IsNullGLContextType(sk_gpu_test::GrContextFactory::ContextType type) { |
| 1427 return type == GrContextFactory::kNullGL_ContextType; |
| 1428 } |
| 1429 #else |
| 1430 bool IsGLContextType(int) { return false; } |
| 1431 bool IsRenderingGLContextType(int) { return false; } |
| 1432 bool IsNullGLContextType(int) { return false; } |
| 1433 #endif |
| 1434 |
| 1435 void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contex
tTypeFilter, |
| 1419 Reporter* reporter, GrContextFactory* factory) { | 1436 Reporter* reporter, GrContextFactory* factory) { |
| 1420 #if SK_SUPPORT_GPU | 1437 #if SK_SUPPORT_GPU |
| 1421 // Iterate over context types, except use "native" instead of explicitly try
ing OpenGL and | |
| 1422 // OpenGL ES. Do not use GLES on desktop, since tests do not account for not
fixing | |
| 1423 // http://skbug.com/2809 | |
| 1424 GrContextFactory::ContextType contextTypes[] = { | |
| 1425 GrContextFactory::kNativeGL_ContextType, | |
| 1426 #if SK_ANGLE | |
| 1427 #ifdef SK_BUILD_FOR_WIN | |
| 1428 GrContextFactory::kANGLE_ContextType, | |
| 1429 #endif | |
| 1430 GrContextFactory::kANGLE_GL_ContextType, | |
| 1431 #endif | |
| 1432 #if SK_COMMAND_BUFFER | |
| 1433 GrContextFactory::kCommandBuffer_ContextType, | |
| 1434 #endif | |
| 1435 #if SK_MESA | |
| 1436 GrContextFactory::kMESA_ContextType, | |
| 1437 #endif | |
| 1438 GrContextFactory::kNullGL_ContextType, | |
| 1439 GrContextFactory::kDebugGL_ContextType, | |
| 1440 }; | |
| 1441 // Should have named all the context types except one of GL or GLES. | |
| 1442 static_assert(SK_ARRAY_COUNT(contextTypes) == GrContextFactory::kContextType
Cnt - 1, | |
| 1443 "Skipping unexpected ContextType for GPU tests"); | |
| 1444 | 1438 |
| 1445 for (auto& contextType : contextTypes) { | 1439 for (int typeInt = 0; typeInt < GrContextFactory::kContextTypeCnt; ++typeInt
) { |
| 1446 int contextSelector = kNone_GPUTestContexts; | 1440 GrContextFactory::ContextType contextType = (GrContextFactory::ContextTy
pe) typeInt; |
| 1447 if (GrContextFactory::IsRenderingContext(contextType)) { | 1441 ContextInfo ctxInfo = factory->getContextInfo(contextType); |
| 1448 contextSelector |= kAllRendering_GPUTestContexts; | 1442 if (!(*contextTypeFilter)(contextType)) { |
| 1449 } else if (contextType == GrContextFactory::kNativeGL_ContextType) { | |
| 1450 contextSelector |= kNative_GPUTestContexts; | |
| 1451 } else if (contextType == GrContextFactory::kNullGL_ContextType) { | |
| 1452 contextSelector |= kNull_GPUTestContexts; | |
| 1453 } else if (contextType == GrContextFactory::kDebugGL_ContextType) { | |
| 1454 contextSelector |= kDebug_GPUTestContexts; | |
| 1455 } | |
| 1456 if ((testContexts & contextSelector) == 0) { | |
| 1457 continue; | 1443 continue; |
| 1458 } | 1444 } |
| 1459 ContextInfo ctxInfo = factory->getContextInfo(contextType); | 1445 // Use "native" instead of explicitly trying OpenGL and OpenGL ES. Do no
t use GLES on, |
| 1446 // desktop since tests do not account for not fixing http://skbug.com/28
09 |
| 1447 if (contextType == GrContextFactory::kGL_ContextType || |
| 1448 contextType == GrContextFactory::kGLES_ContextType) { |
| 1449 if (contextType != GrContextFactory::kNativeGL_ContextType) { |
| 1450 continue; |
| 1451 } |
| 1452 } |
| 1460 if (ctxInfo.fGrContext) { | 1453 if (ctxInfo.fGrContext) { |
| 1461 (*test)(reporter, ctxInfo); | 1454 (*test)(reporter, ctxInfo); |
| 1462 } | 1455 } |
| 1463 ctxInfo = factory->getContextInfo(contextType, | 1456 ctxInfo = factory->getContextInfo(contextType, |
| 1464 GrContextFactory::kEnableNVPR_ContextO
ptions); | 1457 GrContextFactory::kEnableNVPR_ContextO
ptions); |
| 1465 if (ctxInfo.fGrContext) { | 1458 if (ctxInfo.fGrContext) { |
| 1466 (*test)(reporter, ctxInfo); | 1459 (*test)(reporter, ctxInfo); |
| 1467 } | 1460 } |
| 1468 } | 1461 } |
| 1469 #endif | 1462 #endif |
| 1470 } | 1463 } |
| 1471 } // namespace skiatest | 1464 } // namespace skiatest |
| 1472 | 1465 |
| 1473 #if !defined(SK_BUILD_FOR_IOS) | 1466 #if !defined(SK_BUILD_FOR_IOS) |
| 1474 int main(int argc, char** argv) { | 1467 int main(int argc, char** argv) { |
| 1475 SkCommandLineFlags::Parse(argc, argv); | 1468 SkCommandLineFlags::Parse(argc, argv); |
| 1476 return dm_main(); | 1469 return dm_main(); |
| 1477 } | 1470 } |
| 1478 #endif | 1471 #endif |
| OLD | NEW |