Skip to content

Commit

Permalink
Rename:
Browse files Browse the repository at this point in the history
 PrepareSymbols#prepare -> performSymbolLayout
 PlaceSymbols#place -> performSymbolPlacement
  • Loading branch information
ChrisLoer committed Oct 17, 2017
1 parent eb064d9 commit dd91fa4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/data/bucket/symbol_bucket.js
Expand Up @@ -343,7 +343,7 @@ class SymbolBuffers {
* and icons needed (by this bucket and any others). When glyphs and icons
* have been received, the WorkerTile creates a CollisionIndex and invokes:
*
* 3. PrepareSymbols#prepare(bucket, stacks, icons) perform texts shaping and
* 3. performSymbolLayout(bucket, stacks, icons) perform texts shaping and
* layout on a Symbol Bucket. This step populates:
* `this.symbolInstances`: metadata on generated symbols
* `this.collisionBoxArray`: collision data for use by foreground
Expand All @@ -353,7 +353,7 @@ class SymbolBuffers {
* `this.collisionCircle`: Debug SymbolBuffers for collision circles
* The results are sent to the foreground for rendering
*
* 4. PlaceSymbols#place(bucket, collisionIndex): is run on the foreground,
* 4. performSymbolPlacement(bucket, collisionIndex) is run on the foreground,
* and uses the CollisionIndex along with current camera settings to determine
* which symbols can actually show on the map. Collided symbols are hidden
* using a dynamic "OpacityVertexArray".
Expand Down
6 changes: 3 additions & 3 deletions src/source/tile.js
Expand Up @@ -20,7 +20,7 @@ const Texture = require('../render/texture');
const {SegmentVector} = require('../data/segment');
const {TriangleIndexArray} = require('../data/index_array_type');
const projection = require('../symbol/projection');
const PlaceSymbols = require('../symbol/place_symbols');
const {performSymbolPlacement, updateOpacities} = require('../symbol/symbol_placement');
const pixelsToTileUnits = require('../source/pixels_to_tile_units');

const CLOCK_SKEW_RETRY_TIMEOUT = 30000;
Expand Down Expand Up @@ -218,7 +218,7 @@ class Tile {
const pixelRatio = pixelsToTileUnits(this, 1, collisionIndex.transform.zoom);

const labelPlaneMatrix = projection.getLabelPlaneMatrix(posMatrix, pitchWithMap, true, collisionIndex.transform, pixelRatio);
PlaceSymbols.place(bucket, collisionIndex, showCollisionBoxes, collisionIndex.transform.zoom, textPixelRatio, posMatrix, labelPlaneMatrix, this.coord.id, collisionBoxArray);
performSymbolPlacement(bucket, collisionIndex, showCollisionBoxes, collisionIndex.transform.zoom, textPixelRatio, posMatrix, labelPlaneMatrix, this.coord.id, collisionBoxArray);
}
}

Expand All @@ -227,7 +227,7 @@ class Tile {
for (const id in this.buckets) {
const bucket = this.buckets[id];
if (bucket instanceof SymbolBucket) {
PlaceSymbols.updateOpacities(bucket, collisionFadeTimes);
updateOpacities(bucket, collisionFadeTimes);
bucket.sortFeatures(angle);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/source/worker_tile.js
@@ -1,7 +1,7 @@
// @flow

const FeatureIndex = require('../data/feature_index');
const PrepareSymbols = require('../symbol/prepare_symbols');
const {performSymbolLayout} = require('../symbol/symbol_layout');
const CollisionBoxArray = require('../symbol/collision_box');
const DictionaryCoder = require('../util/dictionary_coder');
const SymbolBucket = require('../data/bucket/symbol_bucket');
Expand Down Expand Up @@ -166,7 +166,7 @@ class WorkerTile {
for (const bucket of this.symbolBuckets) {
recalculateLayers(bucket, this.zoom);

PrepareSymbols.prepare(bucket, glyphMap, glyphAtlas.positions, imageMap, imageAtlas.positions, this.showCollisionBoxes);
performSymbolLayout(bucket, glyphMap, glyphAtlas.positions, imageMap, imageAtlas.positions, this.showCollisionBoxes);
}

this.status = 'done';
Expand Down
14 changes: 7 additions & 7 deletions src/symbol/prepare_symbols.js → src/symbol/symbol_layout.js
Expand Up @@ -26,15 +26,15 @@ import type {GlyphPosition} from '../render/glyph_atlas';
const Point = require('@mapbox/point-geometry');

module.exports = {
prepare
performSymbolLayout
};

function prepare(bucket: SymbolBucket,
glyphMap: {[string]: {[number]: ?StyleGlyph}},
glyphPositions: {[string]: {[number]: GlyphPosition}},
imageMap: {[string]: StyleImage},
imagePositions: {[string]: ImagePosition},
showCollisionBoxes: boolean) {
function performSymbolLayout(bucket: SymbolBucket,
glyphMap: {[string]: {[number]: ?StyleGlyph}},
glyphPositions: {[string]: {[number]: GlyphPosition}},
imageMap: {[string]: StyleImage},
imagePositions: {[string]: ImagePosition},
showCollisionBoxes: boolean) {
bucket.createArrays();
bucket.symbolInstances = [];

Expand Down
Expand Up @@ -11,7 +11,7 @@ const mat4 = require('@mapbox/gl-matrix').mat4;

module.exports = {
updateOpacities: updateOpacities,
place: place
performSymbolPlacement: performSymbolPlacement
};

function updateOpacity(symbolInstance: SymbolInstance, opacityState: OpacityState, targetOpacity: number, opacityUpdateTime: number, collisionFadeTimes: any) {
Expand Down Expand Up @@ -133,7 +133,7 @@ function updateCollisionCircles(collisionVertexArray: StructArray, collisionCirc
}
}

function place(bucket: SymbolBucket, collisionIndex: CollisionIndex, showCollisionBoxes: boolean, zoom: number, textPixelRatio: number, posMatrix: mat4, labelPlaneMatrix: mat4, tileID: number, collisionBoxArray: CollisionBoxArray) {
function performSymbolPlacement(bucket: SymbolBucket, collisionIndex: CollisionIndex, showCollisionBoxes: boolean, zoom: number, textPixelRatio: number, posMatrix: mat4, labelPlaneMatrix: mat4, tileID: number, collisionBoxArray: CollisionBoxArray) {
const layer = bucket.layers[0];
const layout = layer.layout;

Expand Down
20 changes: 10 additions & 10 deletions test/unit/data/symbol_bucket.test.js
Expand Up @@ -11,8 +11,8 @@ const CollisionBoxArray = require('../../../src/symbol/collision_box');
const SymbolStyleLayer = require('../../../src/style/style_layer/symbol_style_layer');
const util = require('../../../src/util/util');
const featureFilter = require('../../../src/style-spec/feature_filter');
const PrepareSymbols = require('../../../src/symbol/prepare_symbols');
const PlaceSymbols = require('../../../src/symbol/place_symbols');
const {performSymbolLayout} = require('../../../src/symbol/symbol_layout');
const {performSymbolPlacement} = require('../../../src/symbol/symbol_placement');
const Transform = require('../../../src/geo/transform');

const mat4 = require('@mapbox/gl-matrix').mat4;
Expand Down Expand Up @@ -64,17 +64,17 @@ test('SymbolBucket', (t) => {
// add feature from bucket A
const a = collision.grid.keysLength();
bucketA.populate([{feature}], options);
PrepareSymbols.prepare(bucketA, stacks, {});
PlaceSymbols.place(bucketA, collision, showCollisionBoxes, zoom, pixelRatio, labelPlaneMatrix, labelPlaneMatrix, tileID, collisionBoxArray);
performSymbolLayout(bucketA, stacks, {});
performSymbolPlacement(bucketA, collision, showCollisionBoxes, zoom, pixelRatio, labelPlaneMatrix, labelPlaneMatrix, tileID, collisionBoxArray);

const b = collision.grid.keysLength();
t.notEqual(a, b, 'places feature');

// add same feature from bucket B
const a2 = collision.grid.keysLength();
bucketB.populate([{feature}], options);
PrepareSymbols.prepare(bucketB, stacks, {});
PlaceSymbols.place(bucketB, collision, showCollisionBoxes, zoom, pixelRatio, labelPlaneMatrix, labelPlaneMatrix, tileID, collisionBoxArray);
performSymbolLayout(bucketB, stacks, {});
performSymbolPlacement(bucketB, collision, showCollisionBoxes, zoom, pixelRatio, labelPlaneMatrix, labelPlaneMatrix, tileID, collisionBoxArray);
const b2 = collision.grid.keysLength();
t.equal(b2, a2, 'detects collision and does not place feature');
t.end();
Expand All @@ -89,7 +89,7 @@ test('SymbolBucket integer overflow', (t) => {

bucket.populate([{feature}], options);
const fakeGlyph = { rect: { w: 10, h: 10 }, metrics: { left: 10, top: 10, advance: 10 } };
PrepareSymbols.prepare(bucket, stacks, { 'Test': {97: fakeGlyph, 98: fakeGlyph, 99: fakeGlyph, 100: fakeGlyph, 101: fakeGlyph, 102: fakeGlyph} });
performSymbolLayout(bucket, stacks, { 'Test': {97: fakeGlyph, 98: fakeGlyph, 99: fakeGlyph, 100: fakeGlyph, 101: fakeGlyph, 102: fakeGlyph} });

t.ok(util.warnOnce.calledOnce);
t.ok(util.warnOnce.getCall(0).calledWithMatch(/Too many glyphs being rendered in a tile./));
Expand All @@ -101,9 +101,9 @@ test('SymbolBucket redo placement', (t) => {
const options = {iconDependencies: {}, glyphDependencies: {}};

bucket.populate([{feature}], options);
PrepareSymbols.prepare(bucket, stacks, {});
PlaceSymbols.place(bucket, collision, showCollisionBoxes, zoom, pixelRatio, labelPlaneMatrix, labelPlaneMatrix, tileID, collisionBoxArray);
PlaceSymbols.place(bucket, collision, showCollisionBoxes, zoom, pixelRatio, labelPlaneMatrix, labelPlaneMatrix, tileID, collisionBoxArray);
performSymbolLayout(bucket, stacks, {});
performSymbolPlacement(bucket, collision, showCollisionBoxes, zoom, pixelRatio, labelPlaneMatrix, labelPlaneMatrix, tileID, collisionBoxArray);
performSymbolPlacement(bucket, collision, showCollisionBoxes, zoom, pixelRatio, labelPlaneMatrix, labelPlaneMatrix, tileID, collisionBoxArray);

t.end();
});

0 comments on commit dd91fa4

Please sign in to comment.