|
|
@@ -283,8 +283,8 @@ ol.ext.SVGFilter.prototype.applyTo = function(img) {
|
|
|
var canvas = document.createElement('CANVAS');
|
|
|
canvas.width = img.naturalWidth || img.width;
|
|
|
canvas.height = img.naturalHeight || img.height;
|
|
|
- canvas.getContext('2d').filter = 'url(#'+this.getId()+')';
|
|
|
- canvas.getContext('2d').drawImage(img, 0, 0);
|
|
|
+ canvas.getContext('2d', {willReadFrequently: true}).filter = 'url(#'+this.getId()+')';
|
|
|
+ canvas.getContext('2d', {willReadFrequently: true}).drawImage(img, 0, 0);
|
|
|
return canvas;
|
|
|
};
|
|
|
|
|
|
@@ -1298,7 +1298,7 @@ ol.ext.imageLoader.pixelTransform = function(setPixel) {
|
|
|
var canvas = document.createElement('canvas');
|
|
|
canvas.width = size[0];
|
|
|
canvas.height = size[1];
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
ctx.drawImage(img, 0, 0);
|
|
|
var imgData = ctx.getImageData(0, 0, size[0], size[1]);
|
|
|
var pixels = imgData.data;
|
|
|
@@ -1387,7 +1387,7 @@ ol.ext.imageLoader.shadedRelief = function() {
|
|
|
src,
|
|
|
function(data, size) {
|
|
|
var canvas = document.createElement('canvas');
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
var width = canvas.width = size[0];
|
|
|
var height = canvas.height = size[1];
|
|
|
var imgData = ctx.getImageData(0, 0, width, height);
|
|
|
@@ -1455,7 +1455,7 @@ ol.ext.imageLoader.elevationMap = function(getPixelColor) {
|
|
|
src,
|
|
|
function(data, size) {
|
|
|
var canvas = document.createElement('canvas');
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
canvas.width = size[0];
|
|
|
canvas.height = size[1];
|
|
|
var imgData = ctx.getImageData(0, 0, size[0], size[1]);
|
|
|
@@ -3215,7 +3215,7 @@ ol.legend.Legend.prototype.refresh = function() {
|
|
|
var width = this.get('size')[0] + 2 * margin;
|
|
|
var height = this.get('lineHeight') || this.get('size')[1] + 2 * margin;
|
|
|
var canvas = this.getCanvas();
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
ctx.textAlign = 'left';
|
|
|
ctx.textBaseline = 'middle';
|
|
|
var ratio = ol.has.DEVICE_PIXEL_RATIO;
|
|
|
@@ -3330,7 +3330,7 @@ ol.legend.Legend.getLegendImage = function(item, canvas, row) {
|
|
|
canvas.width = width * ratio;
|
|
|
canvas.height = height * ratio;
|
|
|
}
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
ctx.save();
|
|
|
var vectorContext = ol.render.toContext(ctx, { pixelRatio: ratio });
|
|
|
var typeGeom = item.typeGeom;
|
|
|
@@ -3537,7 +3537,7 @@ ol.control.CanvasBase.prototype.getContext = function(e) {
|
|
|
var ctx = e.context;
|
|
|
if (!ctx && this.getMap()) {
|
|
|
var c = this.getMap().getViewport().getElementsByClassName('ol-fixedoverlay')[0];
|
|
|
- ctx = c ? c.getContext('2d') : null;
|
|
|
+ ctx = c ? c.getContext('2d', {willReadFrequently: true}) : null;
|
|
|
}
|
|
|
return ctx;
|
|
|
};
|
|
|
@@ -9011,7 +9011,7 @@ ol.control.Imageline.prototype._drawLink = function(e) {
|
|
|
if (!this.get('linkColor') | this.isCollapsed()) return;
|
|
|
var map = this.getMap();
|
|
|
if (map && this._select && this._select.elt) {
|
|
|
- var ctx = e.context || ol.ext.getMapCanvas(this.getMap()).getContext('2d');
|
|
|
+ var ctx = e.context || ol.ext.getMapCanvas(this.getMap()).getContext('2d', {willReadFrequently: true});
|
|
|
var ratio = e.frameState.pixelRatio;
|
|
|
var pt = [
|
|
|
this._select.elt.offsetLeft
|
|
|
@@ -10830,13 +10830,13 @@ ol.control.Print.prototype._getCanvas = function(event, imageType, canvas) {
|
|
|
var size = this.getMap().getSize();
|
|
|
canvas.width = size[0];
|
|
|
canvas.height = size[1];
|
|
|
- ctx = canvas.getContext('2d');
|
|
|
+ ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
if (/jp.*g$/.test(imageType)) {
|
|
|
ctx.fillStyle = this.get('bgColor') || 'white';
|
|
|
ctx.fillRect(0,0,canvas.width,canvas.height);
|
|
|
}
|
|
|
} else {
|
|
|
- ctx = canvas.getContext('2d');
|
|
|
+ ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
}
|
|
|
// ol6+ : create canvas using layer canvas
|
|
|
this.getMap().getViewport().querySelectorAll('.ol-layers canvas, canvas.ol-fixedoverlay').forEach(function(c) {
|
|
|
@@ -11314,7 +11314,7 @@ ol.control.PrintDialog = function(options) {
|
|
|
var canvas = document.createElement('CANVAS');
|
|
|
canvas.width = clegend.width;
|
|
|
canvas.height = clegend.height;
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
ctx.fillStyle = '#fff';
|
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
ctx.drawImage(clegend, 0, 0);
|
|
|
@@ -12316,7 +12316,7 @@ ol.control.Profil.prototype.getSelection = function(start, end) {
|
|
|
*/
|
|
|
ol.control.Profil.prototype._drawGraph = function(t, style) {
|
|
|
if (!t.length) return;
|
|
|
- var ctx = this.canvas_.getContext('2d');
|
|
|
+ var ctx = this.canvas_.getContext('2d', {willReadFrequently: true});
|
|
|
var scx = this.scale_[0];
|
|
|
var scy = this.scale_[1];
|
|
|
var dy = this.dy_;
|
|
|
@@ -12417,7 +12417,7 @@ ol.control.Profil.prototype.setGeometry = function(g, options) {
|
|
|
*/
|
|
|
ol.control.Profil.prototype.refresh = function() {
|
|
|
var canvas = this.canvas_;
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
var w = canvas.width;
|
|
|
var h = canvas.height;
|
|
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
|
@@ -19147,7 +19147,7 @@ ol.filter.Colorize.prototype.postcompose = function(e) {
|
|
|
c2 = document.createElement('CANVAS');
|
|
|
c2.width = canvas.width;
|
|
|
c2.height = canvas.height;
|
|
|
- ctx2 = c2.getContext('2d');
|
|
|
+ ctx2 = c2.getContext('2d', {willReadFrequently: true});
|
|
|
ctx2.drawImage (canvas, 0, 0, w, h);
|
|
|
ctx2.globalCompositeOperation = 'color-burn';
|
|
|
console.log(v)
|
|
|
@@ -19170,7 +19170,7 @@ ol.filter.Colorize.prototype.postcompose = function(e) {
|
|
|
c2 = document.createElement('CANVAS');
|
|
|
c2.width = canvas.width;
|
|
|
c2.height = canvas.height;
|
|
|
- ctx2 = c2.getContext('2d');
|
|
|
+ ctx2 = c2.getContext('2d', {willReadFrequently: true});
|
|
|
ctx2.drawImage(canvas, 0,0);
|
|
|
ctx2.globalCompositeOperation = this.get('operation');
|
|
|
ctx2.fillStyle = this.get('color');
|
|
|
@@ -19618,7 +19618,7 @@ ol.filter.PencilSketch.prototype.postcompose = function(e) {
|
|
|
var bwimg = document.createElement('canvas');
|
|
|
bwimg.width = w;
|
|
|
bwimg.height = h;
|
|
|
- var bwctx = bwimg.getContext('2d');
|
|
|
+ var bwctx = bwimg.getContext('2d', {willReadFrequently: true});
|
|
|
bwctx.filter = 'grayscale(1) invert(1) blur('+this.get('blur')+'px)';
|
|
|
bwctx.drawImage(canvas, 0,0);
|
|
|
ctx.save();
|
|
|
@@ -19683,7 +19683,7 @@ ol.filter.Pointillism.prototype.postcompose = function(e) {
|
|
|
var img = document.createElement('canvas');
|
|
|
img.width = w;
|
|
|
img.height = h;
|
|
|
- var ictx = img.getContext('2d');
|
|
|
+ var ictx = img.getContext('2d', {willReadFrequently: true});
|
|
|
ictx.filter = 'saturate('+Math.round(2*this.get('saturate')*100)+'%)';
|
|
|
ictx.drawImage(canvas, 0,0);
|
|
|
ctx.save();
|
|
|
@@ -19762,7 +19762,7 @@ ol.filter.SVGFilter.prototype.postcompose = function(e) {
|
|
|
var canvas = document.createElement('canvas');
|
|
|
canvas.width = e.context.canvas.width;
|
|
|
canvas.height = e.context.canvas.height;
|
|
|
- canvas.getContext('2d').drawImage(e.context.canvas,0,0);
|
|
|
+ canvas.getContext('2d', {willReadFrequently: true}).drawImage(e.context.canvas,0,0);
|
|
|
// Apply filter
|
|
|
if (filter) {
|
|
|
e.context.save();
|
|
|
@@ -22336,7 +22336,7 @@ ol.interaction.Flashlight.prototype.setPosition = function(e) {
|
|
|
/** Postcompose function
|
|
|
*/
|
|
|
ol.interaction.Flashlight.prototype.postcompose_ = function(e) {
|
|
|
- var ctx = ol.ext.getMapCanvas(this.getMap()).getContext('2d');
|
|
|
+ var ctx = ol.ext.getMapCanvas(this.getMap()).getContext('2d', {willReadFrequently: true});
|
|
|
var ratio = e.frameState.pixelRatio;
|
|
|
var w = ctx.canvas.width;
|
|
|
var h = ctx.canvas.height;
|
|
|
@@ -25651,7 +25651,7 @@ ol.interaction.TinkerBell.prototype.onMove = function(e) {
|
|
|
*/
|
|
|
ol.interaction.TinkerBell.prototype.postcompose_ = function(e) {
|
|
|
var delta = 15;
|
|
|
- var ctx = e.context || ol.ext.getMapCanvas(this.getMap()).getContext('2d');
|
|
|
+ var ctx = e.context || ol.ext.getMapCanvas(this.getMap()).getContext('2d', {willReadFrequently: true});
|
|
|
var dt = e.frameState.time - this.time;
|
|
|
this.time = e.frameState.time;
|
|
|
if (e.frameState.time-this.lastSparkle > 30 && !this.isout_) {
|
|
|
@@ -25801,7 +25801,7 @@ ol.interaction.TouchCompass.prototype.getCenter_ = function()
|
|
|
*/
|
|
|
ol.interaction.TouchCompass.prototype.drawCompass_ = function(e)
|
|
|
{ if (!this.getActive()) return;
|
|
|
- var ctx = e.context || ol.ext.getMapCanvas(this.getMap()).getContext('2d');
|
|
|
+ var ctx = e.context || ol.ext.getMapCanvas(this.getMap()).getContext('2d', {willReadFrequently: true});
|
|
|
var ratio = e.frameState.pixelRatio;
|
|
|
ctx.save();
|
|
|
ctx.scale(ratio,ratio);
|
|
|
@@ -29111,7 +29111,7 @@ ol.source.GeoImage.prototype.calculateImage = function(extent, resolution, pixel
|
|
|
var canvas = document.createElement('canvas');
|
|
|
canvas.width = size[0];
|
|
|
canvas.height = size[1];
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
if (!this._imageSize) return canvas;
|
|
|
// transform coords to pixel
|
|
|
function tr(xy) {
|
|
|
@@ -29731,7 +29731,7 @@ ol.source.IDW.prototype.setData = function(v, data, i) {
|
|
|
ol.source.IDW.prototype.getValue = function(coord) {
|
|
|
if (!this._canvas) return null
|
|
|
var pt = this.transform(coord);
|
|
|
- var v = this._canvas.getContext('2d').getImageData(Math.round(pt[0]), Math.round(pt[1]), 1, 1).data;
|
|
|
+ var v = this._canvas.getContext('2d', {willReadFrequently: true}).getImageData(Math.round(pt[0]), Math.round(pt[1]), 1, 1).data;
|
|
|
return (v);
|
|
|
};
|
|
|
/** Calculate IDW at extent / resolution
|
|
|
@@ -29748,7 +29748,7 @@ ol.source.IDW.prototype.calculateImage = function(extent, resolution, pixelRatio
|
|
|
var canvas = document.createElement('CANVAS');
|
|
|
var width = canvas.width = Math.round(size[0] / (this.get('scale')*pixelRatio));
|
|
|
var height = canvas.height = Math.round(size[1] / (this.get('scale')*pixelRatio));
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
var imageData = ctx.getImageData(0, 0, width, height);
|
|
|
// Transform coords to pixel / value
|
|
|
var pts = [];
|
|
|
@@ -29796,7 +29796,7 @@ ol.source.IDW.prototype.calculateImage = function(extent, resolution, pixelRatio
|
|
|
// Draw full resolution canvas
|
|
|
this._canvas.width = Math.round(size[0]);
|
|
|
this._canvas.height = Math.round(size[1]);
|
|
|
- this._canvas.getContext('2d').drawImage(canvas, 0, 0, size[0], size[1]);
|
|
|
+ this._canvas.getContext('2d', {willReadFrequently: true}).drawImage(canvas, 0, 0, size[0], size[1]);
|
|
|
return this._canvas;
|
|
|
}
|
|
|
|
|
|
@@ -32516,7 +32516,7 @@ ol.particule.Cloud = function(options) {
|
|
|
var canvas = document.createElement('CANVAS');
|
|
|
canvas.width = 200;
|
|
|
canvas.height = 200;
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
var grd = this.gradient = ctx.createRadialGradient(50,50, 0, 50,50, 50);
|
|
|
grd.addColorStop(0, 'rgba(255,255,255,.2');
|
|
|
grd.addColorStop(1, 'rgba(255,255,255,0');
|
|
|
@@ -32571,7 +32571,7 @@ ol.particule.Rain = function(options) {
|
|
|
var canvas = document.createElement('CANVAS');
|
|
|
canvas.width = 50;
|
|
|
canvas.height = 50;
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
this.gradient = ctx.createRadialGradient(0,0, 0, 0,0, 25);
|
|
|
this.gradient.addColorStop(0, 'rgba(0,0,80,0)');
|
|
|
this.gradient.addColorStop(1, 'rgba(0,0,80,.3)');
|
|
|
@@ -32624,7 +32624,7 @@ ol.particule.RainDrop = function(options) {
|
|
|
var canvas = document.createElement('CANVAS');
|
|
|
canvas.width = 100;
|
|
|
canvas.height = 100;
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
var grd = ctx.createRadialGradient(50,50, 0, 50,50, 50);
|
|
|
grd.addColorStop(0, 'rgba(128,128,192,.8');
|
|
|
grd.addColorStop(1, 'rgba(128,128,192,0');
|
|
|
@@ -32680,7 +32680,7 @@ ol.particule.Snow = function(options) {
|
|
|
var canvas = document.createElement('CANVAS');
|
|
|
canvas.width = 20;
|
|
|
canvas.height = 20;
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
var grd = ctx.createRadialGradient(10,10, 0, 10,10, 10);
|
|
|
grd.addColorStop(0, "rgba(255, 255, 255,1)"); // white
|
|
|
grd.addColorStop(.8, "rgba(210, 236, 242,.8)"); // bluish
|
|
|
@@ -33026,7 +33026,7 @@ ol.Overlay.AnimatedCanvas = function(options) {
|
|
|
this._canvas = ol.ext.element.create('CANVAS', {
|
|
|
className: ((options.className || '') + ' ol-animated-overlay').trim()
|
|
|
});
|
|
|
- this._ctx = this._canvas.getContext('2d');
|
|
|
+ this._ctx = this._canvas.getContext('2d', {willReadFrequently: true});
|
|
|
ol.Overlay.call(this, {
|
|
|
element: this._canvas,
|
|
|
stopEvent: false
|
|
|
@@ -36626,7 +36626,7 @@ ol.style.Chart.prototype.renderChart_ = function(pixelratio) {
|
|
|
// no atlas manager is used, create a new canvas
|
|
|
var canvas = this.getImage(pixelratio);
|
|
|
// draw the circle on the canvas
|
|
|
- var context = (canvas.getContext('2d'));
|
|
|
+ var context = (canvas.getContext('2d', {willReadFrequently: true}));
|
|
|
context.save();
|
|
|
// reset transform
|
|
|
context.setTransform(pixelratio, 0, 0, pixelratio, 0, 0);
|
|
|
@@ -36758,7 +36758,7 @@ ol.style.FillPattern = function(options) {
|
|
|
var canvas = this.canvas_ = document.createElement('canvas');
|
|
|
var scale = Number(options.scale)>0 ? Number(options.scale) : 1;
|
|
|
var ratio = scale*ol.has.DEVICE_PIXEL_RATIO || ol.has.DEVICE_PIXEL_RATIO;
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
if (options.image) {
|
|
|
options.image.load();
|
|
|
var i;
|
|
|
@@ -37891,7 +37891,7 @@ ol.style.FontSymbol.prototype.renderMarker_ = function(pixelratio) {
|
|
|
size: canvas.width/pixelratio,
|
|
|
};
|
|
|
// draw the circle on the canvas
|
|
|
- var context = (canvas.getContext('2d'));
|
|
|
+ var context = (canvas.getContext('2d', {willReadFrequently: true}));
|
|
|
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
this.drawMarker_(renderOptions, context, 0, 0, pixelratio);
|
|
|
// Set anchor / displacement
|
|
|
@@ -38309,14 +38309,14 @@ ol.style.Photo.prototype.renderPhoto_ = function(pixelratio) {
|
|
|
}
|
|
|
var canvas = this.getImage(pixelratio);
|
|
|
// Draw hitdetection image
|
|
|
- var context = this.getHitDetectionImage().getContext('2d');
|
|
|
+ var context = this.getHitDetectionImage().getContext('2d', {willReadFrequently: true});
|
|
|
context.save();
|
|
|
context.setTransform(1,0,0,1,0,0)
|
|
|
this.drawBack_(context,"#000",strokeWidth, 1);
|
|
|
context.fill();
|
|
|
context.restore();
|
|
|
// Draw the image
|
|
|
- context = canvas.getContext('2d');
|
|
|
+ context = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
context.save();
|
|
|
context.setTransform(pixelratio, 0, 0, pixelratio, 0, 0);
|
|
|
this.drawBack_(context,strokeStyle,strokeWidth, pixelratio);
|
|
|
@@ -38361,7 +38361,7 @@ ol.style.Photo.prototype.drawImage_ = function(img) {
|
|
|
var pixelratio = window.devicePixelRatio;
|
|
|
var canvas = this.getImage(pixelratio);
|
|
|
// Remove the circle on the canvas
|
|
|
- var context = (canvas.getContext('2d'));
|
|
|
+ var context = (canvas.getContext('2d', {willReadFrequently: true}));
|
|
|
var strokeWidth = 0;
|
|
|
if (this._stroke) strokeWidth = this._stroke.getWidth();
|
|
|
var size = 2*this._radius;
|
|
|
@@ -38811,7 +38811,7 @@ ol.style.Shadow.prototype.renderShadow_ = function(pixelratio) {
|
|
|
var radius = this._radius;
|
|
|
var canvas = this.getImage(pixelratio);
|
|
|
// Remove the circle on the canvas
|
|
|
- var context = (canvas.getContext('2d'));
|
|
|
+ var context = (canvas.getContext('2d', {willReadFrequently: true}));
|
|
|
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
context.save();
|
|
|
context.beginPath();
|
|
|
@@ -38863,7 +38863,7 @@ ol.style.StrokePattern = function(options)
|
|
|
var canvas = this.canvas_ = document.createElement('canvas');
|
|
|
var scale = Number(options.scale)>0 ? Number(options.scale) : 1;
|
|
|
var ratio = scale*ol.has.DEVICE_PIXEL_RATIO || ol.has.DEVICE_PIXEL_RATIO;
|
|
|
- var ctx = canvas.getContext('2d');
|
|
|
+ var ctx = canvas.getContext('2d', {willReadFrequently: true});
|
|
|
if (options.image)
|
|
|
{ options.image.load();
|
|
|
var img = options.image.getImage();
|