Skip to content

Commit

Permalink
clean up paint buffers update
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner authored and mike-unearth committed Mar 18, 2020
1 parent 53bdd5e commit 562dc7e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 26 deletions.
31 changes: 8 additions & 23 deletions src/data/program_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,23 +534,19 @@ export default class ProgramConfiguration {
}
}

updatePatternPaintBuffers(crossfade: CrossfadeParameters) {
const buffers = [];
updatePaintBuffers(crossfade?: CrossfadeParameters) {
this._buffers = [];

for (const property in this.binders) {
const binder = this.binders[property];
if (binder instanceof CrossFadedCompositeBinder) {
if (crossfade && binder instanceof CrossFadedCompositeBinder) {
const patternVertexBuffer = crossfade.fromScale === 2 ? binder.zoomInPaintVertexBuffer : binder.zoomOutPaintVertexBuffer;
if (patternVertexBuffer) buffers.push(patternVertexBuffer);
} else if ((binder instanceof SourceExpressionBinder ||
binder instanceof CompositeExpressionBinder) &&
binder.paintVertexBuffer
) {
buffers.push(binder.paintVertexBuffer);
if (patternVertexBuffer) this._buffers.push(patternVertexBuffer);

} else if ((binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder) && binder.paintVertexBuffer) {
this._buffers.push(binder.paintVertexBuffer);
}
}

this._buffers = buffers;
}

upload(context: Context) {
Expand All @@ -559,18 +555,7 @@ export default class ProgramConfiguration {
if (binder instanceof SourceExpressionBinder || binder instanceof CompositeExpressionBinder || binder instanceof CrossFadedCompositeBinder)
binder.upload(context);
}

const buffers = [];
for (const property in this.binders) {
const binder = this.binders[property];
if ((binder instanceof SourceExpressionBinder ||
binder instanceof CompositeExpressionBinder) &&
binder.paintVertexBuffer
) {
buffers.push(binder.paintVertexBuffer);
}
}
this._buffers = buffers;
this.updatePaintBuffers();
}

destroy() {
Expand Down
2 changes: 1 addition & 1 deletion src/render/draw_fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function drawFillTiles(painter, sourceCache, layer, coords, depthMode, colorMode
if (image) {
painter.context.activeTexture.set(gl.TEXTURE0);
tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
programConfiguration.updatePatternPaintBuffers(crossfade);
programConfiguration.updatePaintBuffers(crossfade);
}

const constantPattern = patternProperty.constantOr(null);
Expand Down
2 changes: 1 addition & 1 deletion src/render/draw_fill_extrusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function drawExtrusionTiles(painter, source, layer, coords, depthMode, stencilMo
if (image) {
painter.context.activeTexture.set(gl.TEXTURE0);
tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
programConfiguration.updatePatternPaintBuffers(crossfade);
programConfiguration.updatePaintBuffers(crossfade);
}

const constantPattern = patternProperty.constantOr(null);
Expand Down
2 changes: 1 addition & 1 deletion src/render/draw_line.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default function drawLine(painter: Painter, sourceCache: SourceCache, lay
if (image) {
context.activeTexture.set(gl.TEXTURE0);
tile.imageAtlasTexture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
programConfiguration.updatePatternPaintBuffers(crossfade);
programConfiguration.updatePaintBuffers(crossfade);
} else if (dasharray && (programChanged || painter.lineAtlas.dirty)) {
context.activeTexture.set(gl.TEXTURE0);
painter.lineAtlas.bind(context);
Expand Down

0 comments on commit 562dc7e

Please sign in to comment.