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 | 8 from build_step import BuildStep, BuildStepWarning |
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.) |
13 DEFAULT_TILE_X = 256 | 20 DEFAULT_TILE_X = 256 |
14 DEFAULT_TILE_Y = 256 | 21 DEFAULT_TILE_Y = 256 |
15 JSON_SUMMARY_BASENAME = 'renderskp-' | 22 CONFIGS = { |
| 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 } |
16 | 29 |
17 | 30 |
18 class RenderSKPs(BuildStep): | 31 class RenderSKPs(BuildStep): |
| 32 |
19 def __init__(self, timeout=9600, no_output_timeout=9600, **kwargs): | 33 def __init__(self, timeout=9600, no_output_timeout=9600, **kwargs): |
20 super(RenderSKPs, self).__init__( | 34 super(RenderSKPs, self).__init__( |
21 timeout=timeout, no_output_timeout=no_output_timeout, **kwargs) | 35 timeout=timeout, no_output_timeout=no_output_timeout, **kwargs) |
22 | 36 |
23 def DoRenderSKPs(self, args, config='8888', write_images=True, | 37 |
24 json_summary_filename=None): | 38 def DoRenderSKPs(self, args, description, config='8888', write_images=True): |
25 """Run render_pictures. | 39 """Run render_pictures. |
26 | 40 |
27 Args: | 41 Args: |
28 args: (list of strings) misc args to append to the command line | 42 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 |
29 config: (string) which config to run in | 45 config: (string) which config to run in |
30 write_images: (boolean) whether to save the generated images (IGNORED) | 46 write_images: (boolean) whether to save the generated images (IGNORED) |
31 json_summary_filename: (string) name of file to write summary of actually- | 47 |
32 generated images into | 48 Raises: |
| 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. |
33 """ | 51 """ |
34 # For now, don't run on Android, since it takes too long and we don't use | 52 # For now, don't run on Android, since it takes too long and we don't use |
35 # the results. | 53 # the results. |
36 if 'Android' in self._builder_name: | 54 if 'Android' in self._builder_name: |
37 return | 55 return |
38 | 56 |
39 cmd = ['-r', self._device_dirs.SKPDir(), '--config', config, | 57 json_summary_filename = JSON_SUMMARY_FILENAME_FORMATTER % description |
40 '--mode', 'tile', str(DEFAULT_TILE_X), str(DEFAULT_TILE_Y)] | 58 json_expectations_devicepath = self._flavor_utils.DevicePathJoin( |
41 if json_summary_filename: | 59 self._device_dirs.PlaybackExpectedSummariesDir(), json_summary_filename) |
42 cmd.extend(['--writeJsonSummaryPath', os.path.join( | 60 if not self._flavor_utils.DevicePathExists(json_expectations_devicepath): |
43 self._device_dirs.SKPOutDir(), json_summary_filename)]) | 61 raise BuildStepWarning('could not find JSON expectations file %s' % |
| 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()]) |
44 cmd.extend(args) | 77 cmd.extend(args) |
45 | 78 |
46 if False: | 79 if False: |
47 # For now, skip --validate and writing images on all builders, since they | 80 # For now, skip --validate on all builders, since it takes more time, |
48 # take too long and we aren't making use of them. | 81 # and at last check failed on Windows. |
49 # Also skip --validate on Windows, where it is currently failing. | |
50 if write_images: | |
51 cmd.extend(['-w', self._device_dirs.SKPOutDir()]) | |
52 if not os.name == 'nt': | 82 if not os.name == 'nt': |
53 cmd.append('--validate') | 83 cmd.append('--validate') |
| 84 |
54 self._flavor_utils.RunFlavoredCmd('render_pictures', cmd) | 85 self._flavor_utils.RunFlavoredCmd('render_pictures', cmd) |
55 | 86 |
| 87 |
56 def _Run(self): | 88 def _Run(self): |
57 self.DoRenderSKPs( | 89 exceptions = [] |
58 args=[], | 90 for description, args in sorted(CONFIGS.iteritems()): |
59 json_summary_filename=JSON_SUMMARY_BASENAME + 'defaults.json') | 91 try: |
60 self.DoRenderSKPs( | 92 self.DoRenderSKPs(args=args, description=description) |
61 args=['--bbh', 'grid', str(DEFAULT_TILE_X), str(DEFAULT_TILE_X), | 93 except BuildStepWarning, e: |
62 '--clone', '1'], | 94 exceptions.append(e) |
63 json_summary_filename=JSON_SUMMARY_BASENAME + 'grid.json') | 95 print e |
64 self.DoRenderSKPs( | 96 if exceptions: |
65 args=['--bbh', 'rtree', '--clone', '2'], | 97 raise BuildStepWarning('\nGot %d exceptions:\n%s' % ( |
66 json_summary_filename=JSON_SUMMARY_BASENAME + 'rtree.json') | 98 len(exceptions), '\n'.join([repr(e) for e in exceptions]))) |
67 self.DoRenderSKPs( | |
68 args=['--deferImageDecoding', '--useVolatileCache'], | |
69 json_summary_filename=JSON_SUMMARY_BASENAME + 'deferImageDecoding.json') | |
70 | 99 |
71 | 100 |
72 if '__main__' == __name__: | 101 if '__main__' == __name__: |
73 sys.exit(BuildStep.RunBuildStep(RenderSKPs)) | 102 sys.exit(BuildStep.RunBuildStep(RenderSKPs)) |
OLD | NEW |