Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: tools/cc-frame-viewer/src/model/layer_tree_host_impl.js

Issue 12287014: [cc-frame-viewer] Show layers and levels of detail (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/cc-frame-viewer/src/model/layer_impl.js ('k') | tools/cc-frame-viewer/src/model/layer_tree_impl.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/cc-frame-viewer/src/model/layer_tree_host_impl.js
diff --git a/tools/cc-frame-viewer/src/model/layer_tree_host_impl.js b/tools/cc-frame-viewer/src/model/layer_tree_host_impl.js
index ee225462b9c75ee60db68df7dd8e788a0289ed1b..742daefbd9f759369a82df7bb1cc645dc0e31c47 100644
--- a/tools/cc-frame-viewer/src/model/layer_tree_host_impl.js
+++ b/tools/cc-frame-viewer/src/model/layer_tree_host_impl.js
@@ -24,6 +24,8 @@ base.exportTo('ccfv.model', function() {
this.allTileHistories_ = {};
this.allTilesBBox_ = undefined;
+
+ this.allLayerImplHistories_ = {};
};
LayerTreeHostImplHistory.prototype = {
@@ -32,6 +34,7 @@ base.exportTo('ccfv.model', function() {
var lthi = new LayerTreeHostImpl(this, snapshotNumber);
this.lthiSnapshots.push(lthi);
this.allTilesBBox_ = undefined;
+ this.allContentsScales_ = undefined;
return lthi;
},
@@ -41,6 +44,26 @@ base.exportTo('ccfv.model', function() {
return this.allTileHistories_[tileID];
},
+ getOrCreateLayerImplHistory: function(layerID) {
+ if (!this.allLayerImplHistories_[layerID])
+ this.allLayerImplHistories_[layerID] =
+ new ccfv.model.LayerImplHistory(layerID);
+ return this.allLayerImplHistories_[layerID];
+ },
+
+ get allContentsScales() {
+ if (this.allContentsScales_ !== undefined)
+ return this.allContentsScales_;
+
+ var scales = {};
+ for (var tileID in this.allTileHistories_) {
+ var tileHistory = this.allTileHistories_[tileID];
+ scales[tileHistory.contentsScale] = true;
+ }
+ this.allContentsScales_ = base.dictionaryKeys(scales);
+ return this.allContentsScales_;
+ },
+
get allTilesBBox() {
if (!this.allTilesBBox_) {
var bbox = new base.BBox2();
@@ -72,11 +95,13 @@ base.exportTo('ccfv.model', function() {
this.allTiles = [];
- this.rebuildNeeded_ = false;
-
// These fields are affected by the rebuildIfNeeded_() flow.
- this.pendingTree_ = new ccfv.model.LayerTreeImpl(constants.PENDING_TREE);
- this.activeTree_ = new ccfv.model.LayerTreeImpl(constants.ACTIVE_TREE);
+ this.pendingTree = new ccfv.model.LayerTreeImpl(
+ this, constants.PENDING_TREE);
+ this.activeTree = new ccfv.model.LayerTreeImpl(
+ this, constants.ACTIVE_TREE);
+
+ this.tilesForTree_ = undefined;
this.inactiveTiles_ = [];
}
@@ -85,44 +110,52 @@ base.exportTo('ccfv.model', function() {
return this.history.id;
},
- getOrCreateTile: function(tile_id) {
- var tileHistory = this.history.getOrCreateTileHistory(tile_id);
+ getTree: function(whichTree) {
+ if (whichTree === constants.ACTIVE_TREE)
+ return this.activeTree;
+ else if (whichTree === constants.PENDING_TREE)
+ return this.pendingTree;
+ else
+ throw new Error('Active or pending only.');
+ },
+
+ getOrCreateTile: function(tileID) {
+ var tileHistory = this.history.getOrCreateTileHistory(tileID);
var tile = tileHistory.getOrCreateTileForLTHI(this);
this.allTiles.push(tile);
- this.rebuildNeeded_ = true;
- return tile;
- },
- get activeTree() {
- this.rebuildIfNeeded_();
- return this.activeTree_;
- },
+ this.activeTree.setTilesDirty();
+ this.pendingTree.setTilesDirty();
+ this.tilesForTree_ = undefined;
+ this.inactiveTiles_ = undefined;
- get pendingTree() {
- this.rebuildIfNeeded_();
- return this.pendingTree_;
+ return tile;
},
get inactiveTiles() {
- this.rebuildIfNeeded_();
+ if (this.inactiveTiles_ === undefined)
+ this.rebuildTiles_();
return this.inactiveTiles_;
},
- rebuildIfNeeded_: function() {
- if (!this.rebuildNeeded_)
- return;
- this.activeTree_.resetTiles();
- this.pendingTree_.resetTiles();
+ getTilesForTree: function(which_tree) {
+ if (this.tilesForTree_ === undefined)
+ this.rebuildTiles_();
+ return this.tilesForTree_[which_tree];
+ },
+
+ rebuildTiles_: function() {
+ this.tilesForTree_ = [[], []];
+ this.inactiveTiles_ = [];
this.allTiles.forEach(function(tile) {
if (tile.priority[constants.ACTIVE_TREE].is_live)
- this.activeTree_.tiles.push(tile);
+ this.tilesForTree_[constants.ACTIVE_TREE].push(tile);
if (tile.priority[constants.PENDING_TREE].is_live)
- this.pendingTree_.tiles.push(tile);
+ this.tilesForTree_[constants.PENDING_TREE].push(tile);
if (tile.priority[constants.PENDING_TREE].is_live == false &&
tile.priority[constants.ACTIVE_TREE].is_live == false)
this.inactiveTiles_.push(tile);
}, this);
- this.rebuildNeeded_ = false;
},
};
« no previous file with comments | « tools/cc-frame-viewer/src/model/layer_impl.js ('k') | tools/cc-frame-viewer/src/model/layer_tree_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698