OLD | NEW |
| (Empty) |
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. | |
4 */ | |
5 'use strict'; | |
6 | |
7 base.require('base.bbox2'); | |
8 base.require('model.constants'); | |
9 base.require('model.layer_impl'); | |
10 | |
11 base.exportTo('ccfv.model', function() { | |
12 | |
13 /** | |
14 * Represents a cc::LayerTreeImpl | |
15 * | |
16 * @constructor | |
17 */ | |
18 function LayerTreeImpl(lthi, which_tree) { | |
19 this.lthi = lthi; | |
20 this.which_tree = which_tree; | |
21 this.tiles_ = []; | |
22 this.allLayers = []; | |
23 this.tileBBox_ = undefined; | |
24 }; | |
25 | |
26 LayerTreeImpl.prototype = { | |
27 setTilesDirty: function() { | |
28 this.tiles_ = undefined; | |
29 this.tileBBox_ = undefined; | |
30 }, | |
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 | |
45 get tileBBox() { | |
46 if (!this.tileBBox_) { | |
47 var bbox = new base.BBox2(); | |
48 for (var i = 0; i < this.tiles.length; i++) { | |
49 var tile = this.tiles[i]; | |
50 var priority = tile.priority[this.which_tree]; | |
51 if (!priority.current_screen_quad) | |
52 continue; | |
53 bbox.addQuad(priority.current_screen_quad); | |
54 } | |
55 this.tileBBox_ = bbox; | |
56 } | |
57 return this.tileBBox_; | |
58 }, | |
59 | |
60 }; | |
61 | |
62 return { | |
63 LayerTreeImpl: LayerTreeImpl | |
64 } | |
65 }); | |
66 | |
OLD | NEW |