skia2/tools/bench_pictures_cfg_helper.py

113 lines
3.2 KiB
Python
Raw Normal View History

# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
""" Helper functions to be used in bench_pictures.cfg. """
def Config(**kwargs):
config = {}
for key in kwargs:
config[key] = kwargs[key]
return config
def TileArgs(tile_x, tile_y, timeIndividualTiles=True):
config = {'mode': ['tile', str(tile_x), str(tile_y)]}
if timeIndividualTiles:
config['timeIndividualTiles'] = True
return config
def BitmapConfig(**kwargs):
Created my own flag parser, based off of gflags. Share common code between bench_ and render_ to set up the PictureRenderer. Fix an include error in SkPictureRenderer.h. Simplified parameter passing in render_pictures_main. Switch to using an SkAutoTUnref for the PictureRenderer. I also changed the input format somewhat, so the buildbots need to be updated as well: https://codereview.appspot.com/7441044/ Fixed a bug in PictureBenchmark where calling setTimeIndividualTiles(false) sets the member variable to true. Removed setDeviceType from PictureBenchmark, since only the PictureRenderer needs to know which device type to use. Some changes to the input format: '--logPerIter' no longer takes a 1 or 0. Instead, '--logPerIter' turns it on and '--nologPerIter' turns it off (with off as the default). (Note that this is for bench_pictures; bench still uses the old format) Change '--device' to '--config' and 'bitmap' to '8888' to be the same as gm. Requires '--r' before inputs (to match gm), though there can be multiple inputs following it. Changed --enable-deferred-image-decoding (which no one uses but me yet anyway) to --deferImageDecoding, since the former is incompatible with the flag parser. Changes to behavior: Show a short error message on failure (rather than the explanation of all flags). BUG=https://code.google.com/p/skia/issues/detail?id=1094 Review URL: https://codereview.appspot.com/7230053 git-svn-id: http://skia.googlecode.com/svn/trunk@7961 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-03-04 16:41:06 +00:00
return Config(config='8888', **kwargs)
def GPUConfig(**kwargs):
Created my own flag parser, based off of gflags. Share common code between bench_ and render_ to set up the PictureRenderer. Fix an include error in SkPictureRenderer.h. Simplified parameter passing in render_pictures_main. Switch to using an SkAutoTUnref for the PictureRenderer. I also changed the input format somewhat, so the buildbots need to be updated as well: https://codereview.appspot.com/7441044/ Fixed a bug in PictureBenchmark where calling setTimeIndividualTiles(false) sets the member variable to true. Removed setDeviceType from PictureBenchmark, since only the PictureRenderer needs to know which device type to use. Some changes to the input format: '--logPerIter' no longer takes a 1 or 0. Instead, '--logPerIter' turns it on and '--nologPerIter' turns it off (with off as the default). (Note that this is for bench_pictures; bench still uses the old format) Change '--device' to '--config' and 'bitmap' to '8888' to be the same as gm. Requires '--r' before inputs (to match gm), though there can be multiple inputs following it. Changed --enable-deferred-image-decoding (which no one uses but me yet anyway) to --deferImageDecoding, since the former is incompatible with the flag parser. Changes to behavior: Show a short error message on failure (rather than the explanation of all flags). BUG=https://code.google.com/p/skia/issues/detail?id=1094 Review URL: https://codereview.appspot.com/7230053 git-svn-id: http://skia.googlecode.com/svn/trunk@7961 2bbb7eff-a529-9590-31e7-b0007b416f81
2013-03-04 16:41:06 +00:00
return Config(config='gpu', **kwargs)
def TiledBitmapConfig(tile_x, tile_y, timeIndividualTiles=True, **kwargs):
return BitmapConfig(**dict(TileArgs(tile_x, tile_y,
timeIndividualTiles=timeIndividualTiles).items() + kwargs.items()))
def TiledGPUConfig(tile_x, tile_y, **kwargs):
return GPUConfig(**dict(TileArgs(tile_x, tile_y).items() + kwargs.items()))
def TiledConfig(tile_x, tile_y, timeIndividualTiles=True, **kwargs):
return Config(**dict(TileArgs(tile_x, tile_y,
timeIndividualTiles=timeIndividualTiles).items() + kwargs.items()))
def ViewportBitmapConfig(viewport_x, viewport_y, **kwargs):
return BitmapConfig(viewport=[str(viewport_x), str(viewport_y)], **kwargs)
def ViewportGPUConfig(viewport_x, viewport_y, **kwargs):
return GPUConfig(viewport=[str(viewport_x), str(viewport_y)], **kwargs)
def ViewportRTreeConfig(viewport_x, viewport_y, **kwargs):
return RTreeConfig(mode='simple', viewport=[str(viewport_x), str(viewport_y)],
**kwargs)
def ViewportGridConfig(viewport_x, viewport_y, **kwargs):
return GridConfig(viewport_x, viewport_y, mode='simple',
viewport=[str(viewport_x), str(viewport_y)], **kwargs)
def CopyTilesConfig(tile_x, tile_y, **kwargs):
return BitmapConfig(mode=['copyTile', str(tile_x), str(tile_y)], **kwargs)
def RecordConfig(**kwargs):
return BitmapConfig(mode='record', **kwargs)
def PlaybackCreationConfig(**kwargs):
return BitmapConfig(mode='playbackCreation', **kwargs)
def MultiThreadTileConfig(threads, tile_x, tile_y, **kwargs):
return TiledBitmapConfig(tile_x=tile_x, tile_y=tile_y,
timeIndividualTiles=False, multi=str(threads),
**kwargs)
def RTreeConfig(**kwargs):
return BitmapConfig(bbh='rtree', **kwargs)
def GridConfig(tile_x, tile_y, mode, **kwargs):
return BitmapConfig(mode=mode, bbh=['grid', str(tile_x), str(tile_y)],
**kwargs)
def RecordRTreeConfig(**kwargs):
return RTreeConfig(mode='record', **kwargs)
def PlaybackCreationRTreeConfig(**kwargs):
return RTreeConfig(mode='playbackCreation', **kwargs)
def TileRTreeConfig(tile_x, tile_y, **kwargs):
return RTreeConfig(**dict(TileArgs(tile_x, tile_y).items() + kwargs.items()))
def RecordGridConfig(tile_x, tile_y, **kwargs):
return GridConfig(tile_x=tile_x, tile_y=tile_y, mode='record', **kwargs)
def PlaybackCreationGridConfig(tile_x, tile_y, **kwargs):
return GridConfig(tile_x, tile_y, mode='playbackCreation')
def TileGridConfig(tile_x, tile_y, **kwargs):
return GridConfig(tile_x, tile_y,
**dict(TileArgs(tile_x, tile_y).items() + kwargs.items()))