| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 enum ConfigFlags { | 144 enum ConfigFlags { |
| 145 kNone_ConfigFlag = 0x0, | 145 kNone_ConfigFlag = 0x0, |
| 146 /* Write GM images if a write path is provided. */ | 146 /* Write GM images if a write path is provided. */ |
| 147 kWrite_ConfigFlag = 0x1, | 147 kWrite_ConfigFlag = 0x1, |
| 148 /* Read reference GM images if a read path is provided. */ | 148 /* Read reference GM images if a read path is provided. */ |
| 149 kRead_ConfigFlag = 0x2, | 149 kRead_ConfigFlag = 0x2, |
| 150 kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag), | 150 kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag), |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 struct ConfigData { | 153 struct ConfigData { |
| 154 SkBitmap::Config fConfig; | 154 SkColorType fColorType; |
| 155 Backend fBackend; | 155 Backend fBackend; |
| 156 GLContextType fGLContextType; // GPU backend only | 156 GLContextType fGLContextType; // GPU backend only |
| 157 int fSampleCnt; // GPU backend only | 157 int fSampleCnt; // GPU backend only |
| 158 ConfigFlags fFlags; | 158 ConfigFlags fFlags; |
| 159 const char* fName; | 159 const char* fName; |
| 160 bool fRunByDefault; | 160 bool fRunByDefault; |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 struct PDFRasterizerData { | 163 struct PDFRasterizerData { |
| 164 bool (*fRasterizerFunction)(SkStream*, SkBitmap*); | 164 bool (*fRasterizerFunction)(SkStream*, SkBitmap*); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 * After you've rendered the GM into the SkBitmap, you must call | 470 * After you've rendered the GM into the SkBitmap, you must call |
| 471 * complete_bitmap()! | 471 * complete_bitmap()! |
| 472 * | 472 * |
| 473 * @todo thudson 22 April 2011 - could refactor this to take in | 473 * @todo thudson 22 April 2011 - could refactor this to take in |
| 474 * a factory to generate the context, always call readPixels() | 474 * a factory to generate the context, always call readPixels() |
| 475 * (logically a noop for rasters, if wasted time), and thus collapse the | 475 * (logically a noop for rasters, if wasted time), and thus collapse the |
| 476 * GPU special case and also let this be used for SkPicture testing. | 476 * GPU special case and also let this be used for SkPicture testing. |
| 477 */ | 477 */ |
| 478 static void setup_bitmap(const ConfigData& gRec, SkISize& size, | 478 static void setup_bitmap(const ConfigData& gRec, SkISize& size, |
| 479 SkBitmap* bitmap) { | 479 SkBitmap* bitmap) { |
| 480 bitmap->allocConfigPixels(gRec.fConfig, size.width(), size.height()); | 480 bitmap->allocPixels(SkImageInfo::Make(size.width(), size.height(), |
| 481 gRec.fColorType, kPremul_SkAlphaTy
pe)); |
| 481 bitmap->eraseColor(SK_ColorTRANSPARENT); | 482 bitmap->eraseColor(SK_ColorTRANSPARENT); |
| 482 } | 483 } |
| 483 | 484 |
| 484 /** | 485 /** |
| 485 * Any finalization steps we need to perform on the SkBitmap after | 486 * Any finalization steps we need to perform on the SkBitmap after |
| 486 * we have rendered the GM into it. | 487 * we have rendered the GM into it. |
| 487 * | 488 * |
| 488 * It's too bad that we are throwing away alpha channel data | 489 * It's too bad that we are throwing away alpha channel data |
| 489 * we could otherwise be examining, but this had always been happening | 490 * we could otherwise be examining, but this had always been happening |
| 490 * before... it was buried within the compare() method at | 491 * before... it was buried within the compare() method at |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 #endif | 1281 #endif |
| 1281 }; // end of GMMain class definition | 1282 }; // end of GMMain class definition |
| 1282 | 1283 |
| 1283 #if SK_SUPPORT_GPU | 1284 #if SK_SUPPORT_GPU |
| 1284 static const GLContextType kDontCare_GLContextType = GrContextFactory::kNative_G
LContextType; | 1285 static const GLContextType kDontCare_GLContextType = GrContextFactory::kNative_G
LContextType; |
| 1285 #else | 1286 #else |
| 1286 static const GLContextType kDontCare_GLContextType = 0; | 1287 static const GLContextType kDontCare_GLContextType = 0; |
| 1287 #endif | 1288 #endif |
| 1288 | 1289 |
| 1289 static const ConfigData gRec[] = { | 1290 static const ConfigData gRec[] = { |
| 1290 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "8888", true }, | 1291 { kN32_SkColorType, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "8888", true }, |
| 1291 #if 0 // stop testing this (for now at least) since we want to remove support
for it (soon please!!!) | 1292 { kRGB_565_SkColorType, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "565", true }, |
| 1292 { SkBitmap::kARGB_4444_Config, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "4444", true }, | |
| 1293 #endif | |
| 1294 { SkBitmap::kRGB_565_Config, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "565", true }, | |
| 1295 #if SK_SUPPORT_GPU | 1293 #if SK_SUPPORT_GPU |
| 1296 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GL
ContextType, 0, kRW_ConfigFlag, "gpu", true }, | 1294 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 0, kRW_ConfigFlag, "gpu", true }, |
| 1297 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GL
ContextType, 16, kRW_ConfigFlag, "msaa16", false}, | 1295 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 16, kRW_ConfigFlag, "msaa16", false}, |
| 1298 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNative_GL
ContextType, 4, kRW_ConfigFlag, "msaa4", false}, | 1296 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNative_GLContextType
, 4, kRW_ConfigFlag, "msaa4", false}, |
| 1299 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNVPR_GLCo
ntextType, 4, kRW_ConfigFlag, "nvprmsaa4", true }, | 1297 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNVPR_GLContextType,
4, kRW_ConfigFlag, "nvprmsaa4", true }, |
| 1300 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNVPR_GLCo
ntextType, 16, kRW_ConfigFlag, "nvprmsaa16", false}, | 1298 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNVPR_GLContextType,
16, kRW_ConfigFlag, "nvprmsaa16", false}, |
| 1301 /* The gpudebug context does not generate meaningful images, so don't record | 1299 /* The gpudebug context does not generate meaningful images, so don't record |
| 1302 * the images it generates! We only run it to look for asserts. */ | 1300 * the images it generates! We only run it to look for asserts. */ |
| 1303 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kDebug_GLC
ontextType, 0, kNone_ConfigFlag, "gpudebug", kDebugOnly}, | 1301 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kDebug_GLContextType,
0, kNone_ConfigFlag, "gpudebug", kDebugOnly}, |
| 1304 /* The gpunull context does the least amount of work possible and doesn't | 1302 /* The gpunull context does the least amount of work possible and doesn't |
| 1305 generate meaninful images, so don't record them!. It can be run to | 1303 generate meaninful images, so don't record them!. It can be run to |
| 1306 isolate the CPU-side processing expense from the GPU-side. | 1304 isolate the CPU-side processing expense from the GPU-side. |
| 1307 */ | 1305 */ |
| 1308 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kNull_GLCo
ntextType, 0, kNone_ConfigFlag, "gpunull", kDebugOnly}, | 1306 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kNull_GLContextType,
0, kNone_ConfigFlag, "gpunull", kDebugOnly}, |
| 1309 #if SK_ANGLE | 1307 #if SK_ANGLE |
| 1310 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLC
ontextType, 0, kRW_ConfigFlag, "angle", true }, | 1308 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kANGLE_GLContextType,
0, kRW_ConfigFlag, "angle", true }, |
| 1311 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kANGLE_GLC
ontextType, 16, kRW_ConfigFlag, "anglemsaa16", true }, | 1309 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kANGLE_GLContextType,
16, kRW_ConfigFlag, "anglemsaa16", true }, |
| 1312 #endif // SK_ANGLE | 1310 #endif // SK_ANGLE |
| 1313 #ifdef SK_MESA | 1311 #ifdef SK_MESA |
| 1314 { SkBitmap::kARGB_8888_Config, kGPU_Backend, GrContextFactory::kMESA_GLCo
ntextType, 0, kRW_ConfigFlag, "mesa", true }, | 1312 { kN32_SkColorType, kGPU_Backend, GrContextFactory::kMESA_GLContextType,
0, kRW_ConfigFlag, "mesa", true }, |
| 1315 #endif // SK_MESA | 1313 #endif // SK_MESA |
| 1316 #endif // SK_SUPPORT_GPU | 1314 #endif // SK_SUPPORT_GPU |
| 1317 #ifdef SK_SUPPORT_XPS | 1315 #ifdef SK_SUPPORT_XPS |
| 1318 /* At present we have no way of comparing XPS files (either natively or by c
onverting to PNG). */ | 1316 /* At present we have no way of comparing XPS files (either natively or by c
onverting to PNG). */ |
| 1319 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType,
0, kWrite_ConfigFlag, "xps", true }, | 1317 { kN32_SkColorType, kXPS_Backend, kDontCare_GLContextType,
0, kWrite_ConfigFlag, "xps", true }, |
| 1320 #endif // SK_SUPPORT_XPS | 1318 #endif // SK_SUPPORT_XPS |
| 1321 #ifdef SK_SUPPORT_PDF | 1319 #ifdef SK_SUPPORT_PDF |
| 1322 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "pdf", true }, | 1320 { kN32_SkColorType, kPDF_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "pdf", true }, |
| 1323 #endif // SK_SUPPORT_PDF | 1321 #endif // SK_SUPPORT_PDF |
| 1324 }; | 1322 }; |
| 1325 | 1323 |
| 1326 static bool SkNoRasterizePDF(SkStream*, SkBitmap*) { return false; } | 1324 static bool SkNoRasterizePDF(SkStream*, SkBitmap*) { return false; } |
| 1327 | 1325 |
| 1328 static const PDFRasterizerData kPDFRasterizers[] = { | 1326 static const PDFRasterizerData kPDFRasterizers[] = { |
| 1329 #ifdef SK_BUILD_FOR_MAC | 1327 #ifdef SK_BUILD_FOR_MAC |
| 1330 { &SkPDFDocumentToBitmap, "mac", true }, | 1328 { &SkPDFDocumentToBitmap, "mac", true }, |
| 1331 #endif | 1329 #endif |
| 1332 #ifdef SK_BUILD_POPPLER | 1330 #ifdef SK_BUILD_POPPLER |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 if (gmFlags & GM::kSkipPDF_Flag) { | 1731 if (gmFlags & GM::kSkipPDF_Flag) { |
| 1734 gmmain.RecordSkippedTest(shortNamePlusConfig, | 1732 gmmain.RecordSkippedTest(shortNamePlusConfig, |
| 1735 renderModeDescriptor, | 1733 renderModeDescriptor, |
| 1736 config.fBackend); | 1734 config.fBackend); |
| 1737 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | 1735 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); |
| 1738 continue; | 1736 continue; |
| 1739 } | 1737 } |
| 1740 } | 1738 } |
| 1741 if ((gmFlags & GM::kSkip565_Flag) && | 1739 if ((gmFlags & GM::kSkip565_Flag) && |
| 1742 (kRaster_Backend == config.fBackend) && | 1740 (kRaster_Backend == config.fBackend) && |
| 1743 (SkBitmap::kRGB_565_Config == config.fConfig)) { | 1741 (kRGB_565_SkColorType == config.fColorType)) { |
| 1744 gmmain.RecordSkippedTest(shortNamePlusConfig, | 1742 gmmain.RecordSkippedTest(shortNamePlusConfig, |
| 1745 renderModeDescriptor, | 1743 renderModeDescriptor, |
| 1746 config.fBackend); | 1744 config.fBackend); |
| 1747 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | 1745 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); |
| 1748 continue; | 1746 continue; |
| 1749 } | 1747 } |
| 1750 if (((gmFlags & GM::kSkipGPU_Flag) && kGPU_Backend == config.fBackend) |
| | 1748 if (((gmFlags & GM::kSkipGPU_Flag) && kGPU_Backend == config.fBackend) |
| |
| 1751 ((gmFlags & GM::kGPUOnly_Flag) && kGPU_Backend != config.fBackend))
{ | 1749 ((gmFlags & GM::kGPUOnly_Flag) && kGPU_Backend != config.fBackend))
{ |
| 1752 gmmain.RecordSkippedTest(shortNamePlusConfig, | 1750 gmmain.RecordSkippedTest(shortNamePlusConfig, |
| 1753 renderModeDescriptor, | 1751 renderModeDescriptor, |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2466 if (FLAGS_forceBWtext) { | 2464 if (FLAGS_forceBWtext) { |
| 2467 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2465 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2468 } | 2466 } |
| 2469 } | 2467 } |
| 2470 | 2468 |
| 2471 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2469 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2472 int main(int argc, char * const argv[]) { | 2470 int main(int argc, char * const argv[]) { |
| 2473 return tool_main(argc, (char**) argv); | 2471 return tool_main(argc, (char**) argv); |
| 2474 } | 2472 } |
| 2475 #endif | 2473 #endif |
| OLD | NEW |