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.
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">
16 tvcm.exportTo('cc', function() {
17 var ObjectSnapshot = tracing.trace_model.ObjectSnapshot;
22 function TileSnapshot() {
23 ObjectSnapshot.apply(this, arguments);
26 TileSnapshot.prototype = {
27 __proto__: ObjectSnapshot.prototype,
29 preInitialize: function() {
30 cc.preInitializeObject(this);
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;
46 this.distanceToVisible =
47 this.args.managedState.distanceToVisibleInPixels;
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;
58 if (this.timeToVisible > 60)
59 this.timeToVisible = 60;
61 this.gpuMemoryUsageInBytes = this.args.gpuMemoryUsage;
63 // This check is for backward compatability. It can probably
64 // be removed once we're confident that most traces contain
67 this.layerRect = this.contentRect.scale(1.0 / this.contentsScale);
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;
78 this.type_ = cc.tileTypes.unknown;
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;
93 ObjectSnapshot.register('cc::Tile', TileSnapshot);
96 TileSnapshot: TileSnapshot