Skip to content

Commit

Permalink
Merge pull request #1230 from OpenGeoscience/reduce-texture-update-time
Browse files Browse the repository at this point in the history
perf: Reduce the time it takes to switch texture interpolation.
  • Loading branch information
manthey authored Jun 24, 2022
2 parents 8a83afd + f708bf8 commit 8d01f4a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/webgl/quadFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
}
Expand Down

0 comments on commit 8d01f4a

Please sign in to comment.