OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 glob | 4 import glob |
5 import os | 5 import os |
6 | 6 |
7 from telemetry.page import page_measurement | 7 from telemetry.page import page_measurement |
| 8 from telemetry.value import scalar |
8 | 9 |
9 | 10 |
10 _JS = 'chrome.gpuBenchmarking.printToSkPicture("{0}");' | 11 _JS = 'chrome.gpuBenchmarking.printToSkPicture("{0}");' |
11 | 12 |
12 | 13 |
13 class SkpicturePrinter(page_measurement.PageMeasurement): | 14 class SkpicturePrinter(page_measurement.PageMeasurement): |
14 @classmethod | 15 @classmethod |
15 def AddCommandLineArgs(cls, parser): | 16 def AddCommandLineArgs(cls, parser): |
16 parser.add_option('-s', '--skp-outdir', | 17 parser.add_option('-s', '--skp-outdir', |
17 help='Output directory for the SKP files') | 18 help='Output directory for the SKP files') |
(...skipping 13 matching lines...) Expand all Loading... |
31 if tab.browser.platform.GetOSName() in ['android', 'chromeos']: | 32 if tab.browser.platform.GetOSName() in ['android', 'chromeos']: |
32 raise page_measurement.MeasurementFailure( | 33 raise page_measurement.MeasurementFailure( |
33 'SkPicture printing not supported on this platform') | 34 'SkPicture printing not supported on this platform') |
34 | 35 |
35 # Replace win32 path separator char '\' with '\\'. | 36 # Replace win32 path separator char '\' with '\\'. |
36 outpath = os.path.abspath( | 37 outpath = os.path.abspath( |
37 os.path.join(self._skp_outdir, page.file_safe_name)) | 38 os.path.join(self._skp_outdir, page.file_safe_name)) |
38 js = _JS.format(outpath.replace('\\', '\\\\')) | 39 js = _JS.format(outpath.replace('\\', '\\\\')) |
39 tab.EvaluateJavaScript(js) | 40 tab.EvaluateJavaScript(js) |
40 pictures = glob.glob(os.path.join(outpath, '*.skp')) | 41 pictures = glob.glob(os.path.join(outpath, '*.skp')) |
41 results.Add('saved_picture_count', 'count', len(pictures)) | 42 results.AddValue(scalar.ScalarValue( |
| 43 results.current_page, 'saved_picture_count', 'count', len(pictures))) |
OLD | NEW |