Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / cc / tile.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
6 -->
7
8 <link rel="import" href="/cc/util.html">
9 <link rel="import" href="/cc/debug_colors.html">
10 <link rel="import" href="/tvcm/rect.html">
11 <link rel="import" href="/tracing/trace_model/object_instance.html">
12
13 <script>
14 'use strict';
15
16 tvcm.exportTo('cc', function() {
17   var ObjectSnapshot = tracing.trace_model.ObjectSnapshot;
18
19   /**
20    * @constructor
21    */
22   function TileSnapshot() {
23     ObjectSnapshot.apply(this, arguments);
24   }
25
26   TileSnapshot.prototype = {
27     __proto__: ObjectSnapshot.prototype,
28
29     preInitialize: function() {
30       cc.preInitializeObject(this);
31     },
32
33     initialize: function() {
34       cc.moveOptionalFieldsFromArgsToToplevel(
35           this, ['layerId', 'contentsScale', 'contentRect']);
36       if (this.args.managedState) {
37         this.resolution = this.args.managedState.resolution;
38         this.isSolidColor = this.args.managedState.isSolidColor;
39         this.isUsingGpuMemory = this.args.managedState.isUsingGpuMemory;
40         this.hasResource = this.args.managedState.hasResource;
41         this.scheduledPriority = this.args.managedState.scheduledPriority;
42         if (this.args.managedState.distanceToVisible !== undefined)
43           this.distanceToVisible =
44               this.args.managedState.distanceToVisible;
45         else {
46           this.distanceToVisible =
47               this.args.managedState.distanceToVisibleInPixels;
48         }
49       } else {
50         this.resolution = 'HIGH_RESOLUTION';
51         this.isSolidColor = false;
52         this.isUsingGpuMemory = false;
53         this.hasResource = false;
54         this.scheduledPriority = undefined;
55         this.distanceToVisible = undefined;
56         this.timeToVisible = undefined;
57       }
58       if (this.timeToVisible > 60)
59         this.timeToVisible = 60;
60
61       this.gpuMemoryUsageInBytes = this.args.gpuMemoryUsage;
62
63       // This check is for backward compatability. It can probably
64       // be removed once we're confident that most traces contain
65       // content_rect.
66       if (this.contentRect)
67         this.layerRect = this.contentRect.scale(1.0 / this.contentsScale);
68
69       if (this.isSolidColor)
70         this.type_ = cc.tileTypes.solidColor;
71       else if (!this.hasResource)
72         this.type_ = cc.tileTypes.missing;
73       else if (this.resolution === 'HIGH_RESOLUTION')
74         this.type_ = cc.tileTypes.highRes;
75       else if (this.resolution === 'LOW_RESOLUTION')
76         this.type_ = cc.tileTypes.lowRes;
77       else
78         this.type_ = cc.tileTypes.unknown;
79     },
80
81     getTypeForLayer: function(layer) {
82       var type = this.type_;
83       if (type == cc.tileTypes.unknown) {
84         if (this.contentsScale < layer.idealContentsScale)
85           type = cc.tileTypes.extraLowRes;
86         else if (this.contentsScale > layer.idealContentsScale)
87           type = cc.tileTypes.extraHighRes;
88       }
89       return type;
90     }
91   };
92
93   ObjectSnapshot.register('cc::Tile', TileSnapshot);
94
95   return {
96     TileSnapshot: TileSnapshot
97   };
98 });
99 </script>