Skip to content

Commit

Permalink
add MAX_QUADS constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Molly Lloyd committed Aug 12, 2016
1 parent 2b506b8 commit 1ad4828
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ function SymbolBucket(options) {
this.adjustedTextSize = options.adjustedTextSize;
this.adjustedIconSize = options.adjustedIconSize;
this.fontstack = options.fontstack;

// this constant is based on the size of the glyphQuadEndIndex and iconQuadEndIndex
// in the symbol_instances StructArrayType
// eg the max valid UInt16 is 65,535
this.MAX_QUADS = 65535;
}

SymbolBucket.prototype = util.inherit(Bucket, {});
Expand Down Expand Up @@ -255,6 +260,7 @@ SymbolBucket.prototype.populateArrays = function(collisionTile, stacks, icons) {
};

SymbolBucket.prototype.addFeature = function(lines, shapedText, shapedIcon, feature) {
console.log(arguments);
var layout = this.layer.layout;

var glyphSize = 24;
Expand Down Expand Up @@ -564,6 +570,7 @@ SymbolBucket.prototype.addSymbolInstance = function(anchor, line, shapedText, sh
textBoxScale, textPadding, textAlongLine,
iconBoxScale, iconPadding, iconAlongLine, globalProperties, featureProperties) {


var glyphQuadStartIndex, glyphQuadEndIndex, iconQuadStartIndex, iconQuadEndIndex, textCollisionFeature, iconCollisionFeature, glyphQuads, iconQuads;
if (shapedText) {
glyphQuads = addToBuffers ? getGlyphQuads(anchor, shapedText, textBoxScale, line, layer, textAlongLine) : [];
Expand Down Expand Up @@ -595,8 +602,8 @@ SymbolBucket.prototype.addSymbolInstance = function(anchor, line, shapedText, sh
var iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : this.collisionBoxArray.length;
var iconBoxEndIndex = iconCollisionFeature ? iconCollisionFeature.boxEndIndex : this.collisionBoxArray.length;

if (iconBoxEndIndex > 65535) util.warnOnce("Too many symbols being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907");
if (glyphQuadEndIndex > 65535) util.warnOnce("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907");
if (iconQuadEndIndex > this.MAX_QUADS) util.warnOnce("Too many symbols being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907");
if (glyphQuadEndIndex > this.MAX_QUADS) util.warnOnce("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907");

return this.symbolInstancesArray.emplaceBack(
textBoxStartIndex,
Expand Down

0 comments on commit 1ad4828

Please sign in to comment.