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('base.bbox2');
8 base.require('model.constants');
9 base.require('model.layer_impl');
11 base.exportTo('ccfv.model', function() {
14 * Represents a cc::LayerTreeImpl
18 function LayerTreeImpl(lthi, which_tree) {
20 this.which_tree = which_tree;
23 this.tileBBox_ = undefined;
26 LayerTreeImpl.prototype = {
27 setTilesDirty: function() {
28 this.tiles_ = undefined;
29 this.tileBBox_ = undefined;
34 this.tiles_ = this.lthi.getTilesForTree(this.which_tree);
38 getOrCreateLayerImpl: function(layerID) {
39 var layerHistory = this.lthi.history.getOrCreateLayerImplHistory(layerID);
40 var layer = layerHistory.getOrCreateLayerImplForLTHI(this);
41 this.allLayers.push(layer);
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)
53 bbox.addQuad(priority.current_screen_quad);
55 this.tileBBox_ = bbox;
57 return this.tileBBox_;
63 LayerTreeImpl: LayerTreeImpl