re-enable image smoothing after rendering
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import CanvasLayerRenderer from './Layer.js';
|
||||
import ViewHint from '../../ViewHint.js';
|
||||
import {ENABLE_RASTER_REPROJECTION} from '../../reproj/common.js';
|
||||
import {IMAGE_SMOOTHING_DISABLED} from './common.js';
|
||||
import {IMAGE_SMOOTHING_DISABLED, IMAGE_SMOOTHING_ENABLED} from './common.js';
|
||||
import {assign} from '../../obj.js';
|
||||
import {compose as composeTransform, makeInverse} from '../../transform.js';
|
||||
import {containsExtent, intersects as intersectsExtent} from '../../extent.js';
|
||||
@@ -219,6 +219,7 @@ class CanvasImageLayerRenderer extends CanvasLayerRenderer {
|
||||
if (clipped) {
|
||||
context.restore();
|
||||
}
|
||||
assign(context, IMAGE_SMOOTHING_ENABLED);
|
||||
|
||||
if (canvasTransform !== canvas.style.transform) {
|
||||
canvas.style.transform = canvasTransform;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import CanvasLayerRenderer from './Layer.js';
|
||||
import TileRange from '../../TileRange.js';
|
||||
import TileState from '../../TileState.js';
|
||||
import {IMAGE_SMOOTHING_DISABLED} from './common.js';
|
||||
import {IMAGE_SMOOTHING_DISABLED, IMAGE_SMOOTHING_ENABLED} from './common.js';
|
||||
import {
|
||||
apply as applyTransform,
|
||||
compose as composeTransform,
|
||||
@@ -457,6 +457,7 @@ class CanvasTileLayerRenderer extends CanvasLayerRenderer {
|
||||
if (layerState.extent) {
|
||||
context.restore();
|
||||
}
|
||||
assign(context, IMAGE_SMOOTHING_ENABLED);
|
||||
|
||||
if (canvasTransform !== canvas.style.transform) {
|
||||
canvas.style.transform = canvasTransform;
|
||||
|
||||
@@ -10,3 +10,12 @@ export const IMAGE_SMOOTHING_DISABLED = {
|
||||
imageSmoothingEnabled: false,
|
||||
msImageSmoothingEnabled: false,
|
||||
};
|
||||
|
||||
/**
|
||||
* Context options to enable image smoothing.
|
||||
* @type {Object}
|
||||
*/
|
||||
export const IMAGE_SMOOTHING_ENABLED = {
|
||||
imageSmoothingEnabled: true,
|
||||
msImageSmoothingEnabled: true,
|
||||
};
|
||||
|
||||
@@ -301,6 +301,18 @@ describe('ol.renderer.canvas.ImageLayer', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('image smoothing is re-enabled after rendering', function (done) {
|
||||
let context;
|
||||
layer.on('postrender', function (e) {
|
||||
context = e.context;
|
||||
context.imageSmoothingEnabled = false;
|
||||
});
|
||||
map.on('postrender', function () {
|
||||
expect(context.imageSmoothingEnabled).to.be(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Vector image rendering', function () {
|
||||
|
||||
@@ -87,5 +87,17 @@ describe('ol.renderer.canvas.TileLayer', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('image smoothing is re-enabled after rendering', function (done) {
|
||||
let context;
|
||||
layer.on('postrender', function (e) {
|
||||
context = e.context;
|
||||
context.imageSmoothingEnabled = false;
|
||||
});
|
||||
map.on('postrender', function () {
|
||||
expect(context.imageSmoothingEnabled).to.be(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user