what was initally a feature branch to work on just canvas prerender, evolved into a feature branch focused on broader ideas discussed in issue #4 - I've basically been able to reduce time spent in drawTile by half. good stuff, thanks to dustmoo for getting us looking into this

This commit is contained in:
thatcher 2013-03-06 05:51:31 -05:00
parent 11a0f3b315
commit 61a844bdc0
6 changed files with 66 additions and 23 deletions

View File

@ -515,9 +515,15 @@ function updateViewport( drawer ) {
).x;
zeroRatioT = drawer.viewport.deltaPixelsFromPoints(
drawer.source.getPixelRatio( 0 ),
drawer.source.getPixelRatio(
Math.max(
drawer.source.getClosestLevel( drawer.viewport.containerSize ) - 1,
0
)
),
false
).x;
console.log( "ZERO RATIO T %s", drawer.source.getClosestLevel( drawer.viewport.containerSize ) );
optimalRatio = drawer.immediateRender ?
1 :
@ -850,7 +856,7 @@ function blendTile( drawer, tile, x, y, level, levelOpacity, currentTime ){
}
deltaTime = currentTime - tile.blendStart;
opacity = Math.min( 1, deltaTime / ( blendTimeMillis || 1 ) );
opacity = blendTimeMillis ? Math.min( 1, deltaTime / ( blendTimeMillis ) ) : 1;
if ( drawer.alwaysBlend ) {
opacity *= levelOpacity;
@ -1080,14 +1086,16 @@ function drawTiles( drawer, lastDrawn ){
//$.console.log("Rendering collection tile %s | %s | %s", tile.y, tile.y, position);
if( tileSource ){
drawer.collectionOverlays[ tileKey ] = viewer = new $.Viewer({
element: $.makeNeutralElement( "div" ),
mouseNavEnabled: false,
showNavigator: false,
showSequenceControl: false,
showNavigationControl: false,
//visibilityRatio: 1,
//debugMode: true,
//debugGridColor: 'red',
element: $.makeNeutralElement( "div" ),
mouseNavEnabled: false,
showNavigator: false,
showSequenceControl: false,
showNavigationControl: false,
//visibilityRatio: 1,
//debugMode: true,
//debugGridColor: 'red',
animationTime: 0,
blentTime: 0.1,
tileSources: [
tileSource
]

View File

@ -37,7 +37,10 @@ $.Navigator = function( options ){
showNavigator: false,
mouseNavEnabled: false,
showNavigationControl: false,
showSequenceControl: false
showSequenceControl: false,
immediateRender: true,
blendTime: 0,
animationTime: 0
});
options.minPixelRatio = this.minPixelRatio = viewer.minPixelRatio;
@ -228,6 +231,20 @@ $.extend( $.Navigator.prototype, $.EventHandler.prototype, $.Viewer.prototype, {
}( this.displayRegion.style ));
}
},
open: function( source ){
var containerSize = this.viewer.viewport.containerSize.times( this.sizeRatio );
if( source.tileSize > containerSize.x ||
source.tileSize > containerSize.y ){
this.minPixelRatio = Math.min(
containerSize.x,
containerSize.y
) / source.tileSize;
} else {
this.minPixelRatio = thie.viewer.minPixelRatio;
}
return $.Viewer.prototype.open.apply( this, [ source ] );
}
});

View File

@ -473,25 +473,25 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
wrapHorizontal: false,
wrapVertical: false,
visibilityRatio: 0.5,
minPixelRatio: 0.5,
minZoomImageRatio: 0.8,
maxZoomPixelRatio: 2,
minPixelRatio: 0.9,
defaultZoomLevel: 0,
minZoomLevel: null,
maxZoomLevel: null,
//UI RESPONSIVENESS AND FEEL
springStiffness: 5.0,
springStiffness: 7.0,
clickTimeThreshold: 300,
clickDistThreshold: 5,
zoomPerClick: 2.0,
zoomPerScroll: 1.2,
zoomPerSecond: 2.0,
animationTime: 1.5,
blendTime: 1.5,
animationTime: 1.0,
blendTime: 0,
alwaysBlend: false,
autoHideControls: true,
immediateRender: false,
minZoomImageRatio: 0.8,
maxZoomPixelRatio: 1.2,
//DEFAULT CONTROL SETTINGS
showSequenceControl: true, //SEQUENCE
@ -530,7 +530,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
//PERFORMANCE SETTINGS
imageLoaderLimit: 0,
maxImageCacheCount: 200,
timeout: 5000,
timeout: 30000,
//INTERFACE RESOURCE SETTINGS
prefixUrl: "/images/",

View File

@ -377,11 +377,13 @@ function loadPanels(strip, viewerSize, scroll){
tileSources: [ strip.viewer.tileSources[ i ] ],
element: element,
navigatorSizeRatio: strip.sizeRatio,
minPixelRatio: strip.minPixelRatio,
showNavigator: false,
mouseNavEnabled: false,
showNavigationControl: false,
showSequenceControl: false
showSequenceControl: false,
immediateRender: true,
blendTime: 0,
animationTime: 0
} );
miniViewer.displayRegion = $.makeNeutralElement( "textarea" );

View File

@ -1,7 +1,5 @@
(function( $ ){
var TILE_CACHE = {},
TILE_CACHE_STACK = [],
TILE_CACHE_MAX = 256;
var TILE_CACHE = {};
/**
* @class
* @param {Number} level The zoom level this tile belongs to.

View File

@ -180,6 +180,24 @@ $.TileSource.prototype = {
return new $.Point(rx, ry);
},
/**
* @function
* @param {Number} level
*/
getClosestLevel: function( rect ) {
var i,
tilesPerSide = Math.floor( Math.max( rect.x, rect.y ) / this.tileSize ),
tiles;
for( i = this.minLevel; i < this.maxLevel; i++ ){
tiles = this.getNumTiles( i );
if( Math.max( tiles.x, tiles.y ) + 1 >= tilesPerSide ){
break;
}
}
return Math.max( 0, i - 1 );
},
/**
* @function
* @param {Number} level