blob: ba91fda774f331879da81b1844d4959822ecbd8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright (c) 2013 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.
'use strict';
base.require('base.rect');
base.require('tracing.trace_model.object_instance');
base.require('cc.util');
base.require('cc.debug_colors');
base.exportTo('cc', function() {
var ObjectSnapshot = tracing.trace_model.ObjectSnapshot;
/**
* @constructor
*/
function TileSnapshot() {
ObjectSnapshot.apply(this, arguments);
}
TileSnapshot.prototype = {
__proto__: ObjectSnapshot.prototype,
preInitialize: function() {
cc.preInitializeObject(this);
},
initialize: function() {
cc.moveOptionalFieldsFromArgsToToplevel(
this, ['layerId', 'contentsScale', 'contentRect']);
if (this.args.managedState) {
this.resolution = this.args.managedState.resolution;
this.isSolidColor = this.args.managedState.isSolidColor;
this.isUsingGpuMemory = this.args.managedState.isUsingGpuMemory;
this.hasResource = this.args.managedState.hasResource;
this.scheduledPriority = this.args.managedState.scheduledPriority;
this.distanceToVisible =
this.args.managedState.distanceToVisibleInPixels;
this.timeToVisible = this.args.managedState.timeToNeededInSeconds;
} else {
this.resolution = 'HIGH_RESOLUTION';
this.isSolidColor = false;
this.isUsingGpuMemory = false;
this.hasResource = false;
this.scheduledPriority = undefined;
this.distanceToVisible = undefined;
this.timeToVisible = undefined;
}
if (this.timeToVisible > 60)
this.timeToVisible = 60;
// This check is for backward compatability. It can probably
// be removed once we're confident that most traces contain
// content_rect.
if (this.contentRect)
this.layerRect = this.contentRect.scale(1.0 / this.contentsScale);
if (this.isSolidColor)
this.type_ = cc.tileTypes.solidColor;
else if (!this.hasResource)
this.type_ = cc.tileTypes.missing;
else if (this.resolution === 'HIGH_RESOLUTION')
this.type_ = cc.tileTypes.highRes;
else if (this.resolution === 'LOW_RESOLUTION')
this.type_ = cc.tileTypes.lowRes;
else
this.type_ = cc.tileTypes.unknown;
},
getTypeForLayer: function(layer) {
var type = this.type_;
if (type == cc.tileTypes.unknown) {
if (this.contentsScale < layer.idealContentsScale)
type = cc.tileTypes.extraLowRes;
else if (this.contentsScale > layer.idealContentsScale)
type = cc.tileTypes.extraHighRes;
}
return type;
}
};
ObjectSnapshot.register('cc::Tile', TileSnapshot);
return {
TileSnapshot: TileSnapshot
};
});
|