Backed out old coordinate translation modifications, moving pixel density check to rendering code

This commit is contained in:
Wesley Fok 2015-01-30 15:46:52 -05:00
parent a23da44b8f
commit 28ddf5a809
3 changed files with 14 additions and 21 deletions

View File

@ -268,18 +268,18 @@ $.Tile.prototype = /** @lends OpenSeadragon.Tile.prototype */{
//clearing only the inside of the rectangle occupied //clearing only the inside of the rectangle occupied
//by the png prevents edge flikering //by the png prevents edge flikering
context.clearRect( context.clearRect(
position.x+1, (position.x * $.pixelDensityRatio)+1,
position.y+1, (position.y * $.pixelDensityRatio)+1,
size.x-2, (size.x * $.pixelDensityRatio)-2,
size.y-2 (size.y * $.pixelDensityRatio)-2
); );
} }
if(!rendered){ if(!rendered){
canvas = document.createElement( 'canvas' ); canvas = document.createElement( 'canvas' );
canvas.width = this.image.width; canvas.width = this.image.width * $.pixelDensityRatio;
canvas.height = this.image.height; canvas.height = this.image.height * $.pixelDensityRatio;
rendered = canvas.getContext('2d'); rendered = canvas.getContext('2d');
rendered.drawImage( this.image, 0, 0 ); rendered.drawImage( this.image, 0, 0 );
this.cacheImageRecord.setRenderedContext(rendered); this.cacheImageRecord.setRenderedContext(rendered);
@ -297,10 +297,10 @@ $.Tile.prototype = /** @lends OpenSeadragon.Tile.prototype */{
0, 0,
rendered.canvas.width, rendered.canvas.width,
rendered.canvas.height, rendered.canvas.height,
position.x, position.x * $.pixelDensityRatio,
position.y, position.y * $.pixelDensityRatio,
size.x, size.x * $.pixelDensityRatio,
size.y size.y * $.pixelDensityRatio
); );
}, },

View File

@ -262,7 +262,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
// private // private
_viewportToImageDelta: function( viewerX, viewerY, current ) { _viewportToImageDelta: function( viewerX, viewerY, current ) {
var scale = (current ? this._scaleSpring.current.value : this._scaleSpring.target.value) / $.pixelDensityRatio; var scale = (current ? this._scaleSpring.current.value : this._scaleSpring.target.value);
return new $.Point(viewerX * (this.source.dimensions.x / scale), return new $.Point(viewerX * (this.source.dimensions.x / scale),
viewerY * ((this.source.dimensions.y * this.contentAspectX) / scale)); viewerY * ((this.source.dimensions.y * this.contentAspectX) / scale));
}, },
@ -294,7 +294,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
// private // private
_imageToViewportDelta: function( imageX, imageY, current ) { _imageToViewportDelta: function( imageX, imageY, current ) {
var scale = (current ? this._scaleSpring.current.value : this._scaleSpring.target.value) / $.pixelDensityRatio; var scale = (current ? this._scaleSpring.current.value : this._scaleSpring.target.value);
return new $.Point((imageX / this.source.dimensions.x) * scale, return new $.Point((imageX / this.source.dimensions.x) * scale,
(imageY / this.source.dimensions.y / this.contentAspectX) * scale); (imageY / this.source.dimensions.y / this.contentAspectX) * scale);
}, },
@ -562,6 +562,7 @@ function updateViewport( tiledImage ) {
var viewportBR = viewportBounds.getBottomRight(); var viewportBR = viewportBounds.getBottomRight();
//Don't draw if completely outside of the viewport //Don't draw if completely outside of the viewport
$.console.log(viewportTL.x);
if ( !tiledImage.wrapHorizontal && (viewportBR.x < 0 || viewportTL.x > tiledImage._worldWidthCurrent ) ) { if ( !tiledImage.wrapHorizontal && (viewportBR.x < 0 || viewportTL.x > tiledImage._worldWidthCurrent ) ) {
return; return;
} }

View File

@ -897,8 +897,6 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
deltaPixelsFromPoints: function( deltaPoints, current ) { deltaPixelsFromPoints: function( deltaPoints, current ) {
return deltaPoints.times( return deltaPoints.times(
this._containerInnerSize.x * this.getZoom( current ) this._containerInnerSize.x * this.getZoom( current )
).times(
$.pixelDensityRatio
); );
}, },
@ -910,8 +908,6 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
deltaPointsFromPixels: function( deltaPixels, current ) { deltaPointsFromPixels: function( deltaPixels, current ) {
return deltaPixels.divide( return deltaPixels.divide(
this._containerInnerSize.x * this.getZoom( current ) this._containerInnerSize.x * this.getZoom( current )
).divide(
$.pixelDensityRatio
); );
}, },
@ -932,8 +928,6 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
this._containerInnerSize.x / bounds.width this._containerInnerSize.x / bounds.width
).plus( ).plus(
new $.Point(this._margins.left, this._margins.top) new $.Point(this._margins.left, this._margins.top)
).times(
$.pixelDensityRatio
); );
}, },
@ -944,9 +938,7 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
*/ */
pointFromPixel: function( pixel, current ) { pointFromPixel: function( pixel, current ) {
var bounds = this.getBounds( current ); var bounds = this.getBounds( current );
return pixel.divide( return pixel.minus(
$.pixelDensityRatio
).minus(
new $.Point(this._margins.left, this._margins.top) new $.Point(this._margins.left, this._margins.top)
).divide( ).divide(
this._containerInnerSize.x / bounds.width this._containerInnerSize.x / bounds.width