Webgl / return 0 if doing renderTarget.read outside of data width/height

This would happen when WebGLPointsLayerRenderer.forEachFeatureAtCoordinate
is called on "warped" worlds at -360/+360 degrees, and may produce false
positives.
This commit is contained in:
Olivier Guyot
2019-10-31 13:27:57 +01:00
parent f7b0f6750b
commit 43010c8934
2 changed files with 26 additions and 0 deletions

View File

@@ -123,6 +123,26 @@ describe('ol.webgl.RenderTarget', function() {
expect(spy.callCount).to.eql(2);
});
it('returns an array filled with 0 if outside of range', function() {
const rt = new WebGLRenderTarget(helper, [4, 4]);
helper.createTexture([4, 4], testImage_4x4, rt.getTexture());
let data = rt.readPixel(-1, 0);
expect(data).to.eql([0, 0, 0, 0]);
data = rt.readPixel(3, -1);
expect(data).to.eql([0, 0, 0, 0]);
data = rt.readPixel(6, 2);
expect(data).to.eql([0, 0, 0, 0]);
data = rt.readPixel(2, 7);
expect(data).to.eql([0, 0, 0, 0]);
data = rt.readPixel(2, 3);
expect(data).not.to.eql([0, 0, 0, 0]);
});
});
});