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 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 cv->scale(scale, scale); | 1018 cv->scale(scale, scale); |
1019 invokeGM(gm, cv, false, false); | 1019 invokeGM(gm, cv, false, false); |
1020 pict->endRecording(); | 1020 pict->endRecording(); |
1021 | 1021 |
1022 return pict; | 1022 return pict; |
1023 } | 1023 } |
1024 | 1024 |
1025 static SkPicture* stream_to_new_picture(const SkPicture& src) { | 1025 static SkPicture* stream_to_new_picture(const SkPicture& src) { |
1026 SkDynamicMemoryWStream storage; | 1026 SkDynamicMemoryWStream storage; |
1027 src.serialize(&storage); | 1027 src.serialize(&storage); |
1028 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detatchAsStream()); | 1028 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream()); |
1029 SkPicture* retval = SkPicture::CreateFromStream(pictReadback); | 1029 SkPicture* retval = SkPicture::CreateFromStream(pictReadback); |
1030 return retval; | 1030 return retval; |
1031 } | 1031 } |
1032 | 1032 |
1033 // Test: draw into a bitmap or pdf. | 1033 // Test: draw into a bitmap or pdf. |
1034 // Depending on flags, possibly compare to an expected image. | 1034 // Depending on flags, possibly compare to an expected image. |
1035 ErrorCombination test_drawing(GM* gm, | 1035 ErrorCombination test_drawing(GM* gm, |
1036 const ConfigData& gRec, | 1036 const ConfigData& gRec, |
1037 const char writePath [], | 1037 const char writePath [], |
1038 GrSurface* gpuTarget, | 1038 GrSurface* gpuTarget, |
(...skipping 17 matching lines...) Expand all Loading... |
1056 SkMemoryStream stream(data->data(), data->size()); | 1056 SkMemoryStream stream(data->data(), data->size()); |
1057 SkPDFDocumentToBitmap(&stream, bitmap); | 1057 SkPDFDocumentToBitmap(&stream, bitmap); |
1058 #else | 1058 #else |
1059 bitmap = NULL; // we don't generate a bitmap rendering of the PDF f
ile | 1059 bitmap = NULL; // we don't generate a bitmap rendering of the PDF f
ile |
1060 #endif | 1060 #endif |
1061 } else if (gRec.fBackend == kXPS_Backend) { | 1061 } else if (gRec.fBackend == kXPS_Backend) { |
1062 generate_xps(gm, document); | 1062 generate_xps(gm, document); |
1063 bitmap = NULL; // we don't generate a bitmap rendering of the XPS f
ile | 1063 bitmap = NULL; // we don't generate a bitmap rendering of the XPS f
ile |
1064 } | 1064 } |
1065 | 1065 |
1066 SkAutoTUnref<SkStreamAsset> documentStream(document.detatchAsStream()); | 1066 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream()); |
1067 if (NULL == bitmap) { | 1067 if (NULL == bitmap) { |
1068 return compare_test_results_to_stored_expectations( | 1068 return compare_test_results_to_stored_expectations( |
1069 gm, gRec, writePath, NULL, documentStream); | 1069 gm, gRec, writePath, NULL, documentStream); |
1070 } else { | 1070 } else { |
1071 BitmapAndDigest bitmapAndDigest(*bitmap); | 1071 BitmapAndDigest bitmapAndDigest(*bitmap); |
1072 return compare_test_results_to_stored_expectations( | 1072 return compare_test_results_to_stored_expectations( |
1073 gm, gRec, writePath, &bitmapAndDigest, documentStream); | 1073 gm, gRec, writePath, &bitmapAndDigest, documentStream); |
1074 } | 1074 } |
1075 } | 1075 } |
1076 | 1076 |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 if (FLAGS_forceBWtext) { | 2162 if (FLAGS_forceBWtext) { |
2163 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2163 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2164 } | 2164 } |
2165 } | 2165 } |
2166 | 2166 |
2167 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2167 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2168 int main(int argc, char * const argv[]) { | 2168 int main(int argc, char * const argv[]) { |
2169 return tool_main(argc, (char**) argv); | 2169 return tool_main(argc, (char**) argv); |
2170 } | 2170 } |
2171 #endif | 2171 #endif |
OLD | NEW |