From 73c6d6bb9e161b8ce5b77588bdc290da1d70a7a9 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 20 Dec 2017 17:01:22 -0800 Subject: [PATCH] Move PlacedSymbolArray to SymbolBuffers --- src/data/bucket/symbol_bucket.js | 16 +++++++--------- src/symbol/projection.js | 2 +- src/symbol/symbol_layout.js | 10 ++++------ src/symbol/symbol_placement.js | 6 +++--- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/data/bucket/symbol_bucket.js b/src/data/bucket/symbol_bucket.js index 75696e59755..3c2ff80466f 100644 --- a/src/data/bucket/symbol_bucket.js +++ b/src/data/bucket/symbol_bucket.js @@ -159,6 +159,8 @@ class SymbolBuffers { collisionVertexArray: CollisionVertexArray; collisionVertexBuffer: VertexBuffer; + placedSymbolArray: PlacedSymbolArray; + constructor(programConfigurations: ProgramConfigurationSet) { this.layoutVertexArray = new SymbolLayoutArray(); this.indexArray = new TriangleIndexArray(); @@ -166,6 +168,7 @@ class SymbolBuffers { this.segments = new SegmentVector(); this.dynamicLayoutVertexArray = new SymbolDynamicLayoutArray(); this.opacityVertexArray = new SymbolOpacityArray(); + this.placedSymbolArray = new PlacedSymbolArray(); } upload(context: Context, dynamicIndexBuffer: boolean) { @@ -280,8 +283,6 @@ class SymbolBucket implements Bucket { textSizeData: SizeData; iconSizeData: SizeData; - placedGlyphArray: PlacedSymbolArray; - placedIconArray: PlacedSymbolArray; glyphOffsetArray: GlyphOffsetArray; lineVertexArray: SymbolLineVertexArray; features: Array; @@ -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(); } @@ -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; @@ -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, @@ -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) { @@ -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); diff --git a/src/symbol/projection.js b/src/symbol/projection.js index c045751f734..2abba3a4821 100644 --- a/src/symbol/projection.js +++ b/src/symbol/projection.js @@ -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; diff --git a/src/symbol/symbol_layout.js b/src/symbol/symbol_layout.js index d7ae1636304..614a77939fa 100644 --- a/src/symbol/symbol_layout.js +++ b/src/symbol/symbol_layout.js @@ -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; } @@ -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; diff --git a/src/symbol/symbol_placement.js b/src/symbol/symbol_placement.js index 56c3015cf41..916baf9a287 100644 --- a/src/symbol/symbol_placement.js +++ b/src/symbol/symbol_placement.js @@ -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); } } @@ -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'),