Skip to content

Commit

Permalink
add symbolInstances and symbolQuads to tile.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Molly Lloyd committed May 25, 2016
1 parent 945f4ee commit c68e579
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
17 changes: 7 additions & 10 deletions js/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ function SymbolBucket(options) {
this.showCollisionBoxes = options.showCollisionBoxes;
this.overscaling = options.overscaling;
this.collisionBoxArray = options.collisionBoxArray;
this.symbolQuadsBuffer = options.symbolQuadsBuffer;
this.symbolInstancesBuffer = options.symbolInstancesBuffer;
this.symbolQuadsArray = options.symbolQuadsArray;
this.symbolInstancesArray = options.symbolInstancesArray;

this.sdfIcons = options.sdfIcons;
this.iconsNeedLinear = options.iconsNeedLinear;
Expand Down Expand Up @@ -149,8 +149,6 @@ SymbolBucket.prototype.populateBuffers = function(collisionTile, stacks, icons)
this.tilePixelRatio = EXTENT / tileSize;
this.compareText = {};
this.symbolInstances = [];
// this.symbolInstancesBuffer = new SymbolInstancesArray();
// this.symbolQuadsBuffer = new SymbolQuadsArray();
this.iconsNeedLinear = false;

var layout = this.layer.layout;
Expand Down Expand Up @@ -332,10 +330,9 @@ SymbolBucket.prototype.addFeature = function(lines, shapedText, shapedIcon, feat
}
}

var addSymbolInstance = this.addSymbolInstance.bind(this);
this.symbolInstances.forEach(function(instance) {
addSymbolInstance(instance);
});
for (var k = 0; k < this.symbolInstances.length; k++) {
this.addSymbolInstance(this.symbolInstances[k]);
}

};

Expand Down Expand Up @@ -586,7 +583,7 @@ SymbolBucket.prototype.addSymbolInstance = function(symbolInstance) {
iconQuadIndex = this.addSymbolQuad(symbolInstance.iconQuads[0]);
}

return this.symbolInstancesBuffer.emplaceBack(
return this.symbolInstancesArray.emplaceBack(
startGlyphIndex || -1,
endGlyphIndex || -1,
iconQuadIndex || -1,
Expand All @@ -597,7 +594,7 @@ SymbolBucket.prototype.addSymbolInstance = function(symbolInstance) {
};

SymbolBucket.prototype.addSymbolQuad = function(symbolQuad) {
return this.symbolQuadsBuffer.emplaceBack(
return this.symbolQuadsArray.emplaceBack(
// anchorPoints
symbolQuad.anchorPoint.x,
symbolQuad.anchorPoint.y,
Expand Down
6 changes: 6 additions & 0 deletions js/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var GeoJSONFeature = require('../util/vectortile_to_geojson');
var featureFilter = require('feature-filter');
var CollisionTile = require('../symbol/collision_tile');
var CollisionBoxArray = require('../symbol/collision_box');
var SymbolInstancesArray = require('../symbol/symbol_instances');
var SymbolQuadsArray = require('../symbol/symbol_quads');

module.exports = Tile;

Expand Down Expand Up @@ -50,6 +52,8 @@ Tile.prototype = {

this.collisionBoxArray = new CollisionBoxArray(data.collisionBoxArray);
this.collisionTile = new CollisionTile(data.collisionTile, this.collisionBoxArray);
this.symbolInstancesArray = new SymbolInstancesArray(data.symbolInstancesArray);
this.symbolQuadsArray = new SymbolQuadsArray(data.symbolQuadsArray);
this.featureIndex = new FeatureIndex(data.featureIndex, data.rawTileData, this.collisionTile);
this.rawTileData = data.rawTileData;
this.buckets = unserializeBuckets(data.buckets, style);
Expand Down Expand Up @@ -97,6 +101,8 @@ Tile.prototype = {
}

this.collisionBoxArray = null;
this.symbolQuadsArray = null;
this.symbolInstancesArray = null;
this.collisionTile = null;
this.featureIndex = null;
this.rawTileData = null;
Expand Down
16 changes: 8 additions & 8 deletions js/source/worker_tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ WorkerTile.prototype.parse = function(data, layerFamilies, actor, rawTileData, c
this.data = data;

this.collisionBoxArray = new CollisionBoxArray();
this.symbolInstancesBuffer = new SymbolInstancesArray();
this.symbolQuadsBuffer = new SymbolQuadsArray();
this.symbolInstancesArray = new SymbolInstancesArray();
this.symbolQuadsArray = new SymbolQuadsArray();
var collisionTile = new CollisionTile(this.angle, this.pitch, this.collisionBoxArray);
var featureIndex = new FeatureIndex(this.coord, this.overscaling, collisionTile, data.layers);
var sourceLayerCoder = new DictionaryCoder(data.layers ? Object.keys(data.layers).sort() : ['_geojsonTileLayer']);
Expand Down Expand Up @@ -65,8 +65,8 @@ WorkerTile.prototype.parse = function(data, layerFamilies, actor, rawTileData, c
overscaling: this.overscaling,
showCollisionBoxes: this.showCollisionBoxes,
collisionBoxArray: this.collisionBoxArray,
symbolQuadsBuffer: this.symbolQuadsBuffer,
symbolInstancesBuffer: this.symbolInstancesBuffer,
symbolQuadsArray: this.symbolQuadsArray,
symbolInstancesArray: this.symbolInstancesArray,
sourceLayerIndex: sourceLayerCoder.encode(layer.sourceLayer || '_geojsonTileLayer')
});
bucket.createFilter();
Expand Down Expand Up @@ -213,8 +213,8 @@ WorkerTile.prototype.parse = function(data, layerFamilies, actor, rawTileData, c
var featureIndex_ = featureIndex.serialize();
var collisionTile_ = collisionTile.serialize();
var collisionBoxArray = tile.collisionBoxArray.serialize();
var symbolInstancesBuffer = tile.symbolInstancesBuffer.serialize();
var symbolQuadsBuffer = tile.symbolQuadsBuffer.serialize();
var symbolInstancesArray = tile.symbolInstancesArray.serialize();
var symbolQuadsArray = tile.symbolQuadsArray.serialize();
var transferables = [rawTileData].concat(featureIndex_.transferables).concat(collisionTile_.transferables);

var nonEmptyBuckets = buckets.filter(isBucketEmpty);
Expand All @@ -225,8 +225,8 @@ WorkerTile.prototype.parse = function(data, layerFamilies, actor, rawTileData, c
featureIndex: featureIndex_.data,
collisionTile: collisionTile_.data,
collisionBoxArray: collisionBoxArray,
symbolInstancesBuffer: symbolInstancesBuffer,
symbolQuadsBuffer: symbolQuadsBuffer,
symbolInstancesArray: symbolInstancesArray,
symbolQuadsArray: symbolQuadsArray,
rawTileData: rawTileData
}, getTransferables(nonEmptyBuckets).concat(transferables));
}
Expand Down

0 comments on commit c68e579

Please sign in to comment.