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 3# found in the LICENSE file. 4import os 5 6from telemetry.page import page_measurement 7 8 9_JS = 'chrome.gpuBenchmarking.printToSkPicture("{0}");' 10 11 12class SkpicturePrinter(page_measurement.PageMeasurement): 13 def AddCommandLineOptions(self, parser): 14 parser.add_option('-s', '--skp-outdir', 15 help='Output directory for the SKP files') 16 17 def CustomizeBrowserOptions(self, options): 18 options.extra_browser_args.extend(['--enable-gpu-benchmarking', 19 '--no-sandbox', 20 '--enable-deferred-image-decoding', 21 '--force-compositing-mode']) 22 23 def MeasurePage(self, page, tab, results): 24 skp_outdir = self.options.skp_outdir 25 if not skp_outdir: 26 raise Exception('Please specify --skp-outdir') 27 outpath = os.path.abspath( 28 os.path.join(skp_outdir, 29 page.url_as_file_safe_name)) 30 # Replace win32 path separator char '\' with '\\'. 31 js = _JS.format(outpath.replace('\\', '\\\\')) 32 tab.EvaluateJavaScript(js) 33 results.Add('output_path', 'path', outpath) 34