mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 12:46:09 +03:00
clean up outdated code; add tiled-image-drawn event to canvasdrawer so tests work with this viewer
This commit is contained in:
parent
32f12b3ba5
commit
1200f0b081
@ -176,6 +176,36 @@ class CanvasDrawer extends $.DrawerBase{
|
||||
context.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @inner
|
||||
* Fires the tile-drawing event.
|
||||
*
|
||||
*/
|
||||
_raiseTileDrawingEvent(tiledImage, context, tile, rendered){
|
||||
/**
|
||||
* This event is fired just before the tile is drawn giving the application a chance to alter the image.
|
||||
*
|
||||
* NOTE: This event is only fired when the 'canvas' drawer is being used
|
||||
*
|
||||
* @event tile-drawing
|
||||
* @memberof OpenSeadragon.Viewer
|
||||
* @type {object}
|
||||
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
||||
* @property {OpenSeadragon.Tile} tile - The Tile being drawn.
|
||||
* @property {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
||||
* @property {CanvasRenderingContext2D} context - The HTML canvas context being drawn into.
|
||||
* @property {CanvasRenderingContext2D} rendered - The HTML canvas context containing the tile imagery.
|
||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||
*/
|
||||
this.viewer.raiseEvent('tile-drawing', {
|
||||
tiledImage: tiledImage,
|
||||
context: context,
|
||||
tile: tile,
|
||||
rendered: rendered
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @inner
|
||||
@ -464,6 +494,26 @@ class CanvasDrawer extends $.DrawerBase{
|
||||
}
|
||||
|
||||
this._drawDebugInfo( tiledImage, lastDrawn );
|
||||
|
||||
// Fire tiled-image-drawn event.
|
||||
if( this.viewer ){
|
||||
/**
|
||||
* Raised when a tiled image is drawn to the canvas. Only valid
|
||||
* for webgl and canvas drawers.
|
||||
*
|
||||
* @event tiled-image-drawn
|
||||
* @memberof OpenSeadragon.Viewer
|
||||
* @type {object}
|
||||
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
||||
* @property {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
||||
* @property {Array} tiles - An array of Tile objects that were drawn.
|
||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||
*/
|
||||
this.viewer.raiseEvent( 'tiled-image-drawn', {
|
||||
tiledImage: tiledImage,
|
||||
tiles: tilesToDraw.map(info => info.tile),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,34 +231,6 @@ $.DrawerBase = class DrawerBase{
|
||||
}
|
||||
}
|
||||
|
||||
_raiseTileDrawingEvent(tiledImage, context, tile, rendered){
|
||||
/**
|
||||
* This event is fired just before the tile is drawn giving the application a chance to alter the image.
|
||||
*
|
||||
* NOTE: This event is only fired in certain drawing contexts: either the 'canvas' drawer is
|
||||
* being used, or the 'webgl' drawer with 'drawerOptions.webgl.continuousTileRefresh'.
|
||||
* TODO: if we get rid of this in the webgl drawer, this can be moved to canvas drawer and the comment about continuousTileRefresh can be removed
|
||||
*
|
||||
* @event tile-drawing
|
||||
* @memberof OpenSeadragon.Viewer
|
||||
* @type {object}
|
||||
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
||||
* @property {OpenSeadragon.Tile} tile - The Tile being drawn.
|
||||
* @property {OpenSeadragon.TiledImage} tiledImage - Which TiledImage is being drawn.
|
||||
* @property {CanvasRenderingContext2D} context - The HTML canvas context being drawn into.
|
||||
* @property {CanvasRenderingContext2D} rendered - The HTML canvas context containing the tile imagery.
|
||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||
*/
|
||||
this.viewer.raiseEvent('tile-drawing', {
|
||||
tiledImage: tiledImage,
|
||||
context: context,
|
||||
tile: tile,
|
||||
rendered: rendered
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Utility functions
|
||||
|
||||
|
@ -342,15 +342,6 @@
|
||||
// Draw the quad (two triangles)
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
||||
|
||||
// TODO: Can we get rid of this entirely in this version of the webgl drawer?
|
||||
// iterate over any filters - filters can use this._renderToTexture to get rendered data if desired
|
||||
// let filters = this.filters || [];
|
||||
// for(let fi = 0; fi < filters.length; fi++){
|
||||
// let filter = this.filters[fi];
|
||||
// if(filter.apply){
|
||||
// filter.apply(gl); // filter.apply should write data on top of the backbuffer (bound above)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
renderingBufferHasImageData = true;
|
||||
@ -369,7 +360,7 @@
|
||||
if( this.viewer ){
|
||||
/**
|
||||
* Raised when a tiled image is drawn to the canvas. Only valid
|
||||
* for webgl drawer.
|
||||
* for webgl and canvas drawers.
|
||||
*
|
||||
* @event tiled-image-drawn
|
||||
* @memberof OpenSeadragon.Viewer
|
||||
@ -503,15 +494,6 @@
|
||||
textureDataArray[index] = texture;
|
||||
matrixArray[index] = overallMatrix.values;
|
||||
|
||||
// TODO: can we get rid of this in this version of the webgl drawer?
|
||||
// if(this.continuousTileRefresh){
|
||||
// // Upload the image into the texture
|
||||
// // TODO: test if this works appropriately
|
||||
// let tileContext = tile.getCanvasContext();
|
||||
// this._raiseTileDrawingEvent(tiledImage, this._outputContext, tile, tileContext);
|
||||
// this._uploadImageData(tileContext, tile, tiledImage);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
_setupRenderer(){
|
||||
|
@ -1163,7 +1163,7 @@
|
||||
done();
|
||||
return;
|
||||
}
|
||||
// var previousValue = viewer.drawer.continuousTileRefresh;
|
||||
|
||||
assert.ok(viewer.numberOfHandlers('tile-drawing') === 0,
|
||||
"'tile-drawing' event is empty by default.");
|
||||
|
||||
@ -1171,7 +1171,7 @@
|
||||
viewer.removeHandler( 'tile-drawing', tileDrawing );
|
||||
assert.ok(viewer.numberOfHandlers('tile-drawing') === 0,
|
||||
"'tile-drawing' deleted: count is 0.");
|
||||
// viewer.drawer.continuousTileRefresh = previousValue; // reset property
|
||||
|
||||
viewer.close();
|
||||
done();
|
||||
};
|
||||
@ -1190,7 +1190,6 @@
|
||||
assert.ok(viewer.numberOfHandlers('tile-drawing') === 1,
|
||||
"'tile-drawing' deleted once: count is 1.");
|
||||
|
||||
// viewer.drawer.continuousTileRefresh = true; // set to true so the tile-drawing event fires
|
||||
viewer.open( '/test/data/testpattern.dzi' );
|
||||
} );
|
||||
|
||||
@ -1201,7 +1200,6 @@
|
||||
done();
|
||||
return;
|
||||
}
|
||||
// var previousValue = viewer.drawer.continuousTileRefresh;
|
||||
|
||||
var tileDrawing = function ( event ) {
|
||||
viewer.removeHandler( 'tile-drawing', tileDrawing );
|
||||
@ -1212,12 +1210,10 @@
|
||||
assert.ok(event.tile, "Tile should be set");
|
||||
assert.ok(event.rendered, "Rendered should be set");
|
||||
}
|
||||
// viewer.drawer.continuousTileRefresh = previousValue; // reset property
|
||||
viewer.close();
|
||||
done();
|
||||
};
|
||||
|
||||
// viewer.drawer.continuousTileRefresh = true; // set to true so the tile-drawing event fires
|
||||
viewer.addHandler( 'tile-drawing', tileDrawing );
|
||||
viewer.open( '/test/data/testpattern.dzi' );
|
||||
} );
|
||||
|
Loading…
Reference in New Issue
Block a user