Repository navigation
Conversation
|
|
||
| const {width, height} = image; | ||
| this.size = [width, height]; | ||
| this.powerOfTwoSize = width === height && (Math.log(width) / Math.LN2) % 1 === 0; |
There was a problem hiding this comment.
Is there a reason to use state rather than compute this as needed? As state it could be wrong if the size is changed via update.
There was a problem hiding this comment.
BTW a common neat and fast way to check if a number is a power of two is x & (x - 1) === 0
This lets Texture (instead of RasterTileSource) handle the actual gl calls and dealing with cases where mipmaps can't be used.
|
@jfirebaugh I moved setting I also added 8b5ebb0 which moves update-without-reallocation logic into |
jfirebaugh
left a comment
There was a problem hiding this comment.
Yeah, I think a method would be better, just for the sake of avoiding unnecessary state.
| powerOfTwoSize: boolean; | ||
|
|
||
| constructor(context: Context, image: TextureImage, format: TextureFormat, premultiply: ?boolean) { | ||
| constructor(context: Context, image: TextureImage, format: TextureFormat, premultiply: ?boolean, useMipmap: ?boolean) { |
There was a problem hiding this comment.
Rather than add a second optional boolean parameter, let's move premultiply and useMipmap into an options object so they get descriptive names at the call site and there's no need for an undefined placeholder argument.
Fixes #6440
The WMS source in that example returns 400x400 tiles. WebGL only supports mipmaps for power-of-two size textures. This fix just disables mipmap generation and filtering for textures that are not power-of-two.
Alternative: we could either upscale the image to a power-of-two texture or add padding and draw only part of the texture but both of these solutions are significantly more complex and might not look better. Mipmapping only helps rasters look a bit better when they are significantly underzoomed (zooming out and the tiles get smaller).
I wrote a render test for this but it doesn't fail without the fix (I guess the node module implementation doesn't error the same way) so I didn't include it here. I don't have any other ideas on how to test this.
Launch Checklist