OLD | NEW |
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 'use strict'; | 5 'use strict'; |
6 | 6 |
7 base.require('base.bbox2'); | 7 base.require('base.bbox2'); |
8 base.require('model.constants'); | 8 base.require('model.constants'); |
| 9 base.require('model.layer_impl'); |
9 | 10 |
10 base.exportTo('ccfv.model', function() { | 11 base.exportTo('ccfv.model', function() { |
11 | 12 |
12 /** | 13 /** |
13 * Represents a cc::LayerTreeImpl | 14 * Represents a cc::LayerTreeImpl |
14 * | 15 * |
15 * @constructor | 16 * @constructor |
16 */ | 17 */ |
17 function LayerTreeImpl(which_tree) { | 18 function LayerTreeImpl(lthi, which_tree) { |
| 19 this.lthi = lthi; |
18 this.which_tree = which_tree; | 20 this.which_tree = which_tree; |
19 this.tiles = []; | 21 this.tiles_ = []; |
| 22 this.allLayers = []; |
20 this.tileBBox_ = undefined; | 23 this.tileBBox_ = undefined; |
21 }; | 24 }; |
22 | 25 |
23 LayerTreeImpl.prototype = { | 26 LayerTreeImpl.prototype = { |
24 resetTiles: function() { | 27 setTilesDirty: function() { |
25 this.tilse = []; | 28 this.tiles_ = undefined; |
26 this.tileBBox_ = undefined; | 29 this.tileBBox_ = undefined; |
27 }, | 30 }, |
28 | 31 |
| 32 get tiles() { |
| 33 if (!this.tiles_) |
| 34 this.tiles_ = this.lthi.getTilesForTree(this.which_tree); |
| 35 return this.tiles_; |
| 36 }, |
| 37 |
| 38 getOrCreateLayerImpl: function(layerID) { |
| 39 var layerHistory = this.lthi.history.getOrCreateLayerImplHistory(layerID); |
| 40 var layer = layerHistory.getOrCreateLayerImplForLTHI(this); |
| 41 this.allLayers.push(layer); |
| 42 return layer; |
| 43 }, |
| 44 |
29 get tileBBox() { | 45 get tileBBox() { |
30 if (!this.tileBBox_) { | 46 if (!this.tileBBox_) { |
31 var bbox = new base.BBox2(); | 47 var bbox = new base.BBox2(); |
32 for (var i = 0; i < this.tiles.length; i++) { | 48 for (var i = 0; i < this.tiles.length; i++) { |
33 var tile = this.tiles[i]; | 49 var tile = this.tiles[i]; |
34 var priority = tile.priority[this.which_tree]; | 50 var priority = tile.priority[this.which_tree]; |
35 if (!priority.current_screen_quad) | 51 if (!priority.current_screen_quad) |
36 continue; | 52 continue; |
37 bbox.addQuad(priority.current_screen_quad); | 53 bbox.addQuad(priority.current_screen_quad); |
38 } | 54 } |
39 this.tileBBox_ = bbox; | 55 this.tileBBox_ = bbox; |
40 } | 56 } |
41 return this.tileBBox_; | 57 return this.tileBBox_; |
42 }, | 58 }, |
43 | 59 |
44 }; | 60 }; |
45 | 61 |
46 return { | 62 return { |
47 LayerTreeImpl: LayerTreeImpl | 63 LayerTreeImpl: LayerTreeImpl |
48 } | 64 } |
49 }); | 65 }); |
50 | 66 |
OLD | NEW |