# 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.
  RecordRTreeConfig(          DEFAULT_TILE_X, DEFAULT_TILE_Y),
  RecordGridConfig(           DEFAULT_TILE_X, DEFAULT_TILE_Y),
  PlaybackCreationRTreeConfig(DEFAULT_TILE_X, DEFAULT_TILE_Y),
  PlaybackCreationGridConfig( DEFAULT_TILE_X, DEFAULT_TILE_Y),
  TileRTreeConfig(            DEFAULT_TILE_X, DEFAULT_TILE_Y),
  TileGridConfig(             DEFAULT_TILE_X, DEFAULT_TILE_Y),
]


def AndroidConfigList(tile_size, scale, cores, viewport, do_gpu=True):
  tile_x = tile_size[0]
  tile_y = tile_size[1]

  viewport_x = viewport[0]
  viewport_y = viewport[1]

  configs = [
    # Record
    RecordConfig(scale=str(scale)),
    RecordRTreeConfig(tile_x, tile_y, scale=str(scale)),
    RecordGridConfig( tile_x, tile_y, scale=str(scale)),

    # Tiled playback
    TiledBitmapConfig(tile_x, tile_y, scale=str(scale)),
    TileRTreeConfig(  tile_x, tile_y, scale=str(scale)),
    TileGridConfig(   tile_x, tile_y, scale=str(scale)),

    # Viewport playback
    ViewportBitmapConfig(viewport_x, viewport_y, scale=str(scale)),
    ViewportRTreeConfig( viewport_x, viewport_y, scale=str(scale)),
    ViewportGridConfig(  viewport_x, viewport_y, scale=str(scale)),
  ]

  if do_gpu:
    configs.append(TiledGPUConfig(tile_x, tile_y, scale=str(scale)))
    configs.append(ViewportGPUConfig(viewport_x, viewport_y, scale=str(scale)))

  # Multicore
  for num_cores in cores:
    configs.append(MultiThreadTileConfig(num_cores, tile_x, tile_y,
                                         scale=str(scale)))

  return configs


# 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 = {
  'debug': [TiledBitmapConfig(DEFAULT_TILE_X, DEFAULT_TILE_Y)],
  'default': default_configs,
  'no_gpu': [cfg for cfg in default_configs if cfg['device'] != 'gpu'],
  'nexus_s':      AndroidConfigList((256, 256), 0.4897, [],  (800,  480),
                                    do_gpu=False),
  'nexus_4':      AndroidConfigList((256, 256), 0.8163, [],  (1280, 768)),
  'nexus_7':      AndroidConfigList((256, 256), 0.8163, [2], (1280, 800)),
  'nexus_10':     AndroidConfigList((512, 512), 1.6326, [],  (2560, 1600)),
  'galaxy_nexus': AndroidConfigList((256, 256), 0.8163, [],  (1280, 800)),
  'xoom':         AndroidConfigList((256, 256), 0.8163, [],  (1200, 800)),
}