OLD | NEW |
---|---|
1 /* | 1 /* |
epoger
2013/03/20 17:26:42
Refactor only... no functional change.
Originally
scroggo
2013/03/20 17:41:30
Sorry about that!
epoger
2013/03/20 17:54:49
Hey, it's progress... a good thing.
| |
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 * |
11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh | 11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh |
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1133 #endif | 1133 #endif |
1134 } | 1134 } |
1135 | 1135 |
1136 template <typename T> void appendUnique(SkTDArray<T>* array, const T& value) { | 1136 template <typename T> void appendUnique(SkTDArray<T>* array, const T& value) { |
1137 int index = array->find(value); | 1137 int index = array->find(value); |
1138 if (index < 0) { | 1138 if (index < 0) { |
1139 *array->append() = value; | 1139 *array->append() = value; |
1140 } | 1140 } |
1141 } | 1141 } |
1142 | 1142 |
1143 /** | |
1144 * Run this test in a number of different configs (8888, 565, PDF, | |
1145 * etc.), confirming that the resulting bitmaps match expectations | |
1146 * (which may be different for each config). | |
1147 * | |
1148 * Returns all errors encountered while doing so. | |
1149 */ | |
1150 ErrorBitfield run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<size_ t> &configs, | |
epoger
2013/03/20 17:26:42
All of this code just extracted from tools_main().
| |
1151 GrContextFactory *grFactory) { | |
1152 ErrorBitfield errorsForAllConfigs = kEmptyErrorBitfield; | |
1153 uint32_t gmFlags = gm->getFlags(); | |
1154 | |
1155 #if SK_SUPPORT_GPU | |
1156 struct { | |
1157 int fBytes; | |
1158 int fCount; | |
1159 } gpuCacheSize = { -1, -1 }; // -1s mean use the default | |
1160 | |
1161 if (FLAGS_gpuCacheSize.count() > 0) { | |
1162 if (FLAGS_gpuCacheSize.count() != 2) { | |
1163 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); | |
1164 return -1; | |
1165 } | |
1166 gpuCacheSize.fBytes = atoi(FLAGS_gpuCacheSize[0]); | |
1167 gpuCacheSize.fCount = atoi(FLAGS_gpuCacheSize[1]); | |
1168 } | |
1169 #endif | |
1170 | |
1171 for (int i = 0; i < configs.count(); i++) { | |
1172 ConfigData config = gRec[configs[i]]; | |
1173 | |
1174 // Skip any tests that we don't even need to try. | |
1175 if ((kPDF_Backend == config.fBackend) && | |
1176 (!FLAGS_pdf|| (gmFlags & GM::kSkipPDF_Flag))) | |
1177 { | |
1178 continue; | |
1179 } | |
1180 if ((gmFlags & GM::kSkip565_Flag) && | |
1181 (kRaster_Backend == config.fBackend) && | |
1182 (SkBitmap::kRGB_565_Config == config.fConfig)) { | |
1183 continue; | |
1184 } | |
1185 if ((gmFlags & GM::kSkipGPU_Flag) && | |
1186 kGPU_Backend == config.fBackend) { | |
1187 continue; | |
1188 } | |
1189 | |
1190 // Now we know that we want to run this test and record its | |
1191 // success or failure. | |
1192 ErrorBitfield errorsForThisConfig = kEmptyErrorBitfield; | |
1193 GrRenderTarget* renderTarget = NULL; | |
1194 #if SK_SUPPORT_GPU | |
1195 SkAutoTUnref<GrRenderTarget> rt; | |
1196 AutoResetGr autogr; | |
1197 if ((kEmptyErrorBitfield == errorsForThisConfig) && | |
1198 kGPU_Backend == config.fBackend) { | |
1199 GrContext* gr = grFactory->get(config.fGLContextType); | |
1200 bool grSuccess = false; | |
1201 if (gr) { | |
1202 // create a render target to back the device | |
1203 GrTextureDesc desc; | |
1204 desc.fConfig = kSkia8888_GrPixelConfig; | |
1205 desc.fFlags = kRenderTarget_GrTextureFlagBit; | |
1206 desc.fWidth = gm->getISize().width(); | |
1207 desc.fHeight = gm->getISize().height(); | |
1208 desc.fSampleCnt = config.fSampleCnt; | |
1209 GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0); | |
1210 if (tex) { | |
1211 rt.reset(tex->asRenderTarget()); | |
1212 rt.get()->ref(); | |
1213 tex->unref(); | |
1214 autogr.set(gr); | |
1215 renderTarget = rt.get(); | |
1216 grSuccess = NULL != renderTarget; | |
1217 } | |
1218 // Set the user specified cache limits if non-default. | |
1219 size_t bytes; | |
1220 int count; | |
1221 gr->getTextureCacheLimits(&count, &bytes); | |
1222 if (-1 != gpuCacheSize.fBytes) { | |
1223 bytes = static_cast<size_t>(gpuCacheSize.fBytes); | |
1224 } | |
1225 if (-1 != gpuCacheSize.fCount) { | |
1226 count = gpuCacheSize.fCount; | |
1227 } | |
1228 gr->setTextureCacheLimits(count, bytes); | |
1229 } | |
1230 if (!grSuccess) { | |
1231 errorsForThisConfig |= kNoGpuContext_ErrorBitmask; | |
1232 } | |
1233 } | |
1234 #endif | |
1235 | |
1236 SkBitmap comparisonBitmap; | |
1237 | |
1238 const char* writePath; | |
1239 if (FLAGS_writePath.count() == 1) { | |
1240 writePath = FLAGS_writePath[0]; | |
1241 } else { | |
1242 writePath = NULL; | |
1243 } | |
1244 if (kEmptyErrorBitfield == errorsForThisConfig) { | |
1245 errorsForThisConfig |= gmmain.test_drawing(gm, config, writePath, | |
1246 GetGr(), | |
1247 renderTarget, | |
1248 &comparisonBitmap); | |
1249 } | |
1250 | |
1251 if (FLAGS_deferred && !errorsForThisConfig && | |
1252 (kGPU_Backend == config.fBackend || | |
1253 kRaster_Backend == config.fBackend)) { | |
1254 errorsForThisConfig |= gmmain.test_deferred_drawing(gm, config, | |
1255 comparisonBitmap, | |
1256 GetGr(), | |
1257 renderTarget); | |
1258 } | |
1259 | |
1260 errorsForAllConfigs |= errorsForThisConfig; | |
1261 } | |
1262 return errorsForAllConfigs; | |
1263 } | |
1264 | |
1265 /** | |
1266 * Run this test in a number of different drawing modes (pipe, | |
1267 * deferred, tiled, etc.), confirming that the resulting bitmaps all | |
1268 * *exactly* match comparisonBitmap. | |
1269 * | |
1270 * Returns all errors encountered while doing so. | |
1271 */ | |
1272 ErrorBitfield run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &compa reConfig, | |
epoger
2013/03/20 17:26:42
All of this code just extracted from tools_main().
| |
1273 const SkBitmap &comparisonBitmap) { | |
1274 SkTDArray<SkScalar> tileGridReplayScales; | |
1275 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal e 1.0 | |
1276 if (FLAGS_tileGridReplayScales.count() > 0) { | |
1277 tileGridReplayScales.reset(); | |
1278 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { | |
1279 double val = atof(FLAGS_tileGridReplayScales[i]); | |
1280 if (0 < val) { | |
1281 *tileGridReplayScales.append() = SkDoubleToScalar(val); | |
1282 } | |
1283 } | |
1284 if (0 == tileGridReplayScales.count()) { | |
1285 // Should have at least one scale | |
1286 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca le.\n"); | |
1287 return -1; | |
1288 } | |
1289 } | |
1290 | |
1291 ErrorBitfield errorsForAllModes = kEmptyErrorBitfield; | |
1292 uint32_t gmFlags = gm->getFlags(); | |
1293 | |
1294 // run the picture centric GM steps | |
1295 if (!(gmFlags & GM::kSkipPicture_Flag)) { | |
1296 | |
1297 ErrorBitfield pictErrors = kEmptyErrorBitfield; | |
1298 | |
1299 //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm)); | |
1300 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); | |
1301 SkAutoUnref aur(pict); | |
1302 | |
1303 if (FLAGS_replay) { | |
1304 SkBitmap bitmap; | |
1305 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; | |
1306 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( | |
1307 gm, compareConfig, "-replay", bitmap, &comparisonBitmap); | |
1308 } | |
1309 | |
1310 if ((kEmptyErrorBitfield == pictErrors) && FLAGS_serialize) { | |
1311 SkPicture* repict = gmmain.stream_to_new_picture(*pict); | |
1312 SkAutoUnref aurr(repict); | |
1313 | |
1314 SkBitmap bitmap; | |
1315 gmmain.generate_image_from_picture(gm, compareConfig, repict, | |
1316 &bitmap); | |
1317 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( | |
1318 gm, co mpareConfig, "-serialize", bitmap, &comparisonBitmap); | |
scroggo
2013/03/20 17:41:30
Over 100 lines.
epoger
2013/03/20 17:54:49
Fixed this and other line length / style stuff in
| |
1319 } | |
1320 | |
1321 if (FLAGS_writePicturePath.count() == 1) { | |
1322 const char* pictureSuffix = "skp"; | |
1323 SkString path = make_filename(FLAGS_writePicturePath[0], "", | |
1324 gm->shortName(), | |
1325 pictureSuffix); | |
1326 SkFILEWStream stream(path.c_str()); | |
1327 pict->serialize(&stream); | |
1328 } | |
1329 | |
1330 errorsForAllModes |= pictErrors; | |
1331 } | |
1332 | |
1333 // TODO: add a test in which the RTree rendering results in a | |
1334 // different bitmap than the standard rendering. It should | |
1335 // show up as failed in the JSON summary, and should be listed | |
1336 // in the stdout also. | |
1337 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_rtree) { | |
1338 SkPicture* pict = gmmain.generate_new_picture( | |
1339 gm, kRTree_BbhType, SkPict ure::kUsePathBoundsForClip_RecordingFlag); | |
scroggo
2013/03/20 17:41:30
100 lines.
| |
1340 SkAutoUnref aur(pict); | |
1341 SkBitmap bitmap; | |
1342 gmmain.generate_image_from_picture(gm, compareConfig, pict, | |
1343 &bitmap); | |
1344 errorsForAllModes |= gmmain.compare_test_results_to_reference_bitmap( | |
1345 gm, compareConfig, "-rtree", bitmap, &comparisonBitmap); | |
1346 } | |
1347 | |
1348 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_tileGrid) { | |
1349 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { | |
1350 SkScalar replayScale = tileGridReplayScales[scaleIndex]; | |
1351 if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1) | |
1352 continue; | |
1353 // We record with the reciprocal scale to obtain a replay | |
1354 // result that can be validated against comparisonBitmap. | |
1355 SkScalar recordScale = SkScalarInvert(replayScale); | |
1356 SkPicture* pict = gmmain.generate_new_picture( | |
1357 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFlag, | |
scroggo
2013/03/20 17:41:30
100 lines.
| |
1358 recordScale); | |
1359 SkAutoUnref aur(pict); | |
1360 SkBitmap bitmap; | |
1361 gmmain.generate_image_from_picture(gm, compareConfig, pict, | |
1362 &bitmap, replayScale); | |
1363 SkString suffix("-tilegrid"); | |
1364 if (SK_Scalar1 != replayScale) { | |
1365 suffix += "-scale-"; | |
1366 suffix.appendScalar(replayScale); | |
1367 } | |
1368 errorsForAllModes |= gmmain.compare_test_results_to_reference_bitmap ( | |
1369 gm, compareConfig, suffix.c_str(), bitmap, &comparisonBitmap); | |
1370 } | |
1371 } | |
1372 | |
1373 // run the pipe centric GM steps | |
1374 if (!(gmFlags & GM::kSkipPipe_Flag)) { | |
1375 | |
1376 ErrorBitfield pipeErrors = kEmptyErrorBitfield; | |
1377 | |
1378 if (FLAGS_pipe) { | |
1379 pipeErrors |= gmmain.test_pipe_playback(gm, compareConfig, | |
1380 comparisonBitmap); | |
1381 } | |
1382 | |
1383 if ((kEmptyErrorBitfield == pipeErrors) && | |
1384 FLAGS_tiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) { | |
1385 pipeErrors |= gmmain.test_tiled_pipe_playback(gm, compareConfig, | |
1386 comparisonBitmap); | |
1387 } | |
1388 | |
1389 errorsForAllModes |= pipeErrors; | |
1390 } | |
1391 return errorsForAllModes; | |
1392 } | |
1393 | |
1143 int tool_main(int argc, char** argv); | 1394 int tool_main(int argc, char** argv); |
1144 int tool_main(int argc, char** argv) { | 1395 int tool_main(int argc, char** argv) { |
1145 | 1396 |
1146 #if SK_ENABLE_INST_COUNT | 1397 #if SK_ENABLE_INST_COUNT |
1147 gPrintInstCount = true; | 1398 gPrintInstCount = true; |
1148 #endif | 1399 #endif |
1149 | 1400 |
1150 SkGraphics::Init(); | 1401 SkGraphics::Init(); |
1151 // we don't need to see this during a run | 1402 // we don't need to see this during a run |
1152 gSkSuppressFontCachePurgeSpew = true; | 1403 gSkSuppressFontCachePurgeSpew = true; |
1153 | 1404 |
1154 setSystemPreferences(); | 1405 setSystemPreferences(); |
1155 GMMain gmmain; | 1406 GMMain gmmain; |
1156 | 1407 |
1157 SkTDArray<size_t> configs; | 1408 SkTDArray<size_t> configs; |
1158 SkTDArray<size_t> excludeConfigs; | 1409 SkTDArray<size_t> excludeConfigs; |
1159 SkTDArray<SkScalar> tileGridReplayScales; | |
1160 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal e 1.0 | |
1161 bool userConfig = false; | 1410 bool userConfig = false; |
1162 | 1411 |
1163 SkString usage; | 1412 SkString usage; |
1164 usage.printf("Run the golden master tests.\n"); | 1413 usage.printf("Run the golden master tests.\n"); |
1165 SkFlags::SetUsage(usage.c_str()); | 1414 SkFlags::SetUsage(usage.c_str()); |
1166 SkFlags::ParseCommandLine(argc, argv); | 1415 SkFlags::ParseCommandLine(argc, argv); |
1167 | 1416 |
1168 #if SK_SUPPORT_GPU | |
1169 struct { | |
1170 int fBytes; | |
1171 int fCount; | |
1172 } gpuCacheSize = { -1, -1 }; // -1s mean use the default | |
1173 | |
1174 if (FLAGS_gpuCacheSize.count() > 0) { | |
1175 if (FLAGS_gpuCacheSize.count() != 2) { | |
1176 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); | |
1177 return -1; | |
1178 } | |
1179 gpuCacheSize.fBytes = atoi(FLAGS_gpuCacheSize[0]); | |
1180 gpuCacheSize.fCount = atoi(FLAGS_gpuCacheSize[1]); | |
1181 } | |
1182 #endif | |
1183 | |
1184 gmmain.fUseFileHierarchy = FLAGS_hierarchy; | 1417 gmmain.fUseFileHierarchy = FLAGS_hierarchy; |
1185 if (FLAGS_mismatchPath.count() == 1) { | 1418 if (FLAGS_mismatchPath.count() == 1) { |
1186 gmmain.fMismatchPath = FLAGS_mismatchPath[0]; | 1419 gmmain.fMismatchPath = FLAGS_mismatchPath[0]; |
1187 } | 1420 } |
1188 | 1421 |
1189 for (int i = 0; i < FLAGS_config.count(); i++) { | 1422 for (int i = 0; i < FLAGS_config.count(); i++) { |
1190 int index = findConfig(FLAGS_config[i]); | 1423 int index = findConfig(FLAGS_config[i]); |
1191 if (index >= 0) { | 1424 if (index >= 0) { |
1192 appendUnique<size_t>(&configs, index); | 1425 appendUnique<size_t>(&configs, index); |
1193 userConfig = true; | 1426 userConfig = true; |
1194 } else { | 1427 } else { |
1195 gm_fprintf(stderr, "unrecognized config %s\n", FLAGS_config[i]); | 1428 gm_fprintf(stderr, "unrecognized config %s\n", FLAGS_config[i]); |
1196 return -1; | 1429 return -1; |
1197 } | 1430 } |
1198 } | 1431 } |
1199 | 1432 |
1200 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) { | 1433 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) { |
1201 int index = findConfig(FLAGS_excludeConfig[i]); | 1434 int index = findConfig(FLAGS_excludeConfig[i]); |
1202 if (index >= 0) { | 1435 if (index >= 0) { |
1203 *excludeConfigs.append() = index; | 1436 *excludeConfigs.append() = index; |
1204 } else { | 1437 } else { |
1205 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC onfig[i]); | 1438 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC onfig[i]); |
1206 return -1; | 1439 return -1; |
1207 } | 1440 } |
1208 } | 1441 } |
1209 | 1442 |
1210 if (FLAGS_tileGridReplayScales.count() > 0) { | |
1211 tileGridReplayScales.reset(); | |
1212 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { | |
1213 double val = atof(FLAGS_tileGridReplayScales[i]); | |
1214 if (0 < val) { | |
1215 *tileGridReplayScales.append() = SkDoubleToScalar(val); | |
1216 } | |
1217 } | |
1218 if (0 == tileGridReplayScales.count()) { | |
1219 // Should have at least one scale | |
1220 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca le.\n"); | |
1221 return -1; | |
1222 } | |
1223 } | |
1224 | |
1225 int moduloRemainder = -1; | 1443 int moduloRemainder = -1; |
1226 int moduloDivisor = -1; | 1444 int moduloDivisor = -1; |
1227 | 1445 |
1228 if (FLAGS_modulo.count() == 2) { | 1446 if (FLAGS_modulo.count() == 2) { |
1229 moduloRemainder = atoi(FLAGS_modulo[0]); | 1447 moduloRemainder = atoi(FLAGS_modulo[0]); |
1230 moduloDivisor = atoi(FLAGS_modulo[1]); | 1448 moduloDivisor = atoi(FLAGS_modulo[1]); |
1231 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu loDivisor) { | 1449 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu loDivisor) { |
1232 gm_fprintf(stderr, "invalid modulo values."); | 1450 gm_fprintf(stderr, "invalid modulo values."); |
1233 return -1; | 1451 return -1; |
1234 } | 1452 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1364 if (skip_name(FLAGS_match, shortName)) { | 1582 if (skip_name(FLAGS_match, shortName)) { |
1365 SkDELETE(gm); | 1583 SkDELETE(gm); |
1366 continue; | 1584 continue; |
1367 } | 1585 } |
1368 | 1586 |
1369 SkISize size = gm->getISize(); | 1587 SkISize size = gm->getISize(); |
1370 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, | 1588 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, |
1371 size.width(), size.height()); | 1589 size.width(), size.height()); |
1372 | 1590 |
1373 ErrorBitfield testErrors = kEmptyErrorBitfield; | 1591 ErrorBitfield testErrors = kEmptyErrorBitfield; |
1374 uint32_t gmFlags = gm->getFlags(); | 1592 testErrors |= run_multiple_configs(gmmain, gm, configs, grFactory); |
1375 | |
1376 for (int i = 0; i < configs.count(); i++) { | |
1377 ConfigData config = gRec[configs[i]]; | |
1378 | |
1379 // Skip any tests that we don't even need to try. | |
1380 if ((kPDF_Backend == config.fBackend) && | |
1381 (!FLAGS_pdf|| (gmFlags & GM::kSkipPDF_Flag))) | |
1382 { | |
1383 continue; | |
1384 } | |
1385 if ((gmFlags & GM::kSkip565_Flag) && | |
1386 (kRaster_Backend == config.fBackend) && | |
1387 (SkBitmap::kRGB_565_Config == config.fConfig)) { | |
1388 continue; | |
1389 } | |
1390 if ((gmFlags & GM::kSkipGPU_Flag) && | |
1391 kGPU_Backend == config.fBackend) { | |
1392 continue; | |
1393 } | |
1394 | |
1395 // Now we know that we want to run this test and record its | |
1396 // success or failure. | |
1397 ErrorBitfield renderErrors = kEmptyErrorBitfield; | |
1398 GrRenderTarget* renderTarget = NULL; | |
1399 #if SK_SUPPORT_GPU | |
1400 SkAutoTUnref<GrRenderTarget> rt; | |
1401 AutoResetGr autogr; | |
1402 if ((kEmptyErrorBitfield == renderErrors) && | |
1403 kGPU_Backend == config.fBackend) { | |
1404 GrContext* gr = grFactory->get(config.fGLContextType); | |
1405 bool grSuccess = false; | |
1406 if (gr) { | |
1407 // create a render target to back the device | |
1408 GrTextureDesc desc; | |
1409 desc.fConfig = kSkia8888_GrPixelConfig; | |
1410 desc.fFlags = kRenderTarget_GrTextureFlagBit; | |
1411 desc.fWidth = gm->getISize().width(); | |
1412 desc.fHeight = gm->getISize().height(); | |
1413 desc.fSampleCnt = config.fSampleCnt; | |
1414 GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0); | |
1415 if (tex) { | |
1416 rt.reset(tex->asRenderTarget()); | |
1417 rt.get()->ref(); | |
1418 tex->unref(); | |
1419 autogr.set(gr); | |
1420 renderTarget = rt.get(); | |
1421 grSuccess = NULL != renderTarget; | |
1422 } | |
1423 // Set the user specified cache limits if non-default. | |
1424 size_t bytes; | |
1425 int count; | |
1426 gr->getTextureCacheLimits(&count, &bytes); | |
1427 if (-1 != gpuCacheSize.fBytes) { | |
1428 bytes = static_cast<size_t>(gpuCacheSize.fBytes); | |
1429 } | |
1430 if (-1 != gpuCacheSize.fCount) { | |
1431 count = gpuCacheSize.fCount; | |
1432 } | |
1433 gr->setTextureCacheLimits(count, bytes); | |
1434 } | |
1435 if (!grSuccess) { | |
1436 renderErrors |= kNoGpuContext_ErrorBitmask; | |
1437 } | |
1438 } | |
1439 #endif | |
1440 | |
1441 SkBitmap comparisonBitmap; | |
1442 | |
1443 const char* writePath; | |
1444 if (FLAGS_writePath.count() == 1) { | |
1445 writePath = FLAGS_writePath[0]; | |
1446 } else { | |
1447 writePath = NULL; | |
1448 } | |
1449 if (kEmptyErrorBitfield == renderErrors) { | |
1450 renderErrors |= gmmain.test_drawing(gm, config, writePath, | |
1451 GetGr(), | |
1452 renderTarget, | |
1453 &comparisonBitmap); | |
1454 } | |
1455 | |
1456 if (FLAGS_deferred && !renderErrors && | |
1457 (kGPU_Backend == config.fBackend || | |
1458 kRaster_Backend == config.fBackend)) { | |
1459 renderErrors |= gmmain.test_deferred_drawing(gm, config, | |
1460 comparisonBitmap, | |
1461 GetGr(), | |
1462 renderTarget); | |
1463 } | |
1464 | |
1465 testErrors |= renderErrors; | |
1466 } | |
1467 | 1593 |
1468 SkBitmap comparisonBitmap; | 1594 SkBitmap comparisonBitmap; |
1469 const ConfigData compareConfig = | 1595 const ConfigData compareConfig = |
1470 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT ype, 0, kRW_ConfigFlag, "comparison", false }; | 1596 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT ype, 0, kRW_ConfigFlag, "comparison", false }; |
1471 testErrors |= gmmain.generate_image(gm, compareConfig, NULL, NULL, &comp arisonBitmap, false); | 1597 testErrors |= gmmain.generate_image(gm, compareConfig, NULL, NULL, &comp arisonBitmap, false); |
1472 | 1598 |
1473 // run the picture centric GM steps | 1599 // TODO(epoger): only run this if gmmain.generate_image() succeeded? |
1474 if (!(gmFlags & GM::kSkipPicture_Flag)) { | 1600 // Otherwise, what are we comparing against? |
1475 | 1601 testErrors |= run_multiple_modes(gmmain, gm, compareConfig, comparisonBi tmap); |
1476 ErrorBitfield pictErrors = kEmptyErrorBitfield; | |
1477 | |
1478 //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm)); | |
1479 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); | |
1480 SkAutoUnref aur(pict); | |
1481 | |
1482 if ((kEmptyErrorBitfield == testErrors) && FLAGS_replay) { | |
1483 SkBitmap bitmap; | |
1484 gmmain.generate_image_from_picture(gm, compareConfig, pict, | |
1485 &bitmap); | |
1486 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( | |
1487 gm, compareConfig, "-replay", bitmap, &comparisonBitmap); | |
1488 } | |
1489 | |
1490 if ((kEmptyErrorBitfield == testErrors) && | |
1491 (kEmptyErrorBitfield == pictErrors) && | |
1492 FLAGS_serialize) { | |
1493 SkPicture* repict = gmmain.stream_to_new_picture(*pict); | |
1494 SkAutoUnref aurr(repict); | |
1495 | |
1496 SkBitmap bitmap; | |
1497 gmmain.generate_image_from_picture(gm, compareConfig, repict, | |
1498 &bitmap); | |
1499 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( | |
1500 gm, compareConfig, "-serialize", bitmap, &comparisonBitmap); | |
1501 } | |
1502 | |
1503 if (FLAGS_writePicturePath.count() == 1) { | |
1504 const char* pictureSuffix = "skp"; | |
1505 SkString path = make_filename(FLAGS_writePicturePath[0], "", | |
1506 gm->shortName(), | |
1507 pictureSuffix); | |
1508 SkFILEWStream stream(path.c_str()); | |
1509 pict->serialize(&stream); | |
1510 } | |
1511 | |
1512 testErrors |= pictErrors; | |
1513 } | |
1514 | |
1515 // TODO: add a test in which the RTree rendering results in a | |
1516 // different bitmap than the standard rendering. It should | |
1517 // show up as failed in the JSON summary, and should be listed | |
1518 // in the stdout also. | |
1519 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_rtree) { | |
1520 SkPicture* pict = gmmain.generate_new_picture( | |
1521 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl ag); | |
1522 SkAutoUnref aur(pict); | |
1523 SkBitmap bitmap; | |
1524 gmmain.generate_image_from_picture(gm, compareConfig, pict, | |
1525 &bitmap); | |
1526 testErrors |= gmmain.compare_test_results_to_reference_bitmap( | |
1527 gm, compareConfig, "-rtree", bitmap, &comparisonBitmap); | |
1528 } | |
1529 | |
1530 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_tileGrid) { | |
1531 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); + +scaleIndex) { | |
1532 SkScalar replayScale = tileGridReplayScales[scaleIndex]; | |
1533 if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1) | |
1534 continue; | |
1535 // We record with the reciprocal scale to obtain a replay | |
1536 // result that can be validated against comparisonBitmap. | |
1537 SkScalar recordScale = SkScalarInvert(replayScale); | |
1538 SkPicture* pict = gmmain.generate_new_picture( | |
1539 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco rdingFlag, | |
1540 recordScale); | |
1541 SkAutoUnref aur(pict); | |
1542 SkBitmap bitmap; | |
1543 gmmain.generate_image_from_picture(gm, compareConfig, pict, | |
1544 &bitmap, replayScale); | |
1545 SkString suffix("-tilegrid"); | |
1546 if (SK_Scalar1 != replayScale) { | |
1547 suffix += "-scale-"; | |
1548 suffix.appendScalar(replayScale); | |
1549 } | |
1550 testErrors |= gmmain.compare_test_results_to_reference_bitmap( | |
1551 gm, compareConfig, suffix.c_str(), bitmap, | |
1552 &comparisonBitmap); | |
1553 } | |
1554 } | |
1555 | |
1556 // run the pipe centric GM steps | |
1557 if (!(gmFlags & GM::kSkipPipe_Flag)) { | |
1558 | |
1559 ErrorBitfield pipeErrors = kEmptyErrorBitfield; | |
1560 | |
1561 if ((kEmptyErrorBitfield == testErrors) && FLAGS_pipe) { | |
1562 pipeErrors |= gmmain.test_pipe_playback(gm, compareConfig, | |
1563 comparisonBitmap); | |
1564 } | |
1565 | |
1566 if ((kEmptyErrorBitfield == testErrors) && | |
1567 (kEmptyErrorBitfield == pipeErrors) && | |
1568 FLAGS_tiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) { | |
1569 pipeErrors |= gmmain.test_tiled_pipe_playback(gm, compareConfig, | |
1570 comparisonBitmap); | |
1571 } | |
1572 | |
1573 testErrors |= pipeErrors; | |
1574 } | |
1575 | 1602 |
1576 // Update overall results. | 1603 // Update overall results. |
1577 // We only tabulate the particular error types that we currently | 1604 // We only tabulate the particular error types that we currently |
1578 // care about (e.g., missing reference images). Later on, if we | 1605 // care about (e.g., missing reference images). Later on, if we |
1579 // want to also tabulate other error types, we can do so. | 1606 // want to also tabulate other error types, we can do so. |
1580 testsRun++; | 1607 testsRun++; |
1581 if (!gmmain.fExpectationsSource.get() || | 1608 if (!gmmain.fExpectationsSource.get() || |
1582 (kEmptyErrorBitfield != (kMissingExpectations_ErrorBitmask & testErr ors))) { | 1609 (kEmptyErrorBitfield != (kMissingExpectations_ErrorBitmask & testErr ors))) { |
1583 testsMissingReferenceImages++; | 1610 testsMissingReferenceImages++; |
1584 } | 1611 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1638 if (FLAGS_forceBWtext) { | 1665 if (FLAGS_forceBWtext) { |
1639 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1666 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
1640 } | 1667 } |
1641 } | 1668 } |
1642 | 1669 |
1643 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1670 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
1644 int main(int argc, char * const argv[]) { | 1671 int main(int argc, char * const argv[]) { |
1645 return tool_main(argc, (char**) argv); | 1672 return tool_main(argc, (char**) argv); |
1646 } | 1673 } |
1647 #endif | 1674 #endif |
OLD | NEW |