Skip to content

Commit

Permalink
skip line outlines that specify non-existent draw styles, and log war…
Browse files Browse the repository at this point in the history
…ning
  • Loading branch information
bcamper committed Nov 8, 2017
1 parent 9c25d35 commit 2b540a2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
55 changes: 32 additions & 23 deletions src/styles/lines/lines.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Line rendering style

import log from '../../utils/log';
import {Style} from '../style';
import StyleParser from '../style_parser';
import gl from '../../gl/constants'; // web workers don't have access to GL context, so import all GL constants
Expand All @@ -12,7 +13,7 @@ import WorkerBroker from '../../utils/worker_broker';
import hashString from '../../utils/hash';
import {shaderSrc_polygonsVertex, shaderSrc_polygonsFragment} from '../polygons/polygons';

export var Lines = Object.create(Style);
export const Lines = Object.create(Style);

Lines.vertex_layouts = [[], []]; // first dimension is texcoords on/off, second is offsets on/off
Lines.variants = {}; // mesh variants by variant key
Expand Down Expand Up @@ -303,31 +304,39 @@ Object.assign(Lines, {

// outline inhertits dash pattern, but NOT explicit texture
let outline_style = this.styles[draw.outline.style];
draw.outline.dash = (draw.outline.dash !== undefined ? draw.outline.dash : outline_style.dash);
draw.outline.texture = (draw.outline.texture !== undefined ? draw.outline.texture : outline_style.texture);
if (outline_style) {
draw.outline.dash = (draw.outline.dash !== undefined ? draw.outline.dash : outline_style.dash);
draw.outline.texture = (draw.outline.texture !== undefined ? draw.outline.texture : outline_style.texture);

if (draw.outline.dash != null) { // dash was defined by outline draw or style
draw.outline.dash_key = draw.outline.dash && this.dashTextureKey(draw.outline.dash);
draw.outline.texture_merged = draw.outline.dash_key;
}
else if (draw.outline.dash === null) { // dash explicitly disabled by outline draw or style
draw.outline.dash_key = null;
draw.outline.texture_merged = draw.outline.texture;
}
else if (draw.outline.texture != null) { // texture was defined by outline draw or style
draw.outline.dash_key = null; // outline explicitly turning off dash
draw.outline.texture_merged = draw.outline.texture;
if (draw.outline.dash != null) { // dash was defined by outline draw or style
draw.outline.dash_key = draw.outline.dash && this.dashTextureKey(draw.outline.dash);
draw.outline.texture_merged = draw.outline.dash_key;
}
else if (draw.outline.dash === null) { // dash explicitly disabled by outline draw or style
draw.outline.dash_key = null;
draw.outline.texture_merged = draw.outline.texture;
}
else if (draw.outline.texture != null) { // texture was defined by outline draw or style
draw.outline.dash_key = null; // outline explicitly turning off dash
draw.outline.texture_merged = draw.outline.texture;
}
else { // no dash or texture defined for outline, inherit parent dash
draw.outline.dash = draw.dash;
draw.outline.dash_key = draw.outline.dash && this.dashTextureKey(draw.outline.dash);
draw.outline.texture_merged = draw.outline.dash_key;
}
draw.outline.dash_background_color = (draw.outline.dash_background_color !== undefined ? draw.outline.dash_background_color : outline_style.dash_background_color);
draw.outline.dash_background_color = (draw.outline.dash_background_color !== undefined ? draw.outline.dash_background_color : draw.dash_background_color);
draw.outline.dash_background_color = draw.outline.dash_background_color && StyleParser.parseColor(draw.outline.dash_background_color);
draw.outline.texcoords = ((outline_style.texcoords || draw.outline.texture_merged) ? 1 : 0);
this.computeVariant(draw.outline);
}
else { // no dash or texture defined for outline, inherit parent dash
draw.outline.dash = draw.dash;
draw.outline.dash_key = draw.outline.dash && this.dashTextureKey(draw.outline.dash);
draw.outline.texture_merged = draw.outline.dash_key;
else {
log({ level: 'warn', once: true }, `Layer '${draw.layers[draw.layers.length-1]}': ` +
`line 'outline' specifies non-existent draw style '${draw.outline.style}' (or maybe the style is ` +
`defined but is missing a 'base' or has another error), skipping outlines in layer`);
draw.outline = null;
}
draw.outline.dash_background_color = (draw.outline.dash_background_color !== undefined ? draw.outline.dash_background_color : outline_style.dash_background_color);
draw.outline.dash_background_color = (draw.outline.dash_background_color !== undefined ? draw.outline.dash_background_color : draw.dash_background_color);
draw.outline.dash_background_color = draw.outline.dash_background_color && StyleParser.parseColor(draw.outline.dash_background_color);
draw.outline.texcoords = ((outline_style.texcoords || draw.outline.texture_merged) ? 1 : 0);
this.computeVariant(draw.outline);
}
return draw;
},
Expand Down
2 changes: 1 addition & 1 deletion src/styles/points/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const angles_normalize = 16384 / Math.PI;
const offsets_normalize = 64;
const texcoord_normalize = 65535;

export var Points = Object.create(Style);
export const Points = Object.create(Style);

Points.variants = {}; // mesh variants by variant key

Expand Down

0 comments on commit 2b540a2

Please sign in to comment.