OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 import os | 4 import os |
5 | 5 |
6 from telemetry.page import page_measurement | 6 from telemetry.page import page_measurement |
7 | 7 |
8 | 8 |
9 _JS = 'chrome.gpuBenchmarking.printToSkPicture("{0}");' | 9 _JS = 'chrome.gpuBenchmarking.printToSkPicture("{0}");' |
10 | 10 |
11 | 11 |
12 class SkpicturePrinter(page_measurement.PageMeasurement): | 12 class SkpicturePrinter(page_measurement.PageMeasurement): |
13 def AddCommandLineOptions(self, parser): | 13 def AddCommandLineOptions(self, parser): |
14 parser.add_option('-s', '--skp-outdir', | 14 parser.add_option('-s', '--skp-outdir', |
15 help='Output directory for the SKP files') | 15 help='Output directory for the SKP files') |
16 | 16 |
17 def CustomizeBrowserOptions(self, options): | 17 def CustomizeBrowserOptions(self, options): |
18 options.extra_browser_args.extend(['--enable-gpu-benchmarking', | 18 options.extra_browser_args.extend(['--enable-gpu-benchmarking', |
19 '--no-sandbox', | 19 '--no-sandbox', |
20 '--enable-deferred-image-decoding', | 20 '--enable-deferred-image-decoding', |
21 '--force-compositing-mode']) | 21 '--force-compositing-mode']) |
22 | 22 |
23 def MeasurePage(self, page, tab, results): | 23 def MeasurePage(self, page, tab, results): |
24 skp_outdir = self.options.skp_outdir | 24 skp_outdir = self.options.skp_outdir |
25 if not skp_outdir: | 25 if not skp_outdir: |
26 raise Exception('Please specify --skp-outdir') | 26 raise Exception('Please specify --skp-outdir') |
27 outpath = os.path.abspath( | 27 outpath = os.path.abspath( |
28 os.path.join(skp_outdir, | 28 os.path.join(skp_outdir, |
29 page.url_as_file_safe_name)) | 29 page.file_safe_name)) |
30 # Replace win32 path separator char '\' with '\\'. | 30 # Replace win32 path separator char '\' with '\\'. |
31 js = _JS.format(outpath.replace('\\', '\\\\')) | 31 js = _JS.format(outpath.replace('\\', '\\\\')) |
32 tab.EvaluateJavaScript(js) | 32 tab.EvaluateJavaScript(js) |
33 results.Add('output_path', 'path', outpath) | 33 results.Add('output_path', 'path', outpath) |
OLD | NEW |