Fix replays on transformed contexts
This commit is contained in:
@@ -139,6 +139,12 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution) {
|
|||||||
* @type {!goog.vec.Mat4.Number}
|
* @type {!goog.vec.Mat4.Number}
|
||||||
*/
|
*/
|
||||||
this.tmpLocalTransform_ = goog.vec.Mat4.createNumber();
|
this.tmpLocalTransform_ = goog.vec.Mat4.createNumber();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {!goog.vec.Mat4.Number}
|
||||||
|
*/
|
||||||
|
this.tmpLocalTransformInv_ = goog.vec.Mat4.createNumber();
|
||||||
};
|
};
|
||||||
goog.inherits(ol.render.canvas.Replay, ol.render.VectorContext);
|
goog.inherits(ol.render.canvas.Replay, ol.render.VectorContext);
|
||||||
|
|
||||||
@@ -252,6 +258,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
var d = 0; // data index
|
var d = 0; // data index
|
||||||
var dd; // end of per-instruction data
|
var dd; // end of per-instruction data
|
||||||
var localTransform = this.tmpLocalTransform_;
|
var localTransform = this.tmpLocalTransform_;
|
||||||
|
var localTransformInv = this.tmpLocalTransformInv_;
|
||||||
var prevX, prevY, roundX, roundY;
|
var prevX, prevY, roundX, roundY;
|
||||||
while (i < ii) {
|
while (i < ii) {
|
||||||
var instruction = instructions[i];
|
var instruction = instructions[i];
|
||||||
@@ -331,7 +338,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
ol.vec.Mat4.makeTransform2D(
|
ol.vec.Mat4.makeTransform2D(
|
||||||
localTransform, centerX, centerY, scale, scale,
|
localTransform, centerX, centerY, scale, scale,
|
||||||
rotation, -centerX, -centerY);
|
rotation, -centerX, -centerY);
|
||||||
context.setTransform(
|
context.transform(
|
||||||
goog.vec.Mat4.getElement(localTransform, 0, 0),
|
goog.vec.Mat4.getElement(localTransform, 0, 0),
|
||||||
goog.vec.Mat4.getElement(localTransform, 1, 0),
|
goog.vec.Mat4.getElement(localTransform, 1, 0),
|
||||||
goog.vec.Mat4.getElement(localTransform, 0, 1),
|
goog.vec.Mat4.getElement(localTransform, 0, 1),
|
||||||
@@ -351,7 +358,14 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
context.globalAlpha = alpha;
|
context.globalAlpha = alpha;
|
||||||
}
|
}
|
||||||
if (scale != 1 || rotation !== 0) {
|
if (scale != 1 || rotation !== 0) {
|
||||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
goog.vec.Mat4.invert(localTransform, localTransformInv);
|
||||||
|
context.transform(
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 0, 0),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 1, 0),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 0, 1),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 1, 1),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 0, 3),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 1, 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
@@ -390,7 +404,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
if (scale != 1 || rotation !== 0) {
|
if (scale != 1 || rotation !== 0) {
|
||||||
ol.vec.Mat4.makeTransform2D(
|
ol.vec.Mat4.makeTransform2D(
|
||||||
localTransform, x, y, scale, scale, rotation, -x, -y);
|
localTransform, x, y, scale, scale, rotation, -x, -y);
|
||||||
context.setTransform(
|
context.transform(
|
||||||
goog.vec.Mat4.getElement(localTransform, 0, 0),
|
goog.vec.Mat4.getElement(localTransform, 0, 0),
|
||||||
goog.vec.Mat4.getElement(localTransform, 1, 0),
|
goog.vec.Mat4.getElement(localTransform, 1, 0),
|
||||||
goog.vec.Mat4.getElement(localTransform, 0, 1),
|
goog.vec.Mat4.getElement(localTransform, 0, 1),
|
||||||
@@ -427,7 +441,14 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scale != 1 || rotation !== 0) {
|
if (scale != 1 || rotation !== 0) {
|
||||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
goog.vec.Mat4.invert(localTransform, localTransformInv);
|
||||||
|
context.transform(
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 0, 0),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 1, 0),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 0, 1),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 1, 1),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 0, 3),
|
||||||
|
goog.vec.Mat4.getElement(localTransformInv, 1, 3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
|
|||||||
Reference in New Issue
Block a user