Skip to content

Commit

Permalink
go w the flow 🌊
Browse files Browse the repository at this point in the history
  • Loading branch information
Molly Lloyd committed Aug 5, 2017
1 parent a7c6313 commit 58c2254
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/render/tile_mask.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// @flow

const util = require('../util/util');
const TileCoord = require('../source/tile_coord');

import type Tile from './../source/tile';


// Updates the TileMasks for all renderable tiles. A TileMask describes all regions
// within that tile that are *not* covered by other renderable tiles.
// Example: renderableTiles in our list are 2/1/3, 3/3/6, and 4/5/13. The schematic for creating the
Expand Down Expand Up @@ -53,8 +57,8 @@ const TileCoord = require('../source/tile_coord');
// 2/1/3, since it is not a descendant of it.


module.exports = function(renderableTiles) {
const sortedRenderables = util.objectValues(renderableTiles).sort((a, b) => { return a.coord.isLessThan(b.coord) ? -1 : b.coord.isLessThan(a.coord) ? 1 : 0; });
module.exports = function(renderableTiles: Array<Tile>) {
const sortedRenderables = renderableTiles.sort((a, b) => { return a.coord.isLessThan(b.coord) ? -1 : b.coord.isLessThan(a.coord) ? 1 : 0; });

for (let i = 0; i < sortedRenderables.length; i++) {
const mask = [];
Expand All @@ -70,7 +74,7 @@ module.exports = function(renderableTiles) {
}
};

function computeTileMasks(rootTile, ref, childArray, lowerBound, mask) {
function computeTileMasks(rootTile: TileCoord, ref: TileCoord, childArray: Array<Tile>, lowerBound: TileCoord, mask: Array<number>) {
// If the reference or any of its children is found in the list, we need to recurse.
for (let i = 0; i < childArray.length; i++) {
const childTile = childArray[i];
Expand All @@ -79,7 +83,7 @@ function computeTileMasks(rootTile, ref, childArray, lowerBound, mask) {
return;
} else if (childTile.coord.isChildOf(ref)) {
// There's at least one child tile that is masked out, so recursively descend
const children = ref.children();
const children = ref.children(Infinity);
for (let j = 0; j < children.length; j++) {
const child = children[j];
computeTileMasks(rootTile, child, childArray.slice(i), lowerBound, mask);
Expand Down
3 changes: 3 additions & 0 deletions src/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ class Tile {
placementSource: any;
workerID: number;
vtLayers: {[string]: VectorTileLayer};
mask: Array<number>;

aborted: ?boolean;
boundsBuffer: any;
boundsVAO: any;
maskedRasterBoundsBuffer: any;
maskedRasterBoundsVAO: any;
request: any;
texture: any;
sourceCache: any;
Expand Down

0 comments on commit 58c2254

Please sign in to comment.