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.
7 base.require('base.color');
8 base.require('model.constants');
10 base.exportTo('ccfv', function() {
11 var Color = base.Color;
12 var constants = ccfv.model.constants;
15 var colorInf = new Color(192, 192, 192, 0.5);
16 var colorYes = new Color(0, 255, 0, 0.5);
18 var colorInfAsString = colorInf.toString();
19 var colorYesAsString = colorYes.toString();
21 var allTileColorMaps = [
24 getValueForTile: function(tile, priority) {
27 getBackgroundColorForValue: function(value) {
32 // time_to_visible_in_seconds.
33 var colorRedLo = new Color(255, 0, 0, 1);
34 var colorRedHi = new Color(0, 0, 255, 1);
35 allTileColorMaps.push({
36 title: 'time_to_visible_in_seconds',
37 getValueForTile: function(tile, priority) {
38 return priority.time_to_visible_in_seconds;
40 getBackgroundColorForValue: function(value) {
42 return colorInfAsString;
43 var percentage = Math.max(0, value / 10);
44 var res = Color.lerpRGBA(colorRedLo, colorRedHi,
46 return res.toString();
51 var colorGreenLo = new Color(0, 0, 255, 1);
52 var colorGreenHi = new Color(0, 255, 0, 1);
53 allTileColorMaps.push({
54 title: 'distance_to_visible_in_pixels',
55 getValueForTile: function(tile, priority) {
56 return priority.distance_to_visible_in_pixels;
58 getBackgroundColorForValue: function(value) {
60 return colorInfAsString;
61 var percentage = Math.max(0, value / 2000);
62 var res = Color.lerpRGBA(colorGreenLo, colorGreenHi,
64 return res.toString();
69 allTileColorMaps.push({
70 title: 'can_use_gpu_memory',
71 getValueForTile: function(tile, priority) {
72 return tile.managedState.can_use_gpu_memory;
74 getBackgroundColorForValue: function(value) {
75 return value ? colorYesAsString : undefined;
80 allTileColorMaps.push({
81 title: 'has_resource (consuming gpu memory)',
82 getValueForTile: function(tile, priority) {
83 return tile.managedState.has_resource;
85 getBackgroundColorForValue: function(value) {
86 return value ? colorYesAsString : undefined;
90 // bins of various types
91 var binToColorAsString = {
92 'NOW_BIN': new Color(0, 0, 255, 1).toString(),
93 'SOON_BIN': new Color(255, 255, 0, 1).toString(),
94 'EVENTUALLY_BIN': new Color(0, 255, 255, 1).toString(),
95 'NEVER_BIN': new Color(128, 128, 128, 1).toString(),
96 '<unknown TileManagerBin value>': new Color(255, 0, 0, 1).toString()
99 allTileColorMaps.push({
100 title: 'bin[HIGH_PRIORITY]',
101 getValueForTile: function(tile, priority) {
102 var bin = tile.managedState.bin[constants.HIGH_PRIORITY_BIN];
103 if (binToColorAsString[bin] === undefined)
104 throw new Error('Something has gone very wrong');
107 getBackgroundColorForValue: function(value) {
108 return binToColorAsString[value];
112 allTileColorMaps.push({
113 title: 'bin[LOW_PRIORITY]',
114 getValueForTile: function(tile, priority) {
115 var bin = tile.managedState.bin[constants.LOW_PRIORITY_BIN];
116 if (binToColorAsString[bin] === undefined)
117 throw new Error('Something has gone very wrong');
120 getBackgroundColorForValue: function(value) {
121 return binToColorAsString[value];
125 allTileColorMaps.push({
126 title: 'gpu_memmgr_stats_bin',
127 getValueForTile: function(tile, priority) {
128 var bin = tile.managedState.gpu_memmgr_stats_bin;
129 if (binToColorAsString[bin] === undefined)
130 throw new Error('Something has gone very wrong');
133 getBackgroundColorForValue: function(value) {
134 return binToColorAsString[value];
139 ALL_TILE_COLOR_MAPS: allTileColorMaps