| OLD | NEW |
| (Empty) |
| 1 ''' | |
| 2 Copyright 2012 Google Inc. | |
| 3 | |
| 4 Use of this source code is governed by a BSD-style license that can be | |
| 5 found in the LICENSE file. | |
| 6 | |
| 7 Compares the rendererings of serialized SkPictures to expected images. | |
| 8 | |
| 9 Launch with --help to see more information. | |
| 10 | |
| 11 TODO(epoger): We believe this tool is no longer used, so we have disabled it | |
| 12 and will remove it on 1 Feb 2014 if nobody objects. | |
| 13 See https://code.google.com/p/skia/issues/detail?id=1943#c2 | |
| 14 ''' | |
| 15 # common Python modules | |
| 16 import os | |
| 17 import optparse | |
| 18 import sys | |
| 19 import shutil | |
| 20 import tempfile | |
| 21 | |
| 22 # modules declared within this same directory | |
| 23 import test_rendering | |
| 24 | |
| 25 USAGE_STRING = 'Usage: %s input... expectedDir' | |
| 26 HELP_STRING = ''' | |
| 27 | |
| 28 Takes input SkPicture files and renders them as PNG files, and then compares | |
| 29 those resulting PNG files against PNG files found in expectedDir. | |
| 30 | |
| 31 Each instance of "input" can be either a file (name must end in .skp), or a | |
| 32 directory (in which case this script will process all .skp files within the | |
| 33 directory). | |
| 34 ''' | |
| 35 | |
| 36 def ModeParse(option, opt_str, value, parser): | |
| 37 """Parses the --mode option of the commandline. | |
| 38 | |
| 39 The --mode option will either take in three parameters (if tile or | |
| 40 pow2tile) or a single parameter (otherwise). | |
| 41 """ | |
| 42 result = [value] | |
| 43 if value == "tile": | |
| 44 if (len(parser.rargs) < 2): | |
| 45 raise optparse.OptionValueError(("--mode tile mising width" | |
| 46 " and/or height parameters")) | |
| 47 result.extend(parser.rargs[:2]) | |
| 48 del parser.rargs[:2] | |
| 49 elif value == "pow2tile": | |
| 50 if (len(parser.rargs) < 2): | |
| 51 raise optparse.OptionValueError(("--mode pow2tile mising minWidth" | |
| 52 " and/or height parameters")) | |
| 53 result.extend(parser.rargs[:2]) | |
| 54 del parser.rargs[:2] | |
| 55 | |
| 56 setattr(parser.values, option.dest, result) | |
| 57 | |
| 58 | |
| 59 def Main(args): | |
| 60 """Allow other scripts to call this script with fake command-line args. | |
| 61 | |
| 62 @param The commandline argument list | |
| 63 """ | |
| 64 print ('We believe this tool is no longer used, so we have disabled it ' | |
| 65 'and will remove it on 1 Feb 2014 if nobody objects. See ' | |
| 66 'https://code.google.com/p/skia/issues/detail?id=1943#c2') | |
| 67 sys.exit(-1) | |
| 68 | |
| 69 parser = optparse.OptionParser(USAGE_STRING % '%prog' + HELP_STRING) | |
| 70 parser.add_option('--render_dir', dest='render_dir', | |
| 71 help = ("specify the location to output the rendered files." | |
| 72 " Default is a temp directory.")) | |
| 73 parser.add_option('--diff_dir', dest='diff_dir', | |
| 74 help = ("specify the location to output the diff files." | |
| 75 " Default is a temp directory.")) | |
| 76 parser.add_option('--mode', dest='mode', type='string', | |
| 77 action="callback", callback=ModeParse, | |
| 78 help = ("specify how rendering is to be done.")) | |
| 79 parser.add_option('--device', dest='device', | |
| 80 help = ("specify the device to render to.")) | |
| 81 | |
| 82 options, arguments = parser.parse_args(args) | |
| 83 | |
| 84 if (len(arguments) < 3): | |
| 85 print("Expected at least one input and one ouput folder.") | |
| 86 parser.print_help() | |
| 87 sys.exit(-1) | |
| 88 | |
| 89 inputs = arguments[1:-1] | |
| 90 expected_dir = arguments[-1] | |
| 91 | |
| 92 extra_args = '' | |
| 93 | |
| 94 if (options.mode is not None): | |
| 95 extra_args += ' --mode %s' % ' '.join(options.mode) | |
| 96 | |
| 97 if (options.device is not None): | |
| 98 extra_args += ' --device %s' % options.device | |
| 99 | |
| 100 test_rendering.TestRenderSkps(inputs, expected_dir, options.render_dir, | |
| 101 options.diff_dir, 'render_pictures', | |
| 102 extra_args) | |
| 103 | |
| 104 if __name__ == '__main__': | |
| 105 Main(sys.argv) | |
| OLD | NEW |