Add bench_pictures config
Review URL: https://codereview.appspot.com/6873073

git-svn-id: http://skia.googlecode.com/svn/trunk@6768 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/__init__.py b/tools/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/__init__.py
diff --git a/tools/bench_pictures.cfg b/tools/bench_pictures.cfg
new file mode 100644
index 0000000..5ab462b
--- /dev/null
+++ b/tools/bench_pictures.cfg
@@ -0,0 +1,85 @@
+# 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.
+
+
+"""
+This file defines the configurations in which bench_pictures should be run
+on various platforms. The buildbots read these configurations from the
+bench_pictures_cfg dictionary. Everything else in this file exists to help in
+constructing that dictionary.
+
+This code is executed directly on the buildbot so that convenient things like
+variables and loops can be used to avoid unnecessary verbosity. With great power
+comes great responsibility; don't put any nasty code here. To reiterate, code in
+this file will be directly executed on the build slaves.
+"""
+
+
+import os
+import sys
+
+
+if 'import_path' in globals():
+  sys.path.append(import_path)
+
+
+from bench_pictures_cfg_helper import *
+
+
+# Default tile sizes
+DEFAULT_TILE_X = '256'
+DEFAULT_TILE_Y = '256'
+
+
+# Configs to run on most bots
+default_configs = [
+  # Basic CPU and GPU configs
+  TiledBitmapConfig(DEFAULT_TILE_X, DEFAULT_TILE_Y),
+  TiledGPUConfig(DEFAULT_TILE_X, DEFAULT_TILE_Y),
+
+  # CopyTiles
+  CopyTilesConfig(DEFAULT_TILE_X, DEFAULT_TILE_Y),
+
+  # Record
+  RecordConfig(),
+
+  # Multi-threaded
+  MultiThreadTileConfig(2, DEFAULT_TILE_X, DEFAULT_TILE_Y),
+  MultiThreadTileConfig(3, DEFAULT_TILE_X, DEFAULT_TILE_Y),
+  MultiThreadTileConfig(4, DEFAULT_TILE_X, DEFAULT_TILE_Y),
+
+  # Different tile sizes
+  TiledBitmapConfig(512, 512),
+  TiledBitmapConfig(1024, 256),
+  TiledBitmapConfig(1024, 64),
+
+  # Different bounding box heirarchies, for different modes.
+  RecordConfig(bbh='rtree'),
+  RecordConfig(bbh='grid'),
+  PlaybackCreationConfig(bbh='rtree'),
+  PlaybackCreationConfig(bbh='grid'),
+  TiledBitmapConfig(DEFAULT_TILE_X, DEFAULT_TILE_Y, bbh='rtree'),
+  TiledBitmapConfig(DEFAULT_TILE_X, DEFAULT_TILE_Y, bbh='grid'),
+]
+
+
+# Configs to run on Android devices. This just excludes configs with
+# '--mode playbackCreation'.
+android_configs = [cfg for cfg in default_configs \
+                   if cfg['mode'] != 'playbackCreation']
+
+
+# This dictionary defines the sets of configs for all platforms. Each config is
+# a dictionary of key/value pairs directly corresponding to the command-line
+# flags passed to bench_pictures.
+bench_pictures_cfg = {
+  'default': default_configs,
+  'no_gpu': [cfg for cfg in default_configs if cfg['device'] != 'gpu'],
+  'nexus_s': [cfg for cfg in android_configs if cfg['device'] != 'gpu'],
+  'nexus_4': android_configs,
+  'nexus_7': android_configs,
+  'nexus_10': android_configs,
+  'galaxy_nexus': android_configs,
+  'xoom': android_configs,
+}
\ No newline at end of file
diff --git a/tools/bench_pictures_cfg_helper.py b/tools/bench_pictures_cfg_helper.py
new file mode 100644
index 0000000..c407181
--- /dev/null
+++ b/tools/bench_pictures_cfg_helper.py
@@ -0,0 +1,46 @@
+# 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 BitmapConfig(**kwargs):
+  return Config(device='bitmap', **kwargs)
+
+
+def GPUConfig(**kwargs):
+  return Config(device='gpu', **kwargs)
+
+
+def TiledBitmapConfig(tile_x, tile_y, **kwargs):
+  return BitmapConfig(mode=['tile', str(tile_x), str(tile_y)], **kwargs)
+
+
+def TiledGPUConfig(tile_x, tile_y, **kwargs):
+  return GPUConfig(mode=['tile', str(tile_x), str(tile_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(multi=threads, tile_x=tile_x, tile_y=tile_y,
+                           **kwargs)
\ No newline at end of file