Don't call event handlers in constructor

This commit is contained in:
Tom Payne
2013-04-18 16:35:06 +02:00
parent 87358296f4
commit f274cc99f6

View File

@@ -51,30 +51,6 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) {
*/
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
* @type {!goog.vec.Mat4.Float32}
@@ -87,10 +63,33 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) {
*/
this.colorMatrixDirty_ = true;
this.handleLayerBrightnessChange();
this.handleLayerContrastChange();
this.handleLayerHueChange();
this.handleLayerSaturationChange();
/**
* @private
* @type {!goog.vec.Mat4.Float32}
*/
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);
@@ -193,9 +192,7 @@ ol.renderer.webgl.Layer.prototype.getProjectionMatrix = function() {
* @inheritDoc
*/
ol.renderer.webgl.Layer.prototype.handleLayerBrightnessChange = function() {
var value = this.getLayer().getBrightness();
ol.vec.Mat4.makeBrightness(this.brightnessMatrix_, value);
this.colorMatrixDirty_ = true;
this.updateBrightnessMatrix_();
this.dispatchChangeEvent();
};
@@ -204,9 +201,7 @@ ol.renderer.webgl.Layer.prototype.handleLayerBrightnessChange = function() {
* @inheritDoc
*/
ol.renderer.webgl.Layer.prototype.handleLayerContrastChange = function() {
var value = this.getLayer().getContrast();
ol.vec.Mat4.makeContrast(this.contrastMatrix_, value);
this.colorMatrixDirty_ = true;
this.updateContrastMatrix_();
this.dispatchChangeEvent();
};
@@ -215,9 +210,7 @@ ol.renderer.webgl.Layer.prototype.handleLayerContrastChange = function() {
* @inheritDoc
*/
ol.renderer.webgl.Layer.prototype.handleLayerHueChange = function() {
var value = this.getLayer().getHue();
ol.vec.Mat4.makeHue(this.hueMatrix_, value);
this.colorMatrixDirty_ = true;
this.updateHueMatrix_();
this.dispatchChangeEvent();
};
@@ -226,9 +219,7 @@ ol.renderer.webgl.Layer.prototype.handleLayerHueChange = function() {
* @inheritDoc
*/
ol.renderer.webgl.Layer.prototype.handleLayerSaturationChange = function() {
var saturation = this.getLayer().getSaturation();
ol.vec.Mat4.makeSaturation(this.saturationMatrix_, saturation);
this.colorMatrixDirty_ = true;
this.updateSaturationMatrix_();
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
*/
@@ -255,3 +256,33 @@ ol.renderer.webgl.Layer.prototype.updateColorMatrix_ = function() {
goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix);
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;
};