1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
7 base.require('model.constants');
9 base.exportTo('ccfv.model', function() {
12 * Represents a cc::Tile over the course of its lifetime.
16 function TileHistory(id) {
18 this.tilesBySnapshotNumber = {};
19 this.layerID = undefined;
20 this.picturePile = undefined;
21 this.contentsScale = undefined;
23 this.selected = false;
26 TileHistory.prototype = {
28 return 'TileHistory ' + this.id;
31 getOrCreateTileForLTHI: function(lthi) {
32 if (!this.tilesBySnapshotNumber[lthi.snapshotNumber])
33 this.tilesBySnapshotNumber[lthi.snapshotNumber] = new Tile(this);
34 return this.tilesBySnapshotNumber[lthi.snapshotNumber];
37 dumpToSimpleObject: function(obj) {
39 obj.layerID = this.layerID;
40 obj.picturePile = this.picturePile;
41 obj.contentsScale = this.contentsScale;
46 * Represents a cc::Tile at an instant in time.
50 function Tile(history) {
51 this.history = history;
52 this.managedState = undefined;
53 this.priority = [undefined, undefined];
58 return this.history.id;
62 return this.history.contents_scale;
66 return this.history.picture_pile;
70 return 'Tile ' + this.id;
74 return this.history.selected;
78 this.history.selected = s;
81 dumpToSimpleObject: function(obj) {
83 this.history.dumpToSimpleObject(obj.history);
84 obj.managedState = this.managedState;
85 obj.priority = [{}, {}];
86 dumpAllButQuadToSimpleObject.call(this.priority[0], obj.priority[0]);
87 dumpAllButQuadToSimpleObject.call(this.priority[1], obj.priority[1]);
91 // Called with priority object as context.
92 function dumpAllButQuadToSimpleObject(obj) {
94 if (k == 'current_screen_quad')
102 TileHistory: TileHistory