Introduce new overlaps option for Vector and VectorTile sources

Instead of deciding whether to batch fills and strokes by looking at the
opacity of the style, we now rely on user input.
This commit is contained in:
Andreas Hocevar
2016-04-18 10:41:00 +02:00
parent 091dc9fbf4
commit 3c37ce3990
17 changed files with 132 additions and 62 deletions

View File

@@ -5,11 +5,11 @@ describe('ol.render.canvas.ReplayGroup', function() {
describe('#replay', function() {
var context, replay, fillCount, strokeCount, beginPathCount;
var feature1, feature2, feature3, style1, style2, style3, transform;
var feature1, feature2, feature3, style1, style2, transform;
beforeEach(function() {
transform = goog.vec.Mat4.createNumber();
replay = new ol.render.canvas.ReplayGroup(1, [-180, -90, 180, 90], 1);
replay = new ol.render.canvas.ReplayGroup(1, [-180, -90, 180, 90], 1, false);
feature1 = new ol.Feature(new ol.geom.Polygon(
[[[-90, -45], [-90, 0], [0, 0], [0, -45], [-90, -45]]]));
feature2 = new ol.Feature(new ol.geom.Polygon(
@@ -24,10 +24,6 @@ describe('ol.render.canvas.ReplayGroup', function() {
fill: new ol.style.Fill({color: 'white'}),
stroke: new ol.style.Stroke({color: 'black', width: 1})
});
style3 = new ol.style.Style({
fill: new ol.style.Fill({color: 'rgba(255,255,255,0.8)'}),
stroke: new ol.style.Stroke({color: 'rgba(0,0,0,0.8)', width: 1})
});
fillCount = 0;
strokeCount = 0;
beginPathCount = 0;
@@ -121,10 +117,11 @@ describe('ol.render.canvas.ReplayGroup', function() {
expect(beginPathCount).to.be(1);
});
it('does not batch when transparent fills/strokes are used', function() {
ol.renderer.vector.renderFeature(replay, feature1, style3, 1);
ol.renderer.vector.renderFeature(replay, feature2, style3, 1);
ol.renderer.vector.renderFeature(replay, feature3, style3, 1);
it('does not batch when overlaps is set to true', function() {
replay = new ol.render.canvas.ReplayGroup(1, [-180, -90, 180, 90], 1, true);
ol.renderer.vector.renderFeature(replay, feature1, style1, 1);
ol.renderer.vector.renderFeature(replay, feature2, style1, 1);
ol.renderer.vector.renderFeature(replay, feature3, style1, 1);
replay.replay(context, 1, transform, 0, {});
expect(fillCount).to.be(3);
expect(strokeCount).to.be(3);
@@ -141,7 +138,7 @@ describe('ol.render.canvas.Replay', function() {
it('creates a new replay batch', function() {
var tolerance = 10;
var extent = [-180, -90, 180, 90];
var replay = new ol.render.canvas.Replay(tolerance, extent, 1);
var replay = new ol.render.canvas.Replay(tolerance, extent, 1, true);
expect(replay).to.be.a(ol.render.canvas.Replay);
});
@@ -151,7 +148,7 @@ describe('ol.render.canvas.Replay', function() {
var replay;
beforeEach(function() {
replay = new ol.render.canvas.Replay(1, [-180, -90, 180, 90], 1);
replay = new ol.render.canvas.Replay(1, [-180, -90, 180, 90], 1, true);
});
it('appends coordinates that are within the max extent', function() {