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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 SkString filename = make_shortname_plus_config(shortName, configName); | 240 SkString filename = make_shortname_plus_config(shortName, configName); |
241 filename.append(renderModeDescriptor); | 241 filename.append(renderModeDescriptor); |
242 filename.appendUnichar('.'); | 242 filename.appendUnichar('.'); |
243 filename.append(suffix); | 243 filename.append(suffix); |
244 return SkOSPath::Join(path, filename.c_str()); | 244 return SkOSPath::Join(path, filename.c_str()); |
245 } | 245 } |
246 | 246 |
247 /** | 247 /** |
248 * Assemble filename suitable for writing out an SkBitmap. | 248 * Assemble filename suitable for writing out an SkBitmap. |
249 */ | 249 */ |
250 SkString make_bitmap_filename(const char *path, | 250 SkString makeBitmapFilename(const char *path, |
251 const char *shortName, | 251 const char *shortName, |
252 const char *configName, | 252 const char *configName, |
253 const char *renderModeDescriptor, | 253 const char *renderModeDescriptor, |
254 const GmResultDigest &bitmapDigest) { | 254 const GmResultDigest &bitmapDigest) { |
255 if (fWriteChecksumBasedFilenames) { | 255 if (fWriteChecksumBasedFilenames) { |
256 SkString filename; | 256 SkString filename; |
257 filename.append(bitmapDigest.getHashType()); | 257 filename.append(bitmapDigest.getHashType()); |
258 filename.appendUnichar('_'); | 258 filename.appendUnichar('_'); |
259 filename.append(shortName); | 259 filename.append(shortName); |
260 filename.appendUnichar('_'); | 260 filename.appendUnichar('_'); |
261 filename.append(bitmapDigest.getDigestValue()); | 261 filename.append(bitmapDigest.getDigestValue()); |
262 filename.appendUnichar('.'); | 262 filename.appendUnichar('.'); |
263 filename.append(kPNG_FileExtension); | 263 filename.append(kPNG_FileExtension); |
264 return SkOSPath::Join(path, filename.c_str()); | 264 return SkOSPath::Join(path, filename.c_str()); |
(...skipping 24 matching lines...) Expand all Loading... |
289 | 289 |
290 static void force_all_opaque_8888(const SkBitmap& bitmap) { | 290 static void force_all_opaque_8888(const SkBitmap& bitmap) { |
291 SkAutoLockPixels lock(bitmap); | 291 SkAutoLockPixels lock(bitmap); |
292 for (int y = 0; y < bitmap.height(); y++) { | 292 for (int y = 0; y < bitmap.height(); y++) { |
293 for (int x = 0; x < bitmap.width(); x++) { | 293 for (int x = 0; x < bitmap.width(); x++) { |
294 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 294 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
295 } | 295 } |
296 } | 296 } |
297 } | 297 } |
298 | 298 |
299 static ErrorCombination write_bitmap(const SkString& path, const SkBitmap& b
itmap) { | 299 static ErrorCombination WriteBitmap(const SkString& path, const SkBitmap& bi
tmap) { |
300 // TODO(epoger): Now that we have removed force_all_opaque() | 300 // TODO(epoger): Now that we have removed force_all_opaque() |
301 // from this method, we should be able to get rid of the | 301 // from this method, we should be able to get rid of the |
302 // transformation to 8888 format also. | 302 // transformation to 8888 format also. |
303 SkBitmap copy; | 303 SkBitmap copy; |
304 bitmap.copyTo(©, kN32_SkColorType); | 304 bitmap.copyTo(©, kN32_SkColorType); |
305 if (!SkImageEncoder::EncodeFile(path.c_str(), copy, | 305 if (!SkImageEncoder::EncodeFile(path.c_str(), copy, |
306 SkImageEncoder::kPNG_Type, | 306 SkImageEncoder::kPNG_Type, |
307 100)) { | 307 100)) { |
308 SkDebugf("FAILED to write bitmap: %s\n", path.c_str()); | 308 SkDebugf("FAILED to write bitmap: %s\n", path.c_str()); |
309 return ErrorCombination(kWritingReferenceImage_ErrorType); | 309 return ErrorCombination(kWritingReferenceImage_ErrorType); |
(...skipping 18 matching lines...) Expand all Loading... |
328 if (modeAsString.startsWith("-")) { | 328 if (modeAsString.startsWith("-")) { |
329 modeAsString.remove(0, 1); | 329 modeAsString.remove(0, 1); |
330 } | 330 } |
331 modes.push_back(modeAsString); | 331 modes.push_back(modeAsString); |
332 } | 332 } |
333 } | 333 } |
334 | 334 |
335 /** | 335 /** |
336 * Returns true if failures on this test should be ignored. | 336 * Returns true if failures on this test should be ignored. |
337 */ | 337 */ |
338 bool ShouldIgnoreTest(const char *name) const { | 338 bool shouldIgnoreTest(const char *name) const { |
339 for (int i = 0; i < fIgnorableTestNames.count(); i++) { | 339 for (int i = 0; i < fIgnorableTestNames.count(); i++) { |
340 if (fIgnorableTestNames[i].equals(name)) { | 340 if (fIgnorableTestNames[i].equals(name)) { |
341 return true; | 341 return true; |
342 } | 342 } |
343 } | 343 } |
344 return false; | 344 return false; |
345 } | 345 } |
346 | 346 |
347 /** | 347 /** |
348 * Calls RecordTestResults to record that we skipped a test. | 348 * Calls RecordTestResults to record that we skipped a test. |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 completeNameString.append("."); | 836 completeNameString.append("."); |
837 completeNameString.append(kPNG_FileExtension); | 837 completeNameString.append(kPNG_FileExtension); |
838 const char* completeName = completeNameString.c_str(); | 838 const char* completeName = completeNameString.c_str(); |
839 | 839 |
840 if (expectations.empty()) { | 840 if (expectations.empty()) { |
841 errors.add(kMissingExpectations_ErrorType); | 841 errors.add(kMissingExpectations_ErrorType); |
842 | 842 |
843 // Write out the "actuals" for any tests without expectations, if we
have | 843 // Write out the "actuals" for any tests without expectations, if we
have |
844 // been directed to do so. | 844 // been directed to do so. |
845 if (fMissingExpectationsPath) { | 845 if (fMissingExpectationsPath) { |
846 SkString path = make_bitmap_filename(fMissingExpectationsPath, s
hortName, | 846 SkString path = this->makeBitmapFilename(fMissingExpectationsPat
h, shortName, |
847 configName, renderModeDescr
iptor, | 847 configName, renderModeD
escriptor, |
848 actualBitmapAndDigest.fDige
st); | 848 actualBitmapAndDigest.f
Digest); |
849 write_bitmap(path, actualBitmapAndDigest.fBitmap); | 849 WriteBitmap(path, actualBitmapAndDigest.fBitmap); |
850 } | 850 } |
851 | 851 |
852 } else if (!expectations.match(actualBitmapAndDigest.fDigest)) { | 852 } else if (!expectations.match(actualBitmapAndDigest.fDigest)) { |
853 addToJsonSummary = true; | 853 addToJsonSummary = true; |
854 // The error mode we record depends on whether this was running | 854 // The error mode we record depends on whether this was running |
855 // in a non-standard renderMode. | 855 // in a non-standard renderMode. |
856 if ('\0' == *renderModeDescriptor) { | 856 if ('\0' == *renderModeDescriptor) { |
857 errors.add(kExpectationsMismatch_ErrorType); | 857 errors.add(kExpectationsMismatch_ErrorType); |
858 } else { | 858 } else { |
859 errors.add(kRenderModeMismatch_ErrorType); | 859 errors.add(kRenderModeMismatch_ErrorType); |
860 } | 860 } |
861 | 861 |
862 // Write out the "actuals" for any mismatches, if we have | 862 // Write out the "actuals" for any mismatches, if we have |
863 // been directed to do so. | 863 // been directed to do so. |
864 if (fMismatchPath) { | 864 if (fMismatchPath) { |
865 SkString path = make_bitmap_filename(fMismatchPath, shortName, c
onfigName, | 865 SkString path = this->makeBitmapFilename(fMismatchPath, shortNam
e, configName, |
866 renderModeDescriptor, | 866 renderModeDescriptor, |
867 actualBitmapAndDigest.fDige
st); | 867 actualBitmapAndDigest.f
Digest); |
868 write_bitmap(path, actualBitmapAndDigest.fBitmap); | 868 WriteBitmap(path, actualBitmapAndDigest.fBitmap); |
869 } | 869 } |
870 | 870 |
871 // If we have access to a single expected bitmap, log more | 871 // If we have access to a single expected bitmap, log more |
872 // detail about the mismatch. | 872 // detail about the mismatch. |
873 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); | 873 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); |
874 if (expectedBitmapPtr) { | 874 if (expectedBitmapPtr) { |
875 report_bitmap_diffs(*expectedBitmapPtr, actualBitmapAndDigest.fB
itmap, | 875 report_bitmap_diffs(*expectedBitmapPtr, actualBitmapAndDigest.fB
itmap, |
876 completeName); | 876 completeName); |
877 } | 877 } |
878 } | 878 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 | 937 |
938 /** | 938 /** |
939 * Compare actualBitmap to expectations stored in this->fExpectationsSource. | 939 * Compare actualBitmap to expectations stored in this->fExpectationsSource. |
940 * | 940 * |
941 * @param gm which test generated the actualBitmap | 941 * @param gm which test generated the actualBitmap |
942 * @param gRec | 942 * @param gRec |
943 * @param configName The config name to look for in the expectation file. | 943 * @param configName The config name to look for in the expectation file. |
944 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL | 944 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL |
945 * if we don't have a usable bitmap representation | 945 * if we don't have a usable bitmap representation |
946 */ | 946 */ |
947 ErrorCombination compare_test_results_to_stored_expectations( | 947 ErrorCombination compareTestResultsToStoredExpectations( |
948 GM* gm, const ConfigData& gRec, const char* configName, | 948 GM* gm, const ConfigData& gRec, const char* configName, |
949 const BitmapAndDigest* actualBitmapAndDigest) { | 949 const BitmapAndDigest* actualBitmapAndDigest) { |
950 ErrorCombination errors; | 950 ErrorCombination errors; |
951 | 951 |
952 if (NULL == actualBitmapAndDigest) { | 952 if (NULL == actualBitmapAndDigest) { |
953 // Note that we intentionally skipped validating the results for | 953 // Note that we intentionally skipped validating the results for |
954 // this test, because we don't know how to generate an SkBitmap | 954 // this test, because we don't know how to generate an SkBitmap |
955 // version of the output. | 955 // version of the output. |
956 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); | 956 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); |
957 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) { | 957 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) { |
(...skipping 17 matching lines...) Expand all Loading... |
975 * | 975 * |
976 * TODO(epoger): This relies on the fact that | 976 * TODO(epoger): This relies on the fact that |
977 * force_all_opaque() was called on the bitmap before it | 977 * force_all_opaque() was called on the bitmap before it |
978 * was written to disk as a PNG in the first place. If | 978 * was written to disk as a PNG in the first place. If |
979 * not, the hash digest returned here may not match the | 979 * not, the hash digest returned here may not match the |
980 * hash digest of actualBitmap, which *has* been run through | 980 * hash digest of actualBitmap, which *has* been run through |
981 * force_all_opaque(). | 981 * force_all_opaque(). |
982 * See comments above complete_bitmap() for more detail. | 982 * See comments above complete_bitmap() for more detail. |
983 */ | 983 */ |
984 Expectations expectations = expectationsSource->get(nameWithExte
nsion.c_str()); | 984 Expectations expectations = expectationsSource->get(nameWithExte
nsion.c_str()); |
985 if (this->ShouldIgnoreTest(gm->getName())) { | 985 if (this->shouldIgnoreTest(gm->getName())) { |
986 expectations.setIgnoreFailure(true); | 986 expectations.setIgnoreFailure(true); |
987 } | 987 } |
988 errors.add(compare_to_expectations(expectations, *actualBitmapAn
dDigest, | 988 errors.add(compare_to_expectations(expectations, *actualBitmapAn
dDigest, |
989 gm->getName(), configName, ""
, true)); | 989 gm->getName(), configName, ""
, true)); |
990 } else { | 990 } else { |
991 // If we are running without expectations, we still want to | 991 // If we are running without expectations, we still want to |
992 // record the actual results. | 992 // record the actual results. |
993 add_actual_results_to_json_summary(nameWithExtension.c_str(), | 993 add_actual_results_to_json_summary(nameWithExtension.c_str(), |
994 actualBitmapAndDigest->fDiges
t, | 994 actualBitmapAndDigest->fDiges
t, |
995 ErrorCombination(kMissingExpe
ctations_ErrorType), | 995 ErrorCombination(kMissingExpe
ctations_ErrorType), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 // Test: draw into a bitmap or pdf. | 1065 // Test: draw into a bitmap or pdf. |
1066 // Depending on flags, possibly compare to an expected image. | 1066 // Depending on flags, possibly compare to an expected image. |
1067 // If writePath is not NULL, also write images (or documents) to the specifi
ed path. | 1067 // If writePath is not NULL, also write images (or documents) to the specifi
ed path. |
1068 ErrorCombination test_drawing(GM* gm, const ConfigData& gRec, | 1068 ErrorCombination test_drawing(GM* gm, const ConfigData& gRec, |
1069 const SkTDArray<const PDFRasterizerData*> &pdf
Rasterizers, | 1069 const SkTDArray<const PDFRasterizerData*> &pdf
Rasterizers, |
1070 const char writePath [], | 1070 const char writePath [], |
1071 GrSurface* gpuTarget, | 1071 GrSurface* gpuTarget, |
1072 SkBitmap* bitmap) { | 1072 SkBitmap* bitmap) { |
1073 ErrorCombination errors; | 1073 ErrorCombination errors; |
1074 SkDynamicMemoryWStream document; | 1074 SkDynamicMemoryWStream document; |
1075 SkString path; | |
1076 | 1075 |
1077 if (gRec.fBackend == kRaster_Backend || | 1076 if (gRec.fBackend == kRaster_Backend || |
1078 gRec.fBackend == kGPU_Backend) { | 1077 gRec.fBackend == kGPU_Backend) { |
1079 // Early exit if we can't generate the image. | 1078 // Early exit if we can't generate the image. |
1080 errors.add(generate_image(gm, gRec, gpuTarget, bitmap, false)); | 1079 errors.add(generate_image(gm, gRec, gpuTarget, bitmap, false)); |
1081 if (!errors.isEmpty()) { | 1080 if (!errors.isEmpty()) { |
1082 // TODO: Add a test to exercise what the stdout and | 1081 // TODO: Add a test to exercise what the stdout and |
1083 // JSON look like if we get an "early error" while | 1082 // JSON look like if we get an "early error" while |
1084 // trying to generate the image. | 1083 // trying to generate the image. |
1085 return errors; | 1084 return errors; |
1086 } | 1085 } |
1087 BitmapAndDigest bitmapAndDigest(*bitmap); | |
1088 errors.add(compare_test_results_to_stored_expectations( | |
1089 gm, gRec, gRec.fName, &bitmapAndDigest)); | |
1090 | 1086 |
1091 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 1087 errors.add(this->writeBitmap(gm, gRec, gRec.fName, writePath, *bitma
p)); |
1092 path = make_bitmap_filename(writePath, gm->getName(), gRec.fName
, | |
1093 "", bitmapAndDigest.fDigest); | |
1094 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); | |
1095 } | |
1096 } else if (gRec.fBackend == kPDF_Backend) { | 1088 } else if (gRec.fBackend == kPDF_Backend) { |
1097 if (!generate_pdf(gm, document)) { | 1089 if (!generate_pdf(gm, document)) { |
1098 errors.add(kGeneratePdfFailed_ErrorType); | 1090 errors.add(kGeneratePdfFailed_ErrorType); |
1099 } else { | 1091 } else { |
1100 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStre
am()); | 1092 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStre
am()); |
1101 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 1093 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
1102 path = make_filename(writePath, gm->getName(), gRec.fName, "
", "pdf"); | 1094 SkString path = make_filename(writePath, gm->getName(), gRec
.fName, "", "pdf"); |
1103 errors.add(write_document(path, documentStream)); | 1095 errors.add(write_document(path, documentStream)); |
1104 } | 1096 } |
1105 | 1097 |
1106 if (!(gm->getFlags() & GM::kSkipPDFRasterization_Flag)) { | 1098 if (!(gm->getFlags() & GM::kSkipPDFRasterization_Flag)) { |
1107 for (int i = 0; i < pdfRasterizers.count(); i++) { | 1099 for (int i = 0; i < pdfRasterizers.count(); i++) { |
1108 SkBitmap pdfBitmap; | 1100 SkBitmap pdfBitmap; |
1109 documentStream->rewind(); | 1101 documentStream->rewind(); |
1110 bool success = (*pdfRasterizers[i]->fRasterizerFunction)
( | 1102 bool success = (*pdfRasterizers[i]->fRasterizerFunction)
( |
1111 documentStream.get(), &pdfBitmap); | 1103 documentStream.get(), &pdfBitmap); |
1112 if (!success) { | 1104 if (!success) { |
1113 SkDebugf("FAILED to render PDF for %s using renderer
%s\n", | 1105 SkDebugf("FAILED to render PDF for %s using renderer
%s\n", |
1114 gm->getName(), | 1106 gm->getName(), |
1115 pdfRasterizers[i]->fName); | 1107 pdfRasterizers[i]->fName); |
1116 continue; | 1108 continue; |
1117 } | 1109 } |
1118 | 1110 |
1119 SkString configName(gRec.fName); | 1111 SkString configName(gRec.fName); |
1120 configName.append("-"); | 1112 configName.append("-"); |
1121 configName.append(pdfRasterizers[i]->fName); | 1113 configName.append(pdfRasterizers[i]->fName); |
1122 | 1114 |
1123 BitmapAndDigest bitmapAndDigest(pdfBitmap); | 1115 errors.add(this->writeBitmap(gm, gRec, configName.c_str(
), |
1124 errors.add(compare_test_results_to_stored_expectations( | 1116 writePath, pdfBitmap)); |
1125 gm, gRec, configName.c_str(), &bitmapAndDiges
t)); | |
1126 | |
1127 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | |
1128 path = make_bitmap_filename(writePath, gm->getName()
, | |
1129 configName.c_str(), | |
1130 "", bitmapAndDigest.fDig
est); | |
1131 errors.add(write_bitmap(path, bitmapAndDigest.fBitma
p)); | |
1132 } | |
1133 } | 1117 } |
1134 } else { | 1118 } else { |
1135 errors.add(kIntentionallySkipped_ErrorType); | 1119 errors.add(kIntentionallySkipped_ErrorType); |
1136 } | 1120 } |
1137 } | 1121 } |
1138 } else if (gRec.fBackend == kXPS_Backend) { | 1122 } else if (gRec.fBackend == kXPS_Backend) { |
1139 generate_xps(gm, document); | 1123 generate_xps(gm, document); |
1140 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream()
); | 1124 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream()
); |
1141 | 1125 |
1142 errors.add(compare_test_results_to_stored_expectations( | 1126 errors.add(this->compareTestResultsToStoredExpectations( |
1143 gm, gRec, gRec.fName, NULL)); | 1127 gm, gRec, gRec.fName, NULL)); |
1144 | 1128 |
1145 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 1129 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
1146 path = make_filename(writePath, gm->getName(), gRec.fName, "", "
xps"); | 1130 SkString path = make_filename(writePath, gm->getName(), gRec.fNa
me, "", "xps"); |
1147 errors.add(write_document(path, documentStream)); | 1131 errors.add(write_document(path, documentStream)); |
1148 } | 1132 } |
1149 } else { | 1133 } else { |
1150 SkASSERT(false); | 1134 SkASSERT(false); |
1151 } | 1135 } |
1152 return errors; | 1136 return errors; |
1153 } | 1137 } |
1154 | 1138 |
1155 ErrorCombination test_deferred_drawing(GM* gm, | 1139 ErrorCombination test_deferred_drawing(GM* gm, |
1156 const ConfigData& gRec, | 1140 const ConfigData& gRec, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 uint32_t flags = (config.fFlags & kDFText_ConfigFlag) ? | 1183 uint32_t flags = (config.fFlags & kDFText_ConfigFlag) ? |
1200 SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; | 1184 SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; |
1201 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType
); | 1185 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType
); |
1202 return SkSurface::NewRenderTargetDirect(gpuTarget->asRenderTarget(),
&props); | 1186 return SkSurface::NewRenderTargetDirect(gpuTarget->asRenderTarget(),
&props); |
1203 } | 1187 } |
1204 #endif | 1188 #endif |
1205 | 1189 |
1206 return NULL; | 1190 return NULL; |
1207 } | 1191 } |
1208 | 1192 |
| 1193 ErrorCombination writeBitmap(GM* gm, |
| 1194 const ConfigData& config, |
| 1195 const char* configName, |
| 1196 const char* writePath, |
| 1197 const SkBitmap& bitmap) { |
| 1198 ErrorCombination errors; |
| 1199 |
| 1200 BitmapAndDigest bitmapAndDigest(bitmap); |
| 1201 errors.add(this->compareTestResultsToStoredExpectations(gm, config, |
| 1202 configName, &bit
mapAndDigest)); |
| 1203 |
| 1204 if (writePath && (config.fFlags & kWrite_ConfigFlag)) { |
| 1205 SkString path; |
| 1206 |
| 1207 path = this->makeBitmapFilename(writePath, gm->getName(), configName
, |
| 1208 "", bitmapAndDigest.fDigest); |
| 1209 errors.add(WriteBitmap(path, bitmapAndDigest.fBitmap)); |
| 1210 } |
| 1211 |
| 1212 return errors; |
| 1213 } |
| 1214 |
1209 ErrorCombination testMPDDrawing(GM* gm, | 1215 ErrorCombination testMPDDrawing(GM* gm, |
1210 const ConfigData& config, | 1216 const ConfigData& config, |
| 1217 const char* writePath, |
1211 GrSurface* gpuTarget, | 1218 GrSurface* gpuTarget, |
1212 const SkBitmap& referenceBitmap) { | 1219 const SkBitmap& referenceBitmap) { |
1213 SkASSERT(kRaster_Backend == config.fBackend || kGPU_Backend == config.fB
ackend); | 1220 SkASSERT(kRaster_Backend == config.fBackend || kGPU_Backend == config.fB
ackend); |
1214 | 1221 |
1215 static const uint32_t kMPDFlags = SkPictureRecorder::kComputeSaveLayerIn
fo_RecordFlag; | 1222 static const uint32_t kMPDFlags = SkPictureRecorder::kComputeSaveLayerIn
fo_RecordFlag; |
1216 | 1223 |
1217 SkAutoTUnref<SkPicture> pict(generate_new_picture(gm, kRTree_BbhType, kM
PDFlags)); | 1224 SkAutoTUnref<SkPicture> pict(generate_new_picture(gm, kRTree_BbhType, kM
PDFlags)); |
1218 | 1225 |
1219 SkAutoTUnref<SkSurface> surf(CreateSurface(config, gm->getISize(), gpuTa
rget)); | 1226 SkAutoTUnref<SkSurface> surf(CreateSurface(config, gm->getISize(), gpuTa
rget)); |
1220 | 1227 |
1221 DrawPictureToSurface(surf, pict, SK_Scalar1, false, true); | 1228 DrawPictureToSurface(surf, pict, SK_Scalar1, false, true); |
1222 | 1229 |
1223 SkBitmap bitmap; | 1230 SkBitmap bitmap; |
1224 | 1231 |
1225 setup_bitmap(config, gm->getISize(), &bitmap); | 1232 setup_bitmap(config, gm->getISize(), &bitmap); |
1226 | 1233 |
1227 surf->readPixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), 0
, 0); | 1234 surf->readPixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), 0
, 0); |
1228 complete_bitmap(&bitmap); | 1235 complete_bitmap(&bitmap); |
1229 | 1236 |
1230 return compare_test_results_to_reference_bitmap( | 1237 SkString configName(config.fName); |
1231 gm->getName(), config.fName, "-mpd", bitmap, &referenceBitmap); | 1238 configName.append("-mpd"); |
| 1239 |
| 1240 return this->writeBitmap(gm, config, configName.c_str(), writePath, bitm
ap); |
1232 } | 1241 } |
1233 | 1242 |
1234 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, | 1243 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, |
1235 const SkBitmap& referenceBitmap, bool si
mulateFailure) { | 1244 const SkBitmap& referenceBitmap, bool si
mulateFailure) { |
1236 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->getN
ame(), | 1245 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->getN
ame(), |
1237 gRec.fNa
me); | 1246 gRec.fNa
me); |
1238 ErrorCombination errors; | 1247 ErrorCombination errors; |
1239 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 1248 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
1240 SkString renderModeDescriptor("-pipe"); | 1249 SkString renderModeDescriptor("-pipe"); |
1241 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); | 1250 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 } | 1900 } |
1892 | 1901 |
1893 if (FLAGS_mpd && (kGPU_Backend == config.fBackend || kRaster_Backend ==
config.fBackend)) { | 1902 if (FLAGS_mpd && (kGPU_Backend == config.fBackend || kRaster_Backend ==
config.fBackend)) { |
1894 | 1903 |
1895 if (gmFlags & GM::kSkipPicture_Flag) { | 1904 if (gmFlags & GM::kSkipPicture_Flag) { |
1896 gmmain.RecordSkippedTest(shortNamePlusConfig, | 1905 gmmain.RecordSkippedTest(shortNamePlusConfig, |
1897 renderModeDescriptor, | 1906 renderModeDescriptor, |
1898 config.fBackend); | 1907 config.fBackend); |
1899 errorsForThisConfig.add(kIntentionallySkipped_ErrorType); | 1908 errorsForThisConfig.add(kIntentionallySkipped_ErrorType); |
1900 } else if (!(gmFlags & GM::kGPUOnly_Flag)) { | 1909 } else if (!(gmFlags & GM::kGPUOnly_Flag)) { |
1901 errorsForThisConfig.add(gmmain.testMPDDrawing(gm, config, gpuTar
get, | 1910 errorsForThisConfig.add(gmmain.testMPDDrawing(gm, config, |
| 1911 writePath, gpuTarg
et, |
1902 comparisonBitmap))
; | 1912 comparisonBitmap))
; |
1903 } | 1913 } |
1904 } | 1914 } |
1905 | 1915 |
1906 errorsForAllConfigs.add(errorsForThisConfig); | 1916 errorsForAllConfigs.add(errorsForThisConfig); |
1907 } | 1917 } |
1908 return errorsForAllConfigs; | 1918 return errorsForAllConfigs; |
1909 } | 1919 } |
1910 | 1920 |
1911 | 1921 |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2570 if (FLAGS_forceBWtext) { | 2580 if (FLAGS_forceBWtext) { |
2571 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2581 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2572 } | 2582 } |
2573 } | 2583 } |
2574 | 2584 |
2575 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2585 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2576 int main(int argc, char * const argv[]) { | 2586 int main(int argc, char * const argv[]) { |
2577 return tool_main(argc, (char**) argv); | 2587 return tool_main(argc, (char**) argv); |
2578 } | 2588 } |
2579 #endif | 2589 #endif |
OLD | NEW |