borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 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. |
| 4 | |
| 5 | |
| 6 | """ Helper functions to be used in bench_pictures.cfg. """ |
| 7 | |
| 8 | |
| 9 | def Config(**kwargs): |
| 10 | config = {} |
| 11 | for key in kwargs: |
| 12 | config[key] = kwargs[key] |
| 13 | return config |
| 14 | |
| 15 | |
borenet@google.com | b8f0de1 | 2013-03-07 20:18:27 +0000 | [diff] [blame] | 16 | def TileArgs(tile_x, tile_y, timeIndividualTiles=True): |
| 17 | config = {'mode': ['tile', str(tile_x), str(tile_y)]} |
| 18 | if timeIndividualTiles: |
| 19 | config['timeIndividualTiles'] = True |
| 20 | return config |
borenet@google.com | b00d670 | 2013-01-11 20:45:24 +0000 | [diff] [blame] | 21 | |
| 22 | |
borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 23 | def BitmapConfig(**kwargs): |
scroggo@google.com | 161e1ba | 2013-03-04 16:41:06 +0000 | [diff] [blame] | 24 | return Config(config='8888', **kwargs) |
borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 25 | |
| 26 | |
| 27 | def GPUConfig(**kwargs): |
scroggo@google.com | 161e1ba | 2013-03-04 16:41:06 +0000 | [diff] [blame] | 28 | return Config(config='gpu', **kwargs) |
borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 29 | |
| 30 | |
borenet@google.com | b8f0de1 | 2013-03-07 20:18:27 +0000 | [diff] [blame] | 31 | def TiledBitmapConfig(tile_x, tile_y, timeIndividualTiles=True, **kwargs): |
| 32 | return BitmapConfig(**dict(TileArgs(tile_x, tile_y, |
| 33 | timeIndividualTiles=timeIndividualTiles).items() + kwargs.items())) |
borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 34 | |
| 35 | |
| 36 | def TiledGPUConfig(tile_x, tile_y, **kwargs): |
borenet@google.com | b00d670 | 2013-01-11 20:45:24 +0000 | [diff] [blame] | 37 | return GPUConfig(**dict(TileArgs(tile_x, tile_y).items() + kwargs.items())) |
borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 38 | |
| 39 | |
borenet@google.com | b8f0de1 | 2013-03-07 20:18:27 +0000 | [diff] [blame] | 40 | def TiledConfig(tile_x, tile_y, timeIndividualTiles=True, **kwargs): |
| 41 | return Config(**dict(TileArgs(tile_x, tile_y, |
| 42 | timeIndividualTiles=timeIndividualTiles).items() + kwargs.items())) |
borenet@google.com | 46dc43d | 2013-02-20 20:01:23 +0000 | [diff] [blame] | 43 | |
| 44 | |
borenet@google.com | 9afba74 | 2012-12-18 21:44:53 +0000 | [diff] [blame] | 45 | def ViewportBitmapConfig(viewport_x, viewport_y, **kwargs): |
| 46 | return BitmapConfig(viewport=[str(viewport_x), str(viewport_y)], **kwargs) |
| 47 | |
| 48 | |
| 49 | def ViewportGPUConfig(viewport_x, viewport_y, **kwargs): |
| 50 | return GPUConfig(viewport=[str(viewport_x), str(viewport_y)], **kwargs) |
| 51 | |
| 52 | |
| 53 | def ViewportRTreeConfig(viewport_x, viewport_y, **kwargs): |
borenet@google.com | 8b95474 | 2012-12-19 14:47:53 +0000 | [diff] [blame] | 54 | return RTreeConfig(mode='simple', viewport=[str(viewport_x), str(viewport_y)], |
| 55 | **kwargs) |
borenet@google.com | 9afba74 | 2012-12-18 21:44:53 +0000 | [diff] [blame] | 56 | |
| 57 | |
| 58 | def ViewportGridConfig(viewport_x, viewport_y, **kwargs): |
| 59 | return GridConfig(viewport_x, viewport_y, mode='simple', |
| 60 | viewport=[str(viewport_x), str(viewport_y)], **kwargs) |
| 61 | |
| 62 | |
borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 63 | def CopyTilesConfig(tile_x, tile_y, **kwargs): |
| 64 | return BitmapConfig(mode=['copyTile', str(tile_x), str(tile_y)], **kwargs) |
| 65 | |
| 66 | |
| 67 | def RecordConfig(**kwargs): |
| 68 | return BitmapConfig(mode='record', **kwargs) |
| 69 | |
| 70 | |
| 71 | def PlaybackCreationConfig(**kwargs): |
| 72 | return BitmapConfig(mode='playbackCreation', **kwargs) |
| 73 | |
| 74 | |
| 75 | def MultiThreadTileConfig(threads, tile_x, tile_y, **kwargs): |
borenet@google.com | b8f0de1 | 2013-03-07 20:18:27 +0000 | [diff] [blame] | 76 | return TiledBitmapConfig(tile_x=tile_x, tile_y=tile_y, |
| 77 | timeIndividualTiles=False, multi=str(threads), |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 78 | **kwargs) |
| 79 | |
| 80 | |
borenet@google.com | 8b95474 | 2012-12-19 14:47:53 +0000 | [diff] [blame] | 81 | def RTreeConfig(**kwargs): |
| 82 | return BitmapConfig(bbh='rtree', **kwargs) |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 83 | |
| 84 | |
| 85 | def GridConfig(tile_x, tile_y, mode, **kwargs): |
| 86 | return BitmapConfig(mode=mode, bbh=['grid', str(tile_x), str(tile_y)], |
| 87 | **kwargs) |
| 88 | |
| 89 | |
borenet@google.com | 8b95474 | 2012-12-19 14:47:53 +0000 | [diff] [blame] | 90 | def RecordRTreeConfig(**kwargs): |
| 91 | return RTreeConfig(mode='record', **kwargs) |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 92 | |
| 93 | |
borenet@google.com | 8b95474 | 2012-12-19 14:47:53 +0000 | [diff] [blame] | 94 | def PlaybackCreationRTreeConfig(**kwargs): |
| 95 | return RTreeConfig(mode='playbackCreation', **kwargs) |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 96 | |
| 97 | |
| 98 | def TileRTreeConfig(tile_x, tile_y, **kwargs): |
borenet@google.com | b00d670 | 2013-01-11 20:45:24 +0000 | [diff] [blame] | 99 | return RTreeConfig(**dict(TileArgs(tile_x, tile_y).items() + kwargs.items())) |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 100 | |
| 101 | |
| 102 | def RecordGridConfig(tile_x, tile_y, **kwargs): |
| 103 | return GridConfig(tile_x=tile_x, tile_y=tile_y, mode='record', **kwargs) |
| 104 | |
| 105 | |
| 106 | def PlaybackCreationGridConfig(tile_x, tile_y, **kwargs): |
| 107 | return GridConfig(tile_x, tile_y, mode='playbackCreation') |
| 108 | |
| 109 | |
| 110 | def TileGridConfig(tile_x, tile_y, **kwargs): |
borenet@google.com | b00d670 | 2013-01-11 20:45:24 +0000 | [diff] [blame] | 111 | return GridConfig(tile_x, tile_y, |
borenet@google.com | 2fd0979 | 2013-02-06 16:27:38 +0000 | [diff] [blame] | 112 | **dict(TileArgs(tile_x, tile_y).items() + kwargs.items())) |