| <!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/cc/util.html"> |
| <link rel="import" href="/extras/cc/debug_colors.html"> |
| <link rel="import" href="/base/rect.html"> |
| <link rel="import" href="/core/trace_model/object_instance.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tv.exportTo('tv.e.cc', function() { |
| var ObjectSnapshot = tv.c.trace_model.ObjectSnapshot; |
| |
| /** |
| * @constructor |
| */ |
| function TileSnapshot() { |
| ObjectSnapshot.apply(this, arguments); |
| } |
| |
| TileSnapshot.prototype = { |
| __proto__: ObjectSnapshot.prototype, |
| |
| preInitialize: function() { |
| tv.e.cc.preInitializeObject(this); |
| }, |
| |
| initialize: function() { |
| tv.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_ = tv.e.cc.tileTypes.solidColor; |
| else if (!this.hasResource) |
| this.type_ = tv.e.cc.tileTypes.missing; |
| else if (this.resolution === 'HIGH_RESOLUTION') |
| this.type_ = tv.e.cc.tileTypes.highRes; |
| else if (this.resolution === 'LOW_RESOLUTION') |
| this.type_ = tv.e.cc.tileTypes.lowRes; |
| else |
| this.type_ = tv.e.cc.tileTypes.unknown; |
| }, |
| |
| getTypeForLayer: function(layer) { |
| var type = this.type_; |
| if (type == tv.e.cc.tileTypes.unknown) { |
| if (this.contentsScale < layer.idealContentsScale) |
| type = tv.e.cc.tileTypes.extraLowRes; |
| else if (this.contentsScale > layer.idealContentsScale) |
| type = tv.e.cc.tileTypes.extraHighRes; |
| } |
| return type; |
| } |
| }; |
| |
| ObjectSnapshot.register(TileSnapshot, {typeName: 'cc::Tile'}); |
| |
| return { |
| TileSnapshot: TileSnapshot |
| }; |
| }); |
| </script> |