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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 kRaster_Backend, | 135 kRaster_Backend, |
136 kGPU_Backend, | 136 kGPU_Backend, |
137 kPDF_Backend, | 137 kPDF_Backend, |
138 kXPS_Backend, | 138 kXPS_Backend, |
139 }; | 139 }; |
140 | 140 |
141 enum BbhType { | 141 enum BbhType { |
142 kNone_BbhType, | 142 kNone_BbhType, |
143 kRTree_BbhType, | 143 kRTree_BbhType, |
144 kTileGrid_BbhType, | 144 kTileGrid_BbhType, |
145 kQuadTree_BbhType | |
146 }; | 145 }; |
147 | 146 |
148 enum ConfigFlags { | 147 enum ConfigFlags { |
149 kNone_ConfigFlag = 0x0, | 148 kNone_ConfigFlag = 0x0, |
150 /* Write GM images if a write path is provided. */ | 149 /* Write GM images if a write path is provided. */ |
151 kWrite_ConfigFlag = 0x1, | 150 kWrite_ConfigFlag = 0x1, |
152 /* Read reference GM images if a read path is provided. */ | 151 /* Read reference GM images if a read path is provided. */ |
153 kRead_ConfigFlag = 0x2, | 152 kRead_ConfigFlag = 0x2, |
154 kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag), | 153 kRW_ConfigFlag = (kWrite_ConfigFlag | kRead_ConfigFlag), |
155 }; | 154 }; |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w
idth()), scale)); | 1014 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w
idth()), scale)); |
1016 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().
height()), scale)); | 1015 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().
height()), scale)); |
1017 | 1016 |
1018 SkAutoTDelete<SkBBHFactory> factory; | 1017 SkAutoTDelete<SkBBHFactory> factory; |
1019 if (kTileGrid_BbhType == bbhType) { | 1018 if (kTileGrid_BbhType == bbhType) { |
1020 SkTileGridFactory::TileGridInfo info; | 1019 SkTileGridFactory::TileGridInfo info; |
1021 info.fMargin.setEmpty(); | 1020 info.fMargin.setEmpty(); |
1022 info.fOffset.setZero(); | 1021 info.fOffset.setZero(); |
1023 info.fTileInterval.set(16, 16); | 1022 info.fTileInterval.set(16, 16); |
1024 factory.reset(SkNEW_ARGS(SkTileGridFactory, (info))); | 1023 factory.reset(SkNEW_ARGS(SkTileGridFactory, (info))); |
1025 } else if (kQuadTree_BbhType == bbhType) { | |
1026 factory.reset(SkNEW(SkQuadTreeFactory)); | |
1027 } else if (kRTree_BbhType == bbhType) { | 1024 } else if (kRTree_BbhType == bbhType) { |
1028 factory.reset(SkNEW(SkRTreeFactory)); | 1025 factory.reset(SkNEW(SkRTreeFactory)); |
1029 } | 1026 } |
1030 SkPictureRecorder recorder; | 1027 SkPictureRecorder recorder; |
1031 SkCanvas* cv = recorder.beginRecording(width, height, factory.get(), rec
ordFlags); | 1028 SkCanvas* cv = recorder.beginRecording(width, height, factory.get(), rec
ordFlags); |
1032 cv->scale(scale, scale); | 1029 cv->scale(scale, scale); |
1033 invokeGM(gm, cv, false, false); | 1030 invokeGM(gm, cv, false, false); |
1034 return recorder.endRecording(); | 1031 return recorder.endRecording(); |
1035 } | 1032 } |
1036 | 1033 |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 "^ and $ requires an exact match\n" | 1456 "^ and $ requires an exact match\n" |
1460 "If a test does not match any list entry,\n" | 1457 "If a test does not match any list entry,\n" |
1461 "it is skipped unless some list entry starts with ~"); | 1458 "it is skipped unless some list entry starts with ~"); |
1462 DEFINE_string(missingExpectationsPath, "", "Write images for tests without expec
tations " | 1459 DEFINE_string(missingExpectationsPath, "", "Write images for tests without expec
tations " |
1463 "into this directory."); | 1460 "into this directory."); |
1464 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " | 1461 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " |
1465 "pixel mismatches into this directory."); | 1462 "pixel mismatches into this directory."); |
1466 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for
which " | 1463 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for
which " |
1467 "testIndex %% divisor == remainder."); | 1464 "testIndex %% divisor == remainder."); |
1468 DEFINE_bool(pipe, false, "Exercise the SkGPipe replay test pass."); | 1465 DEFINE_bool(pipe, false, "Exercise the SkGPipe replay test pass."); |
1469 DEFINE_bool(quadtree, false, "Exercise the QuadTree variant of SkPicture test pa
ss."); | |
1470 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report
" | 1466 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report
" |
1471 "any differences between those and the newly generated ones."); | 1467 "any differences between those and the newly generated ones."); |
1472 DEFINE_bool(replay, false, "Exercise the SkPicture replay test pass."); | 1468 DEFINE_bool(replay, false, "Exercise the SkPicture replay test pass."); |
1473 #if SK_SUPPORT_GPU | 1469 #if SK_SUPPORT_GPU |
1474 DEFINE_bool(resetGpuContext, false, "Reset the GrContext prior to running each G
M."); | 1470 DEFINE_bool(resetGpuContext, false, "Reset the GrContext prior to running each G
M."); |
1475 #endif | 1471 #endif |
1476 DEFINE_bool(rtree, false, "Exercise the R-Tree variant of SkPicture test pass.")
; | 1472 DEFINE_bool(rtree, false, "Exercise the R-Tree variant of SkPicture test pass.")
; |
1477 DEFINE_bool(serialize, false, "Exercise the SkPicture serialization & deserializ
ation test pass."); | 1473 DEFINE_bool(serialize, false, "Exercise the SkPicture serialization & deserializ
ation test pass."); |
1478 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in
pipe mode only."); | 1474 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in
pipe mode only."); |
1479 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); | 1475 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 SkPicture* pict = gmmain.generate_new_picture(gm, kRTree_BbhType, 0)
; | 1628 SkPicture* pict = gmmain.generate_new_picture(gm, kRTree_BbhType, 0)
; |
1633 SkAutoUnref aur(pict); | 1629 SkAutoUnref aur(pict); |
1634 SkBitmap bitmap; | 1630 SkBitmap bitmap; |
1635 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap)
; | 1631 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap)
; |
1636 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma
p( | 1632 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma
p( |
1637 gm->getName(), compareConfig.fName, renderModeDescriptor, bitmap
, | 1633 gm->getName(), compareConfig.fName, renderModeDescriptor, bitmap
, |
1638 &comparisonBitmap)); | 1634 &comparisonBitmap)); |
1639 } | 1635 } |
1640 } | 1636 } |
1641 | 1637 |
1642 if (FLAGS_quadtree) { | |
1643 const char renderModeDescriptor[] = "-quadtree"; | |
1644 if ((gmFlags & GM::kSkipPicture_Flag) || (gmFlags & GM::kSkipTiled_Flag)
) { | |
1645 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP
lusConfig, | |
1646 renderModeDescriptor); | |
1647 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | |
1648 } else { | |
1649 SkPicture* pict = gmmain.generate_new_picture(gm, kQuadTree_BbhType,
0); | |
1650 SkAutoUnref aur(pict); | |
1651 SkBitmap bitmap; | |
1652 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap)
; | |
1653 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma
p( | |
1654 gm->getName(), compareConfig.fName, renderModeDescriptor, bitmap
, | |
1655 &comparisonBitmap)); | |
1656 } | |
1657 } | |
1658 | |
1659 if (FLAGS_tileGrid) { | 1638 if (FLAGS_tileGrid) { |
1660 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca
leIndex) { | 1639 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca
leIndex) { |
1661 SkScalar replayScale = tileGridReplayScales[scaleIndex]; | 1640 SkScalar replayScale = tileGridReplayScales[scaleIndex]; |
1662 SkString renderModeDescriptor("-tilegrid"); | 1641 SkString renderModeDescriptor("-tilegrid"); |
1663 if (SK_Scalar1 != replayScale) { | 1642 if (SK_Scalar1 != replayScale) { |
1664 renderModeDescriptor += "-scale-"; | 1643 renderModeDescriptor += "-scale-"; |
1665 renderModeDescriptor.appendScalar(replayScale); | 1644 renderModeDescriptor.appendScalar(replayScale); |
1666 } | 1645 } |
1667 | 1646 |
1668 if ((gmFlags & GM::kSkipPicture_Flag) || | 1647 if ((gmFlags & GM::kSkipPicture_Flag) || |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2500 if (FLAGS_forceBWtext) { | 2479 if (FLAGS_forceBWtext) { |
2501 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2480 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2502 } | 2481 } |
2503 } | 2482 } |
2504 | 2483 |
2505 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2484 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2506 int main(int argc, char * const argv[]) { | 2485 int main(int argc, char * const argv[]) { |
2507 return tool_main(argc, (char**) argv); | 2486 return tool_main(argc, (char**) argv); |
2508 } | 2487 } |
2509 #endif | 2488 #endif |
OLD | NEW |