Merge pull request #5273 from fredj/gutter_pixelRatio
Take the pixelRatio into account when computing the gutter
@@ -233,7 +233,7 @@ ol.renderer.canvas.TileLayer.prototype.renderTileImages = function(context, fram
|
||||
var pixelScale = pixelRatio / resolution;
|
||||
var layer = this.getLayer();
|
||||
var source = /** @type {ol.source.Tile} */ (layer.getSource());
|
||||
var tileGutter = source.getGutter(projection);
|
||||
var tileGutter = pixelRatio * source.getGutter(projection);
|
||||
var tileGrid = source.getTileGridForProjection(projection);
|
||||
|
||||
var hasRenderListeners = layer.hasListener(ol.render.EventType.RENDER);
|
||||
|
||||
@@ -84,7 +84,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame = function(frameState, layerSta
|
||||
var tileLayer = /** @type {ol.layer.Tile} */ (this.getLayer());
|
||||
var tileSource = tileLayer.getSource();
|
||||
var tileGrid = tileSource.getTileGridForProjection(projection);
|
||||
var tileGutter = tileSource.getGutter(projection);
|
||||
var tileGutter = pixelRatio * tileSource.getGutter(projection);
|
||||
var z = tileGrid.getZForResolution(viewState.resolution);
|
||||
var tileResolution = tileGrid.getResolution(z);
|
||||
var center = viewState.center;
|
||||
|
||||
@@ -161,7 +161,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame = function(frameState, layerS
|
||||
var pixelRatio = tilePixelSize[0] /
|
||||
ol.size.toSize(tileGrid.getTileSize(z), this.tmpSize_)[0];
|
||||
var tilePixelResolution = tileResolution / pixelRatio;
|
||||
var tileGutter = tileSource.getGutter(projection);
|
||||
var tileGutter = frameState.pixelRatio * tileSource.getGutter(projection);
|
||||
|
||||
var center = viewState.center;
|
||||
var extent;
|
||||
|
||||
BIN
test_rendering/spec/ol/data/tiles/wms/wms0.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
test_rendering/spec/ol/data/tiles/wms/wms20.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
test_rendering/spec/ol/source/expected/0_1.canvas.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
test_rendering/spec/ol/source/expected/0_1.webgl.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
test_rendering/spec/ol/source/expected/0_2.canvas.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
test_rendering/spec/ol/source/expected/0_2.webgl.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
test_rendering/spec/ol/source/expected/20_1.canvas.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
test_rendering/spec/ol/source/expected/20_1.webgl.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
test_rendering/spec/ol/source/expected/20_2.canvas.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
test_rendering/spec/ol/source/expected/20_2.webgl.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
151
test_rendering/spec/ol/source/tilewms.test.js
Normal file
@@ -0,0 +1,151 @@
|
||||
goog.provide('ol.test.rendering.source.TileWMS');
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.TileWMS');
|
||||
|
||||
describe('ol.rendering.source.TileWMS', function() {
|
||||
|
||||
function tilesLoaded(source, callback) {
|
||||
var loading = 0;
|
||||
|
||||
source.on('tileloadstart', function(event) {
|
||||
loading++;
|
||||
});
|
||||
source.on('tileloadend', function(event) {
|
||||
loading--;
|
||||
if (loading == 0) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
source.on('tileloaderror', function(event) {
|
||||
expect().fail('Tile failed to load');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function createMap(renderer, pixelRatio) {
|
||||
return new ol.Map({
|
||||
target: createMapDiv(200, 200),
|
||||
pixelRatio: pixelRatio,
|
||||
renderer: renderer,
|
||||
view: new ol.View({
|
||||
center: [0, 0],
|
||||
zoom: 5
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function createSource(gutter) {
|
||||
return new ol.source.TileWMS({
|
||||
params: {
|
||||
'LAYERS': 'layer'
|
||||
},
|
||||
gutter: gutter,
|
||||
url: 'spec/ol/data/tiles/wms/wms' + gutter + '.png'
|
||||
});
|
||||
}
|
||||
|
||||
describe('0px gutter, 1 pixel ratio', function() {
|
||||
it('tests the canvas renderer', function(done) {
|
||||
var map = createMap('canvas', 1);
|
||||
var source = createSource(0);
|
||||
tilesLoaded(source, function() {
|
||||
expectResemble(map, 'spec/ol/source/expected/0_1.canvas.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
map.addLayer(new ol.layer.Tile({
|
||||
source: source
|
||||
}));
|
||||
});
|
||||
|
||||
it('tests the WebGL renderer', function(done) {
|
||||
assertWebGL();
|
||||
var map = createMap('webgl', 1);
|
||||
var source = createSource(0);
|
||||
tilesLoaded(source, function() {
|
||||
expectResemble(map, 'spec/ol/source/expected/0_1.webgl.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
map.addLayer(new ol.layer.Tile({
|
||||
source: source
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('0px gutter, 2 pixel ratio', function() {
|
||||
it('tests the canvas renderer', function(done) {
|
||||
var map = createMap('canvas', 2);
|
||||
var source = createSource(0);
|
||||
tilesLoaded(source, function() {
|
||||
expectResemble(map, 'spec/ol/source/expected/0_2.canvas.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
map.addLayer(new ol.layer.Tile({
|
||||
source: source
|
||||
}));
|
||||
});
|
||||
|
||||
it('tests the WebGL renderer', function(done) {
|
||||
assertWebGL();
|
||||
var map = createMap('webgl', 2);
|
||||
var source = createSource(0);
|
||||
tilesLoaded(source, function() {
|
||||
expectResemble(map, 'spec/ol/source/expected/0_2.webgl.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
map.addLayer(new ol.layer.Tile({
|
||||
source: source
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('20px gutter, 1 pixel ratio', function() {
|
||||
it('tests the canvas renderer', function(done) {
|
||||
var map = createMap('canvas', 1);
|
||||
var source = createSource(20);
|
||||
tilesLoaded(source, function() {
|
||||
expectResemble(map, 'spec/ol/source/expected/20_1.canvas.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
map.addLayer(new ol.layer.Tile({
|
||||
source: source
|
||||
}));
|
||||
});
|
||||
|
||||
it('tests the WebGL renderer', function(done) {
|
||||
assertWebGL();
|
||||
var map = createMap('webgl', 1);
|
||||
var source = createSource(20);
|
||||
tilesLoaded(source, function() {
|
||||
expectResemble(map, 'spec/ol/source/expected/20_1.webgl.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
map.addLayer(new ol.layer.Tile({
|
||||
source: source
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('20px gutter, 2 pixel ratio', function() {
|
||||
it('tests the canvas renderer', function(done) {
|
||||
var map = createMap('canvas', 2);
|
||||
var source = createSource(20);
|
||||
tilesLoaded(source, function() {
|
||||
expectResemble(map, 'spec/ol/source/expected/20_2.canvas.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
map.addLayer(new ol.layer.Tile({
|
||||
source: source
|
||||
}));
|
||||
});
|
||||
|
||||
it('tests the WebGL renderer', function(done) {
|
||||
assertWebGL();
|
||||
var map = createMap('webgl', 2);
|
||||
var source = createSource(20);
|
||||
tilesLoaded(source, function() {
|
||||
expectResemble(map, 'spec/ol/source/expected/20_2.webgl.png', IMAGE_TOLERANCE, done);
|
||||
});
|
||||
map.addLayer(new ol.layer.Tile({
|
||||
source: source
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||