Skip to content

Commit

Permalink
Move PlacedSymbolArray to SymbolBuffers
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Dec 29, 2017
1 parent e728172 commit 73c6d6b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
16 changes: 7 additions & 9 deletions src/data/bucket/symbol_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,16 @@ class SymbolBuffers {
collisionVertexArray: CollisionVertexArray;
collisionVertexBuffer: VertexBuffer;

placedSymbolArray: PlacedSymbolArray;

constructor(programConfigurations: ProgramConfigurationSet<SymbolStyleLayer>) {
this.layoutVertexArray = new SymbolLayoutArray();
this.indexArray = new TriangleIndexArray();
this.programConfigurations = programConfigurations;
this.segments = new SegmentVector();
this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray();
this.opacityVertexArray = new SymbolOpacityArray();
this.placedSymbolArray = new PlacedSymbolArray();
}

upload(context: Context, dynamicIndexBuffer: boolean) {
Expand Down Expand Up @@ -280,8 +283,6 @@ class SymbolBucket implements Bucket {
textSizeData: SizeData;
iconSizeData: SizeData;

placedGlyphArray: PlacedSymbolArray;
placedIconArray: PlacedSymbolArray;
glyphOffsetArray: GlyphOffsetArray;
lineVertexArray: SymbolLineVertexArray;
features: Array<SymbolFeature>;
Expand Down Expand Up @@ -325,8 +326,6 @@ class SymbolBucket implements Bucket {
this.collisionBox = new CollisionBuffers(CollisionBoxLayoutArray, collisionBoxLayout.members, LineIndexArray);
this.collisionCircle = new CollisionBuffers(CollisionCircleLayoutArray, collisionCircleLayout.members, TriangleIndexArray);

this.placedGlyphArray = new PlacedSymbolArray();
this.placedIconArray = new PlacedSymbolArray();
this.glyphOffsetArray = new GlyphOffsetArray();
this.lineVertexArray = new SymbolLineVertexArray();
}
Expand Down Expand Up @@ -472,8 +471,7 @@ class SymbolBucket implements Bucket {
writingMode: any,
labelAnchor: Anchor,
lineStartIndex: number,
lineLength: number,
placedSymbolArray: PlacedSymbolArray) {
lineLength: number) {
const indexArray = arrays.indexArray;
const layoutVertexArray = arrays.layoutVertexArray;
const dynamicLayoutVertexArray = arrays.dynamicLayoutVertexArray;
Expand Down Expand Up @@ -509,7 +507,7 @@ class SymbolBucket implements Bucket {
this.glyphOffsetArray.emplaceBack(symbol.glyphOffset[0]);
}

placedSymbolArray.emplaceBack(labelAnchor.x, labelAnchor.y,
arrays.placedSymbolArray.emplaceBack(labelAnchor.x, labelAnchor.y,
glyphOffsetArrayStart, this.glyphOffsetArray.length - glyphOffsetArrayStart, vertexStartIndex,
lineStartIndex, lineLength, (labelAnchor.segment: any),
sizeVertex ? sizeVertex[0] : 0, sizeVertex ? sizeVertex[1] : 0,
Expand Down Expand Up @@ -656,7 +654,7 @@ class SymbolBucket implements Bucket {
const symbolInstance = this.symbolInstances[i];

for (const placedTextSymbolIndex of symbolInstance.placedTextSymbolIndices) {
const placedSymbol = (this.placedGlyphArray.get(placedTextSymbolIndex): any);
const placedSymbol = this.text.placedSymbolArray.get(placedTextSymbolIndex);

const endIndex = placedSymbol.vertexStartIndex + placedSymbol.numGlyphs * 4;
for (let vertexIndex = placedSymbol.vertexStartIndex; vertexIndex < endIndex; vertexIndex += 4) {
Expand All @@ -665,7 +663,7 @@ class SymbolBucket implements Bucket {
}
}

const placedIcon = (this.placedIconArray.get(i): any);
const placedIcon = this.icon.placedSymbolArray.get(i);
if (placedIcon.numGlyphs) {
const vertexIndex = placedIcon.vertexStartIndex;
this.icon.indexArray.emplaceBack(vertexIndex, vertexIndex + 1, vertexIndex + 2);
Expand Down
2 changes: 1 addition & 1 deletion src/symbol/projection.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function updateLineLabels(bucket: SymbolBucket,
dynamicLayoutVertexArray.clear();

const lineVertexArray = bucket.lineVertexArray;
const placedSymbols = isText ? bucket.placedGlyphArray : bucket.placedIconArray;
const placedSymbols = isText ? bucket.text.placedSymbolArray : bucket.icon.placedSymbolArray;

const aspectRatio = painter.transform.width / painter.transform.height;

Expand Down
10 changes: 4 additions & 6 deletions src/symbol/symbol_layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,11 @@ function addTextVertices(bucket: SymbolBucket,
writingMode,
anchor,
lineArray.lineStartIndex,
lineArray.lineLength,
bucket.placedGlyphArray);
lineArray.lineLength);

// The placedGlyphArray is used at render time in drawTileSymbols
// The placedSymbolArray is used at render time in drawTileSymbols
// These indices allow access to the array at collision detection time
placedTextSymbolIndices.push(bucket.placedGlyphArray.length - 1);
placedTextSymbolIndices.push(bucket.text.placedSymbolArray.length - 1);

return glyphQuads.length * 4;
}
Expand Down Expand Up @@ -385,8 +384,7 @@ function addSymbol(bucket: SymbolBucket,
false,
anchor,
lineArray.lineStartIndex,
lineArray.lineLength,
bucket.placedIconArray);
lineArray.lineLength);
}

const iconBoxStartIndex = iconCollisionFeature ? iconCollisionFeature.boxStartIndex : bucket.collisionBoxArray.length;
Expand Down
6 changes: 3 additions & 3 deletions src/symbol/symbol_placement.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ function updateOpacities(bucket: SymbolBucket, collisionFadeTimes: any, instant:
const nowHidden = opacityState.opacity === 0 && opacityState.targetOpacity === 0;
if (initialHidden !== nowHidden) {
for (const placedTextSymbolIndex of symbolInstance.placedTextSymbolIndices) {
const placedSymbol = (bucket.placedGlyphArray.get(placedTextSymbolIndex): any);
const placedSymbol = bucket.text.placedSymbolArray.get(placedTextSymbolIndex);
// If this label is completely faded, mark it so that we don't have to calculate
// its position at render time
placedSymbol.hidden = nowHidden;
placedSymbol.hidden = (nowHidden: any);
}
}

Expand Down Expand Up @@ -196,7 +196,7 @@ function performSymbolPlacement(bucket: SymbolBucket, collisionIndex: CollisionI

const textCircles = symbolInstance.collisionArrays.textCircles;
if (textCircles) {
const placedSymbol = (bucket.placedGlyphArray.get(symbolInstance.placedTextSymbolIndices[0]): any);
const placedSymbol = bucket.text.placedSymbolArray.get(symbolInstance.placedTextSymbolIndices[0]);
const fontSize = symbolSize.evaluateSizeForFeature(bucket.textSizeData, partiallyEvaluatedTextSize, placedSymbol);
placedGlyphCircles = collisionIndex.placeCollisionCircles(textCircles,
layout.get('text-allow-overlap'),
Expand Down

0 comments on commit 73c6d6b

Please sign in to comment.