Correct ol.renderer.canvas.ImageLayer transform for HiDPI devices
This commit is contained in:
@@ -64,6 +64,7 @@ ol.renderer.canvas.ImageLayer.prototype.getImageTransform = function() {
|
|||||||
ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
|
ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
|
||||||
function(frameState, layerState) {
|
function(frameState, layerState) {
|
||||||
|
|
||||||
|
var devicePixelRatio = frameState.devicePixelRatio;
|
||||||
var view2DState = frameState.view2DState;
|
var view2DState = frameState.view2DState;
|
||||||
var viewCenter = view2DState.center;
|
var viewCenter = view2DState.center;
|
||||||
var viewResolution = view2DState.resolution;
|
var viewResolution = view2DState.resolution;
|
||||||
@@ -79,7 +80,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
|
|||||||
|
|
||||||
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING]) {
|
if (!hints[ol.ViewHint.ANIMATING] && !hints[ol.ViewHint.INTERACTING]) {
|
||||||
image = imageSource.getImage(frameState.extent, viewResolution,
|
image = imageSource.getImage(frameState.extent, viewResolution,
|
||||||
frameState.devicePixelRatio, view2DState.projection);
|
devicePixelRatio, view2DState.projection);
|
||||||
if (!goog.isNull(image)) {
|
if (!goog.isNull(image)) {
|
||||||
var imageState = image.getState();
|
var imageState = image.getState();
|
||||||
if (imageState == ol.ImageState.IDLE) {
|
if (imageState == ol.ImageState.IDLE) {
|
||||||
@@ -95,16 +96,17 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
|
|||||||
if (!goog.isNull(this.image_)) {
|
if (!goog.isNull(this.image_)) {
|
||||||
image = this.image_;
|
image = this.image_;
|
||||||
var imageExtent = image.getExtent();
|
var imageExtent = image.getExtent();
|
||||||
var imageResolution = image.getResolution() / image.getPixelRatio();
|
var imageResolution = image.getResolution();
|
||||||
var devicePixelRatio = frameState.devicePixelRatio;
|
var imagePixelRatio = image.getPixelRatio();
|
||||||
|
var scale = devicePixelRatio * imageResolution /
|
||||||
|
(viewResolution * imagePixelRatio);
|
||||||
ol.vec.Mat4.makeTransform2D(this.imageTransform_,
|
ol.vec.Mat4.makeTransform2D(this.imageTransform_,
|
||||||
devicePixelRatio * frameState.size[0] / 2,
|
devicePixelRatio * frameState.size[0] / 2,
|
||||||
devicePixelRatio * frameState.size[1] / 2,
|
devicePixelRatio * frameState.size[1] / 2,
|
||||||
devicePixelRatio * imageResolution / viewResolution,
|
scale, scale,
|
||||||
devicePixelRatio * imageResolution / viewResolution,
|
|
||||||
viewRotation,
|
viewRotation,
|
||||||
(imageExtent[0] - viewCenter[0]) / imageResolution,
|
imagePixelRatio * (imageExtent[0] - viewCenter[0]) / imageResolution,
|
||||||
(viewCenter[1] - imageExtent[3]) / imageResolution);
|
imagePixelRatio * (viewCenter[1] - imageExtent[3]) / imageResolution);
|
||||||
this.updateAttributions(frameState.attributions, image.getAttributions());
|
this.updateAttributions(frameState.attributions, image.getAttributions());
|
||||||
this.updateLogos(frameState, imageSource);
|
this.updateLogos(frameState, imageSource);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user