1<!DOCTYPE html> 2<!-- 3Copyright (c) 2015 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/extras/chrome/cc/util.html"> 9<link rel="import" href="/tracing/extras/chrome/cc/debug_colors.html"> 10<link rel="import" href="/tracing/base/rect.html"> 11<link rel="import" href="/tracing/model/object_instance.html"> 12 13<script> 14'use strict'; 15 16tr.exportTo('tr.e.cc', function() { 17 var ObjectSnapshot = tr.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 tr.e.cc.preInitializeObject(this); 31 }, 32 33 initialize: function() { 34 tr.e.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.scheduledPriority; 42 this.gpuMemoryUsageInBytes = this.args.gpuMemoryUsage; 43 } else { 44 this.resolution = this.args.resolution; 45 this.isSolidColor = this.args.drawInfo.isSolidColor; 46 this.isUsingGpuMemory = this.args.isUsingGpuMemory; 47 this.hasResource = this.args.hasResource; 48 this.scheduledPriority = this.args.scheduledPriority; 49 this.gpuMemoryUsageInBytes = this.args.gpuMemoryUsage; 50 } 51 52 // This check is for backward compatability. It can probably 53 // be removed once we're confident that most traces contain 54 // content_rect. 55 if (this.contentRect) 56 this.layerRect = this.contentRect.scale(1.0 / this.contentsScale); 57 58 if (this.isSolidColor) 59 this.type_ = tr.e.cc.tileTypes.solidColor; 60 else if (!this.hasResource) 61 this.type_ = tr.e.cc.tileTypes.missing; 62 else if (this.resolution === 'HIGH_RESOLUTION') 63 this.type_ = tr.e.cc.tileTypes.highRes; 64 else if (this.resolution === 'LOW_RESOLUTION') 65 this.type_ = tr.e.cc.tileTypes.lowRes; 66 else 67 this.type_ = tr.e.cc.tileTypes.unknown; 68 }, 69 70 getTypeForLayer: function(layer) { 71 var type = this.type_; 72 if (type == tr.e.cc.tileTypes.unknown) { 73 if (this.contentsScale < layer.idealContentsScale) 74 type = tr.e.cc.tileTypes.extraLowRes; 75 else if (this.contentsScale > layer.idealContentsScale) 76 type = tr.e.cc.tileTypes.extraHighRes; 77 } 78 return type; 79 } 80 }; 81 82 ObjectSnapshot.register(TileSnapshot, {typeName: 'cc::Tile'}); 83 84 return { 85 TileSnapshot: TileSnapshot 86 }; 87}); 88</script> 89