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 | b00d670 | 2013-01-11 20:45:24 +0000 | [diff] [blame] | 16 | def TileArgs(tile_x, tile_y): |
| 17 | return {'mode': ['tile', str(tile_x), str(tile_y)], |
borenet@google.com | 96b17aa | 2013-01-15 15:50:42 +0000 | [diff] [blame] | 18 | # TODO(borenet): Turn this back on once the parser is working. |
| 19 | #'timeIndividualTiles': True |
| 20 | } |
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): |
| 24 | return Config(device='bitmap', **kwargs) |
| 25 | |
| 26 | |
| 27 | def GPUConfig(**kwargs): |
| 28 | return Config(device='gpu', **kwargs) |
| 29 | |
| 30 | |
| 31 | def TiledBitmapConfig(tile_x, tile_y, **kwargs): |
borenet@google.com | b00d670 | 2013-01-11 20:45:24 +0000 | [diff] [blame] | 32 | return BitmapConfig(**dict(TileArgs(tile_x, tile_y).items() + kwargs.items())) |
borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 33 | |
| 34 | |
| 35 | def TiledGPUConfig(tile_x, tile_y, **kwargs): |
borenet@google.com | b00d670 | 2013-01-11 20:45:24 +0000 | [diff] [blame] | 36 | return GPUConfig(**dict(TileArgs(tile_x, tile_y).items() + kwargs.items())) |
borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 37 | |
| 38 | |
borenet@google.com | 9afba74 | 2012-12-18 21:44:53 +0000 | [diff] [blame] | 39 | def ViewportBitmapConfig(viewport_x, viewport_y, **kwargs): |
| 40 | return BitmapConfig(viewport=[str(viewport_x), str(viewport_y)], **kwargs) |
| 41 | |
| 42 | |
| 43 | def ViewportGPUConfig(viewport_x, viewport_y, **kwargs): |
| 44 | return GPUConfig(viewport=[str(viewport_x), str(viewport_y)], **kwargs) |
| 45 | |
| 46 | |
| 47 | def ViewportRTreeConfig(viewport_x, viewport_y, **kwargs): |
borenet@google.com | 8b95474 | 2012-12-19 14:47:53 +0000 | [diff] [blame] | 48 | return RTreeConfig(mode='simple', viewport=[str(viewport_x), str(viewport_y)], |
| 49 | **kwargs) |
borenet@google.com | 9afba74 | 2012-12-18 21:44:53 +0000 | [diff] [blame] | 50 | |
| 51 | |
| 52 | def ViewportGridConfig(viewport_x, viewport_y, **kwargs): |
| 53 | return GridConfig(viewport_x, viewport_y, mode='simple', |
| 54 | viewport=[str(viewport_x), str(viewport_y)], **kwargs) |
| 55 | |
| 56 | |
borenet@google.com | 1558d68 | 2012-12-12 20:13:26 +0000 | [diff] [blame] | 57 | def CopyTilesConfig(tile_x, tile_y, **kwargs): |
| 58 | return BitmapConfig(mode=['copyTile', str(tile_x), str(tile_y)], **kwargs) |
| 59 | |
| 60 | |
| 61 | def RecordConfig(**kwargs): |
| 62 | return BitmapConfig(mode='record', **kwargs) |
| 63 | |
| 64 | |
| 65 | def PlaybackCreationConfig(**kwargs): |
| 66 | return BitmapConfig(mode='playbackCreation', **kwargs) |
| 67 | |
| 68 | |
| 69 | def MultiThreadTileConfig(threads, tile_x, tile_y, **kwargs): |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 70 | return TiledBitmapConfig(multi=str(threads), tile_x=tile_x, tile_y=tile_y, |
| 71 | **kwargs) |
| 72 | |
| 73 | |
borenet@google.com | 8b95474 | 2012-12-19 14:47:53 +0000 | [diff] [blame] | 74 | def RTreeConfig(**kwargs): |
| 75 | return BitmapConfig(bbh='rtree', **kwargs) |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 76 | |
| 77 | |
| 78 | def GridConfig(tile_x, tile_y, mode, **kwargs): |
| 79 | return BitmapConfig(mode=mode, bbh=['grid', str(tile_x), str(tile_y)], |
| 80 | **kwargs) |
| 81 | |
| 82 | |
borenet@google.com | 8b95474 | 2012-12-19 14:47:53 +0000 | [diff] [blame] | 83 | def RecordRTreeConfig(**kwargs): |
| 84 | return RTreeConfig(mode='record', **kwargs) |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 85 | |
| 86 | |
borenet@google.com | 8b95474 | 2012-12-19 14:47:53 +0000 | [diff] [blame] | 87 | def PlaybackCreationRTreeConfig(**kwargs): |
| 88 | return RTreeConfig(mode='playbackCreation', **kwargs) |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 89 | |
| 90 | |
| 91 | def TileRTreeConfig(tile_x, tile_y, **kwargs): |
borenet@google.com | b00d670 | 2013-01-11 20:45:24 +0000 | [diff] [blame] | 92 | return RTreeConfig(**dict(TileArgs(tile_x, tile_y).items() + kwargs.items())) |
borenet@google.com | ddf36e7 | 2012-12-14 14:56:37 +0000 | [diff] [blame] | 93 | |
| 94 | |
| 95 | def RecordGridConfig(tile_x, tile_y, **kwargs): |
| 96 | return GridConfig(tile_x=tile_x, tile_y=tile_y, mode='record', **kwargs) |
| 97 | |
| 98 | |
| 99 | def PlaybackCreationGridConfig(tile_x, tile_y, **kwargs): |
| 100 | return GridConfig(tile_x, tile_y, mode='playbackCreation') |
| 101 | |
| 102 | |
| 103 | def TileGridConfig(tile_x, tile_y, **kwargs): |
borenet@google.com | b00d670 | 2013-01-11 20:45:24 +0000 | [diff] [blame] | 104 | return GridConfig(tile_x, tile_y, |
| 105 | **dict(TileArgs(tile_x, tile_y).items() + kwargs.items())) |