OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ Run the Skia render_pictures executable. """ | 6 """ Run the Skia render_pictures executable. """ |
7 | 7 |
8 from build_step import BuildStep, BuildStepWarning | 8 from build_step import BuildStep |
9 import os | 9 import os |
10 import sys | 10 import sys |
11 | 11 |
12 | 12 |
13 JSON_SUMMARY_FILENAME_FORMATTER = 'renderskp-%s.json' | |
14 # TODO(epoger): Consider defining these configs in a separate config file within | |
15 # the Skia repo, like we do with | |
16 # https://skia.googlesource.com/skia/+/master/tools/bench_pictures.cfg | |
17 # Or, perhaps we should even share the specific configs with bench_pictures? | |
18 # (Generally, we want to test the same code for both correctness and | |
19 # performance.) | |
20 DEFAULT_TILE_X = 256 | 13 DEFAULT_TILE_X = 256 |
21 DEFAULT_TILE_Y = 256 | 14 DEFAULT_TILE_Y = 256 |
22 CONFIGS = { | 15 JSON_SUMMARY_BASENAME = 'renderskp-' |
23 'defaults': [], | |
24 'deferImageDecoding': ['--deferImageDecoding', '--useVolatileCache'], | |
25 'grid': ['--bbh', 'grid', str(DEFAULT_TILE_X), str(DEFAULT_TILE_X), | |
26 '--clone', '1'], | |
27 'rtree': ['--bbh', 'rtree', '--clone', '2'], | |
28 } | |
29 | 16 |
30 | 17 |
31 class RenderSKPs(BuildStep): | 18 class RenderSKPs(BuildStep): |
32 | |
33 def __init__(self, timeout=9600, no_output_timeout=9600, **kwargs): | 19 def __init__(self, timeout=9600, no_output_timeout=9600, **kwargs): |
34 super(RenderSKPs, self).__init__( | 20 super(RenderSKPs, self).__init__( |
35 timeout=timeout, no_output_timeout=no_output_timeout, **kwargs) | 21 timeout=timeout, no_output_timeout=no_output_timeout, **kwargs) |
36 | 22 |
37 | 23 def DoRenderSKPs(self, args, config='8888', write_images=True, |
38 def DoRenderSKPs(self, args, description, config='8888', write_images=True): | 24 json_summary_filename=None): |
39 """Run render_pictures. | 25 """Run render_pictures. |
40 | 26 |
41 Args: | 27 Args: |
42 args: (list of strings) misc args to append to the command line | 28 args: (list of strings) misc args to append to the command line |
43 description: (string) description of this RenderSKPs run; used as part | |
44 of the JSON summary filename | |
45 config: (string) which config to run in | 29 config: (string) which config to run in |
46 write_images: (boolean) whether to save the generated images (IGNORED) | 30 write_images: (boolean) whether to save the generated images (IGNORED) |
47 | 31 json_summary_filename: (string) name of file to write summary of actually- |
48 Raises: | 32 generated images into |
49 BuildStepWarning if there was a problem, but the step should keep going. | |
50 Something else if there was a major problem and we should give up now. | |
51 """ | 33 """ |
52 # For now, don't run on Android, since it takes too long and we don't use | 34 # For now, don't run on Android, since it takes too long and we don't use |
53 # the results. | 35 # the results. |
54 if 'Android' in self._builder_name: | 36 if 'Android' in self._builder_name: |
55 return | 37 return |
56 | 38 |
57 json_summary_filename = JSON_SUMMARY_FILENAME_FORMATTER % description | 39 cmd = ['-r', self._device_dirs.SKPDir(), '--config', config, |
58 json_expectations_devicepath = self._flavor_utils.DevicePathJoin( | 40 '--mode', 'tile', str(DEFAULT_TILE_X), str(DEFAULT_TILE_Y)] |
59 self._device_dirs.PlaybackExpectedSummariesDir(), json_summary_filename) | 41 if json_summary_filename: |
60 if not self._flavor_utils.DevicePathExists(json_expectations_devicepath): | 42 cmd.extend(['--writeJsonSummaryPath', os.path.join( |
61 raise BuildStepWarning('could not find JSON expectations file %s' % | 43 self._device_dirs.SKPOutDir(), json_summary_filename)]) |
62 json_expectations_devicepath) | |
63 | |
64 cmd = [ | |
65 '--config', config, | |
66 '--mode', 'tile', str(DEFAULT_TILE_X), str(DEFAULT_TILE_Y), | |
67 '--readJsonSummaryPath', json_expectations_devicepath, | |
68 '--readPath', self._device_dirs.SKPDir(), | |
69 '--writeChecksumBasedFilenames', | |
70 '--writeJsonSummaryPath', self._flavor_utils.DevicePathJoin( | |
71 self._device_dirs.PlaybackActualSummariesDir(), | |
72 json_summary_filename), | |
73 ] | |
74 if write_images: | |
75 cmd.extend([ | |
76 '--mismatchPath', self._device_dirs.PlaybackActualImagesDir()]) | |
77 cmd.extend(args) | 44 cmd.extend(args) |
78 | 45 |
79 if False: | 46 if False: |
80 # For now, skip --validate on all builders, since it takes more time, | 47 # For now, skip --validate and writing images on all builders, since they |
81 # and at last check failed on Windows. | 48 # take too long and we aren't making use of them. |
| 49 # Also skip --validate on Windows, where it is currently failing. |
| 50 if write_images: |
| 51 cmd.extend(['-w', self._device_dirs.SKPOutDir()]) |
82 if not os.name == 'nt': | 52 if not os.name == 'nt': |
83 cmd.append('--validate') | 53 cmd.append('--validate') |
84 | |
85 self._flavor_utils.RunFlavoredCmd('render_pictures', cmd) | 54 self._flavor_utils.RunFlavoredCmd('render_pictures', cmd) |
86 | 55 |
87 | |
88 def _Run(self): | 56 def _Run(self): |
89 exceptions = [] | 57 self.DoRenderSKPs( |
90 for description, args in sorted(CONFIGS.iteritems()): | 58 args=[], |
91 try: | 59 json_summary_filename=JSON_SUMMARY_BASENAME + 'defaults.json') |
92 self.DoRenderSKPs(args=args, description=description) | 60 self.DoRenderSKPs( |
93 except BuildStepWarning, e: | 61 args=['--bbh', 'grid', str(DEFAULT_TILE_X), str(DEFAULT_TILE_X), |
94 exceptions.append(e) | 62 '--clone', '1'], |
95 print e | 63 json_summary_filename=JSON_SUMMARY_BASENAME + 'grid.json') |
96 if exceptions: | 64 self.DoRenderSKPs( |
97 raise BuildStepWarning('\nGot %d exceptions:\n%s' % ( | 65 args=['--bbh', 'rtree', '--clone', '2'], |
98 len(exceptions), '\n'.join([repr(e) for e in exceptions]))) | 66 json_summary_filename=JSON_SUMMARY_BASENAME + 'rtree.json') |
| 67 self.DoRenderSKPs( |
| 68 args=['--deferImageDecoding', '--useVolatileCache'], |
| 69 json_summary_filename=JSON_SUMMARY_BASENAME + 'deferImageDecoding.json') |
99 | 70 |
100 | 71 |
101 if '__main__' == __name__: | 72 if '__main__' == __name__: |
102 sys.exit(BuildStep.RunBuildStep(RenderSKPs)) | 73 sys.exit(BuildStep.RunBuildStep(RenderSKPs)) |
OLD | NEW |