Do not draw image with width or height < 0.5
This commit is contained in:
@@ -63,8 +63,10 @@ class IntermediateCanvasRenderer extends CanvasLayerRenderer {
|
|||||||
const dy = imageTransform[5];
|
const dy = imageTransform[5];
|
||||||
const dw = image.width * imageTransform[0];
|
const dw = image.width * imageTransform[0];
|
||||||
const dh = image.height * imageTransform[3];
|
const dh = image.height * imageTransform[3];
|
||||||
context.drawImage(image, 0, 0, +image.width, +image.height,
|
if (dw >= 0.5 && dh >= 0.5) {
|
||||||
Math.round(dx), Math.round(dy), Math.round(dw), Math.round(dh));
|
context.drawImage(image, 0, 0, +image.width, +image.height,
|
||||||
|
Math.round(dx), Math.round(dy), Math.round(dw), Math.round(dh));
|
||||||
|
}
|
||||||
context.globalAlpha = alpha;
|
context.globalAlpha = alpha;
|
||||||
|
|
||||||
if (clipped) {
|
if (clipped) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {create as createTransform} from '../../../../../src/ol/transform.js';
|
import {create as createTransform, scale} from '../../../../../src/ol/transform.js';
|
||||||
import ImageLayer from '../../../../../src/ol/layer/Image.js';
|
import ImageLayer from '../../../../../src/ol/layer/Image.js';
|
||||||
import MapRenderer from '../../../../../src/ol/renderer/Map.js';
|
import MapRenderer from '../../../../../src/ol/renderer/Map.js';
|
||||||
import IntermediateCanvasRenderer from '../../../../../src/ol/renderer/canvas/IntermediateCanvas.js';
|
import IntermediateCanvasRenderer from '../../../../../src/ol/renderer/canvas/IntermediateCanvas.js';
|
||||||
@@ -94,6 +94,17 @@ describe('ol.renderer.canvas.IntermediateCanvas', function() {
|
|||||||
expect(context.restore.callCount).to.be(0);
|
expect(context.restore.callCount).to.be(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not draw image with width or height < 0.5', function() {
|
||||||
|
frameState.extent = [10, 20, 30, 40];
|
||||||
|
renderer.getImageTransform = function() {
|
||||||
|
return scale(createTransform(), 0.1, 0.1);
|
||||||
|
};
|
||||||
|
|
||||||
|
renderer.composeFrame(frameState, layerState, context);
|
||||||
|
|
||||||
|
expect(context.drawImage.notCalled).to.be(true);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user