diff --git a/externs/oli.js b/externs/oli.js index 659148c77c..d8d4b86cb1 100644 --- a/externs/oli.js +++ b/externs/oli.js @@ -266,6 +266,18 @@ oli.source.ImageEvent = function() {}; oli.source.ImageEvent.prototype.image; +/** + * @interface + */ +oli.source.RasterEvent = function() {}; + + +/** + * @type {number} + */ +oli.source.RasterEvent.prototype.resolution; + + /** * @interface */ diff --git a/src/ol/source/rastersource.js b/src/ol/source/rastersource.js index 8acfdbf9fd..861fe86605 100644 --- a/src/ol/source/rastersource.js +++ b/src/ol/source/rastersource.js @@ -1,6 +1,9 @@ goog.provide('ol.source.Raster'); +goog.provide('ol.source.RasterEvent'); +goog.provide('ol.source.RasterEventType'); goog.require('goog.asserts'); +goog.require('goog.events.Event'); goog.require('goog.functions'); goog.require('goog.vec.Mat4'); goog.require('ol.ImageCanvas'); @@ -182,6 +185,11 @@ ol.source.Raster.prototype.composeFrame_ = function(frameState) { var targetImageData = context.getImageData(0, 0, canvas.width, canvas.height); var target = targetImageData.data; + + var resolution = frameState.viewState.resolution / frameState.pixelRatio; + this.dispatchEvent(new ol.source.RasterEvent( + ol.source.RasterEventType.BEFOREOPERATIONS, resolution)); + var source, pixel; for (var j = 0, jj = target.length; j < jj; j += 4) { for (var k = 0; k < len; ++k) { @@ -192,13 +200,17 @@ ol.source.Raster.prototype.composeFrame_ = function(frameState) { pixel[2] = source[j + 2]; pixel[3] = source[j + 3]; } - this.transformPixels_(pixels); + this.runOperations_(pixels); pixel = pixels[0]; target[j] = pixel[0]; target[j + 1] = pixel[1]; target[j + 2] = pixel[2]; target[j + 3] = pixel[3]; } + + this.dispatchEvent(new ol.source.RasterEvent( + ol.source.RasterEventType.AFTEROPERATIONS, resolution)); + context.putImageData(targetImageData, 0, 0); frameState.tileQueue.loadMoreTiles(16, 16); @@ -211,7 +223,7 @@ ol.source.Raster.prototype.composeFrame_ = function(frameState) { * @return {Array.