blob: b5f7df56322ee76a83379604c8250e185e44041f [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 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.
-->
<link rel="import" href="/extras/chrome/cc/util.html">
<link rel="import" href="/extras/chrome/cc/debug_colors.html">
<link rel="import" href="/base/rect.html">
<link rel="import" href="/model/object_instance.html">
<script>
'use strict';
tr.exportTo('tr.e.cc', function() {
var ObjectSnapshot = tr.model.ObjectSnapshot;
/**
* @constructor
*/
function TileSnapshot() {
ObjectSnapshot.apply(this, arguments);
}
TileSnapshot.prototype = {
__proto__: ObjectSnapshot.prototype,
preInitialize: function() {
tr.e.cc.preInitializeObject(this);
},
initialize: function() {
tr.e.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.scheduledPriority;
this.gpuMemoryUsageInBytes = this.args.gpuMemoryUsage;
} else {
this.resolution = this.args.resolution;
this.isSolidColor = this.args.drawInfo.isSolidColor;
this.isUsingGpuMemory = this.args.isUsingGpuMemory;
this.hasResource = this.args.hasResource;
this.scheduledPriority = this.args.scheduledPriority;
this.gpuMemoryUsageInBytes = this.args.gpuMemoryUsage;
}
// 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_ = tr.e.cc.tileTypes.solidColor;
else if (!this.hasResource)
this.type_ = tr.e.cc.tileTypes.missing;
else if (this.resolution === 'HIGH_RESOLUTION')
this.type_ = tr.e.cc.tileTypes.highRes;
else if (this.resolution === 'LOW_RESOLUTION')
this.type_ = tr.e.cc.tileTypes.lowRes;
else
this.type_ = tr.e.cc.tileTypes.unknown;
},
getTypeForLayer: function(layer) {
var type = this.type_;
if (type == tr.e.cc.tileTypes.unknown) {
if (this.contentsScale < layer.idealContentsScale)
type = tr.e.cc.tileTypes.extraLowRes;
else if (this.contentsScale > layer.idealContentsScale)
type = tr.e.cc.tileTypes.extraHighRes;
}
return type;
}
};
ObjectSnapshot.register(TileSnapshot, {typeName: 'cc::Tile'});
return {
TileSnapshot: TileSnapshot
};
});
</script>