removed existing webgl rendering unit tests
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 838 B |
Binary file not shown.
|
Before Width: | Height: | Size: 801 B |
Binary file not shown.
|
Before Width: | Height: | Size: 733 B |
Binary file not shown.
|
Before Width: | Height: | Size: 799 B |
@@ -1,8 +1,6 @@
|
|||||||
import Map from '../../../../src/ol/Map.js';
|
import Map from '../../../../src/ol/Map.js';
|
||||||
import WebGLMap from '../../../../src/ol/WebGLMap.js';
|
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import ImageLayer from '../../../../src/ol/layer/Image.js';
|
import ImageLayer from '../../../../src/ol/layer/Image.js';
|
||||||
import WebGLImageLayer from '../../../../src/ol/layer/Image.js';
|
|
||||||
import {assign} from '../../../../src/ol/obj.js';
|
import {assign} from '../../../../src/ol/obj.js';
|
||||||
import {get as getProjection, transform, transformExtent} from '../../../../src/ol/proj.js';
|
import {get as getProjection, transform, transformExtent} from '../../../../src/ol/proj.js';
|
||||||
import Static from '../../../../src/ol/source/ImageStatic.js';
|
import Static from '../../../../src/ol/source/ImageStatic.js';
|
||||||
@@ -14,7 +12,7 @@ describe('ol.rendering.layer.Image', function() {
|
|||||||
let map;
|
let map;
|
||||||
|
|
||||||
function createMap(renderer) {
|
function createMap(renderer) {
|
||||||
const MapConstructor = renderer === 'webgl' ? WebGLMap : Map;
|
const MapConstructor = Map;
|
||||||
map = new MapConstructor({
|
map = new MapConstructor({
|
||||||
pixelRatio: 1,
|
pixelRatio: 1,
|
||||||
target: createMapDiv(50, 50),
|
target: createMapDiv(50, 50),
|
||||||
@@ -34,7 +32,7 @@ describe('ol.rendering.layer.Image', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function waitForImages(renderer, sources, layerOptions, onImagesLoaded) {
|
function waitForImages(renderer, sources, layerOptions, onImagesLoaded) {
|
||||||
const LayerConstructor = renderer === 'webgl' ? WebGLImageLayer : ImageLayer;
|
const LayerConstructor = ImageLayer;
|
||||||
let imagesLoading = 0;
|
let imagesLoading = 0;
|
||||||
let imagesLoaded = 0;
|
let imagesLoaded = 0;
|
||||||
|
|
||||||
@@ -83,15 +81,6 @@ describe('ol.rendering.layer.Image', function() {
|
|||||||
IMAGE_TOLERANCE, done);
|
IMAGE_TOLERANCE, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
waitForImages('webgl', [source], {}, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/layer/expected/image-webgl.png',
|
|
||||||
IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('single image layer - scaled', function() {
|
describe('single image layer - scaled', function() {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import Map from '../../../../src/ol/Map.js';
|
import Map from '../../../../src/ol/Map.js';
|
||||||
import WebGLMap from '../../../../src/ol/WebGLMap.js';
|
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import {getSize} from '../../../../src/ol/extent.js';
|
import {getSize} from '../../../../src/ol/extent.js';
|
||||||
import Point from '../../../../src/ol/geom/Point.js';
|
import Point from '../../../../src/ol/geom/Point.js';
|
||||||
import TileLayer from '../../../../src/ol/layer/Tile.js';
|
import TileLayer from '../../../../src/ol/layer/Tile.js';
|
||||||
import WebGLTileLayer from '../../../../src/ol/layer/WebGLTile.js';
|
|
||||||
import {assign} from '../../../../src/ol/obj.js';
|
import {assign} from '../../../../src/ol/obj.js';
|
||||||
import {transform} from '../../../../src/ol/proj.js';
|
import {transform} from '../../../../src/ol/proj.js';
|
||||||
import TileImage from '../../../../src/ol/source/TileImage.js';
|
import TileImage from '../../../../src/ol/source/TileImage.js';
|
||||||
@@ -20,7 +18,7 @@ describe('ol.rendering.layer.Tile', function() {
|
|||||||
let map;
|
let map;
|
||||||
|
|
||||||
function createMap(renderer, opt_center, opt_size, opt_pixelRatio, opt_resolutions) {
|
function createMap(renderer, opt_center, opt_size, opt_pixelRatio, opt_resolutions) {
|
||||||
const MapConstructor = renderer === 'webgl' ? WebGLMap : Map;
|
const MapConstructor = Map;
|
||||||
const size = opt_size !== undefined ? opt_size : [50, 50];
|
const size = opt_size !== undefined ? opt_size : [50, 50];
|
||||||
|
|
||||||
map = new MapConstructor({
|
map = new MapConstructor({
|
||||||
@@ -43,7 +41,7 @@ describe('ol.rendering.layer.Tile', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function waitForTiles(renderer, sources, layerOptions, onTileLoaded) {
|
function waitForTiles(renderer, sources, layerOptions, onTileLoaded) {
|
||||||
const LayerConstructor = renderer === 'webgl' ? WebGLTileLayer : TileLayer;
|
const LayerConstructor = TileLayer;
|
||||||
let tilesLoading = 0;
|
let tilesLoading = 0;
|
||||||
let tileLoaded = 0;
|
let tileLoaded = 0;
|
||||||
|
|
||||||
@@ -73,6 +71,40 @@ describe('ol.rendering.layer.Tile', function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
describe('with tile transition', function() {
|
||||||
|
it('renders correctly after the transition', function(done) {
|
||||||
|
createMap('canvas');
|
||||||
|
const source = new XYZ({
|
||||||
|
url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png'
|
||||||
|
});
|
||||||
|
waitForTiles('canvas', [source], {}, function() {
|
||||||
|
setTimeout(function() {
|
||||||
|
expectResemble(map, 'rendering/ol/layer/expected/osm-canvas.png',
|
||||||
|
IMAGE_TOLERANCE, done);
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('single tile layer', function() {
|
||||||
|
let source;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
source = new XYZ({
|
||||||
|
url: 'rendering/ol/data/tiles/osm/{z}/{x}/{y}.png',
|
||||||
|
transition: 0
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tests the canvas renderer', function(done) {
|
||||||
|
createMap('canvas');
|
||||||
|
waitForTiles('canvas', [source], {}, function() {
|
||||||
|
expectResemble(map, 'rendering/ol/layer/expected/osm-canvas.png',
|
||||||
|
IMAGE_TOLERANCE, done);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('two tile layers', function() {
|
describe('two tile layers', function() {
|
||||||
let source1, source2;
|
let source1, source2;
|
||||||
|
|
||||||
@@ -87,15 +119,6 @@ describe('ol.rendering.layer.Tile', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
waitForTiles('webgl', [source1, source2], {}, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/layer/expected/2-layers-webgl.png',
|
|
||||||
IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function centerExtent(map) {
|
function centerExtent(map) {
|
||||||
const c = map.getView().calculateExtent(map.getSize());
|
const c = map.getView().calculateExtent(map.getSize());
|
||||||
const qw = getSize(c)[0] / 4;
|
const qw = getSize(c)[0] / 4;
|
||||||
@@ -148,15 +171,6 @@ describe('ol.rendering.layer.Tile', function() {
|
|||||||
IMAGE_TOLERANCE, done);
|
IMAGE_TOLERANCE, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
waitForTiles('webgl', [source], {opacity: 0.2}, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/layer/expected/opacity-webgl.png',
|
|
||||||
IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('tile layer with non-square tiles', function() {
|
describe('tile layer with non-square tiles', function() {
|
||||||
@@ -180,16 +194,6 @@ describe('ol.rendering.layer.Tile', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('512x256 renders correcly using the webgl renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
const source = createSource('512x256');
|
|
||||||
createMap('webgl', [-10997148, 4569099]);
|
|
||||||
waitForTiles('webgl', [source], {}, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/layer/expected/512x256-webgl.png',
|
|
||||||
IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('192x256 renders correcly using the canvas renderer', function(done) {
|
it('192x256 renders correcly using the canvas renderer', function(done) {
|
||||||
const source = createSource('192x256');
|
const source = createSource('192x256');
|
||||||
createMap('canvas', [-11271098, 3747248], [100, 100], undefined,
|
createMap('canvas', [-11271098, 3747248], [100, 100], undefined,
|
||||||
@@ -199,17 +203,6 @@ describe('ol.rendering.layer.Tile', function() {
|
|||||||
IMAGE_TOLERANCE, done);
|
IMAGE_TOLERANCE, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('192x256 renders correcly using the webgl renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
const source = createSource('192x256');
|
|
||||||
createMap('webgl', [-11271098, 3747248], [100, 100], undefined,
|
|
||||||
source.getTileGrid().getResolutions());
|
|
||||||
waitForTiles('webgl', [source], {}, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/layer/expected/192x256-webgl.png',
|
|
||||||
IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('tile layer with render listener', function() {
|
describe('tile layer with render listener', function() {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import Feature from '../../../src/ol/Feature.js';
|
import Feature from '../../../src/ol/Feature.js';
|
||||||
import Point from '../../../src/ol/geom/Point.js';
|
import Point from '../../../src/ol/geom/Point.js';
|
||||||
import Map from '../../../src/ol/Map.js';
|
import Map from '../../../src/ol/Map.js';
|
||||||
import WebGLMap from '../../../src/ol/WebGLMap.js';
|
|
||||||
import View from '../../../src/ol/View.js';
|
import View from '../../../src/ol/View.js';
|
||||||
import VectorLayer from '../../../src/ol/layer/Vector.js';
|
import VectorLayer from '../../../src/ol/layer/Vector.js';
|
||||||
import WebGLVectorLayer from '../../../src/ol/layer/WebGLVector.js';
|
|
||||||
import VectorSource from '../../../src/ol/source/Vector.js';
|
import VectorSource from '../../../src/ol/source/Vector.js';
|
||||||
|
|
||||||
|
|
||||||
@@ -12,8 +10,8 @@ describe('ol.rendering.Map', function() {
|
|||||||
|
|
||||||
let map;
|
let map;
|
||||||
function createMap(renderer) {
|
function createMap(renderer) {
|
||||||
const MapConstructor = renderer === 'webgl' ? WebGLMap : Map;
|
const MapConstructor = Map;
|
||||||
const LayerConstructor = renderer === 'webgl' ? WebGLVectorLayer : VectorLayer;
|
const LayerConstructor = VectorLayer;
|
||||||
|
|
||||||
const vectorLayer = new LayerConstructor({
|
const vectorLayer = new LayerConstructor({
|
||||||
source: new VectorSource({
|
source: new VectorSource({
|
||||||
@@ -53,17 +51,6 @@ describe('ol.rendering.Map', function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
map.once('postrender', function() {
|
|
||||||
const initialSize = map.getSize();
|
|
||||||
map.updateSize();
|
|
||||||
expect(map.getSize()).to.eql(initialSize);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#render()', function() {
|
describe('#render()', function() {
|
||||||
@@ -73,13 +60,6 @@ describe('ol.rendering.Map', function() {
|
|||||||
expectResemble(
|
expectResemble(
|
||||||
map, 'rendering/ol/expected/render-canvas.png', IMAGE_TOLERANCE, done);
|
map, 'rendering/ol/expected/render-canvas.png', IMAGE_TOLERANCE, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
expectResemble(
|
|
||||||
map, 'rendering/ol/expected/render-webgl.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#pan()', function() {
|
describe('#pan()', function() {
|
||||||
@@ -90,37 +70,5 @@ describe('ol.rendering.Map', function() {
|
|||||||
expectResemble(
|
expectResemble(
|
||||||
map, 'rendering/ol/expected/pan-canvas.png', IMAGE_TOLERANCE, done);
|
map, 'rendering/ol/expected/pan-canvas.png', IMAGE_TOLERANCE, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
map.getView().setCenter([10, 10]);
|
|
||||||
expectResemble(
|
|
||||||
map, 'rendering/ol/expected/pan-webgl.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#rotate()', function() {
|
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
map.getView().setRotation(90);
|
|
||||||
map.getView().setCenter([10, 10]);
|
|
||||||
expectResemble(
|
|
||||||
map, 'rendering/ol/expected/rotate-webgl.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#zoom()', function() {
|
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
map.getView().setCenter([10, 10]);
|
|
||||||
map.getView().setResolution(2);
|
|
||||||
expectResemble(
|
|
||||||
map, 'rendering/ol/expected/zoom-webgl.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import WebGLMap from '../../../../src/ol/WebGLMap.js';
|
|
||||||
import Map from '../../../../src/ol/Map.js';
|
import Map from '../../../../src/ol/Map.js';
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import TileLayer from '../../../../src/ol/layer/Tile.js';
|
import TileLayer from '../../../../src/ol/layer/Tile.js';
|
||||||
import WebGLTileLayer from '../../../../src/ol/layer/WebGLTile.js';
|
|
||||||
import TileWMS from '../../../../src/ol/source/TileWMS.js';
|
import TileWMS from '../../../../src/ol/source/TileWMS.js';
|
||||||
|
|
||||||
describe('ol.rendering.source.TileWMS', function() {
|
describe('ol.rendering.source.TileWMS', function() {
|
||||||
@@ -27,7 +25,7 @@ describe('ol.rendering.source.TileWMS', function() {
|
|||||||
|
|
||||||
let map;
|
let map;
|
||||||
function createMap(renderer, pixelRatio) {
|
function createMap(renderer, pixelRatio) {
|
||||||
const MapConstructor = renderer === 'webgl' ? WebGLMap : Map;
|
const MapConstructor = Map;
|
||||||
|
|
||||||
map = new MapConstructor({
|
map = new MapConstructor({
|
||||||
target: createMapDiv(200, 200),
|
target: createMapDiv(200, 200),
|
||||||
@@ -69,18 +67,6 @@ describe('ol.rendering.source.TileWMS', function() {
|
|||||||
source: source
|
source: source
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl', 1);
|
|
||||||
const source = createSource(0);
|
|
||||||
tilesLoaded(source, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/source/expected/0_1.webgl.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
map.addLayer(new WebGLTileLayer({
|
|
||||||
source: source
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('0px gutter, 2 pixel ratio', function() {
|
describe('0px gutter, 2 pixel ratio', function() {
|
||||||
@@ -94,18 +80,6 @@ describe('ol.rendering.source.TileWMS', function() {
|
|||||||
source: source
|
source: source
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl', 2);
|
|
||||||
const source = createSource(0);
|
|
||||||
tilesLoaded(source, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/source/expected/0_2.webgl.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
map.addLayer(new WebGLTileLayer({
|
|
||||||
source: source
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -120,18 +94,6 @@ describe('ol.rendering.source.TileWMS', function() {
|
|||||||
source: source
|
source: source
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl', 1);
|
|
||||||
const source = createSource(20);
|
|
||||||
tilesLoaded(source, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/source/expected/20_1.webgl.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
map.addLayer(new WebGLTileLayer({
|
|
||||||
source: source
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('20px gutter, 2 pixel ratio', function() {
|
describe('20px gutter, 2 pixel ratio', function() {
|
||||||
@@ -145,18 +107,6 @@ describe('ol.rendering.source.TileWMS', function() {
|
|||||||
source: source
|
source: source
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl', 2);
|
|
||||||
const source = createSource(20);
|
|
||||||
tilesLoaded(source, function() {
|
|
||||||
expectResemble(map, 'rendering/ol/source/expected/20_2.webgl.png', IMAGE_TOLERANCE, done);
|
|
||||||
});
|
|
||||||
map.addLayer(new WebGLTileLayer({
|
|
||||||
source: source
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ import Feature from '../../../../src/ol/Feature.js';
|
|||||||
import Point from '../../../../src/ol/geom/Point.js';
|
import Point from '../../../../src/ol/geom/Point.js';
|
||||||
import MultiPoint from '../../../../src/ol/geom/MultiPoint.js';
|
import MultiPoint from '../../../../src/ol/geom/MultiPoint.js';
|
||||||
import Map from '../../../../src/ol/Map.js';
|
import Map from '../../../../src/ol/Map.js';
|
||||||
import WebGLMap from '../../../../src/ol/WebGLMap.js';
|
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
||||||
import WebGLVectorLayer from '../../../../src/ol/layer/Vector.js';
|
|
||||||
import VectorSource from '../../../../src/ol/source/Vector.js';
|
import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||||
import CircleStyle from '../../../../src/ol/style/Circle.js';
|
import CircleStyle from '../../../../src/ol/style/Circle.js';
|
||||||
import Fill from '../../../../src/ol/style/Fill.js';
|
import Fill from '../../../../src/ol/style/Fill.js';
|
||||||
@@ -18,8 +16,8 @@ describe('ol.rendering.style.Circle', function() {
|
|||||||
let map, vectorSource;
|
let map, vectorSource;
|
||||||
|
|
||||||
function createMap(renderer) {
|
function createMap(renderer) {
|
||||||
const MapConstructor = renderer === 'webgl' ? WebGLMap : Map;
|
const MapConstructor = Map;
|
||||||
const LayerConstructor = renderer === 'webgl' ? WebGLVectorLayer : VectorLayer;
|
const LayerConstructor = VectorLayer;
|
||||||
|
|
||||||
vectorSource = new VectorSource();
|
vectorSource = new VectorSource();
|
||||||
const vectorLayer = new LayerConstructor({
|
const vectorLayer = new LayerConstructor({
|
||||||
@@ -201,13 +199,5 @@ describe('ol.rendering.style.Circle', function() {
|
|||||||
expectResemble(map, 'rendering/ol/style/expected/circle-canvas.png',
|
expectResemble(map, 'rendering/ol/style/expected/circle-canvas.png',
|
||||||
8.0, done);
|
8.0, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
createFeatures();
|
|
||||||
expectResemble(map, 'rendering/ol/style/expected/circle-webgl.png',
|
|
||||||
8.0, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import Feature from '../../../../src/ol/Feature.js';
|
import Feature from '../../../../src/ol/Feature.js';
|
||||||
import LineString from '../../../../src/ol/geom/LineString.js';
|
import LineString from '../../../../src/ol/geom/LineString.js';
|
||||||
import Map from '../../../../src/ol/Map.js';
|
import Map from '../../../../src/ol/Map.js';
|
||||||
import WebGLMap from '../../../../src/ol/WebGLMap.js';
|
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
||||||
import WebGLVectorLayer from '../../../../src/ol/layer/Vector.js';
|
|
||||||
import VectorSource from '../../../../src/ol/source/Vector.js';
|
import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||||
import Style from '../../../../src/ol/style/Style.js';
|
import Style from '../../../../src/ol/style/Style.js';
|
||||||
import Stroke from '../../../../src/ol/style/Stroke.js';
|
import Stroke from '../../../../src/ol/style/Stroke.js';
|
||||||
@@ -15,8 +13,8 @@ describe('ol.rendering.style.LineString', function() {
|
|||||||
let map, vectorSource;
|
let map, vectorSource;
|
||||||
|
|
||||||
function createMap(renderer, opt_pixelRatio) {
|
function createMap(renderer, opt_pixelRatio) {
|
||||||
const MapConstructor = renderer === 'webgl' ? WebGLMap : Map;
|
const MapConstructor = Map;
|
||||||
const LayerConstructor = renderer === 'webgl' ? WebGLVectorLayer : VectorLayer;
|
const LayerConstructor = VectorLayer;
|
||||||
|
|
||||||
vectorSource = new VectorSource();
|
vectorSource = new VectorSource();
|
||||||
const vectorLayer = new LayerConstructor({
|
const vectorLayer = new LayerConstructor({
|
||||||
@@ -120,13 +118,6 @@ describe('ol.rendering.style.LineString', function() {
|
|||||||
map, 'rendering/ol/style/expected/linestring-strokes-canvas.png',
|
map, 'rendering/ol/style/expected/linestring-strokes-canvas.png',
|
||||||
3.0, done);
|
3.0, done);
|
||||||
});
|
});
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
createFeatures();
|
|
||||||
expectResemble(map, 'rendering/ol/style/expected/linestring-strokes-webgl.png',
|
|
||||||
14.6, done);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('tests the canvas renderer (HiDPI)', function(done) {
|
it('tests the canvas renderer (HiDPI)', function(done) {
|
||||||
createMap('canvas', 2);
|
createMap('canvas', 2);
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import Feature from '../../../../src/ol/Feature.js';
|
import Feature from '../../../../src/ol/Feature.js';
|
||||||
import Point from '../../../../src/ol/geom/Point.js';
|
import Point from '../../../../src/ol/geom/Point.js';
|
||||||
import Map from '../../../../src/ol/Map.js';
|
import Map from '../../../../src/ol/Map.js';
|
||||||
import WebGLMap from '../../../../src/ol/WebGLMap.js';
|
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
||||||
import WebGLVectorLayer from '../../../../src/ol/layer/Vector.js';
|
|
||||||
import VectorSource from '../../../../src/ol/source/Vector.js';
|
import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||||
import Fill from '../../../../src/ol/style/Fill.js';
|
import Fill from '../../../../src/ol/style/Fill.js';
|
||||||
import RegularShape from '../../../../src/ol/style/RegularShape.js';
|
import RegularShape from '../../../../src/ol/style/RegularShape.js';
|
||||||
@@ -17,8 +15,8 @@ describe('ol.rendering.style.RegularShape', function() {
|
|||||||
let map, vectorSource;
|
let map, vectorSource;
|
||||||
|
|
||||||
function createMap(renderer) {
|
function createMap(renderer) {
|
||||||
const MapConstructor = renderer === 'webgl' ? WebGLMap : Map;
|
const MapConstructor = Map;
|
||||||
const LayerConstructor = renderer === 'webgl' ? WebGLVectorLayer : VectorLayer;
|
const LayerConstructor = VectorLayer;
|
||||||
|
|
||||||
vectorSource = new VectorSource();
|
vectorSource = new VectorSource();
|
||||||
const vectorLayer = new LayerConstructor({
|
const vectorLayer = new LayerConstructor({
|
||||||
@@ -137,13 +135,6 @@ describe('ol.rendering.style.RegularShape', function() {
|
|||||||
}));
|
}));
|
||||||
expectResemble(map, 'rendering/ol/style/expected/regularshape-canvas-linedashoffset.png', 5, done);
|
expectResemble(map, 'rendering/ol/style/expected/regularshape-canvas-linedashoffset.png', 5, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
createFeatures(stroke, fill);
|
|
||||||
expectResemble(map, 'rendering/ol/style/expected/regularshape-webgl.png', 8.2, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('uses the default fill and stroke color', function() {
|
describe('uses the default fill and stroke color', function() {
|
||||||
@@ -155,12 +146,5 @@ describe('ol.rendering.style.RegularShape', function() {
|
|||||||
createFeatures(stroke, fill);
|
createFeatures(stroke, fill);
|
||||||
expectResemble(map, 'rendering/ol/style/expected/regularshape-canvas-default-style.png', 3.0, done);
|
expectResemble(map, 'rendering/ol/style/expected/regularshape-canvas-default-style.png', 3.0, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the WebGL renderer', function(done) {
|
|
||||||
assertWebGL();
|
|
||||||
createMap('webgl');
|
|
||||||
createFeatures(stroke, fill);
|
|
||||||
expectResemble(map, 'rendering/ol/style/expected/regularshape-webgl-default-style.png', 3.0, done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
|
|||||||
import Point from '../../../../src/ol/geom/Point.js';
|
import Point from '../../../../src/ol/geom/Point.js';
|
||||||
import Polygon from '../../../../src/ol/geom/Polygon.js';
|
import Polygon from '../../../../src/ol/geom/Polygon.js';
|
||||||
import Map from '../../../../src/ol/Map.js';
|
import Map from '../../../../src/ol/Map.js';
|
||||||
import WebGLMap from '../../../../src/ol/WebGLMap.js';
|
|
||||||
import View from '../../../../src/ol/View.js';
|
import View from '../../../../src/ol/View.js';
|
||||||
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
import VectorLayer from '../../../../src/ol/layer/Vector.js';
|
||||||
import WebGLVectorLayer from '../../../../src/ol/layer/Vector.js';
|
|
||||||
import VectorSource from '../../../../src/ol/source/Vector.js';
|
import VectorSource from '../../../../src/ol/source/Vector.js';
|
||||||
import Text from '../../../../src/ol/style/Text.js';
|
import Text from '../../../../src/ol/style/Text.js';
|
||||||
import Fill from '../../../../src/ol/style/Fill.js';
|
import Fill from '../../../../src/ol/style/Fill.js';
|
||||||
@@ -20,8 +18,8 @@ describe('ol.rendering.style.Text', function() {
|
|||||||
let map, vectorSource;
|
let map, vectorSource;
|
||||||
|
|
||||||
function createMap(renderer, opt_pixelRatio) {
|
function createMap(renderer, opt_pixelRatio) {
|
||||||
const MapConstructor = renderer === 'webgl' ? WebGLMap : Map;
|
const MapConstructor = Map;
|
||||||
const LayerConstructor = renderer === 'webgl' ? WebGLVectorLayer : VectorLayer;
|
const LayerConstructor = VectorLayer;
|
||||||
|
|
||||||
const pixelRatio = opt_pixelRatio || 1;
|
const pixelRatio = opt_pixelRatio || 1;
|
||||||
vectorSource = new VectorSource();
|
vectorSource = new VectorSource();
|
||||||
@@ -446,18 +444,5 @@ describe('ol.rendering.style.Text', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
where('WebGL').it('tests the webgl renderer without rotation', function(done) {
|
|
||||||
createMap('webgl');
|
|
||||||
createFeatures();
|
|
||||||
expectResemble(map, 'rendering/ol/style/expected/text-webgl.png', 1.8, done);
|
|
||||||
});
|
|
||||||
|
|
||||||
where('WebGL').it('tests the webgl renderer with rotation', function(done) {
|
|
||||||
createMap('webgl');
|
|
||||||
createFeatures();
|
|
||||||
map.getView().setRotation(Math.PI / 7);
|
|
||||||
expectResemble(map, 'rendering/ol/style/expected/text-rotated-webgl.png', 1.8, done);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,240 +0,0 @@
|
|||||||
import {getUid} from '../../../../../src/ol/util.js';
|
|
||||||
import Feature from '../../../../../src/ol/Feature.js';
|
|
||||||
import Circle from '../../../../../src/ol/geom/Circle.js';
|
|
||||||
import WebGLCircleReplay from '../../../../../src/ol/render/webgl/CircleReplay.js';
|
|
||||||
import {fragment, vertex} from '../../../../../src/ol/render/webgl/circlereplay/defaultshader.js';
|
|
||||||
import Locations from '../../../../../src/ol/render/webgl/circlereplay/defaultshader/Locations.js';
|
|
||||||
import Fill from '../../../../../src/ol/style/Fill.js';
|
|
||||||
import Stroke from '../../../../../src/ol/style/Stroke.js';
|
|
||||||
|
|
||||||
describe('ol.render.webgl.CircleReplay', function() {
|
|
||||||
let replay;
|
|
||||||
|
|
||||||
const strokeStyle = new Stroke({
|
|
||||||
color: [0, 255, 0, 0.4]
|
|
||||||
});
|
|
||||||
|
|
||||||
const fillStyle = new Fill({
|
|
||||||
color: [255, 0, 0, 1]
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
const tolerance = 0.1;
|
|
||||||
const maxExtent = [-10000, -20000, 10000, 20000];
|
|
||||||
replay = new WebGLCircleReplay(tolerance, maxExtent);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#setFillStrokeStyle', function() {
|
|
||||||
it('set expected states', function() {
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
expect(replay.state_).not.be(null);
|
|
||||||
expect(replay.state_.strokeColor).to.eql([0, 1, 0, 0.4]);
|
|
||||||
expect(replay.state_.lineWidth).to.be(1);
|
|
||||||
expect(replay.state_.fillColor).to.eql([1, 0, 0, 1]);
|
|
||||||
expect(replay.state_.changed).to.be(true);
|
|
||||||
expect(replay.styles_).to.have.length(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets a transparent stroke, if none provided', function() {
|
|
||||||
replay.setFillStrokeStyle(fillStyle, null);
|
|
||||||
expect(replay.state_.strokeColor).to.eql([0, 0, 0, 0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets a transparent fill, if none provided', function() {
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle);
|
|
||||||
expect(replay.state_.fillColor).to.eql([0, 0, 0, 0]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawCircle', function() {
|
|
||||||
it('sets the buffer data', function() {
|
|
||||||
const circle = new Circle([0, 0], 5000);
|
|
||||||
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawCircle(circle, null);
|
|
||||||
expect(replay.vertices).to.have.length(16);
|
|
||||||
expect(replay.indices).to.have.length(6);
|
|
||||||
expect(replay.state_.changed).to.be(false);
|
|
||||||
expect(replay.startIndices).to.have.length(1);
|
|
||||||
expect(replay.startIndicesFeature).to.have.length(1);
|
|
||||||
expect(replay.radius_).to.be(5000);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not draw if radius is zero', function() {
|
|
||||||
const circle = new Circle([0, 0], 0);
|
|
||||||
|
|
||||||
replay.drawCircle(circle, null);
|
|
||||||
expect(replay.vertices).to.have.length(0);
|
|
||||||
expect(replay.indices).to.have.length(0);
|
|
||||||
expect(replay.startIndices).to.have.length(0);
|
|
||||||
expect(replay.startIndicesFeature).to.have.length(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('resets state and removes style if it belongs to a zero radius circle', function() {
|
|
||||||
const circle = new Circle([0, 0], 0);
|
|
||||||
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle);
|
|
||||||
replay.drawCircle(circle, null);
|
|
||||||
expect(replay.styles_).to.have.length(1);
|
|
||||||
expect(replay.state_).not.be(null);
|
|
||||||
expect(replay.state_.strokeColor).to.eql([0, 1, 0, 0.4]);
|
|
||||||
expect(replay.state_.lineWidth).to.be(1);
|
|
||||||
expect(replay.state_.fillColor).to.eql([1, 0, 0, 1]);
|
|
||||||
expect(replay.state_.changed).to.be(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawCoordinates_', function() {
|
|
||||||
it('envelopes the circle into a right isosceles triangle', function() {
|
|
||||||
replay.radius_ = 5000;
|
|
||||||
replay.drawCoordinates_([0, 0], 0, 2, 2);
|
|
||||||
|
|
||||||
expect(replay.vertices).to.eql([0, 0, 0, 5000, 0, 0, 1, 5000,
|
|
||||||
0, 0, 2, 5000, 0, 0, 3, 5000]);
|
|
||||||
expect(replay.indices).to.eql([0, 1, 2, 2, 3, 0]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#setUpProgram', function() {
|
|
||||||
let context, gl;
|
|
||||||
beforeEach(function() {
|
|
||||||
context = {
|
|
||||||
getProgram: function() {},
|
|
||||||
useProgram: function() {}
|
|
||||||
};
|
|
||||||
gl = {
|
|
||||||
enableVertexAttribArray: function() {},
|
|
||||||
vertexAttribPointer: function() {},
|
|
||||||
uniform1f: function() {},
|
|
||||||
uniform2fv: function() {},
|
|
||||||
getUniformLocation: function() {},
|
|
||||||
getAttribLocation: function() {}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the locations used by the shaders', function() {
|
|
||||||
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(locations).to.be.a(Locations);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('gets and compiles the shaders', function() {
|
|
||||||
sinon.spy(context, 'getProgram');
|
|
||||||
sinon.spy(context, 'useProgram');
|
|
||||||
|
|
||||||
replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(context.getProgram.calledWithExactly(fragment, vertex)).to.be(true);
|
|
||||||
expect(context.useProgram.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('initializes the attrib pointers', function() {
|
|
||||||
sinon.spy(gl, 'getAttribLocation');
|
|
||||||
sinon.spy(gl, 'vertexAttribPointer');
|
|
||||||
sinon.spy(gl, 'enableVertexAttribArray');
|
|
||||||
|
|
||||||
replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(gl.vertexAttribPointer.callCount).to.be(gl.getAttribLocation.callCount);
|
|
||||||
expect(gl.enableVertexAttribArray.callCount).to.be(
|
|
||||||
gl.getAttribLocation.callCount);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#shutDownProgram', function() {
|
|
||||||
let context, gl;
|
|
||||||
beforeEach(function() {
|
|
||||||
context = {
|
|
||||||
getProgram: function() {},
|
|
||||||
useProgram: function() {}
|
|
||||||
};
|
|
||||||
gl = {
|
|
||||||
enableVertexAttribArray: function() {},
|
|
||||||
disableVertexAttribArray: function() {},
|
|
||||||
vertexAttribPointer: function() {},
|
|
||||||
uniform1f: function() {},
|
|
||||||
uniform2fv: function() {},
|
|
||||||
getUniformLocation: function() {},
|
|
||||||
getAttribLocation: function() {}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('disables the attrib pointers', function() {
|
|
||||||
sinon.spy(gl, 'getAttribLocation');
|
|
||||||
sinon.spy(gl, 'disableVertexAttribArray');
|
|
||||||
|
|
||||||
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
replay.shutDownProgram(gl, locations);
|
|
||||||
expect(gl.disableVertexAttribArray.callCount).to.be(
|
|
||||||
gl.getAttribLocation.callCount);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawReplay', function() {
|
|
||||||
let gl, context;
|
|
||||||
const feature1 = new Feature({
|
|
||||||
geometry: new Circle([0, 0], 5000)
|
|
||||||
});
|
|
||||||
const feature2 = new Feature({
|
|
||||||
geometry: new Circle([10, 10], 5000)
|
|
||||||
});
|
|
||||||
const feature3 = new Feature({
|
|
||||||
geometry: new Circle([20, 20], 5000)
|
|
||||||
});
|
|
||||||
beforeEach(function() {
|
|
||||||
gl = {};
|
|
||||||
context = {};
|
|
||||||
replay.setFillStyle_ = function() {};
|
|
||||||
replay.setStrokeStyle_ = function() {};
|
|
||||||
replay.drawElements = function() {};
|
|
||||||
sinon.spy(replay, 'setFillStyle_');
|
|
||||||
sinon.spy(replay, 'setStrokeStyle_');
|
|
||||||
sinon.spy(replay, 'drawElements');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws the elements in a single call if they have the same style', function() {
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawCircle(feature1.getGeometry(), feature1);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawCircle(feature2.getGeometry(), feature2);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawCircle(feature3.getGeometry(), feature3);
|
|
||||||
replay.startIndices.push(replay.indices.length);
|
|
||||||
|
|
||||||
replay.drawReplay(gl, context, {}, false);
|
|
||||||
expect(replay.setFillStyle_.calledOnce).to.be(true);
|
|
||||||
expect(replay.setStrokeStyle_.calledOnce).to.be(true);
|
|
||||||
expect(replay.drawElements.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws the elements in batches if there are multiple styles', function() {
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawCircle(feature1.getGeometry(), feature1);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, null);
|
|
||||||
replay.drawCircle(feature2.getGeometry(), feature2);
|
|
||||||
replay.setFillStrokeStyle(strokeStyle, null);
|
|
||||||
replay.drawCircle(feature3.getGeometry(), feature3);
|
|
||||||
replay.startIndices.push(replay.indices.length);
|
|
||||||
|
|
||||||
replay.drawReplay(gl, context, {}, false);
|
|
||||||
expect(replay.setFillStyle_.calledThrice).to.be(true);
|
|
||||||
expect(replay.setStrokeStyle_.calledThrice).to.be(true);
|
|
||||||
expect(replay.drawElements.calledThrice).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can skip elements if needed', function() {
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawCircle(feature1.getGeometry(), feature1);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawCircle(feature2.getGeometry(), feature2);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawCircle(feature3.getGeometry(), feature3);
|
|
||||||
replay.startIndices.push(replay.indices.length);
|
|
||||||
const skippedFeatHash = {};
|
|
||||||
skippedFeatHash[getUid(feature2)] = true;
|
|
||||||
|
|
||||||
replay.drawReplay(gl, context, skippedFeatHash, false);
|
|
||||||
expect(replay.setFillStyle_.calledOnce).to.be(true);
|
|
||||||
expect(replay.setStrokeStyle_.calledOnce).to.be(true);
|
|
||||||
expect(replay.drawElements.calledTwice).to.be(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,207 +0,0 @@
|
|||||||
import MultiPoint from '../../../../../src/ol/geom/MultiPoint.js';
|
|
||||||
import Point from '../../../../../src/ol/geom/Point.js';
|
|
||||||
import WebGLImageReplay from '../../../../../src/ol/render/webgl/ImageReplay.js';
|
|
||||||
import ImageStyle from '../../../../../src/ol/style/Image.js';
|
|
||||||
|
|
||||||
describe('ol.render.webgl.ImageReplay', function() {
|
|
||||||
let replay;
|
|
||||||
|
|
||||||
const createImageStyle = function(image) {
|
|
||||||
const imageStyle = new ImageStyle({
|
|
||||||
opacity: 0.1,
|
|
||||||
rotateWithView: true,
|
|
||||||
rotation: 1.5,
|
|
||||||
scale: 2.0
|
|
||||||
});
|
|
||||||
imageStyle.getAnchor = function() {
|
|
||||||
return [0.5, 1];
|
|
||||||
};
|
|
||||||
imageStyle.getImage = function() {
|
|
||||||
return image;
|
|
||||||
};
|
|
||||||
imageStyle.getHitDetectionImage = function() {
|
|
||||||
return image;
|
|
||||||
};
|
|
||||||
imageStyle.getImageSize = function() {
|
|
||||||
return [512, 512];
|
|
||||||
};
|
|
||||||
imageStyle.getHitDetectionImageSize = function() {
|
|
||||||
return [512, 512];
|
|
||||||
};
|
|
||||||
imageStyle.getOrigin = function() {
|
|
||||||
return [200, 200];
|
|
||||||
};
|
|
||||||
imageStyle.getSize = function() {
|
|
||||||
return [256, 256];
|
|
||||||
};
|
|
||||||
return imageStyle;
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
const tolerance = 0.1;
|
|
||||||
const maxExtent = [-10000, -20000, 10000, 20000];
|
|
||||||
replay = new WebGLImageReplay(tolerance, maxExtent);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#setImageStyle', function() {
|
|
||||||
|
|
||||||
let imageStyle1, imageStyle2;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
imageStyle1 = createImageStyle(new Image());
|
|
||||||
imageStyle2 = createImageStyle(new Image());
|
|
||||||
});
|
|
||||||
|
|
||||||
it('set expected states', function() {
|
|
||||||
replay.setImageStyle(imageStyle1);
|
|
||||||
expect(replay.anchorX).to.be(0.5);
|
|
||||||
expect(replay.anchorY).to.be(1);
|
|
||||||
expect(replay.height).to.be(256);
|
|
||||||
expect(replay.imageHeight).to.be(512);
|
|
||||||
expect(replay.imageWidth).to.be(512);
|
|
||||||
expect(replay.opacity).to.be(0.1);
|
|
||||||
expect(replay.originX).to.be(200);
|
|
||||||
expect(replay.originY).to.be(200);
|
|
||||||
expect(replay.rotation).to.be(1.5);
|
|
||||||
expect(replay.rotateWithView).to.be(true);
|
|
||||||
expect(replay.scale).to.be(2.0);
|
|
||||||
expect(replay.width).to.be(256);
|
|
||||||
expect(replay.images_).to.have.length(1);
|
|
||||||
expect(replay.groupIndices).to.have.length(0);
|
|
||||||
expect(replay.hitDetectionImages_).to.have.length(1);
|
|
||||||
expect(replay.hitDetectionGroupIndices).to.have.length(0);
|
|
||||||
|
|
||||||
replay.setImageStyle(imageStyle1);
|
|
||||||
expect(replay.images_).to.have.length(1);
|
|
||||||
expect(replay.groupIndices).to.have.length(0);
|
|
||||||
expect(replay.hitDetectionImages_).to.have.length(1);
|
|
||||||
expect(replay.hitDetectionGroupIndices).to.have.length(0);
|
|
||||||
|
|
||||||
replay.setImageStyle(imageStyle2);
|
|
||||||
expect(replay.images_).to.have.length(2);
|
|
||||||
expect(replay.groupIndices).to.have.length(1);
|
|
||||||
expect(replay.hitDetectionImages_).to.have.length(2);
|
|
||||||
expect(replay.hitDetectionGroupIndices).to.have.length(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawPoint', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
const imageStyle = createImageStyle(new Image());
|
|
||||||
replay.setImageStyle(imageStyle);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets the buffer data', function() {
|
|
||||||
let point;
|
|
||||||
|
|
||||||
point = new Point([1000, 2000]);
|
|
||||||
replay.drawPoint(point, null);
|
|
||||||
expect(replay.vertices).to.have.length(32);
|
|
||||||
expect(replay.indices).to.have.length(6);
|
|
||||||
expect(replay.indices[0]).to.be(0);
|
|
||||||
expect(replay.indices[1]).to.be(1);
|
|
||||||
expect(replay.indices[2]).to.be(2);
|
|
||||||
expect(replay.indices[3]).to.be(0);
|
|
||||||
expect(replay.indices[4]).to.be(2);
|
|
||||||
expect(replay.indices[5]).to.be(3);
|
|
||||||
|
|
||||||
point = new Point([2000, 3000]);
|
|
||||||
replay.drawPoint(point, null);
|
|
||||||
expect(replay.vertices).to.have.length(64);
|
|
||||||
expect(replay.indices).to.have.length(12);
|
|
||||||
expect(replay.indices[6]).to.be(4);
|
|
||||||
expect(replay.indices[7]).to.be(5);
|
|
||||||
expect(replay.indices[8]).to.be(6);
|
|
||||||
expect(replay.indices[9]).to.be(4);
|
|
||||||
expect(replay.indices[10]).to.be(6);
|
|
||||||
expect(replay.indices[11]).to.be(7);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawMultiPoint', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
const imageStyle = createImageStyle(new Image());
|
|
||||||
replay.setImageStyle(imageStyle);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets the buffer data', function() {
|
|
||||||
let multiPoint;
|
|
||||||
|
|
||||||
multiPoint = new MultiPoint(
|
|
||||||
[[1000, 2000], [2000, 3000]]);
|
|
||||||
replay.drawMultiPoint(multiPoint, null);
|
|
||||||
expect(replay.vertices).to.have.length(64);
|
|
||||||
expect(replay.indices).to.have.length(12);
|
|
||||||
expect(replay.indices[0]).to.be(0);
|
|
||||||
expect(replay.indices[1]).to.be(1);
|
|
||||||
expect(replay.indices[2]).to.be(2);
|
|
||||||
expect(replay.indices[3]).to.be(0);
|
|
||||||
expect(replay.indices[4]).to.be(2);
|
|
||||||
expect(replay.indices[5]).to.be(3);
|
|
||||||
expect(replay.indices[6]).to.be(4);
|
|
||||||
expect(replay.indices[7]).to.be(5);
|
|
||||||
expect(replay.indices[8]).to.be(6);
|
|
||||||
expect(replay.indices[9]).to.be(4);
|
|
||||||
expect(replay.indices[10]).to.be(6);
|
|
||||||
expect(replay.indices[11]).to.be(7);
|
|
||||||
|
|
||||||
multiPoint = new MultiPoint(
|
|
||||||
[[3000, 4000], [4000, 5000]]);
|
|
||||||
replay.drawMultiPoint(multiPoint, null);
|
|
||||||
expect(replay.vertices).to.have.length(128);
|
|
||||||
expect(replay.indices).to.have.length(24);
|
|
||||||
expect(replay.indices[12]).to.be(8);
|
|
||||||
expect(replay.indices[13]).to.be(9);
|
|
||||||
expect(replay.indices[14]).to.be(10);
|
|
||||||
expect(replay.indices[15]).to.be(8);
|
|
||||||
expect(replay.indices[16]).to.be(10);
|
|
||||||
expect(replay.indices[17]).to.be(11);
|
|
||||||
expect(replay.indices[18]).to.be(12);
|
|
||||||
expect(replay.indices[19]).to.be(13);
|
|
||||||
expect(replay.indices[20]).to.be(14);
|
|
||||||
expect(replay.indices[21]).to.be(12);
|
|
||||||
expect(replay.indices[22]).to.be(14);
|
|
||||||
expect(replay.indices[23]).to.be(15);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#getTextures', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
replay.textures_ = [1, 2];
|
|
||||||
replay.hitDetectionTextures_ = [3, 4];
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the textures', function() {
|
|
||||||
const textures = replay.getTextures();
|
|
||||||
|
|
||||||
expect(textures).to.have.length(2);
|
|
||||||
expect(textures[0]).to.be(1);
|
|
||||||
expect(textures[1]).to.be(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can additionally return the hit detection textures', function() {
|
|
||||||
const textures = replay.getTextures(true);
|
|
||||||
|
|
||||||
expect(textures).to.have.length(4);
|
|
||||||
expect(textures[0]).to.be(1);
|
|
||||||
expect(textures[1]).to.be(2);
|
|
||||||
expect(textures[2]).to.be(3);
|
|
||||||
expect(textures[3]).to.be(4);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#getHitDetectionTextures', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
replay.textures_ = [1, 2];
|
|
||||||
replay.hitDetectionTextures_ = [3, 4];
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the hit detection textures', function() {
|
|
||||||
const textures = replay.getHitDetectionTextures();
|
|
||||||
|
|
||||||
expect(textures).to.have.length(2);
|
|
||||||
expect(textures[0]).to.be(3);
|
|
||||||
expect(textures[1]).to.be(4);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,272 +0,0 @@
|
|||||||
import Feature from '../../../../../src/ol/Feature.js';
|
|
||||||
import Circle from '../../../../../src/ol/geom/Circle.js';
|
|
||||||
import GeometryCollection from '../../../../../src/ol/geom/GeometryCollection.js';
|
|
||||||
import LineString from '../../../../../src/ol/geom/LineString.js';
|
|
||||||
import MultiLineString from '../../../../../src/ol/geom/MultiLineString.js';
|
|
||||||
import MultiPoint from '../../../../../src/ol/geom/MultiPoint.js';
|
|
||||||
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
|
|
||||||
import Point from '../../../../../src/ol/geom/Point.js';
|
|
||||||
import Polygon from '../../../../../src/ol/geom/Polygon.js';
|
|
||||||
import WebGLCircleReplay from '../../../../../src/ol/render/webgl/CircleReplay.js';
|
|
||||||
import WebGLImageReplay from '../../../../../src/ol/render/webgl/ImageReplay.js';
|
|
||||||
import WebGLImmediateRenderer from '../../../../../src/ol/render/webgl/Immediate.js';
|
|
||||||
import WebGLLineStringReplay from '../../../../../src/ol/render/webgl/LineStringReplay.js';
|
|
||||||
import WebGLPolygonReplay from '../../../../../src/ol/render/webgl/PolygonReplay.js';
|
|
||||||
import CircleStyle from '../../../../../src/ol/style/Circle.js';
|
|
||||||
import Fill from '../../../../../src/ol/style/Fill.js';
|
|
||||||
import Stroke from '../../../../../src/ol/style/Stroke.js';
|
|
||||||
import Style from '../../../../../src/ol/style/Style.js';
|
|
||||||
|
|
||||||
describe('ol.render.webgl.Immediate', function() {
|
|
||||||
let context, style, circle, line, multiLine, point, multiPoint, polygon, multiPolygon;
|
|
||||||
beforeEach(function() {
|
|
||||||
context = new WebGLImmediateRenderer({}, [0, 0], 0, 0, [0, 0], [-180, -90, 180, 90], 1);
|
|
||||||
style = new Style({
|
|
||||||
image: new CircleStyle(),
|
|
||||||
fill: new Fill(),
|
|
||||||
stroke: new Stroke()
|
|
||||||
});
|
|
||||||
circle = new Circle([0, 0], 5);
|
|
||||||
line = new LineString([[0, 0], [5, 5]]);
|
|
||||||
multiLine = new MultiLineString([[[0, 0], [5, 5]]]);
|
|
||||||
point = new Point([0, 0]);
|
|
||||||
multiPoint = new MultiPoint([[0, 0]]);
|
|
||||||
polygon = new Polygon([[[0, 0], [5, 5], [5, 0], [0, 0]]]);
|
|
||||||
multiPolygon = new MultiPolygon([[[[0, 0], [5, 5], [5, 0], [0, 0]]]]);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#setStyle', function() {
|
|
||||||
it('sets the style of the context', function() {
|
|
||||||
context.setStyle(style);
|
|
||||||
expect(context.fillStyle_).to.be(style.getFill());
|
|
||||||
expect(context.strokeStyle_).to.be(style.getStroke());
|
|
||||||
expect(context.imageStyle_).to.be(style.getImage());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawFeature', function() {
|
|
||||||
let feat;
|
|
||||||
beforeEach(function() {
|
|
||||||
feat = new Feature({
|
|
||||||
geometry: circle
|
|
||||||
});
|
|
||||||
context.setStyle = function() {};
|
|
||||||
context.drawGeometry = function() {};
|
|
||||||
sinon.spy(context, 'setStyle');
|
|
||||||
sinon.spy(context, 'drawGeometry');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('updates the style of the context', function() {
|
|
||||||
context.drawFeature(feat, style);
|
|
||||||
expect(context.setStyle.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws the geometry of the feature', function() {
|
|
||||||
context.drawFeature(feat, style);
|
|
||||||
expect(context.drawGeometry.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does nothing if no geometry is provided', function() {
|
|
||||||
feat = new Feature();
|
|
||||||
context.drawFeature(feat, style);
|
|
||||||
expect(context.setStyle.called).to.be(false);
|
|
||||||
expect(context.drawGeometry.called).to.be(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does nothing if geometry is out of bounds', function() {
|
|
||||||
feat = new Feature({
|
|
||||||
geometry: new Circle([540, 540], 1)
|
|
||||||
});
|
|
||||||
context.drawFeature(feat, style);
|
|
||||||
expect(context.setStyle.called).to.be(false);
|
|
||||||
expect(context.drawGeometry.called).to.be(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawGeometryCollection', function() {
|
|
||||||
let geomColl;
|
|
||||||
beforeEach(function() {
|
|
||||||
geomColl = new GeometryCollection([circle, point, multiPoint,
|
|
||||||
line, multiLine, polygon, multiPolygon]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws every geometry in the collection', function() {
|
|
||||||
context.drawGeometry = function() {};
|
|
||||||
sinon.spy(context, 'drawGeometry');
|
|
||||||
|
|
||||||
context.drawGeometryCollection(geomColl);
|
|
||||||
expect(context.drawGeometry.callCount).to.be(7);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('geometry functions', function() {
|
|
||||||
function mock(ctor, geomFunc) {
|
|
||||||
const tmpObj = {};
|
|
||||||
tmpObj.replay = ctor.prototype.replay;
|
|
||||||
ctor.prototype.replay = sinon.spy();
|
|
||||||
tmpObj.finish = ctor.prototype.finish;
|
|
||||||
ctor.prototype.finish = sinon.spy();
|
|
||||||
tmpObj.getDeleteResourcesFunction = ctor.prototype.getDeleteResourcesFunction;
|
|
||||||
ctor.prototype.getDeleteResourcesFunction = sinon.spy(function() {
|
|
||||||
return function() {};
|
|
||||||
});
|
|
||||||
sinon.spy(ctor.prototype.getDeleteResourcesFunction);
|
|
||||||
if (ctor === WebGLImageReplay) {
|
|
||||||
tmpObj.setImageStyle = ctor.prototype.setImageStyle;
|
|
||||||
ctor.prototype.setImageStyle = sinon.spy();
|
|
||||||
} else {
|
|
||||||
tmpObj.setFillStrokeStyle = ctor.prototype.setFillStrokeStyle;
|
|
||||||
ctor.prototype.setFillStrokeStyle = sinon.spy();
|
|
||||||
}
|
|
||||||
tmpObj[geomFunc] = ctor.prototype[geomFunc];
|
|
||||||
ctor.prototype[geomFunc] = sinon.spy();
|
|
||||||
return tmpObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function restore(ctor, tmpObj) {
|
|
||||||
for (const i in tmpObj) {
|
|
||||||
ctor.prototype[i] = tmpObj[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('#drawPoint', function() {
|
|
||||||
let tmpObj;
|
|
||||||
beforeEach(function() {
|
|
||||||
tmpObj = mock(WebGLImageReplay, 'drawPoint');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws a point', function() {
|
|
||||||
context.drawGeometry(point);
|
|
||||||
expect(WebGLImageReplay.prototype.setImageStyle.calledOnce).to.be(true);
|
|
||||||
expect(WebGLImageReplay.prototype.drawPoint.calledOnce).to.be(true);
|
|
||||||
expect(WebGLImageReplay.prototype.finish.calledOnce).to.be(true);
|
|
||||||
expect(WebGLImageReplay.prototype.replay.calledOnce).to.be(true);
|
|
||||||
expect(WebGLImageReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
after(function() {
|
|
||||||
restore(WebGLImageReplay, tmpObj);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawMultiPoint', function() {
|
|
||||||
let tmpObj;
|
|
||||||
beforeEach(function() {
|
|
||||||
tmpObj = mock(WebGLImageReplay, 'drawMultiPoint');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws a multi point', function() {
|
|
||||||
context.drawGeometry(multiPoint);
|
|
||||||
expect(WebGLImageReplay.prototype.setImageStyle.calledOnce).to.be(true);
|
|
||||||
expect(WebGLImageReplay.prototype.drawMultiPoint.calledOnce).to.be(true);
|
|
||||||
expect(WebGLImageReplay.prototype.finish.calledOnce).to.be(true);
|
|
||||||
expect(WebGLImageReplay.prototype.replay.calledOnce).to.be(true);
|
|
||||||
expect(WebGLImageReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
after(function() {
|
|
||||||
restore(WebGLImageReplay, tmpObj);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawLineString', function() {
|
|
||||||
let tmpObj;
|
|
||||||
beforeEach(function() {
|
|
||||||
tmpObj = mock(WebGLLineStringReplay, 'drawLineString');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws a line string', function() {
|
|
||||||
context.drawGeometry(line);
|
|
||||||
expect(WebGLLineStringReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true);
|
|
||||||
expect(WebGLLineStringReplay.prototype.drawLineString.calledOnce).to.be(true);
|
|
||||||
expect(WebGLLineStringReplay.prototype.finish.calledOnce).to.be(true);
|
|
||||||
expect(WebGLLineStringReplay.prototype.replay.calledOnce).to.be(true);
|
|
||||||
expect(WebGLLineStringReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
after(function() {
|
|
||||||
restore(WebGLLineStringReplay, tmpObj);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawMultiLineString', function() {
|
|
||||||
let tmpObj;
|
|
||||||
beforeEach(function() {
|
|
||||||
tmpObj = mock(WebGLLineStringReplay, 'drawMultiLineString');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws a multi line string', function() {
|
|
||||||
context.drawGeometry(multiLine);
|
|
||||||
expect(WebGLLineStringReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true);
|
|
||||||
expect(WebGLLineStringReplay.prototype.drawMultiLineString.calledOnce).to.be(true);
|
|
||||||
expect(WebGLLineStringReplay.prototype.finish.calledOnce).to.be(true);
|
|
||||||
expect(WebGLLineStringReplay.prototype.replay.calledOnce).to.be(true);
|
|
||||||
expect(WebGLLineStringReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
after(function() {
|
|
||||||
restore(WebGLLineStringReplay, tmpObj);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawPolygon', function() {
|
|
||||||
let tmpObj;
|
|
||||||
beforeEach(function() {
|
|
||||||
tmpObj = mock(WebGLPolygonReplay, 'drawPolygon');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws a polygon', function() {
|
|
||||||
context.drawGeometry(polygon);
|
|
||||||
expect(WebGLPolygonReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true);
|
|
||||||
expect(WebGLPolygonReplay.prototype.drawPolygon.calledOnce).to.be(true);
|
|
||||||
expect(WebGLPolygonReplay.prototype.finish.calledOnce).to.be(true);
|
|
||||||
expect(WebGLPolygonReplay.prototype.replay.calledOnce).to.be(true);
|
|
||||||
expect(WebGLPolygonReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
after(function() {
|
|
||||||
restore(WebGLPolygonReplay, tmpObj);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawMultiPolygon', function() {
|
|
||||||
let tmpObj;
|
|
||||||
beforeEach(function() {
|
|
||||||
tmpObj = mock(WebGLPolygonReplay, 'drawMultiPolygon');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws a multi polygon', function() {
|
|
||||||
context.drawGeometry(multiPolygon);
|
|
||||||
expect(WebGLPolygonReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true);
|
|
||||||
expect(WebGLPolygonReplay.prototype.drawMultiPolygon.calledOnce).to.be(true);
|
|
||||||
expect(WebGLPolygonReplay.prototype.finish.calledOnce).to.be(true);
|
|
||||||
expect(WebGLPolygonReplay.prototype.replay.calledOnce).to.be(true);
|
|
||||||
expect(WebGLPolygonReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
after(function() {
|
|
||||||
restore(WebGLPolygonReplay, tmpObj);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawCircle', function() {
|
|
||||||
let tmpObj;
|
|
||||||
beforeEach(function() {
|
|
||||||
tmpObj = mock(WebGLCircleReplay, 'drawCircle');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws a circle', function() {
|
|
||||||
context.drawGeometry(circle);
|
|
||||||
expect(WebGLCircleReplay.prototype.setFillStrokeStyle.calledOnce).to.be(true);
|
|
||||||
expect(WebGLCircleReplay.prototype.drawCircle.calledOnce).to.be(true);
|
|
||||||
expect(WebGLCircleReplay.prototype.finish.calledOnce).to.be(true);
|
|
||||||
expect(WebGLCircleReplay.prototype.replay.calledOnce).to.be(true);
|
|
||||||
expect(WebGLCircleReplay.prototype.getDeleteResourcesFunction.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
after(function() {
|
|
||||||
restore(WebGLCircleReplay, tmpObj);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
import WebGLReplay from '../../../../../src/ol/render/webgl/Replay.js';
|
|
||||||
|
|
||||||
describe('ol.render.Replay', function() {
|
|
||||||
let replay;
|
|
||||||
beforeEach(function() {
|
|
||||||
replay = new WebGLReplay(5, [-180, -90, 180, 90]);
|
|
||||||
replay.drawReplay = replay.shutDownProgram = function() {};
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
describe('constructor', function() {
|
|
||||||
it('stores view related data', function() {
|
|
||||||
expect(replay.tolerance).to.be(5);
|
|
||||||
expect(replay.maxExtent).to.eql([-180, -90, 180, 90]);
|
|
||||||
expect(replay.origin).to.eql([0, 0]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it ('sets up the required matrices', function() {
|
|
||||||
const mat3 = [1, 0, 0, 1, 0, 0];
|
|
||||||
const mat4 = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
||||||
expect(replay.projectionMatrix_).to.eql(mat3);
|
|
||||||
expect(replay.offsetRotateMatrix_).to.eql(mat3);
|
|
||||||
expect(replay.offsetScaleMatrix_).to.eql(mat3);
|
|
||||||
expect(replay.tmpMat4_).to.eql(mat4);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#replay', function() {
|
|
||||||
const gl = {
|
|
||||||
uniformMatrix4fv: function() {},
|
|
||||||
uniform1f: function() {}
|
|
||||||
};
|
|
||||||
const context = {
|
|
||||||
bindBuffer: function() {},
|
|
||||||
getGL: function() {
|
|
||||||
return gl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
beforeEach(function() {
|
|
||||||
replay.setUpProgram = function() {
|
|
||||||
return {
|
|
||||||
u_projectionMatrix: true,
|
|
||||||
u_offsetScaleMatrix: true,
|
|
||||||
u_offsetRotateMatrix: true,
|
|
||||||
u_opacity: true
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calculates the correct matrices', function() {
|
|
||||||
const sin = Math.sin(Math.PI);
|
|
||||||
replay.replay(context, [0, 0], 10, Math.PI, [10, 10], 1, 0, {}, undefined,
|
|
||||||
false, undefined);
|
|
||||||
|
|
||||||
expect(replay.projectionMatrix_).to.eql([-0.02, -sin * 0.02, sin * 0.02,
|
|
||||||
-0.02, 0, 0]);
|
|
||||||
expect(replay.offsetRotateMatrix_).to.eql([-1, -sin, sin, -1, 0, 0]);
|
|
||||||
expect(replay.offsetScaleMatrix_).to.eql([0.2, 0, 0, 0.2, 0, 0]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,347 +0,0 @@
|
|||||||
import {getUid} from '../../../../../src/ol/util.js';
|
|
||||||
import Feature from '../../../../../src/ol/Feature.js';
|
|
||||||
import LineString from '../../../../../src/ol/geom/LineString.js';
|
|
||||||
import MultiLineString from '../../../../../src/ol/geom/MultiLineString.js';
|
|
||||||
import WebGLLineStringReplay from '../../../../../src/ol/render/webgl/LineStringReplay.js';
|
|
||||||
import {fragment, vertex} from '../../../../../src/ol/render/webgl/linestringreplay/defaultshader.js';
|
|
||||||
import Locations from '../../../../../src/ol/render/webgl/linestringreplay/defaultshader/Locations.js';
|
|
||||||
import Stroke from '../../../../../src/ol/style/Stroke.js';
|
|
||||||
|
|
||||||
describe('ol.render.webgl.LineStringReplay', function() {
|
|
||||||
let replay;
|
|
||||||
|
|
||||||
const strokeStyle1 = new Stroke({
|
|
||||||
color: [0, 255, 0, 0.4]
|
|
||||||
});
|
|
||||||
|
|
||||||
const strokeStyle2 = new Stroke({
|
|
||||||
color: [255, 0, 0, 1],
|
|
||||||
lineCap: 'square',
|
|
||||||
lineJoin: 'miter'
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
const tolerance = 0.1;
|
|
||||||
const maxExtent = [-10000, -20000, 10000, 20000];
|
|
||||||
replay = new WebGLLineStringReplay(tolerance, maxExtent);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#setFillStrokeStyle', function() {
|
|
||||||
|
|
||||||
it('set expected states', function() {
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
expect(replay.state_).not.be(null);
|
|
||||||
expect(replay.state_.lineCap).to.be('round');
|
|
||||||
expect(replay.state_.lineJoin).to.be('round');
|
|
||||||
expect(replay.state_.strokeColor).to.eql([0, 1, 0, 0.4]);
|
|
||||||
expect(replay.state_.lineWidth).to.be(1);
|
|
||||||
expect(replay.state_.miterLimit).to.be(10);
|
|
||||||
expect(replay.state_.changed).to.be(true);
|
|
||||||
expect(replay.styles_).to.have.length(1);
|
|
||||||
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle2);
|
|
||||||
expect(replay.state_.lineCap).to.be('square');
|
|
||||||
expect(replay.state_.lineJoin).to.be('miter');
|
|
||||||
expect(replay.state_.strokeColor).to.eql([1, 0, 0, 1]);
|
|
||||||
expect(replay.state_.lineWidth).to.be(1);
|
|
||||||
expect(replay.state_.miterLimit).to.be(10);
|
|
||||||
expect(replay.state_.changed).to.be(true);
|
|
||||||
expect(replay.styles_).to.have.length(2);
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawLineString', function() {
|
|
||||||
|
|
||||||
it('sets the buffer data', function() {
|
|
||||||
let linestring;
|
|
||||||
|
|
||||||
linestring = new LineString(
|
|
||||||
[[1000, 2000], [2000, 3000]]);
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawLineString(linestring, null);
|
|
||||||
expect(replay.vertices).to.have.length(56);
|
|
||||||
expect(replay.indices).to.have.length(18);
|
|
||||||
expect(replay.state_.changed).to.be(false);
|
|
||||||
expect(replay.startIndices).to.have.length(1);
|
|
||||||
expect(replay.startIndicesFeature).to.have.length(1);
|
|
||||||
|
|
||||||
linestring = new LineString(
|
|
||||||
[[1000, 3000], [2000, 4000], [3000, 3000]]);
|
|
||||||
replay.drawLineString(linestring, null);
|
|
||||||
expect(replay.vertices).to.have.length(140);
|
|
||||||
expect(replay.indices).to.have.length(48);
|
|
||||||
expect(replay.state_.changed).to.be(false);
|
|
||||||
expect(replay.startIndices).to.have.length(2);
|
|
||||||
expect(replay.startIndicesFeature).to.have.length(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawMultiLineString', function() {
|
|
||||||
|
|
||||||
it('sets the buffer data', function() {
|
|
||||||
const multilinestring = new MultiLineString(
|
|
||||||
[[[1000, 2000], [2000, 3000]],
|
|
||||||
[[1000, 3000], [2000, 4000], [3000, 3000]]]);
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawMultiLineString(multilinestring, null);
|
|
||||||
expect(replay.vertices).to.have.length(140);
|
|
||||||
expect(replay.indices).to.have.length(48);
|
|
||||||
expect(replay.state_.changed).to.be(false);
|
|
||||||
expect(replay.startIndices).to.have.length(1);
|
|
||||||
expect(replay.startIndicesFeature).to.have.length(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawCoordinates_', function() {
|
|
||||||
|
|
||||||
it('triangulates linestrings', function() {
|
|
||||||
const stroke = new Stroke({
|
|
||||||
color: [0, 255, 0, 1],
|
|
||||||
lineCap: 'butt',
|
|
||||||
lineJoin: 'bevel'
|
|
||||||
});
|
|
||||||
|
|
||||||
const linestring = new LineString(
|
|
||||||
[[1000, 3000], [2000, 4000], [3000, 3000]]);
|
|
||||||
const flatCoordinates = linestring.getFlatCoordinates();
|
|
||||||
replay.setFillStrokeStyle(null, stroke);
|
|
||||||
replay.drawCoordinates_(flatCoordinates, 0,
|
|
||||||
flatCoordinates.length, 2);
|
|
||||||
expect(replay.indices).to.eql(
|
|
||||||
[2, 0, 1, 4, 2, 1,
|
|
||||||
2, 4, 3,
|
|
||||||
5, 3, 4, 4, 6, 5]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('optionally creates miters', function() {
|
|
||||||
const stroke = new Stroke({
|
|
||||||
color: [0, 255, 0, 1],
|
|
||||||
lineCap: 'butt'
|
|
||||||
});
|
|
||||||
|
|
||||||
const linestring = new LineString(
|
|
||||||
[[1000, 3000], [2000, 4000], [3000, 3000]]);
|
|
||||||
const flatCoordinates = linestring.getFlatCoordinates();
|
|
||||||
replay.setFillStrokeStyle(null, stroke);
|
|
||||||
replay.drawCoordinates_(flatCoordinates, 0,
|
|
||||||
flatCoordinates.length, 2);
|
|
||||||
expect(replay.indices).to.eql(
|
|
||||||
[2, 0, 1, 4, 2, 1,
|
|
||||||
2, 4, 3, 3, 5, 2,
|
|
||||||
6, 3, 4, 4, 7, 6]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('optionally creates caps', function() {
|
|
||||||
const stroke = new Stroke({
|
|
||||||
color: [0, 255, 0, 1]
|
|
||||||
});
|
|
||||||
|
|
||||||
const linestring = new LineString(
|
|
||||||
[[1000, 3000], [2000, 4000], [3000, 3000]]);
|
|
||||||
const flatCoordinates = linestring.getFlatCoordinates();
|
|
||||||
replay.setFillStrokeStyle(null, stroke);
|
|
||||||
replay.drawCoordinates_(flatCoordinates, 0,
|
|
||||||
flatCoordinates.length, 2);
|
|
||||||
expect(replay.indices).to.eql(
|
|
||||||
[2, 0, 1, 1, 3, 2,
|
|
||||||
4, 2, 3, 6, 4, 3,
|
|
||||||
4, 6, 5, 5, 7, 4,
|
|
||||||
8, 5, 6, 6, 9, 8,
|
|
||||||
10, 8, 9, 9, 11, 10]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('respects segment orientation', function() {
|
|
||||||
const stroke = new Stroke({
|
|
||||||
color: [0, 255, 0, 1],
|
|
||||||
lineCap: 'butt',
|
|
||||||
lineJoin: 'bevel'
|
|
||||||
});
|
|
||||||
|
|
||||||
const linestring = new LineString(
|
|
||||||
[[1000, 3000], [2000, 2000], [3000, 3000]]);
|
|
||||||
const flatCoordinates = linestring.getFlatCoordinates();
|
|
||||||
replay.setFillStrokeStyle(null, stroke);
|
|
||||||
replay.drawCoordinates_(flatCoordinates, 0,
|
|
||||||
flatCoordinates.length, 2);
|
|
||||||
expect(replay.indices).to.eql(
|
|
||||||
[2, 0, 1, 4, 2, 0,
|
|
||||||
2, 4, 3,
|
|
||||||
5, 3, 4, 4, 6, 5]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('closes boundaries', function() {
|
|
||||||
const stroke = new Stroke({
|
|
||||||
color: [0, 255, 0, 1],
|
|
||||||
lineCap: 'butt',
|
|
||||||
lineJoin: 'bevel'
|
|
||||||
});
|
|
||||||
|
|
||||||
const linestring = new LineString(
|
|
||||||
[[1000, 3000], [2000, 4000], [3000, 3000], [1000, 3000]]);
|
|
||||||
const flatCoordinates = linestring.getFlatCoordinates();
|
|
||||||
replay.setFillStrokeStyle(null, stroke);
|
|
||||||
replay.drawCoordinates_(flatCoordinates, 0,
|
|
||||||
flatCoordinates.length, 2);
|
|
||||||
expect(replay.indices).to.eql(
|
|
||||||
[0, 2, 1, 3, 1, 2,
|
|
||||||
5, 3, 2,
|
|
||||||
3, 5, 4, 6, 4, 5,
|
|
||||||
8, 6, 5,
|
|
||||||
6, 8, 7, 9, 7, 8,
|
|
||||||
10, 9, 8]);
|
|
||||||
expect(replay.vertices.slice(0, 7)).to.eql(
|
|
||||||
replay.vertices.slice(-14, -7));
|
|
||||||
expect(replay.vertices.slice(14, 21)).to.eql(
|
|
||||||
replay.vertices.slice(-7));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#setUpProgram', function() {
|
|
||||||
let context, gl;
|
|
||||||
beforeEach(function() {
|
|
||||||
context = {
|
|
||||||
getProgram: function() {},
|
|
||||||
useProgram: function() {}
|
|
||||||
};
|
|
||||||
gl = {
|
|
||||||
enableVertexAttribArray: function() {},
|
|
||||||
vertexAttribPointer: function() {},
|
|
||||||
uniform1f: function() {},
|
|
||||||
uniform2fv: function() {},
|
|
||||||
getUniformLocation: function() {},
|
|
||||||
getAttribLocation: function() {}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the locations used by the shaders', function() {
|
|
||||||
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(locations).to.be.a(Locations);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('gets and compiles the shaders', function() {
|
|
||||||
sinon.spy(context, 'getProgram');
|
|
||||||
sinon.spy(context, 'useProgram');
|
|
||||||
|
|
||||||
replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(context.getProgram.calledWithExactly(fragment, vertex)).to.be(true);
|
|
||||||
expect(context.useProgram.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('initializes the attrib pointers', function() {
|
|
||||||
sinon.spy(gl, 'getAttribLocation');
|
|
||||||
sinon.spy(gl, 'vertexAttribPointer');
|
|
||||||
sinon.spy(gl, 'enableVertexAttribArray');
|
|
||||||
|
|
||||||
replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(gl.vertexAttribPointer.callCount).to.be(gl.getAttribLocation.callCount);
|
|
||||||
expect(gl.enableVertexAttribArray.callCount).to.be(
|
|
||||||
gl.getAttribLocation.callCount);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#shutDownProgram', function() {
|
|
||||||
let context, gl;
|
|
||||||
beforeEach(function() {
|
|
||||||
context = {
|
|
||||||
getProgram: function() {},
|
|
||||||
useProgram: function() {}
|
|
||||||
};
|
|
||||||
gl = {
|
|
||||||
enableVertexAttribArray: function() {},
|
|
||||||
disableVertexAttribArray: function() {},
|
|
||||||
vertexAttribPointer: function() {},
|
|
||||||
uniform1f: function() {},
|
|
||||||
uniform2fv: function() {},
|
|
||||||
getUniformLocation: function() {},
|
|
||||||
getAttribLocation: function() {}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('disables the attrib pointers', function() {
|
|
||||||
sinon.spy(gl, 'getAttribLocation');
|
|
||||||
sinon.spy(gl, 'disableVertexAttribArray');
|
|
||||||
|
|
||||||
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
replay.shutDownProgram(gl, locations);
|
|
||||||
expect(gl.disableVertexAttribArray.callCount).to.be(
|
|
||||||
gl.getAttribLocation.callCount);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawReplay', function() {
|
|
||||||
let gl, context;
|
|
||||||
const feature1 = new Feature({
|
|
||||||
geometry: new LineString([[0, 0], [500, 500]])
|
|
||||||
});
|
|
||||||
const feature2 = new Feature({
|
|
||||||
geometry: new LineString([[0, 0], [500, 500]])
|
|
||||||
});
|
|
||||||
const feature3 = new Feature({
|
|
||||||
geometry: new LineString([[0, 0], [500, 500]])
|
|
||||||
});
|
|
||||||
beforeEach(function() {
|
|
||||||
gl = {
|
|
||||||
enable: function() {},
|
|
||||||
disable: function() {},
|
|
||||||
depthMask: function() {},
|
|
||||||
depthFunc: function() {},
|
|
||||||
clear: function() {},
|
|
||||||
getParameter: function() {}
|
|
||||||
};
|
|
||||||
context = {};
|
|
||||||
replay.setStrokeStyle_ = function() {};
|
|
||||||
replay.drawElements = function() {};
|
|
||||||
sinon.spy(replay, 'setStrokeStyle_');
|
|
||||||
sinon.spy(replay, 'drawElements');
|
|
||||||
sinon.spy(gl, 'clear');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws the elements in a single call if they have the same style', function() {
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawLineString(feature1.getGeometry(), feature1);
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawLineString(feature2.getGeometry(), feature2);
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawLineString(feature3.getGeometry(), feature3);
|
|
||||||
replay.startIndices.push(replay.indices.length);
|
|
||||||
|
|
||||||
replay.drawReplay(gl, context, {}, false);
|
|
||||||
expect(replay.setStrokeStyle_.calledOnce).to.be(true);
|
|
||||||
expect(replay.drawElements.calledOnce).to.be(true);
|
|
||||||
expect(gl.clear.called).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws the elements in batches if there are multiple styles', function() {
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawLineString(feature1.getGeometry(), feature1);
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle2);
|
|
||||||
replay.drawLineString(feature2.getGeometry(), feature2);
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawLineString(feature3.getGeometry(), feature3);
|
|
||||||
replay.startIndices.push(replay.indices.length);
|
|
||||||
|
|
||||||
replay.drawReplay(gl, context, {}, false);
|
|
||||||
expect(replay.setStrokeStyle_.calledThrice).to.be(true);
|
|
||||||
expect(replay.drawElements.calledThrice).to.be(true);
|
|
||||||
expect(gl.clear.called).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can skip elements if needed', function() {
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawLineString(feature1.getGeometry(), feature1);
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawLineString(feature2.getGeometry(), feature2);
|
|
||||||
replay.setFillStrokeStyle(null, strokeStyle1);
|
|
||||||
replay.drawLineString(feature3.getGeometry(), feature3);
|
|
||||||
replay.startIndices.push(replay.indices.length);
|
|
||||||
const skippedFeatHash = {};
|
|
||||||
skippedFeatHash[getUid(feature2)] = true;
|
|
||||||
|
|
||||||
replay.drawReplay(gl, context, skippedFeatHash, false);
|
|
||||||
expect(replay.setStrokeStyle_.calledOnce).to.be(true);
|
|
||||||
expect(replay.drawElements.calledTwice).to.be(true);
|
|
||||||
expect(gl.clear.called).to.be(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,467 +0,0 @@
|
|||||||
import {getUid} from '../../../../../src/ol/util.js';
|
|
||||||
import Feature from '../../../../../src/ol/Feature.js';
|
|
||||||
import MultiPolygon from '../../../../../src/ol/geom/MultiPolygon.js';
|
|
||||||
import Polygon from '../../../../../src/ol/geom/Polygon.js';
|
|
||||||
import WebGLPolygonReplay from '../../../../../src/ol/render/webgl/PolygonReplay.js';
|
|
||||||
import {fragment, vertex} from '../../../../../src/ol/render/webgl/polygonreplay/defaultshader.js';
|
|
||||||
import Locations from '../../../../../src/ol/render/webgl/polygonreplay/defaultshader/Locations.js';
|
|
||||||
import LinkedList from '../../../../../src/ol/structs/LinkedList.js';
|
|
||||||
import RBush from '../../../../../src/ol/structs/RBush.js';
|
|
||||||
import Fill from '../../../../../src/ol/style/Fill.js';
|
|
||||||
import Stroke from '../../../../../src/ol/style/Stroke.js';
|
|
||||||
|
|
||||||
describe('ol.render.webgl.PolygonReplay', function() {
|
|
||||||
let replay;
|
|
||||||
|
|
||||||
const fillStyle = new Fill({
|
|
||||||
color: [0, 0, 255, 0.5]
|
|
||||||
});
|
|
||||||
const strokeStyle = new Stroke({
|
|
||||||
color: [0, 255, 0, 0.4]
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
const tolerance = 0.1;
|
|
||||||
const maxExtent = [-10000, -20000, 10000, 20000];
|
|
||||||
replay = new WebGLPolygonReplay(tolerance, maxExtent);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawPolygon', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets the buffer data', function() {
|
|
||||||
const polygon1 = new Polygon(
|
|
||||||
[[[1000, 2000], [1200, 2000], [1200, 3000]]]
|
|
||||||
);
|
|
||||||
replay.drawPolygon(polygon1, null);
|
|
||||||
expect(replay.vertices).to.have.length(8);
|
|
||||||
expect(replay.indices).to.have.length(3);
|
|
||||||
|
|
||||||
expect(replay.vertices).to.eql([
|
|
||||||
1000, 2000, 1200, 3000, 1200, 2000, 1000, 2000]);
|
|
||||||
expect(replay.indices).to.eql([2, 0, 1]);
|
|
||||||
|
|
||||||
const polygon2 = new Polygon(
|
|
||||||
[[[4000, 2000], [4200, 2000], [4200, 3000]]]
|
|
||||||
);
|
|
||||||
replay.drawPolygon(polygon2, null);
|
|
||||||
expect(replay.vertices).to.have.length(16);
|
|
||||||
expect(replay.indices).to.have.length(6);
|
|
||||||
|
|
||||||
expect(replay.vertices).to.eql([
|
|
||||||
1000, 2000, 1200, 3000, 1200, 2000, 1000, 2000,
|
|
||||||
4000, 2000, 4200, 3000, 4200, 2000, 4000, 2000
|
|
||||||
]);
|
|
||||||
expect(replay.indices).to.eql([2, 0, 1, 6, 4, 5]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawMultiPolygon', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets the buffer data', function() {
|
|
||||||
const multiPolygon = new MultiPolygon([
|
|
||||||
[[[1000, 2000], [1200, 2000], [1200, 3000]]],
|
|
||||||
[[[4000, 2000], [4200, 2000], [4200, 3000]]]
|
|
||||||
]);
|
|
||||||
replay.drawMultiPolygon(multiPolygon, null);
|
|
||||||
expect(replay.vertices).to.have.length(16);
|
|
||||||
expect(replay.indices).to.have.length(6);
|
|
||||||
|
|
||||||
expect(replay.vertices).to.eql([
|
|
||||||
1000, 2000, 1200, 3000, 1200, 2000, 1000, 2000,
|
|
||||||
4000, 2000, 4200, 3000, 4200, 2000, 4000, 2000
|
|
||||||
]);
|
|
||||||
expect(replay.indices).to.eql([2, 0, 1, 6, 4, 5]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('triangulating functions', function() {
|
|
||||||
let list, rtree;
|
|
||||||
beforeEach(function() {
|
|
||||||
list = new LinkedList();
|
|
||||||
rtree = new RBush();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#createPoint_', function() {
|
|
||||||
it('creates a WebGL polygon vertex', function() {
|
|
||||||
const p = replay.createPoint_(1, 1, 1);
|
|
||||||
expect(p.x).to.be(1);
|
|
||||||
expect(p.y).to.be(1);
|
|
||||||
expect(p.i).to.be(1);
|
|
||||||
expect(p.reflex).to.be(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds the point to the vertex array', function() {
|
|
||||||
replay.createPoint_(1, 1, 1);
|
|
||||||
expect(replay.vertices.length).to.be(2);
|
|
||||||
expect(replay.vertices[0]).to.be(1);
|
|
||||||
expect(replay.vertices[1]).to.be(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#insertItem_', function() {
|
|
||||||
let p0, p1;
|
|
||||||
beforeEach(function() {
|
|
||||||
p0 = replay.createPoint_(1, 1, 1);
|
|
||||||
p1 = replay.createPoint_(2, 2, 2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('creates a WebGL polygon segment', function() {
|
|
||||||
const seg = replay.insertItem_(p0, p1, list, rtree);
|
|
||||||
expect(seg.p0).to.be(p0);
|
|
||||||
expect(seg.p1).to.be(p1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('inserts the segment into the provided linked list', function() {
|
|
||||||
const seg = replay.insertItem_(p0, p1, list, rtree);
|
|
||||||
expect(list.head_.data).to.be(seg);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('inserts the segment into the R-Tree, if provided', function() {
|
|
||||||
replay.insertItem_(p0, p1, list);
|
|
||||||
expect(rtree.isEmpty()).to.be(true);
|
|
||||||
replay.insertItem_(p0, p1, list, rtree);
|
|
||||||
expect(rtree.isEmpty()).to.be(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#removeItem_', function() {
|
|
||||||
let s0, s1;
|
|
||||||
beforeEach(function() {
|
|
||||||
const p = replay.createPoint_(2, 2, 2);
|
|
||||||
s0 = replay.insertItem_(replay.createPoint_(1, 1, 1),
|
|
||||||
p, list, rtree);
|
|
||||||
s1 = replay.insertItem_(p,
|
|
||||||
replay.createPoint_(5, 2, 3), list, rtree);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('removes the current item', function() {
|
|
||||||
replay.removeItem_(s0, s1, list, rtree);
|
|
||||||
expect(list.head_.data).not.to.be(s1);
|
|
||||||
expect(rtree.getAll().length).to.be(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('updates the preceding segment', function() {
|
|
||||||
const dataExtent = rtree.getExtent();
|
|
||||||
replay.removeItem_(s0, s1, list, rtree);
|
|
||||||
expect(s0.p1).to.be(s1.p1);
|
|
||||||
expect(rtree.getExtent()).to.eql(dataExtent);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#getPointsInTriangle_', function() {
|
|
||||||
let p0, p1, p2, p3;
|
|
||||||
beforeEach(function() {
|
|
||||||
p0 = replay.createPoint_(2, 0, 0);
|
|
||||||
p1 = replay.createPoint_(0, 5, 1);
|
|
||||||
p2 = replay.createPoint_(2, 3, 2);
|
|
||||||
p3 = replay.createPoint_(4, 5, 3);
|
|
||||||
replay.insertItem_(p0, p1, list, rtree);
|
|
||||||
replay.insertItem_(p1, p2, list, rtree);
|
|
||||||
replay.insertItem_(p2, p3, list, rtree);
|
|
||||||
replay.insertItem_(p3, p0, list, rtree);
|
|
||||||
replay.classifyPoints_(list, rtree, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('gets every point in a triangle', function() {
|
|
||||||
const points = replay.getPointsInTriangle_({x: -3, y: 6}, {x: 7, y: 6},
|
|
||||||
{x: 2, y: 2}, rtree);
|
|
||||||
expect(points).to.eql([p1, p2, p3]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('gets only reflex points in a triangle', function() {
|
|
||||||
const points = replay.getPointsInTriangle_({x: -3, y: 6}, {x: 7, y: 6},
|
|
||||||
{x: 2, y: 2}, rtree, true);
|
|
||||||
expect(points).to.eql([p2]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#getIntersections_', function() {
|
|
||||||
let p0, p1, p2, p3, s0, s1, s2, s3;
|
|
||||||
beforeEach(function() {
|
|
||||||
p0 = replay.createPoint_(2, 0, 0);
|
|
||||||
p1 = replay.createPoint_(0, 5, 1);
|
|
||||||
p2 = replay.createPoint_(2, 3, 2);
|
|
||||||
p3 = replay.createPoint_(4, 5, 3);
|
|
||||||
s0 = replay.insertItem_(p0, p1, list, rtree);
|
|
||||||
s1 = replay.insertItem_(p1, p2, list, rtree);
|
|
||||||
s2 = replay.insertItem_(p2, p3, list, rtree);
|
|
||||||
s3 = replay.insertItem_(p3, p0, list, rtree);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('gets intersecting, but non touching segments', function() {
|
|
||||||
const segments = replay.getIntersections_({p0: {x: 0, y: 3}, p1: {x: 4, y: 5}},
|
|
||||||
rtree);
|
|
||||||
expect(segments).to.eql([s0, s1]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('gets intersecting and touching segments', function() {
|
|
||||||
const segments = replay.getIntersections_({p0: {x: 0, y: 3}, p1: {x: 4, y: 5}},
|
|
||||||
rtree, true);
|
|
||||||
expect(segments).to.eql([s0, s1, s2, s3]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#calculateIntersection_', function() {
|
|
||||||
const p0 = {x: 0, y: 0};
|
|
||||||
const p1 = {x: 4, y: 4};
|
|
||||||
const p2 = {x: 0, y: 4};
|
|
||||||
const p3 = {x: 4, y: 0};
|
|
||||||
|
|
||||||
it('calculates the intersection point of two intersecting segments', function() {
|
|
||||||
const i = replay.calculateIntersection_(p0, p1, p2, p3);
|
|
||||||
const t = replay.calculateIntersection_(p0, p1, p1, p2);
|
|
||||||
expect(i).to.eql([2, 2]);
|
|
||||||
expect(t).to.be(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calculates the intersection point of two touching segments', function() {
|
|
||||||
const t = replay.calculateIntersection_(p0, p1, p1, p2, true);
|
|
||||||
expect(t).to.eql([4, 4]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#diagonalIsInside_', function() {
|
|
||||||
let p0, p1, p2, p3;
|
|
||||||
beforeEach(function() {
|
|
||||||
p0 = replay.createPoint_(2, 0, 0);
|
|
||||||
p1 = replay.createPoint_(0, 5, 1);
|
|
||||||
p2 = replay.createPoint_(2, 3, 2);
|
|
||||||
p3 = replay.createPoint_(4, 5, 3);
|
|
||||||
replay.insertItem_(p0, p1, list, rtree);
|
|
||||||
replay.insertItem_(p1, p2, list, rtree);
|
|
||||||
replay.insertItem_(p2, p3, list, rtree);
|
|
||||||
replay.insertItem_(p3, p0, list, rtree);
|
|
||||||
replay.classifyPoints_(list, rtree, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('identifies if diagonal is inside the polygon', function() {
|
|
||||||
const inside = replay.diagonalIsInside_(p1, p2, p3, p0, p1);
|
|
||||||
expect(inside).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('identifies if diagonal is outside the polygon', function() {
|
|
||||||
const inside = replay.diagonalIsInside_(p0, p1, p2, p3, p0);
|
|
||||||
expect(inside).to.be(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#classifyPoints_', function() {
|
|
||||||
let p0, p1, p2, p3;
|
|
||||||
beforeEach(function() {
|
|
||||||
p0 = replay.createPoint_(2, 0, 0);
|
|
||||||
p1 = replay.createPoint_(0, 5, 1);
|
|
||||||
p2 = replay.createPoint_(2, 3, 2);
|
|
||||||
p3 = replay.createPoint_(4, 5, 3);
|
|
||||||
replay.insertItem_(p0, p1, list, rtree);
|
|
||||||
replay.insertItem_(p1, p2, list, rtree);
|
|
||||||
replay.insertItem_(p2, p3, list, rtree);
|
|
||||||
replay.insertItem_(p3, p0, list, rtree);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('classifies the points of clockwise polygons', function() {
|
|
||||||
replay.classifyPoints_(list, rtree, false);
|
|
||||||
expect(p0.reflex).to.be(false);
|
|
||||||
expect(p1.reflex).to.be(false);
|
|
||||||
expect(p2.reflex).to.be(true);
|
|
||||||
expect(p3.reflex).to.be(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('classifies the points of counter-clockwise polygons', function() {
|
|
||||||
replay.classifyPoints_(list, rtree, true);
|
|
||||||
expect(p0.reflex).to.be(true);
|
|
||||||
expect(p1.reflex).to.be(true);
|
|
||||||
expect(p2.reflex).to.be(false);
|
|
||||||
expect(p3.reflex).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('removes collinear points', function() {
|
|
||||||
replay.insertItem_(p3, p0, list, rtree);
|
|
||||||
replay.classifyPoints_(list, rtree, false);
|
|
||||||
expect(list.getLength()).to.be(4);
|
|
||||||
expect(rtree.getAll().length).to.be(4);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#isSimple_', function() {
|
|
||||||
let p0, p1, p2, p3;
|
|
||||||
beforeEach(function() {
|
|
||||||
p0 = replay.createPoint_(2, 0, 0);
|
|
||||||
p1 = replay.createPoint_(0, 5, 1);
|
|
||||||
p2 = replay.createPoint_(2, 3, 2);
|
|
||||||
p3 = replay.createPoint_(4, 5, 3);
|
|
||||||
replay.insertItem_(p0, p1, list, rtree);
|
|
||||||
replay.insertItem_(p1, p2, list, rtree);
|
|
||||||
replay.insertItem_(p2, p3, list, rtree);
|
|
||||||
replay.insertItem_(p3, p0, list, rtree);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('identifies simple polygons', function() {
|
|
||||||
const simple = replay.isSimple_(list, rtree);
|
|
||||||
expect(simple).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('identifies self-intersecting polygons', function() {
|
|
||||||
const p4 = replay.createPoint_(2, 5, 4);
|
|
||||||
const p5 = replay.createPoint_(4, 2, 5);
|
|
||||||
replay.insertItem_(p0, p4, list, rtree);
|
|
||||||
replay.insertItem_(p4, p5, list, rtree);
|
|
||||||
replay.insertItem_(p5, p0, list, rtree);
|
|
||||||
const simple = replay.isSimple_(list, rtree);
|
|
||||||
expect(simple).to.be(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#setUpProgram', function() {
|
|
||||||
let context, gl;
|
|
||||||
beforeEach(function() {
|
|
||||||
context = {
|
|
||||||
getProgram: function() {},
|
|
||||||
useProgram: function() {}
|
|
||||||
};
|
|
||||||
gl = {
|
|
||||||
enableVertexAttribArray: function() {},
|
|
||||||
vertexAttribPointer: function() {},
|
|
||||||
uniform1f: function() {},
|
|
||||||
uniform2fv: function() {},
|
|
||||||
getUniformLocation: function() {},
|
|
||||||
getAttribLocation: function() {}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the locations used by the shaders', function() {
|
|
||||||
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(locations).to.be.a(Locations);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('gets and compiles the shaders', function() {
|
|
||||||
sinon.spy(context, 'getProgram');
|
|
||||||
sinon.spy(context, 'useProgram');
|
|
||||||
|
|
||||||
replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(context.getProgram.calledWithExactly(fragment, vertex)).to.be(true);
|
|
||||||
expect(context.useProgram.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('initializes the attrib pointers', function() {
|
|
||||||
sinon.spy(gl, 'getAttribLocation');
|
|
||||||
sinon.spy(gl, 'vertexAttribPointer');
|
|
||||||
sinon.spy(gl, 'enableVertexAttribArray');
|
|
||||||
|
|
||||||
replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(gl.vertexAttribPointer.callCount).to.be(gl.getAttribLocation.callCount);
|
|
||||||
expect(gl.enableVertexAttribArray.callCount).to.be(
|
|
||||||
gl.getAttribLocation.callCount);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#shutDownProgram', function() {
|
|
||||||
let context, gl;
|
|
||||||
beforeEach(function() {
|
|
||||||
context = {
|
|
||||||
getProgram: function() {},
|
|
||||||
useProgram: function() {}
|
|
||||||
};
|
|
||||||
gl = {
|
|
||||||
enableVertexAttribArray: function() {},
|
|
||||||
disableVertexAttribArray: function() {},
|
|
||||||
vertexAttribPointer: function() {},
|
|
||||||
uniform1f: function() {},
|
|
||||||
uniform2fv: function() {},
|
|
||||||
getUniformLocation: function() {},
|
|
||||||
getAttribLocation: function() {}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('disables the attrib pointers', function() {
|
|
||||||
sinon.spy(gl, 'getAttribLocation');
|
|
||||||
sinon.spy(gl, 'disableVertexAttribArray');
|
|
||||||
|
|
||||||
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
replay.shutDownProgram(gl, locations);
|
|
||||||
expect(gl.disableVertexAttribArray.callCount).to.be(
|
|
||||||
gl.getAttribLocation.callCount);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawReplay', function() {
|
|
||||||
let gl, context;
|
|
||||||
const feature1 = new Feature({
|
|
||||||
geometry: new Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]])
|
|
||||||
});
|
|
||||||
const feature2 = new Feature({
|
|
||||||
geometry: new Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]])
|
|
||||||
});
|
|
||||||
const feature3 = new Feature({
|
|
||||||
geometry: new Polygon([[[0, 0], [500, 500], [500, 0], [0, 0]]])
|
|
||||||
});
|
|
||||||
beforeEach(function() {
|
|
||||||
gl = {
|
|
||||||
getParameter: function() {},
|
|
||||||
enable: function() {},
|
|
||||||
disable: function() {},
|
|
||||||
depthMask: function() {},
|
|
||||||
depthFunc: function() {},
|
|
||||||
clear: function() {}
|
|
||||||
};
|
|
||||||
context = {};
|
|
||||||
replay.setFillStyle_ = function() {};
|
|
||||||
replay.drawElements = function() {};
|
|
||||||
sinon.spy(replay, 'setFillStyle_');
|
|
||||||
sinon.spy(replay, 'drawElements');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws the elements in a single call if they have the same style', function() {
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawPolygon(feature1.getGeometry(), feature1);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawPolygon(feature2.getGeometry(), feature2);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawPolygon(feature3.getGeometry(), feature3);
|
|
||||||
replay.startIndices.push(replay.indices.length);
|
|
||||||
|
|
||||||
replay.drawReplay(gl, context, {}, false);
|
|
||||||
expect(replay.setFillStyle_.calledOnce).to.be(true);
|
|
||||||
expect(replay.drawElements.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('draws the elements in batches if there are multiple fill styles', function() {
|
|
||||||
const fillStyle2 = new Fill({
|
|
||||||
color: [0, 255, 0, 1]
|
|
||||||
});
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawPolygon(feature1.getGeometry(), feature1);
|
|
||||||
replay.setFillStrokeStyle(fillStyle2, strokeStyle);
|
|
||||||
replay.drawPolygon(feature2.getGeometry(), feature2);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawPolygon(feature3.getGeometry(), feature3);
|
|
||||||
replay.startIndices.push(replay.indices.length);
|
|
||||||
|
|
||||||
replay.drawReplay(gl, context, {}, false);
|
|
||||||
expect(replay.setFillStyle_.calledThrice).to.be(true);
|
|
||||||
expect(replay.drawElements.calledThrice).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can skip elements if needed', function() {
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawPolygon(feature1.getGeometry(), feature1);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawPolygon(feature2.getGeometry(), feature2);
|
|
||||||
replay.setFillStrokeStyle(fillStyle, strokeStyle);
|
|
||||||
replay.drawPolygon(feature3.getGeometry(), feature3);
|
|
||||||
replay.startIndices.push(replay.indices.length);
|
|
||||||
const skippedFeatHash = {};
|
|
||||||
skippedFeatHash[getUid(feature2)] = true;
|
|
||||||
|
|
||||||
replay.drawReplay(gl, context, skippedFeatHash, false);
|
|
||||||
expect(replay.setFillStyle_.calledOnce).to.be(true);
|
|
||||||
expect(replay.drawElements.calledTwice).to.be(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,318 +0,0 @@
|
|||||||
import {createCanvasContext2D} from '../../../../../src/ol/dom.js';
|
|
||||||
import Point from '../../../../../src/ol/geom/Point.js';
|
|
||||||
import WebGLTextReplay from '../../../../../src/ol/render/webgl/TextReplay.js';
|
|
||||||
import Fill from '../../../../../src/ol/style/Fill.js';
|
|
||||||
import Stroke from '../../../../../src/ol/style/Stroke.js';
|
|
||||||
import Text from '../../../../../src/ol/style/Text.js';
|
|
||||||
|
|
||||||
describe('ol.render.webgl.TextReplay', function() {
|
|
||||||
let replay;
|
|
||||||
|
|
||||||
const createTextStyle = function(fillStyle, strokeStyle, text) {
|
|
||||||
const textStyle = new Text({
|
|
||||||
rotateWithView: true,
|
|
||||||
rotation: 1.5,
|
|
||||||
scale: 2,
|
|
||||||
textAlign: 'left',
|
|
||||||
textBaseline: 'top',
|
|
||||||
font: '12px Arial',
|
|
||||||
offsetX: 10,
|
|
||||||
offsetY: 10,
|
|
||||||
text: text,
|
|
||||||
fill: fillStyle,
|
|
||||||
stroke: strokeStyle
|
|
||||||
});
|
|
||||||
return textStyle;
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
const tolerance = 0.1;
|
|
||||||
const maxExtent = [-10000, -20000, 10000, 20000];
|
|
||||||
replay = new WebGLTextReplay(tolerance, maxExtent);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#setTextStyle', function() {
|
|
||||||
|
|
||||||
let textStyle1, textStyle2, textStyle3, textStyle4;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
textStyle1 = createTextStyle(
|
|
||||||
new Fill({
|
|
||||||
color: [0, 0, 0, 1]
|
|
||||||
}),
|
|
||||||
new Stroke({
|
|
||||||
width: 1,
|
|
||||||
color: [0, 0, 0, 1],
|
|
||||||
lineCap: 'butt',
|
|
||||||
lineJoin: 'bevel',
|
|
||||||
lineDash: [5, 5],
|
|
||||||
lineDashOffset: 15,
|
|
||||||
miterLimit: 2
|
|
||||||
}),
|
|
||||||
'someText');
|
|
||||||
textStyle2 = createTextStyle(
|
|
||||||
new Fill({
|
|
||||||
color: [255, 255, 255, 1]
|
|
||||||
}),
|
|
||||||
new Stroke({
|
|
||||||
width: 1,
|
|
||||||
color: [255, 255, 255, 1]
|
|
||||||
}),
|
|
||||||
'someText'
|
|
||||||
);
|
|
||||||
textStyle3 = createTextStyle(null, null, 'someText');
|
|
||||||
textStyle4 = createTextStyle(
|
|
||||||
new Fill({
|
|
||||||
color: [0, 0, 0, 1]
|
|
||||||
}),
|
|
||||||
new Stroke({
|
|
||||||
width: 1,
|
|
||||||
color: [0, 0, 0, 1]
|
|
||||||
}),
|
|
||||||
''
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('set expected states', function() {
|
|
||||||
replay.setTextStyle(textStyle1);
|
|
||||||
expect(replay.opacity).to.be(1);
|
|
||||||
expect(replay.rotation).to.be(1.5);
|
|
||||||
expect(replay.rotateWithView).to.be(true);
|
|
||||||
expect(replay.scale).to.be(1);
|
|
||||||
expect(replay.offsetX_).to.be(10);
|
|
||||||
expect(replay.offsetY_).to.be(10);
|
|
||||||
expect(replay.text_).to.be('someText');
|
|
||||||
expect(Object.keys(replay.atlases_)).to.have.length(1);
|
|
||||||
|
|
||||||
expect(replay.state_.fillColor).to.be('rgba(0,0,0,1)');
|
|
||||||
expect(replay.state_.strokeColor).to.be('rgba(0,0,0,1)');
|
|
||||||
expect(replay.state_.scale).to.be(2);
|
|
||||||
expect(replay.state_.lineWidth).to.be(1);
|
|
||||||
expect(replay.state_.lineJoin).to.be('bevel');
|
|
||||||
expect(replay.state_.lineCap).to.be('butt');
|
|
||||||
expect(replay.state_.lineDash).to.eql([5, 5]);
|
|
||||||
expect(replay.state_.lineDashOffset).to.be(15);
|
|
||||||
expect(replay.state_.miterLimit).to.be(2);
|
|
||||||
expect(replay.state_.font).to.be('12px Arial');
|
|
||||||
|
|
||||||
replay.setTextStyle(textStyle2);
|
|
||||||
expect(Object.keys(replay.atlases_)).to.have.length(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not create an atlas, if an empty text is supplied', function() {
|
|
||||||
replay.setTextStyle(textStyle4);
|
|
||||||
expect(replay.text_).to.be('');
|
|
||||||
expect(Object.keys(replay.atlases_)).to.have.length(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not create an atlas, if both fill and stroke styles are missing', function() {
|
|
||||||
replay.setTextStyle(textStyle3);
|
|
||||||
expect(replay.text_).to.be('');
|
|
||||||
expect(Object.keys(replay.atlases_)).to.have.length(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#drawText', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
const textStyle = createTextStyle(
|
|
||||||
new Fill({
|
|
||||||
color: [0, 0, 0, 1]
|
|
||||||
}),
|
|
||||||
null, 'someText');
|
|
||||||
replay.setTextStyle(textStyle);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets the buffer data', function() {
|
|
||||||
let point;
|
|
||||||
|
|
||||||
point = [1000, 2000];
|
|
||||||
replay.drawText(new Point(point), null);
|
|
||||||
expect(replay.vertices).to.have.length(256);
|
|
||||||
expect(replay.indices).to.have.length(48);
|
|
||||||
|
|
||||||
point = [2000, 3000];
|
|
||||||
replay.drawText(new Point(point), null);
|
|
||||||
expect(replay.vertices).to.have.length(512);
|
|
||||||
expect(replay.indices).to.have.length(96);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sets part of its state during drawing', function() {
|
|
||||||
const point = [1000, 2000];
|
|
||||||
replay.drawText(new Point(point), null);
|
|
||||||
|
|
||||||
const height = replay.currAtlas_.height;
|
|
||||||
const widths = replay.currAtlas_.width;
|
|
||||||
const width = widths.t;
|
|
||||||
const widthX = widths.s + widths.o + widths.m + widths.e + widths.T +
|
|
||||||
widths.e + widths.x;
|
|
||||||
const charInfo = replay.currAtlas_.atlas.getInfo('t');
|
|
||||||
|
|
||||||
expect(replay.height).to.be(height);
|
|
||||||
expect(replay.width).to.be(width);
|
|
||||||
expect(replay.originX).to.be(charInfo.offsetX);
|
|
||||||
expect(replay.originY).to.be(charInfo.offsetY);
|
|
||||||
expect(replay.imageHeight).to.be(charInfo.image.height);
|
|
||||||
expect(replay.imageWidth).to.be(charInfo.image.width);
|
|
||||||
expect(replay.anchorX).to.be(-widthX - 10);
|
|
||||||
expect(replay.anchorY).to.be(-10);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not draw if text is empty', function() {
|
|
||||||
replay.text_ = '';
|
|
||||||
|
|
||||||
const point = [1000, 2000];
|
|
||||||
replay.drawText(new Point(point), null);
|
|
||||||
expect(replay.vertices).to.have.length(0);
|
|
||||||
expect(replay.indices).to.have.length(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#addCharToAtlas_', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
const textStyle = createTextStyle(
|
|
||||||
new Fill({
|
|
||||||
color: [0, 0, 0, 1]
|
|
||||||
}),
|
|
||||||
null, 'someText');
|
|
||||||
replay.setTextStyle(textStyle);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds a single character to the current atlas', function() {
|
|
||||||
const glyphAtlas = replay.currAtlas_.atlas;
|
|
||||||
let info;
|
|
||||||
|
|
||||||
replay.addCharToAtlas_('someText');
|
|
||||||
info = glyphAtlas.getInfo('someText');
|
|
||||||
expect(info).to.be(null);
|
|
||||||
|
|
||||||
replay.addCharToAtlas_('e');
|
|
||||||
replay.addCharToAtlas_('x');
|
|
||||||
info = glyphAtlas.getInfo('e');
|
|
||||||
expect(info).not.to.be(null);
|
|
||||||
info = glyphAtlas.getInfo('x');
|
|
||||||
expect(info).not.to.be(null);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('keeps the atlas and the width dictionary synced', function() {
|
|
||||||
const glyphAtlas = replay.currAtlas_;
|
|
||||||
|
|
||||||
replay.addCharToAtlas_('e');
|
|
||||||
replay.addCharToAtlas_('x');
|
|
||||||
expect(Object.keys(glyphAtlas.width)).to.have.length(2);
|
|
||||||
|
|
||||||
replay.addCharToAtlas_('someText');
|
|
||||||
expect(Object.keys(glyphAtlas.width)).to.have.length(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#getTextSize_', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
const textStyle = createTextStyle(
|
|
||||||
new Fill({
|
|
||||||
color: [0, 0, 0, 1]
|
|
||||||
}),
|
|
||||||
null, 'someText');
|
|
||||||
textStyle.setScale(1);
|
|
||||||
replay.setTextStyle(textStyle);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds missing characters to the current atlas', function() {
|
|
||||||
const glyphAtlas = replay.currAtlas_;
|
|
||||||
let info;
|
|
||||||
|
|
||||||
expect(Object.keys(glyphAtlas.width)).to.have.length(0);
|
|
||||||
replay.getTextSize_(['someText']);
|
|
||||||
expect(Object.keys(glyphAtlas.width)).to.have.length(7);
|
|
||||||
info = glyphAtlas.atlas.getInfo('s');
|
|
||||||
expect(info).not.to.be(null);
|
|
||||||
info = glyphAtlas.atlas.getInfo('o');
|
|
||||||
expect(info).not.to.be(null);
|
|
||||||
info = glyphAtlas.atlas.getInfo('m');
|
|
||||||
expect(info).not.to.be(null);
|
|
||||||
info = glyphAtlas.atlas.getInfo('e');
|
|
||||||
expect(info).not.to.be(null);
|
|
||||||
info = glyphAtlas.atlas.getInfo('T');
|
|
||||||
expect(info).not.to.be(null);
|
|
||||||
info = glyphAtlas.atlas.getInfo('x');
|
|
||||||
expect(info).not.to.be(null);
|
|
||||||
info = glyphAtlas.atlas.getInfo('t');
|
|
||||||
expect(info).not.to.be(null);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the size of the label\'s bounding box in pixels', function() {
|
|
||||||
let size;
|
|
||||||
const mCtx = createCanvasContext2D(0, 0);
|
|
||||||
mCtx.font = '12px Arial';
|
|
||||||
const width = mCtx.measureText('someText').width;
|
|
||||||
const width2 = mCtx.measureText('anEvenLongerLine').width;
|
|
||||||
const height = Math.ceil(mCtx.measureText('M').width * 1.5);
|
|
||||||
|
|
||||||
size = replay.getTextSize_(['someText']);
|
|
||||||
expect(size[0]).to.be.within(width, width + 8);
|
|
||||||
expect(size[1]).to.be(height);
|
|
||||||
|
|
||||||
size = replay.getTextSize_(['someText', 'anEvenLongerLine']);
|
|
||||||
expect(size[0]).to.be.within(width2, width2 + 16);
|
|
||||||
expect(size[1]).to.be(height * 2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#getAtlas_', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
const textStyle = createTextStyle(
|
|
||||||
new Fill({
|
|
||||||
color: [0, 0, 0, 1]
|
|
||||||
}),
|
|
||||||
null, 'someText');
|
|
||||||
replay.setTextStyle(textStyle);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the appropriate atlas for the current state', function() {
|
|
||||||
const atlas = replay.currAtlas_;
|
|
||||||
const state = replay.state_;
|
|
||||||
|
|
||||||
expect(Object.keys(replay.atlases_)).to.have.length(1);
|
|
||||||
expect(replay.getAtlas_(state)).to.be(atlas);
|
|
||||||
expect(Object.keys(replay.atlases_)).to.have.length(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('creates a new atlas if it cannot find the one for the current state', function() {
|
|
||||||
const atlas = replay.currAtlas_;
|
|
||||||
const state = replay.state_;
|
|
||||||
state.lineWidth = 50;
|
|
||||||
|
|
||||||
expect(Object.keys(replay.atlases_)).to.have.length(1);
|
|
||||||
expect(replay.getAtlas_(state)).not.to.be(atlas);
|
|
||||||
expect(Object.keys(replay.atlases_)).to.have.length(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#getTextures', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
replay.textures_ = [1, 2];
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the textures', function() {
|
|
||||||
const textures = replay.getTextures();
|
|
||||||
|
|
||||||
expect(textures).to.have.length(2);
|
|
||||||
expect(textures[0]).to.be(1);
|
|
||||||
expect(textures[1]).to.be(2);
|
|
||||||
expect(textures).to.eql(replay.getTextures(true));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#getHitDetectionTextures', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
replay.textures_ = [1, 2];
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the textures', function() {
|
|
||||||
const textures = replay.getHitDetectionTextures();
|
|
||||||
|
|
||||||
expect(textures).to.have.length(2);
|
|
||||||
expect(textures[0]).to.be(1);
|
|
||||||
expect(textures[1]).to.be(2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
import WebGLTextureReplay from '../../../../../src/ol/render/webgl/TextureReplay.js';
|
|
||||||
import {fragment, vertex} from '../../../../../src/ol/render/webgl/texturereplay/defaultshader.js';
|
|
||||||
import Locations from '../../../../../src/ol/render/webgl/texturereplay/defaultshader/Locations.js';
|
|
||||||
|
|
||||||
describe('ol.render.webgl.TextureReplay', function() {
|
|
||||||
let replay;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
const tolerance = 0.1;
|
|
||||||
const maxExtent = [-10000, -20000, 10000, 20000];
|
|
||||||
replay = new WebGLTextureReplay(tolerance, maxExtent);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#setUpProgram', function() {
|
|
||||||
let context, gl;
|
|
||||||
beforeEach(function() {
|
|
||||||
context = {
|
|
||||||
getProgram: function() {},
|
|
||||||
useProgram: function() {}
|
|
||||||
};
|
|
||||||
gl = {
|
|
||||||
enableVertexAttribArray: function() {},
|
|
||||||
vertexAttribPointer: function() {},
|
|
||||||
uniform1f: function() {},
|
|
||||||
uniform2fv: function() {},
|
|
||||||
getUniformLocation: function() {},
|
|
||||||
getAttribLocation: function() {}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the locations used by the shaders', function() {
|
|
||||||
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(locations).to.be.a(Locations);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('gets and compiles the shaders', function() {
|
|
||||||
sinon.spy(context, 'getProgram');
|
|
||||||
sinon.spy(context, 'useProgram');
|
|
||||||
|
|
||||||
replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(context.getProgram.calledWithExactly(fragment, vertex)).to.be(true);
|
|
||||||
expect(context.useProgram.calledOnce).to.be(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('initializes the attrib pointers', function() {
|
|
||||||
sinon.spy(gl, 'getAttribLocation');
|
|
||||||
sinon.spy(gl, 'vertexAttribPointer');
|
|
||||||
sinon.spy(gl, 'enableVertexAttribArray');
|
|
||||||
|
|
||||||
replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
expect(gl.vertexAttribPointer.callCount).to.be(gl.getAttribLocation.callCount);
|
|
||||||
expect(gl.enableVertexAttribArray.callCount).to.be(
|
|
||||||
gl.getAttribLocation.callCount);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('#shutDownProgram', function() {
|
|
||||||
let context, gl;
|
|
||||||
beforeEach(function() {
|
|
||||||
context = {
|
|
||||||
getProgram: function() {},
|
|
||||||
useProgram: function() {}
|
|
||||||
};
|
|
||||||
gl = {
|
|
||||||
enableVertexAttribArray: function() {},
|
|
||||||
disableVertexAttribArray: function() {},
|
|
||||||
vertexAttribPointer: function() {},
|
|
||||||
uniform1f: function() {},
|
|
||||||
uniform2fv: function() {},
|
|
||||||
getUniformLocation: function() {},
|
|
||||||
getAttribLocation: function() {}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('disables the attrib pointers', function() {
|
|
||||||
sinon.spy(gl, 'getAttribLocation');
|
|
||||||
sinon.spy(gl, 'disableVertexAttribArray');
|
|
||||||
|
|
||||||
const locations = replay.setUpProgram(gl, context, [2, 2], 1);
|
|
||||||
replay.shutDownProgram(gl, locations);
|
|
||||||
expect(gl.disableVertexAttribArray.callCount).to.be(
|
|
||||||
gl.getAttribLocation.callCount);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
import {apply as applyTransform} from '../../../../../src/ol/transform.js';
|
|
||||||
import Map from '../../../../../src/ol/Map.js';
|
|
||||||
import ImageLayer from '../../../../../src/ol/layer/Image.js';
|
|
||||||
import ImageSource from '../../../../../src/ol/source/Image.js';
|
|
||||||
import WebGLImageLayerRenderer from '../../../../../src/ol/renderer/webgl/ImageLayer.js';
|
|
||||||
|
|
||||||
|
|
||||||
describe('ol.renderer.webgl.ImageLayer', function() {
|
|
||||||
describe('updateProjectionMatrix_', function() {
|
|
||||||
let map;
|
|
||||||
let renderer;
|
|
||||||
let canvasWidth;
|
|
||||||
let canvasHeight;
|
|
||||||
let pixelRatio;
|
|
||||||
let viewResolution;
|
|
||||||
let viewRotation;
|
|
||||||
let viewCenter;
|
|
||||||
let imageExtent;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
|
||||||
map = new Map({
|
|
||||||
target: document.createElement('div')
|
|
||||||
});
|
|
||||||
const layer = new ImageLayer({
|
|
||||||
source: new ImageSource({
|
|
||||||
extent: [0, 0, 1, 1]
|
|
||||||
})
|
|
||||||
});
|
|
||||||
renderer = new WebGLImageLayerRenderer(map.renderer_, layer);
|
|
||||||
|
|
||||||
// input params
|
|
||||||
canvasWidth = 512;
|
|
||||||
canvasHeight = 256;
|
|
||||||
pixelRatio = 2;
|
|
||||||
viewResolution = 10;
|
|
||||||
viewRotation = 0;
|
|
||||||
viewCenter = [7680, 3840];
|
|
||||||
// view extent is 512O, 2560, 10240, 5120
|
|
||||||
|
|
||||||
// image size is 1024, 768
|
|
||||||
// image resolution is 10
|
|
||||||
imageExtent = [0, 0, 10240, 7680];
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
map.dispose();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('produces a correct matrix', function() {
|
|
||||||
|
|
||||||
renderer.updateProjectionMatrix_(canvasWidth, canvasHeight,
|
|
||||||
pixelRatio, viewCenter, viewResolution, viewRotation, imageExtent);
|
|
||||||
const matrix = renderer.getProjectionMatrix();
|
|
||||||
|
|
||||||
let output = applyTransform(matrix, [-1, -1]);
|
|
||||||
expect(output[0]).to.eql(-6);
|
|
||||||
expect(output[1]).to.eql(-6);
|
|
||||||
|
|
||||||
output = applyTransform(matrix, [1, -1]);
|
|
||||||
expect(output[0]).to.eql(2);
|
|
||||||
expect(output[1]).to.eql(-6);
|
|
||||||
|
|
||||||
output = applyTransform(matrix, [-1, 1]);
|
|
||||||
expect(output[0]).to.eql(-6);
|
|
||||||
expect(output[1]).to.eql(6);
|
|
||||||
|
|
||||||
output = applyTransform(matrix, [1, 1]);
|
|
||||||
expect(output[0]).to.eql(2);
|
|
||||||
expect(output[1]).to.eql(6);
|
|
||||||
|
|
||||||
output = applyTransform(matrix, [0, 0]);
|
|
||||||
expect(output[0]).to.eql(-2);
|
|
||||||
expect(output[1]).to.eql(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import _ol_webgl_Buffer_ from '../../../../src/ol/webgl/Buffer.js';
|
import WebGLArrayBuffer from '../../../../src/ol/webgl/Buffer';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.webgl.Buffer', function() {
|
describe('ol.webgl.Buffer', function() {
|
||||||
@@ -9,7 +9,7 @@ describe('ol.webgl.Buffer', function() {
|
|||||||
|
|
||||||
let b;
|
let b;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
b = new _ol_webgl_Buffer_();
|
b = new WebGLArrayBuffer();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('constructs an empty instance', function() {
|
it('constructs an empty instance', function() {
|
||||||
@@ -22,7 +22,7 @@ describe('ol.webgl.Buffer', function() {
|
|||||||
|
|
||||||
let b;
|
let b;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
b = new _ol_webgl_Buffer_([0, 1, 2, 3]);
|
b = new WebGLArrayBuffer([0, 1, 2, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('constructs a populated instance', function() {
|
it('constructs a populated instance', function() {
|
||||||
@@ -37,7 +37,7 @@ describe('ol.webgl.Buffer', function() {
|
|||||||
|
|
||||||
let b;
|
let b;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
b = new _ol_webgl_Buffer_();
|
b = new WebGLArrayBuffer();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getArray', function() {
|
describe('getArray', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user