Promote projectionMatrix and texCoordMatrix into base class
This commit is contained in:
@@ -28,18 +28,6 @@ ol.renderer.webgl.ImageLayer = function(mapRenderer, imageLayer) {
|
||||
*/
|
||||
this.image_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
*/
|
||||
this.texCoordMatrix_ = goog.vec.Mat4.createNumberIdentity();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
*/
|
||||
this.projectionMatrix_ = goog.vec.Mat4.createNumber();
|
||||
|
||||
};
|
||||
goog.inherits(ol.renderer.webgl.ImageLayer, ol.renderer.webgl.Layer);
|
||||
|
||||
@@ -79,22 +67,6 @@ ol.renderer.webgl.ImageLayer.prototype.createTexture_ = function(image) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.renderer.webgl.ImageLayer.prototype.getTexCoordMatrix = function() {
|
||||
return this.texCoordMatrix_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.renderer.webgl.ImageLayer.prototype.getProjectionMatrix = function() {
|
||||
return this.projectionMatrix_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.layer.ImageLayer} Tile layer.
|
||||
*/
|
||||
@@ -156,7 +128,7 @@ ol.renderer.webgl.ImageLayer.prototype.renderFrame =
|
||||
viewCenter, viewResolution, viewRotation, image.getExtent());
|
||||
|
||||
// Translate and scale to flip the Y coord.
|
||||
var texCoordMatrix = this.texCoordMatrix_;
|
||||
var texCoordMatrix = this.texCoordMatrix;
|
||||
goog.vec.Mat4.makeIdentity(texCoordMatrix);
|
||||
goog.vec.Mat4.scale(texCoordMatrix, 1, -1, 1);
|
||||
goog.vec.Mat4.translate(texCoordMatrix, 0, -1, 0);
|
||||
@@ -185,7 +157,7 @@ ol.renderer.webgl.ImageLayer.prototype.updateProjectionMatrix_ =
|
||||
var canvasExtentWidth = canvasWidth * viewResolution;
|
||||
var canvasExtentHeight = canvasHeight * viewResolution;
|
||||
|
||||
var projectionMatrix = this.projectionMatrix_;
|
||||
var projectionMatrix = this.projectionMatrix;
|
||||
goog.vec.Mat4.makeIdentity(projectionMatrix);
|
||||
goog.vec.Mat4.scale(projectionMatrix,
|
||||
2 / canvasExtentWidth, 2 / canvasExtentHeight, 1);
|
||||
|
||||
@@ -38,6 +38,18 @@ ol.renderer.webgl.Layer = function(mapRenderer, layer) {
|
||||
*/
|
||||
this.framebufferDimension = undefined;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
*/
|
||||
this.texCoordMatrix = goog.vec.Mat4.createNumber();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
*/
|
||||
this.projectionMatrix = goog.vec.Mat4.createNumberIdentity();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Float32}
|
||||
@@ -154,7 +166,9 @@ ol.renderer.webgl.Layer.prototype.getWebGLMapRenderer = function() {
|
||||
/**
|
||||
* @return {!goog.vec.Mat4.Number} Matrix.
|
||||
*/
|
||||
ol.renderer.webgl.Layer.prototype.getTexCoordMatrix = goog.abstractMethod;
|
||||
ol.renderer.webgl.Layer.prototype.getTexCoordMatrix = function() {
|
||||
return this.texCoordMatrix;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@@ -168,7 +182,9 @@ ol.renderer.webgl.Layer.prototype.getTexture = function() {
|
||||
/**
|
||||
* @return {!goog.vec.Mat4.Number} Matrix.
|
||||
*/
|
||||
ol.renderer.webgl.Layer.prototype.getProjectionMatrix = goog.abstractMethod;
|
||||
ol.renderer.webgl.Layer.prototype.getProjectionMatrix = function() {
|
||||
return this.projectionMatrix;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,18 +123,6 @@ ol.renderer.webgl.TileLayer = function(mapRenderer, tileLayer) {
|
||||
1, 1, 1, 0
|
||||
]);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
*/
|
||||
this.texCoordMatrix_ = goog.vec.Mat4.createNumber();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!goog.vec.Mat4.Number}
|
||||
*/
|
||||
this.projectionMatrix_ = goog.vec.Mat4.createNumberIdentity();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.TileRange}
|
||||
@@ -161,22 +149,6 @@ ol.renderer.webgl.TileLayer.prototype.disposeInternal = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.renderer.webgl.TileLayer.prototype.getTexCoordMatrix = function() {
|
||||
return this.texCoordMatrix_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.renderer.webgl.TileLayer.prototype.getProjectionMatrix = function() {
|
||||
return this.projectionMatrix_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {ol.layer.TileLayer} Tile layer.
|
||||
*/
|
||||
@@ -378,21 +350,21 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
|
||||
tileSource.useLowResolutionTiles(z, extent, tileGrid);
|
||||
this.scheduleExpireCache(frameState, tileSource);
|
||||
|
||||
goog.vec.Mat4.makeIdentity(this.texCoordMatrix_);
|
||||
goog.vec.Mat4.translate(this.texCoordMatrix_,
|
||||
goog.vec.Mat4.makeIdentity(this.texCoordMatrix);
|
||||
goog.vec.Mat4.translate(this.texCoordMatrix,
|
||||
(center.x - framebufferExtent.minX) /
|
||||
(framebufferExtent.maxX - framebufferExtent.minX),
|
||||
(center.y - framebufferExtent.minY) /
|
||||
(framebufferExtent.maxY - framebufferExtent.minY),
|
||||
0);
|
||||
goog.vec.Mat4.rotateZ(this.texCoordMatrix_, view2DState.rotation);
|
||||
goog.vec.Mat4.scale(this.texCoordMatrix_,
|
||||
goog.vec.Mat4.rotateZ(this.texCoordMatrix, view2DState.rotation);
|
||||
goog.vec.Mat4.scale(this.texCoordMatrix,
|
||||
frameState.size.width * view2DState.resolution /
|
||||
(framebufferExtent.maxX - framebufferExtent.minX),
|
||||
frameState.size.height * view2DState.resolution /
|
||||
(framebufferExtent.maxY - framebufferExtent.minY),
|
||||
1);
|
||||
goog.vec.Mat4.translate(this.texCoordMatrix_,
|
||||
goog.vec.Mat4.translate(this.texCoordMatrix,
|
||||
-0.5,
|
||||
-0.5,
|
||||
0);
|
||||
|
||||
Reference in New Issue
Block a user