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 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag; | 1007 recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag; |
1008 } | 1008 } |
1009 SkCanvas* cv = pict->beginRecording(width, height, recordFlags); | 1009 SkCanvas* cv = pict->beginRecording(width, height, recordFlags); |
1010 cv->scale(scale, scale); | 1010 cv->scale(scale, scale); |
1011 invokeGM(gm, cv, false, false); | 1011 invokeGM(gm, cv, false, false); |
1012 pict->endRecording(); | 1012 pict->endRecording(); |
1013 | 1013 |
1014 return pict; | 1014 return pict; |
1015 } | 1015 } |
1016 | 1016 |
| 1017 static SkData* bitmap_encoder(size_t* pixelRefOffset, const SkBitmap& bm) { |
| 1018 SkPixelRef* pr = bm.pixelRef(); |
| 1019 if (pr != NULL) { |
| 1020 SkData* data = pr->refEncodedData(); |
| 1021 if (data != NULL) { |
| 1022 *pixelRefOffset = bm.pixelRefOffset(); |
| 1023 return data; |
| 1024 } |
| 1025 } |
| 1026 return NULL; |
| 1027 } |
| 1028 |
1017 static SkPicture* stream_to_new_picture(const SkPicture& src) { | 1029 static SkPicture* stream_to_new_picture(const SkPicture& src) { |
1018 SkDynamicMemoryWStream storage; | 1030 SkDynamicMemoryWStream storage; |
1019 src.serialize(&storage); | 1031 src.serialize(&storage, &bitmap_encoder); |
1020 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream()); | 1032 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream()); |
1021 SkPicture* retval = SkPicture::CreateFromStream(pictReadback); | 1033 SkPicture* retval = SkPicture::CreateFromStream(pictReadback, |
| 1034 &SkImageDecoder::DecodeM
emory); |
1022 return retval; | 1035 return retval; |
1023 } | 1036 } |
1024 | 1037 |
1025 // Test: draw into a bitmap or pdf. | 1038 // Test: draw into a bitmap or pdf. |
1026 // Depending on flags, possibly compare to an expected image. | 1039 // Depending on flags, possibly compare to an expected image. |
1027 ErrorCombination test_drawing(GM* gm, | 1040 ErrorCombination test_drawing(GM* gm, |
1028 const ConfigData& gRec, | 1041 const ConfigData& gRec, |
1029 const char writePath [], | 1042 const char writePath [], |
1030 GrSurface* gpuTarget, | 1043 GrSurface* gpuTarget, |
1031 SkBitmap* bitmap) { | 1044 SkBitmap* bitmap) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 | 1114 |
1102 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, | 1115 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, |
1103 const SkBitmap& referenceBitmap, bool si
mulateFailure) { | 1116 const SkBitmap& referenceBitmap, bool si
mulateFailure) { |
1104 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor
tName(), | 1117 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor
tName(), |
1105 gRec.fNa
me); | 1118 gRec.fNa
me); |
1106 ErrorCombination errors; | 1119 ErrorCombination errors; |
1107 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 1120 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
1108 SkString renderModeDescriptor("-pipe"); | 1121 SkString renderModeDescriptor("-pipe"); |
1109 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); | 1122 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); |
1110 | 1123 |
1111 if (gm->getFlags() & GM::kSkipPipe_Flag) { | 1124 if (gm->getFlags() & GM::kSkipPipe_Flag |
| 1125 || (gPipeWritingFlagCombos[i].flags == SkGPipeWriter::kCrossProc
ess_Flag |
| 1126 && gm->getFlags() & GM::kSkipPipeCrossProcess_Flag)) { |
1112 RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlus
Config, | 1127 RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlus
Config, |
1113 renderModeDescriptor.c_str()); | 1128 renderModeDescriptor.c_str()); |
1114 errors.add(kIntentionallySkipped_ErrorType); | 1129 errors.add(kIntentionallySkipped_ErrorType); |
1115 } else { | 1130 } else { |
1116 SkBitmap bitmap; | 1131 SkBitmap bitmap; |
1117 SkISize size = gm->getISize(); | 1132 SkISize size = gm->getISize(); |
1118 setup_bitmap(gRec, size, &bitmap); | 1133 setup_bitmap(gRec, size, &bitmap); |
1119 SkCanvas canvas(bitmap); | 1134 SkCanvas canvas(bitmap); |
1120 installFilter(&canvas); | 1135 installFilter(&canvas); |
1121 // Pass a decoding function so the factory GM (which has an SkBi
tmap | 1136 // Pass a decoding function so the factory GM (which has an SkBi
tmap |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2169 if (FLAGS_forceBWtext) { | 2184 if (FLAGS_forceBWtext) { |
2170 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2185 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2171 } | 2186 } |
2172 } | 2187 } |
2173 | 2188 |
2174 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2189 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2175 int main(int argc, char * const argv[]) { | 2190 int main(int argc, char * const argv[]) { |
2176 return tool_main(argc, (char**) argv); | 2191 return tool_main(argc, (char**) argv); |
2177 } | 2192 } |
2178 #endif | 2193 #endif |
OLD | NEW |