| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 "File containing a list of uninteresting hashes. If a result hashes to s
omething in " | 65 "File containing a list of uninteresting hashes. If a result hashes to s
omething in " |
| 66 "this list, no image is written for that result."); | 66 "this list, no image is written for that result."); |
| 67 | 67 |
| 68 DEFINE_int32(shards, 1, "We're splitting source data into this many shards."); | 68 DEFINE_int32(shards, 1, "We're splitting source data into this many shards."); |
| 69 DEFINE_int32(shard, 0, "Which shard do I run?"); | 69 DEFINE_int32(shard, 0, "Which shard do I run?"); |
| 70 DEFINE_bool(simpleCodec, false, "Only decode images to native scale"); | 70 DEFINE_bool(simpleCodec, false, "Only decode images to native scale"); |
| 71 | 71 |
| 72 using namespace DM; | 72 using namespace DM; |
| 73 using sk_gpu_test::GrContextFactory; | 73 using sk_gpu_test::GrContextFactory; |
| 74 using sk_gpu_test::GLTestContext; | 74 using sk_gpu_test::GLTestContext; |
| 75 using sk_gpu_test::ContextInfo; |
| 75 | 76 |
| 76 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ | 77 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~*/ |
| 77 | 78 |
| 78 static const double kStartMs = SkTime::GetMSecs(); | 79 static const double kStartMs = SkTime::GetMSecs(); |
| 79 | 80 |
| 80 static FILE* gVLog; | 81 static FILE* gVLog; |
| 81 | 82 |
| 82 template <typename... Args> | 83 template <typename... Args> |
| 83 static void vlog(const char* fmt, Args&&... args) { | 84 static void vlog(const char* fmt, Args&&... args) { |
| 84 if (gVLog) { | 85 if (gVLog) { |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 #endif // SK_PDF_IMAGE_STATS | 1409 #endif // SK_PDF_IMAGE_STATS |
| 1409 | 1410 |
| 1410 print_status(); | 1411 print_status(); |
| 1411 info("Finished!\n"); | 1412 info("Finished!\n"); |
| 1412 return 0; | 1413 return 0; |
| 1413 } | 1414 } |
| 1414 | 1415 |
| 1415 // TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards. | 1416 // TODO: currently many GPU tests are declared outside SK_SUPPORT_GPU guards. |
| 1416 // Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0. | 1417 // Thus we export the empty RunWithGPUTestContexts when SK_SUPPORT_GPU=0. |
| 1417 namespace skiatest { | 1418 namespace skiatest { |
| 1418 namespace { | 1419 void RunWithGPUTestContexts(GrContextTestFn* test, GPUTestContexts testContexts, |
| 1419 typedef void(*TestWithGrContext)(skiatest::Reporter*, GrContext*); | 1420 Reporter* reporter, GrContextFactory* factory) { |
| 1420 typedef void(*TestWithGrContextAndGLContext)(skiatest::Reporter*, GrContext*, GL
TestContext*); | |
| 1421 #if SK_SUPPORT_GPU | |
| 1422 template<typename T> | |
| 1423 void call_test(T test, skiatest::Reporter* reporter, const GrContextFactory::Con
textInfo& context); | |
| 1424 template<> | |
| 1425 void call_test(TestWithGrContext test, skiatest::Reporter* reporter, | |
| 1426 const GrContextFactory::ContextInfo& context) { | |
| 1427 test(reporter, context.fGrContext); | |
| 1428 } | |
| 1429 template<> | |
| 1430 void call_test(TestWithGrContextAndGLContext test, skiatest::Reporter* reporter, | |
| 1431 const GrContextFactory::ContextInfo& context) { | |
| 1432 test(reporter, context.fGrContext, context.fGLContext); | |
| 1433 } | |
| 1434 #endif | |
| 1435 } // namespace | |
| 1436 | |
| 1437 template<typename T> | |
| 1438 void RunWithGPUTestContexts(T test, GPUTestContexts testContexts, Reporter* repo
rter, | |
| 1439 GrContextFactory* factory) { | |
| 1440 #if SK_SUPPORT_GPU | 1421 #if SK_SUPPORT_GPU |
| 1441 // Iterate over context types, except use "native" instead of explicitly try
ing OpenGL and | 1422 // Iterate over context types, except use "native" instead of explicitly try
ing OpenGL and |
| 1442 // OpenGL ES. Do not use GLES on desktop, since tests do not account for not
fixing | 1423 // OpenGL ES. Do not use GLES on desktop, since tests do not account for not
fixing |
| 1443 // http://skbug.com/2809 | 1424 // http://skbug.com/2809 |
| 1444 GrContextFactory::ContextType contextTypes[] = { | 1425 GrContextFactory::ContextType contextTypes[] = { |
| 1445 GrContextFactory::kNativeGL_ContextType, | 1426 GrContextFactory::kNativeGL_ContextType, |
| 1446 #if SK_ANGLE | 1427 #if SK_ANGLE |
| 1447 #ifdef SK_BUILD_FOR_WIN | 1428 #ifdef SK_BUILD_FOR_WIN |
| 1448 GrContextFactory::kANGLE_ContextType, | 1429 GrContextFactory::kANGLE_ContextType, |
| 1449 #endif | 1430 #endif |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1469 } else if (contextType == GrContextFactory::kNativeGL_ContextType) { | 1450 } else if (contextType == GrContextFactory::kNativeGL_ContextType) { |
| 1470 contextSelector |= kNative_GPUTestContexts; | 1451 contextSelector |= kNative_GPUTestContexts; |
| 1471 } else if (contextType == GrContextFactory::kNullGL_ContextType) { | 1452 } else if (contextType == GrContextFactory::kNullGL_ContextType) { |
| 1472 contextSelector |= kNull_GPUTestContexts; | 1453 contextSelector |= kNull_GPUTestContexts; |
| 1473 } else if (contextType == GrContextFactory::kDebugGL_ContextType) { | 1454 } else if (contextType == GrContextFactory::kDebugGL_ContextType) { |
| 1474 contextSelector |= kDebug_GPUTestContexts; | 1455 contextSelector |= kDebug_GPUTestContexts; |
| 1475 } | 1456 } |
| 1476 if ((testContexts & contextSelector) == 0) { | 1457 if ((testContexts & contextSelector) == 0) { |
| 1477 continue; | 1458 continue; |
| 1478 } | 1459 } |
| 1479 GrContextFactory::ContextInfo context = factory->getContextInfo(contextT
ype); | 1460 ContextInfo ctxInfo = factory->getContextInfo(contextType); |
| 1480 if (context.fGrContext) { | 1461 if (ctxInfo.fGrContext) { |
| 1481 call_test(test, reporter, context); | 1462 (*test)(reporter, ctxInfo); |
| 1482 } | 1463 } |
| 1483 context = factory->getContextInfo(contextType, | 1464 ctxInfo = factory->getContextInfo(contextType, |
| 1484 GrContextFactory::kEnableNVPR_ContextO
ptions); | 1465 GrContextFactory::kEnableNVPR_ContextO
ptions); |
| 1485 if (context.fGrContext) { | 1466 if (ctxInfo.fGrContext) { |
| 1486 call_test(test, reporter, context); | 1467 (*test)(reporter, ctxInfo); |
| 1487 } | 1468 } |
| 1488 } | 1469 } |
| 1489 #endif | 1470 #endif |
| 1490 } | 1471 } |
| 1491 | |
| 1492 template | |
| 1493 void RunWithGPUTestContexts<TestWithGrContext>(TestWithGrContext test, | |
| 1494 GPUTestContexts testContexts, | |
| 1495 Reporter* reporter, | |
| 1496 GrContextFactory* factory); | |
| 1497 template | |
| 1498 void RunWithGPUTestContexts<TestWithGrContextAndGLContext>(TestWithGrContextAndG
LContext test, | |
| 1499 GPUTestContexts testC
ontexts, | |
| 1500 Reporter* reporter, | |
| 1501 GrContextFactory* fac
tory); | |
| 1502 } // namespace skiatest | 1472 } // namespace skiatest |
| 1503 | 1473 |
| 1504 #if !defined(SK_BUILD_FOR_IOS) | 1474 #if !defined(SK_BUILD_FOR_IOS) |
| 1505 int main(int argc, char** argv) { | 1475 int main(int argc, char** argv) { |
| 1506 SkCommandLineFlags::Parse(argc, argv); | 1476 SkCommandLineFlags::Parse(argc, argv); |
| 1507 return dm_main(); | 1477 return dm_main(); |
| 1508 } | 1478 } |
| 1509 #endif | 1479 #endif |
| OLD | NEW |