diff --git a/src/data/program_configuration.js b/src/data/program_configuration.js index 9d3aa230351..75603644f4f 100644 --- a/src/data/program_configuration.js +++ b/src/data/program_configuration.js @@ -116,7 +116,7 @@ class ConstantBinder implements Binder { uniform.set(currentValue.constantOr(this.value)); } - getBinding(context: Context, location: WebGLUniformLocation): $Subtype> { + getBinding(context: Context, location: WebGLUniformLocation): $Subtype> { return (this.type === 'color') ? new UniformColor(context, location) : new Uniform1f(context, location); @@ -345,7 +345,7 @@ class CompositeExpressionBinder implements Binder { * * @private */ -class ProgramConfiguration { +export default class ProgramConfiguration { binders: Array>; cacheKey: string; layoutAttributes: Array; @@ -400,9 +400,9 @@ class ProgramConfiguration { return self; } - populatePaintArrays(length: number, feature: Feature) { + populatePaintArrays(newLength: number, feature: Feature, index: number) { for (let i = 0; i < this.binderLen; i++) { - this.binders[i].populatePaintArray(length, feature); + this.binders[i].populatePaintArray(newLength, feature); } if (feature.id) { const featureId = String(feature.id); @@ -427,12 +427,12 @@ class ProgramConfiguration { for (const pos of posArray) { const feature = vtLayer.feature(pos.index); - for (const property in this.binders) { - const binder = this.binders[property]; + for (let i = 0; i < this.binderLen; i++) { + const binder = this.binders[i]; if (binder instanceof ConstantBinder) continue; if ((binder: any).expression.isStateDependent === true) { //AHM: Remove after https://github.com/mapbox/mapbox-gl-js/issues/6255 - const value = layer.paint.get(property); + const value = layer.paint.get(binder.property); (binder: any).expression = value.value; binder.updatePaintArray(pos.start, pos.end, feature, featureState); dirty = true; @@ -464,10 +464,10 @@ class ProgramConfiguration { return result; } - setUniforms(context: Context, uniformBindings: UniformBindings, properties: PossiblyEvaluated, globals: GlobalProperties, i: number) { + setUniforms(context: Context, uniformBindings: UniformBindings, properties: PossiblyEvaluated, globals: GlobalProperties) { // Uniform state bindings are owned by the Program, but we set them // from within the ProgramConfiguraton's binder members. - for (; i < this.binderLen; i++) { + for (let i = 0; i < this.binderLen; i++) { this.binders[i].setUniforms(context, uniformBindings[this.binders[i].uniformName], globals, properties.get(this.binders[i].property)); } } diff --git a/src/render/draw_fill.js b/src/render/draw_fill.js index 60df69a7081..3c853898f33 100644 --- a/src/render/draw_fill.js +++ b/src/render/draw_fill.js @@ -25,7 +25,6 @@ function drawFill(painter: Painter, sourceCache: SourceCache, layer: FillStyleLa return; } - const context = painter.context; const colorMode = painter.colorModeForRenderPass(); const pass = (!layer.paint.get('fill-pattern') && diff --git a/src/render/draw_line.js b/src/render/draw_line.js index 96ada917162..50f76e931af 100644 --- a/src/render/draw_line.js +++ b/src/render/draw_line.js @@ -4,6 +4,7 @@ import DepthMode from '../gl/depth_mode'; import Texture from './texture'; import { lineUniformValues, + lineGradientUniformValues, linePatternUniformValues, lineSDFUniformValues } from './program/line_program'; diff --git a/src/render/program.js b/src/render/program.js index bf6c3eb553f..44ec70c9331 100644 --- a/src/render/program.js +++ b/src/render/program.js @@ -121,10 +121,7 @@ class Program { } if (configuration) { - // For whatever reason, initializing `setUniforms`'s - // loop iterator here creates consistently better performance: - const i = 0; - configuration.setUniforms(context, this.binderUniforms, currentProperties, {zoom: (zoom: any)}, i); + configuration.setUniforms(context, this.binderUniforms, currentProperties, {zoom: (zoom: any)}); } const primitiveSize = { diff --git a/src/render/program/fill_extrusion_program.js b/src/render/program/fill_extrusion_program.js index 2de50d700d5..439b178cab6 100644 --- a/src/render/program/fill_extrusion_program.js +++ b/src/render/program/fill_extrusion_program.js @@ -9,10 +9,7 @@ import { UniformMatrix4fv } from '../uniform_binding'; -import glMatrix from '@mapbox/gl-matrix'; -const mat3 = glMatrix.mat3; -const vec3 = glMatrix.vec3; -const mat4 = glMatrix.mat4; +import { mat3, vec3, mat4 } from 'gl-matrix'; import { extend } from '../../util/util'; import type Context from '../../gl/context'; diff --git a/src/render/program/heatmap_program.js b/src/render/program/heatmap_program.js index 6643272aab2..b93cccbd29c 100644 --- a/src/render/program/heatmap_program.js +++ b/src/render/program/heatmap_program.js @@ -1,6 +1,6 @@ // @flow -import { mat4 } from '@mapbox/gl-matrix'; +import { mat4 } from 'gl-matrix'; import { Uniform1i, diff --git a/src/render/program/hillshade_program.js b/src/render/program/hillshade_program.js index 6897a5a102b..bc274d49408 100644 --- a/src/render/program/hillshade_program.js +++ b/src/render/program/hillshade_program.js @@ -1,6 +1,6 @@ // @flow -import { mat4 } from '@mapbox/gl-matrix'; +import { mat4 } from 'gl-matrix'; import { Uniform1i, diff --git a/src/render/program/line_program.js b/src/render/program/line_program.js index 5c8ca9c7a84..cf278a7cf7c 100644 --- a/src/render/program/line_program.js +++ b/src/render/program/line_program.js @@ -125,7 +125,7 @@ const lineGradientUniformValues = ( return extend(lineUniformValues(painter, tile, layer), { 'u_image': 0 }); -} +}; const linePatternUniformValues = ( painter: Painter,