diff --git a/CHANGELOG.md b/CHANGELOG.md index 527ffbbce0..a0f568226a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # GeoJS Change Log +## Version 1.10.3 + +### Performance improvements + +- Reduce the time it takes to switch texture interpolation ([#1230](../../pull/1230)) + ## Version 1.10.2 ### Improvements diff --git a/src/webgl/quadFeature.js b/src/webgl/quadFeature.js index cbcfa30646..b946289aed 100644 --- a/src/webgl/quadFeature.js +++ b/src/webgl/quadFeature.js @@ -373,7 +373,19 @@ var webgl_quadFeature = function (arg) { } m_quads.imgQuads.forEach((quad) => { if (quad.image && quad.texture && quad.texture.nearestPixel() !== nearestPixel) { + /* This could just be + * quad.texture.setNearestPixel(nearestPixel); + * but that needlessly redecodes the image. Instead, just change the + * the interpolation flags, then change the nearestPixel value + * without triggering a complete re-setup. */ + renderState.m_context.bindTexture(vgl.GL.TEXTURE_2D, quad.texture.textureHandle()); + renderState.m_context.texParameteri(vgl.GL.TEXTURE_2D, vgl.GL.TEXTURE_MIN_FILTER, nearestPixel ? vgl.GL.NEAREST : vgl.GL.LINEAR); + renderState.m_context.texParameteri(vgl.GL.TEXTURE_2D, vgl.GL.TEXTURE_MAG_FILTER, nearestPixel ? vgl.GL.NEAREST : vgl.GL.LINEAR); + renderState.m_context.bindTexture(vgl.GL.TEXTURE_2D, null); + const oldmod = quad.texture.modified; + quad.texture.modified = () => {}; quad.texture.setNearestPixel(nearestPixel); + quad.texture.modified = oldmod; } }); }