OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 /* | 8 /* |
9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
10 * | 10 * |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag), | 156 kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag), |
157 }; | 157 }; |
158 | 158 |
159 struct ConfigData { | 159 struct ConfigData { |
160 SkBitmap::Config fConfig; | 160 SkBitmap::Config fConfig; |
161 Backend fBackend; | 161 Backend fBackend; |
162 GLContextType fGLContextType; // GPU backend only | 162 GLContextType fGLContextType; // GPU backend only |
163 int fSampleCnt; // GPU backend only | 163 int fSampleCnt; // GPU backend only |
164 ConfigFlags fFlags; | 164 ConfigFlags fFlags; |
165 const char* fName; | 165 const char* fName; |
| 166 bool fRunByDefault; |
166 }; | 167 }; |
167 | 168 |
168 class BWTextDrawFilter : public SkDrawFilter { | 169 class BWTextDrawFilter : public SkDrawFilter { |
169 public: | 170 public: |
170 virtual bool filter(SkPaint*, Type) SK_OVERRIDE; | 171 virtual bool filter(SkPaint*, Type) SK_OVERRIDE; |
171 }; | 172 }; |
172 bool BWTextDrawFilter::filter(SkPaint* p, Type t) { | 173 bool BWTextDrawFilter::filter(SkPaint* p, Type t) { |
173 if (kText_Type == t) { | 174 if (kText_Type == t) { |
174 p->setAntiAlias(false); | 175 p->setAntiAlias(false); |
175 } | 176 } |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 #else | 978 #else |
978 static const GLContextType kDontCare_GLContextType = 0; | 979 static const GLContextType kDontCare_GLContextType = 0; |
979 #endif | 980 #endif |
980 | 981 |
981 // If the platform does not support writing PNGs of PDFs then there will be no | 982 // If the platform does not support writing PNGs of PDFs then there will be no |
982 // reference images to read. However, we can always write the .pdf files | 983 // reference images to read. However, we can always write the .pdf files |
983 static const ConfigFlags kPDFConfigFlags = CAN_IMAGE_PDF ? kRW_ConfigFlag : | 984 static const ConfigFlags kPDFConfigFlags = CAN_IMAGE_PDF ? kRW_ConfigFlag : |
984 kWrite_ConfigFlag; | 985 kWrite_ConfigFlag; |
985 | 986 |
986 static const ConfigData gRec[] = { | 987 static const ConfigData gRec[] = { |
987 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "8888" }, | 988 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "8888", true }, |
988 #if 0 // stop testing this (for now at least) since we want to remove support
for it (soon please!!!) | 989 #if 0 // stop testing this (for now at least) since we want to remove support
for it (soon please!!!) |
989 { SkBitmap::kARGB_4444_Config, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "4444" }, | 990 { SkBitmap::kARGB_4444_Config, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "4444", true }, |
990 #endif | 991 #endif |
991 { SkBitmap::kRGB_565_Config, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "565" }, | 992 { SkBitmap::kRGB_565_Config, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "565", true }, |
992 #if defined(SK_SCALAR_IS_FLOAT) && SK_SUPPORT_GPU | 993 #if SK_SUPPORT_GPU |
993 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GL
ContextType, 0, kRW_ConfigFlag, "gpu" }, | 994 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GL
ContextType, 0, kRW_ConfigFlag, "gpu", true }, |
994 #ifndef SK_BUILD_FOR_ANDROID | 995 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GL
ContextType, 16, kRW_ConfigFlag, "msaa16", true }, |
995 // currently we don't want to run MSAA tests on Android | 996 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GL
ContextType, 4, kRW_ConfigFlag, "msaa4", false}, |
996 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GL
ContextType, 16, kRW_ConfigFlag, "msaa16" }, | |
997 #endif | |
998 /* The debug context does not generate images */ | 997 /* The debug context does not generate images */ |
999 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kDebug_GLC
ontextType, 0, kNone_ConfigFlag, "debug" }, | 998 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kDebug_GLC
ontextType, 0, kNone_ConfigFlag, "debug", true }, |
1000 #if SK_ANGLE | 999 #if SK_ANGLE |
1001 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLC
ontextType, 0, kRW_ConfigFlag, "angle" }, | 1000 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLC
ontextType, 0, kRW_ConfigFlag, "angle" true }, |
1002 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLC
ontextType, 16, kRW_ConfigFlag, "anglemsaa16" }, | 1001 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLC
ontextType, 16, kRW_ConfigFlag, "anglemsaa16", true }, |
1003 #endif // SK_ANGLE | 1002 #endif // SK_ANGLE |
1004 #ifdef SK_MESA | 1003 #ifdef SK_MESA |
1005 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kMESA_GLCo
ntextType, 0, kRW_ConfigFlag, "mesa" }, | 1004 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kMESA_GLCo
ntextType, 0, kRW_ConfigFlag, "mesa", true }, |
1006 #endif // SK_MESA | 1005 #endif // SK_MESA |
1007 #endif // defined(SK_SCALAR_IS_FLOAT) && SK_SUPPORT_GPU | 1006 #endif // SK_SUPPORT_GPU |
1008 #ifdef SK_SUPPORT_XPS | 1007 #ifdef SK_SUPPORT_XPS |
1009 /* At present we have no way of comparing XPS files (either natively or by c
onverting to PNG). */ | 1008 /* At present we have no way of comparing XPS files (either natively or by c
onverting to PNG). */ |
1010 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType,
0, kWrite_ConfigFlag, "xps" }, | 1009 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType,
0, kWrite_ConfigFlag, "xps", true }, |
1011 #endif // SK_SUPPORT_XPS | 1010 #endif // SK_SUPPORT_XPS |
1012 #ifdef SK_SUPPORT_PDF | 1011 #ifdef SK_SUPPORT_PDF |
1013 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType,
0, kPDFConfigFlags, "pdf" }, | 1012 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType,
0, kPDFConfigFlags, "pdf", true }, |
1014 #endif // SK_SUPPORT_PDF | 1013 #endif // SK_SUPPORT_PDF |
1015 }; | 1014 }; |
1016 | 1015 |
1017 static void usage(const char * argv0) { | 1016 static void usage(const char * argv0) { |
1018 fprintf(stderr, "%s\n", argv0); | 1017 fprintf(stderr, "%s\n", argv0); |
1019 fprintf(stderr, " [--config "); | 1018 fprintf(stderr, " [--config "); |
1020 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1019 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
1021 if (i > 0) { | 1020 if (i > 0) { |
1022 fprintf(stderr, "|"); | 1021 fprintf(stderr, "|"); |
1023 } | 1022 } |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 usage(commandName); | 1346 usage(commandName); |
1348 return -1; | 1347 return -1; |
1349 } | 1348 } |
1350 } | 1349 } |
1351 if (argv != stop) { | 1350 if (argv != stop) { |
1352 usage(commandName); | 1351 usage(commandName); |
1353 return -1; | 1352 return -1; |
1354 } | 1353 } |
1355 | 1354 |
1356 if (!userConfig) { | 1355 if (!userConfig) { |
1357 // if no config is specified by user, we add them all. | 1356 // if no config is specified by user, add the defaults |
1358 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1357 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
1359 *configs.append() = i; | 1358 if (gRec[i].fRunByDefault) { |
| 1359 *configs.append() = i; |
| 1360 } |
1360 } | 1361 } |
1361 } | 1362 } |
1362 // now remove any explicitly excluded configs | 1363 // now remove any explicitly excluded configs |
1363 for (int i = 0; i < excludeConfigs.count(); ++i) { | 1364 for (int i = 0; i < excludeConfigs.count(); ++i) { |
1364 int index = configs.find(excludeConfigs[i]); | 1365 int index = configs.find(excludeConfigs[i]); |
1365 if (index >= 0) { | 1366 if (index >= 0) { |
1366 configs.remove(index); | 1367 configs.remove(index); |
1367 // now assert that there was only one copy in configs[] | 1368 // now assert that there was only one copy in configs[] |
1368 SkASSERT(configs.find(excludeConfigs[i]) < 0); | 1369 SkASSERT(configs.find(excludeConfigs[i]) < 0); |
1369 } | 1370 } |
1370 } | 1371 } |
1371 | 1372 |
| 1373 #if SK_SUPPORT_GPU |
| 1374 GrContextFactory* grFactory = new GrContextFactory; |
| 1375 for (int i = 0; i < configs.count(); ++i) { |
| 1376 int index = configs[i]; |
| 1377 if (kGPU_Backend == gRec[index].fBackend) { |
| 1378 GrContext* ctx = grFactory->get(gRec[index].fGLContextType); |
| 1379 if (NULL == ctx) { |
| 1380 SkDebugf("GrContext could not be created for config %s. Config w
ill be skipped.", |
| 1381 gRec[index].fName); |
| 1382 configs.remove(i); |
| 1383 --i; |
| 1384 } |
| 1385 if (gRec[index].fSampleCnt > ctx->getMaxSampleCount()) { |
| 1386 SkDebugf("Sample count (%d) of config %s is not supported. Confi
g will be skipped.", |
| 1387 gRec[index].fSampleCnt, gRec[index].fName); |
| 1388 configs.remove(i); |
| 1389 --i; |
| 1390 } |
| 1391 } |
| 1392 } |
| 1393 #endif |
| 1394 |
1372 if (doVerbose) { | 1395 if (doVerbose) { |
1373 SkString str; | 1396 SkString str; |
1374 str.printf("%d configs:", configs.count()); | 1397 str.printf("%d configs:", configs.count()); |
1375 for (int i = 0; i < configs.count(); ++i) { | 1398 for (int i = 0; i < configs.count(); ++i) { |
1376 str.appendf(" %s", gRec[configs[i]].fName); | 1399 str.appendf(" %s", gRec[configs[i]].fName); |
1377 } | 1400 } |
1378 gm_fprintf(stderr, "%s\n", str.c_str()); | 1401 gm_fprintf(stderr, "%s\n", str.c_str()); |
1379 } | 1402 } |
1380 | 1403 |
1381 GM::SetResourcePath(resourcePath); | 1404 GM::SetResourcePath(resourcePath); |
(...skipping 30 matching lines...) Expand all Loading... |
1412 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { | 1435 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { |
1413 moduloRemainder = -1; | 1436 moduloRemainder = -1; |
1414 } | 1437 } |
1415 | 1438 |
1416 // Accumulate success of all tests. | 1439 // Accumulate success of all tests. |
1417 int testsRun = 0; | 1440 int testsRun = 0; |
1418 int testsPassed = 0; | 1441 int testsPassed = 0; |
1419 int testsFailed = 0; | 1442 int testsFailed = 0; |
1420 int testsMissingReferenceImages = 0; | 1443 int testsMissingReferenceImages = 0; |
1421 | 1444 |
1422 #if SK_SUPPORT_GPU | |
1423 GrContextFactory* grFactory = new GrContextFactory; | |
1424 #endif | |
1425 | |
1426 int gmIndex = -1; | 1445 int gmIndex = -1; |
1427 SkString moduloStr; | 1446 SkString moduloStr; |
1428 | 1447 |
1429 // If we will be writing out files, prepare subdirectories. | 1448 // If we will be writing out files, prepare subdirectories. |
1430 if (writePath) { | 1449 if (writePath) { |
1431 if (!sk_mkdir(writePath)) { | 1450 if (!sk_mkdir(writePath)) { |
1432 return -1; | 1451 return -1; |
1433 } | 1452 } |
1434 if (gmmain.fUseFileHierarchy) { | 1453 if (gmmain.fUseFileHierarchy) { |
1435 for (int i = 0; i < configs.count(); i++) { | 1454 for (int i = 0; i < configs.count(); i++) { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 SkGraphics::Term(); | 1741 SkGraphics::Term(); |
1723 | 1742 |
1724 return (0 == testsFailed) ? 0 : -1; | 1743 return (0 == testsFailed) ? 0 : -1; |
1725 } | 1744 } |
1726 | 1745 |
1727 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1746 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
1728 int main(int argc, char * const argv[]) { | 1747 int main(int argc, char * const argv[]) { |
1729 return tool_main(argc, (char**) argv); | 1748 return tool_main(argc, (char**) argv); |
1730 } | 1749 } |
1731 #endif | 1750 #endif |
OLD | NEW |