| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """ Run the Skia render_pictures executable. """ | |
| 7 | |
| 8 from build_step import BuildStep, BuildStepWarning | |
| 9 import os | |
| 10 import sys | |
| 11 | |
| 12 | |
| 13 JSON_SUMMARY_FILENAME_FORMATTER = 'renderskp-%s.json' | |
| 14 # TODO(epoger): Consider defining these render modes in a separate config file | |
| 15 # within the Skia repo, like we do with | |
| 16 # https://skia.googlesource.com/skia/+/master/tools/bench_pictures.cfg | |
| 17 # Or, maybe we should even share the specific render modes with bench_pictures? | |
| 18 # (Generally, we want to test the same code for both correctness and | |
| 19 # performance.) | |
| 20 DEFAULT_TILE_X = 256 | |
| 21 DEFAULT_TILE_Y = 256 | |
| 22 RENDER_MODES = { | |
| 23 'defaults': [], | |
| 24 'deferImageDecoding': ['--deferImageDecoding', '--useVolatileCache'], | |
| 25 'grid': ['--bbh', 'grid', str(DEFAULT_TILE_X), str(DEFAULT_TILE_X) ], | |
| 26 'rtree': ['--bbh', 'rtree' ], | |
| 27 } | |
| 28 | |
| 29 # Keys we use within render_pictures's --descriptions argument. | |
| 30 # They are just for human consumption; they don't need to be kept in sync | |
| 31 # with values anywhere else. | |
| 32 DESCRIPTION__BUILDER = 'builder' | |
| 33 DESCRIPTION__RENDER_MODE = 'renderMode' | |
| 34 | |
| 35 | |
| 36 class RenderSKPs(BuildStep): | |
| 37 | |
| 38 def __init__(self, timeout=9600, no_output_timeout=9600, **kwargs): | |
| 39 super(RenderSKPs, self).__init__( | |
| 40 timeout=timeout, no_output_timeout=no_output_timeout, **kwargs) | |
| 41 | |
| 42 | |
| 43 def DoRenderSKPs(self, args, render_mode_name, config='8888', | |
| 44 write_images=True): | |
| 45 """Run render_pictures. | |
| 46 | |
| 47 Args: | |
| 48 args: (list of strings) misc args to append to the command line | |
| 49 render_mode_name: (string) human-readable description of this particular | |
| 50 RenderSKPs run (perhaps "default", or "tiled"); used as part | |
| 51 of the JSON summary filename, and also inserted within the file | |
| 52 config: (string) which config to run in | |
| 53 write_images: (boolean) whether to save the generated images (IGNORED) | |
| 54 | |
| 55 Raises: | |
| 56 BuildStepWarning if there was a problem, but the step should keep going. | |
| 57 Something else if there was a major problem and we should give up now. | |
| 58 """ | |
| 59 json_summary_filename = JSON_SUMMARY_FILENAME_FORMATTER % render_mode_name | |
| 60 json_expectations_devicepath = self._flavor_utils.DevicePathJoin( | |
| 61 self._device_dirs.PlaybackExpectedSummariesDir(), json_summary_filename) | |
| 62 if not self._flavor_utils.DevicePathExists(json_expectations_devicepath): | |
| 63 raise BuildStepWarning('could not find JSON expectations file %s' % | |
| 64 json_expectations_devicepath) | |
| 65 | |
| 66 # TODO(stephana): We should probably start rendering whole images too, not | |
| 67 # just tiles. | |
| 68 cmd = [ | |
| 69 '--config', config, | |
| 70 '--descriptions', | |
| 71 '='.join([DESCRIPTION__BUILDER, self._builder_name]), | |
| 72 '='.join([DESCRIPTION__RENDER_MODE, render_mode_name]), | |
| 73 '--mode', 'tile', str(DEFAULT_TILE_X), str(DEFAULT_TILE_Y), | |
| 74 '--readJsonSummaryPath', json_expectations_devicepath, | |
| 75 '--readPath', self._device_dirs.SKPDir(), | |
| 76 '--writeChecksumBasedFilenames', | |
| 77 '--writeJsonSummaryPath', self._flavor_utils.DevicePathJoin( | |
| 78 self._device_dirs.PlaybackActualSummariesDir(), | |
| 79 json_summary_filename), | |
| 80 ] | |
| 81 if write_images: | |
| 82 cmd.extend([ | |
| 83 '--mismatchPath', self._device_dirs.PlaybackActualImagesDir()]) | |
| 84 cmd.extend(args) | |
| 85 | |
| 86 if False: | |
| 87 # For now, skip --validate on all builders, since it takes more time, | |
| 88 # and at last check failed on Windows. | |
| 89 if not os.name == 'nt': | |
| 90 cmd.append('--validate') | |
| 91 | |
| 92 self._flavor_utils.RunFlavoredCmd('render_pictures', cmd) | |
| 93 | |
| 94 | |
| 95 def _Run(self): | |
| 96 exceptions = [] | |
| 97 for render_mode_name, args in sorted(RENDER_MODES.iteritems()): | |
| 98 try: | |
| 99 self.DoRenderSKPs(args=args, render_mode_name=render_mode_name) | |
| 100 except BuildStepWarning, e: | |
| 101 exceptions.append(e) | |
| 102 print e | |
| 103 if exceptions: | |
| 104 raise BuildStepWarning('\nGot %d exceptions:\n%s' % ( | |
| 105 len(exceptions), '\n'.join([repr(e) for e in exceptions]))) | |
| 106 | |
| 107 | |
| 108 if '__main__' == __name__: | |
| 109 sys.exit(BuildStep.RunBuildStep(RenderSKPs)) | |
| OLD | NEW |