| 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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 errors.add(compare_to_expectations(expectations, actualBitmapAndDigest,
shortName, | 1001 errors.add(compare_to_expectations(expectations, actualBitmapAndDigest,
shortName, |
| 1002 configName, renderModeDescriptor, fal
se)); | 1002 configName, renderModeDescriptor, fal
se)); |
| 1003 SkString shortNamePlusConfig = make_shortname_plus_config(shortName, con
figName); | 1003 SkString shortNamePlusConfig = make_shortname_plus_config(shortName, con
figName); |
| 1004 RecordTestResults(errors, shortNamePlusConfig, renderModeDescriptor); | 1004 RecordTestResults(errors, shortNamePlusConfig, renderModeDescriptor); |
| 1005 | 1005 |
| 1006 return errors; | 1006 return errors; |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec
ordFlags, | 1009 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec
ordFlags, |
| 1010 SkScalar scale = SK_Scalar1) { | 1010 SkScalar scale = SK_Scalar1) { |
| 1011 // Pictures are refcounted so must be on heap | |
| 1012 SkPicture* pict; | |
| 1013 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w
idth()), scale)); | 1011 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w
idth()), scale)); |
| 1014 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().
height()), scale)); | 1012 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().
height()), scale)); |
| 1015 | 1013 |
| 1014 SkAutoTUnref<SkPictureFactory> factory; |
| 1016 if (kTileGrid_BbhType == bbhType) { | 1015 if (kTileGrid_BbhType == bbhType) { |
| 1017 SkTileGridPicture::TileGridInfo info; | 1016 SkTileGridPicture::TileGridInfo info; |
| 1018 info.fMargin.setEmpty(); | 1017 info.fMargin.setEmpty(); |
| 1019 info.fOffset.setZero(); | 1018 info.fOffset.setZero(); |
| 1020 info.fTileInterval.set(16, 16); | 1019 info.fTileInterval.set(16, 16); |
| 1021 pict = new SkTileGridPicture(width, height, info); | 1020 factory.reset(SkNEW_ARGS(SkTileGridPictureFactory, (info))); |
| 1022 } else { | |
| 1023 pict = new SkPicture; | |
| 1024 } | 1021 } |
| 1025 if (kNone_BbhType != bbhType) { | 1022 if (kNone_BbhType != bbhType) { |
| 1026 recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag; | 1023 recordFlags |= SkPicture::kOptimizeForClippedPlayback_RecordingFlag; |
| 1027 } | 1024 } |
| 1028 SkCanvas* cv = pict->beginRecording(width, height, recordFlags); | 1025 SkPictureRecorder recorder(factory); |
| 1026 SkCanvas* cv = recorder.beginRecording(width, height, recordFlags); |
| 1029 cv->scale(scale, scale); | 1027 cv->scale(scale, scale); |
| 1030 invokeGM(gm, cv, false, false); | 1028 invokeGM(gm, cv, false, false); |
| 1031 pict->endRecording(); | 1029 return recorder.endRecording(); |
| 1032 | |
| 1033 return pict; | |
| 1034 } | 1030 } |
| 1035 | 1031 |
| 1036 static SkPicture* stream_to_new_picture(const SkPicture& src) { | 1032 static SkPicture* stream_to_new_picture(const SkPicture& src) { |
| 1037 SkDynamicMemoryWStream storage; | 1033 SkDynamicMemoryWStream storage; |
| 1038 src.serialize(&storage, NULL); | 1034 src.serialize(&storage, NULL); |
| 1039 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream()); | 1035 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream()); |
| 1040 SkPicture* retval = SkPicture::CreateFromStream(pictReadback, | 1036 SkPicture* retval = SkPicture::CreateFromStream(pictReadback, |
| 1041 &SkImageDecoder::DecodeM
emory); | 1037 &SkImageDecoder::DecodeM
emory); |
| 1042 return retval; | 1038 return retval; |
| 1043 } | 1039 } |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2441 if (FLAGS_forceBWtext) { | 2437 if (FLAGS_forceBWtext) { |
| 2442 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2438 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2443 } | 2439 } |
| 2444 } | 2440 } |
| 2445 | 2441 |
| 2446 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2442 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2447 int main(int argc, char * const argv[]) { | 2443 int main(int argc, char * const argv[]) { |
| 2448 return tool_main(argc, (char**) argv); | 2444 return tool_main(argc, (char**) argv); |
| 2449 } | 2445 } |
| 2450 #endif | 2446 #endif |
| OLD | NEW |