-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Use gl.pixelStorei to premultiply alphas on icons and images in SpriteAtlas #4644
Conversation
src/symbol/sprite_atlas.js
Outdated
@@ -61,6 +61,8 @@ class SpriteAtlas extends Evented { | |||
|
|||
if (ArrayBuffer.isView(pixels)) { | |||
pixels = new Uint32Array(pixels.buffer); | |||
} else if (pixels.data) { //Support ImageData correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason to add this? We don't document Map#addImage
as accepting ImageData
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it isn't documented. I was thrown off by the error message at Line 67 below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -221,6 +221,7 @@ class SpriteAtlas extends Evented { | |||
gl.bindTexture(gl.TEXTURE_2D, this.texture); | |||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); | |||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); | |||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This closes #4534
Images and Icons added to the SpriteAtlas need to premultiply the alpha channel in the image data to improve alpha blending. This is now done using WebGLs built-in flag for unpacking image data in textures
Launch Checklist
document any changes to public APIs