Don't call event handlers in constructor
This commit is contained in:
@@ -51,30 +51,6 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) {
|
|||||||
*/
|
*/
|
||||||
this.projectionMatrix = goog.vec.Mat4.createNumberIdentity();
|
this.projectionMatrix = goog.vec.Mat4.createNumberIdentity();
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {!goog.vec.Mat4.Float32}
|
|
||||||
*/
|
|
||||||
this.brightnessMatrix_ = goog.vec.Mat4.createFloat32();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {!goog.vec.Mat4.Float32}
|
|
||||||
*/
|
|
||||||
this.contrastMatrix_ = goog.vec.Mat4.createFloat32();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {!goog.vec.Mat4.Float32}
|
|
||||||
*/
|
|
||||||
this.hueMatrix_ = goog.vec.Mat4.createFloat32();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @type {!goog.vec.Mat4.Float32}
|
|
||||||
*/
|
|
||||||
this.saturationMatrix_ = goog.vec.Mat4.createFloat32();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {!goog.vec.Mat4.Float32}
|
* @type {!goog.vec.Mat4.Float32}
|
||||||
@@ -87,10 +63,33 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) {
|
|||||||
*/
|
*/
|
||||||
this.colorMatrixDirty_ = true;
|
this.colorMatrixDirty_ = true;
|
||||||
|
|
||||||
this.handleLayerBrightnessChange();
|
/**
|
||||||
this.handleLayerContrastChange();
|
* @private
|
||||||
this.handleLayerHueChange();
|
* @type {!goog.vec.Mat4.Float32}
|
||||||
this.handleLayerSaturationChange();
|
*/
|
||||||
|
this.brightnessMatrix_ = goog.vec.Mat4.createFloat32();
|
||||||
|
this.updateBrightnessMatrix_();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {!goog.vec.Mat4.Float32}
|
||||||
|
*/
|
||||||
|
this.contrastMatrix_ = goog.vec.Mat4.createFloat32();
|
||||||
|
this.updateContrastMatrix_();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {!goog.vec.Mat4.Float32}
|
||||||
|
*/
|
||||||
|
this.hueMatrix_ = goog.vec.Mat4.createFloat32();
|
||||||
|
this.updateHueMatrix_();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {!goog.vec.Mat4.Float32}
|
||||||
|
*/
|
||||||
|
this.saturationMatrix_ = goog.vec.Mat4.createFloat32();
|
||||||
|
this.updateSaturationMatrix_();
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.renderer.webgl.Layer, ol.renderer.Layer);
|
goog.inherits(ol.renderer.webgl.Layer, ol.renderer.Layer);
|
||||||
@@ -193,9 +192,7 @@ ol.renderer.webgl.Layer.prototype.getProjectionMatrix = function() {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.handleLayerBrightnessChange = function() {
|
ol.renderer.webgl.Layer.prototype.handleLayerBrightnessChange = function() {
|
||||||
var value = this.getLayer().getBrightness();
|
this.updateBrightnessMatrix_();
|
||||||
ol.vec.Mat4.makeBrightness(this.brightnessMatrix_, value);
|
|
||||||
this.colorMatrixDirty_ = true;
|
|
||||||
this.dispatchChangeEvent();
|
this.dispatchChangeEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -204,9 +201,7 @@ ol.renderer.webgl.Layer.prototype.handleLayerBrightnessChange = function() {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.handleLayerContrastChange = function() {
|
ol.renderer.webgl.Layer.prototype.handleLayerContrastChange = function() {
|
||||||
var value = this.getLayer().getContrast();
|
this.updateContrastMatrix_();
|
||||||
ol.vec.Mat4.makeContrast(this.contrastMatrix_, value);
|
|
||||||
this.colorMatrixDirty_ = true;
|
|
||||||
this.dispatchChangeEvent();
|
this.dispatchChangeEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -215,9 +210,7 @@ ol.renderer.webgl.Layer.prototype.handleLayerContrastChange = function() {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.handleLayerHueChange = function() {
|
ol.renderer.webgl.Layer.prototype.handleLayerHueChange = function() {
|
||||||
var value = this.getLayer().getHue();
|
this.updateHueMatrix_();
|
||||||
ol.vec.Mat4.makeHue(this.hueMatrix_, value);
|
|
||||||
this.colorMatrixDirty_ = true;
|
|
||||||
this.dispatchChangeEvent();
|
this.dispatchChangeEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -226,9 +219,7 @@ ol.renderer.webgl.Layer.prototype.handleLayerHueChange = function() {
|
|||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.renderer.webgl.Layer.prototype.handleLayerSaturationChange = function() {
|
ol.renderer.webgl.Layer.prototype.handleLayerSaturationChange = function() {
|
||||||
var saturation = this.getLayer().getSaturation();
|
this.updateSaturationMatrix_();
|
||||||
ol.vec.Mat4.makeSaturation(this.saturationMatrix_, saturation);
|
|
||||||
this.colorMatrixDirty_ = true;
|
|
||||||
this.dispatchChangeEvent();
|
this.dispatchChangeEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -243,6 +234,16 @@ ol.renderer.webgl.Layer.prototype.handleWebGLContextLost = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.renderer.webgl.Layer.prototype.updateBrightnessMatrix_ = function() {
|
||||||
|
var brightness = this.getLayer().getBrightness();
|
||||||
|
ol.vec.Mat4.makeBrightness(this.brightnessMatrix_, brightness);
|
||||||
|
this.colorMatrixDirty_ = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@@ -255,3 +256,33 @@ ol.renderer.webgl.Layer.prototype.updateColorMatrix_ = function() {
|
|||||||
goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix);
|
goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix);
|
||||||
this.colorMatrixDirty_ = false;
|
this.colorMatrixDirty_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.renderer.webgl.Layer.prototype.updateContrastMatrix_ = function() {
|
||||||
|
var contrast = this.getLayer().getContrast();
|
||||||
|
ol.vec.Mat4.makeContrast(this.contrastMatrix_, contrast);
|
||||||
|
this.colorMatrixDirty_ = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.renderer.webgl.Layer.prototype.updateHueMatrix_ = function() {
|
||||||
|
var hue = this.getLayer().getHue();
|
||||||
|
ol.vec.Mat4.makeHue(this.hueMatrix_, hue);
|
||||||
|
this.colorMatrixDirty_ = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.renderer.webgl.Layer.prototype.updateSaturationMatrix_ = function() {
|
||||||
|
var saturation = this.getLayer().getSaturation();
|
||||||
|
ol.vec.Mat4.makeSaturation(this.saturationMatrix_, saturation);
|
||||||
|
this.colorMatrixDirty_ = true;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user