Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Reduce the time it takes to switch texture interpolation. #1230

Merged
merged 1 commit into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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