mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-28 08:06:08 +03:00
Better drawer resolution, also supporting inline class spec. Fix minor review stuff.
This commit is contained in:
parent
3c3842bdce
commit
046612f8da
@ -67,7 +67,7 @@ module.exports = function(grunt) {
|
|||||||
"src/tilecache.js",
|
"src/tilecache.js",
|
||||||
"src/world.js",
|
"src/world.js",
|
||||||
|
|
||||||
// Aoisa's webgl drawer - needs optimization, polishing, trimming
|
// Aiosa's webgl drawer - needs optimization, polishing, trimming
|
||||||
// "src/webgl/webGLWrapper.js",
|
// "src/webgl/webGLWrapper.js",
|
||||||
// "src/webgl/visualisationLayer.js",
|
// "src/webgl/visualisationLayer.js",
|
||||||
// "src/webgl/dataLoader.js",
|
// "src/webgl/dataLoader.js",
|
||||||
|
@ -108,9 +108,7 @@ $.DrawerBase = class DrawerBase{
|
|||||||
|
|
||||||
this._checkForAPIOverrides();
|
this._checkForAPIOverrides();
|
||||||
}
|
}
|
||||||
get isOpenSeadragonDrawer(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
get canvas(){
|
get canvas(){
|
||||||
if(!this._renderingTarget){
|
if(!this._renderingTarget){
|
||||||
this._renderingTarget = this.createDrawingElement();
|
this._renderingTarget = this.createDrawingElement();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* OpenSeadragon - Mat3
|
* OpenSeadragon - Mat3
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010-2023 OpenSeadragon contributors
|
* Modified from https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
|
||||||
|
* Copyright (C) 2010-2023 webglfundamentals.org and OpenSeadragon contributors
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are
|
* modification, are permitted provided that the following conditions are
|
||||||
@ -36,7 +36,6 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Matrix left-to-right system representation
|
* Matrix left-to-right system representation
|
||||||
* Modified from https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html
|
|
||||||
*/
|
*/
|
||||||
$.Mat3 = class Mat3 {
|
$.Mat3 = class Mat3 {
|
||||||
constructor(values){
|
constructor(values){
|
||||||
|
@ -445,44 +445,44 @@ $.Viewer = function( options ) {
|
|||||||
|
|
||||||
delete this.drawerOptions.useCanvas;
|
delete this.drawerOptions.useCanvas;
|
||||||
}
|
}
|
||||||
let drawerPriority = Array.isArray(this.drawer) ? this.drawer : [this.drawer];
|
let drawerCandidates = Array.isArray(this.drawer) ? this.drawer : [this.drawer];
|
||||||
let drawersToTry = drawerPriority.filter(d => ['webgl', 'canvas', 'html'].includes(d) || (d.prototype && d.prototype.isOpenSeadragonDrawer) );
|
if (drawerCandidates.length === 0){
|
||||||
if(drawerPriority.length !== drawersToTry.length){
|
drawerCandidates = [$.DEFAULT_SETTINGS.drawer].flat(); // ensure it is a list
|
||||||
$.console.error('An invalid drawer was requested.');
|
|
||||||
}
|
|
||||||
if(drawersToTry.length === 0){
|
|
||||||
drawersToTry = [$.DEFAULT_SETTINGS.drawer].flat(); // ensure it is a list
|
|
||||||
$.console.warn('No valid drawers were selected. Using the default value.');
|
$.console.warn('No valid drawers were selected. Using the default value.');
|
||||||
}
|
}
|
||||||
// extend the drawerOptions object with additional properties to pass to the Drawer implementation
|
// extend the drawerOptions object with additional properties to pass to the Drawer implementation
|
||||||
// TODO: how to deal with the possibility that none of the requested drawers are supported?
|
// TODO: how to deal with the possibility that none of the requested drawers are supported?
|
||||||
this.drawer = null;
|
this.drawer = null;
|
||||||
for(let i = 0; i < drawersToTry.length; i++){
|
for (let i = 0; i < drawerCandidates.length; i++) {
|
||||||
|
|
||||||
//todo necessary? why not to use class names as drawer IDs
|
let drawerCandidate = drawerCandidates[i];
|
||||||
let optsKey = drawersToTry[i];
|
let Drawer = null;
|
||||||
let Drawer = $.determineDrawer(optsKey);
|
|
||||||
if (!Drawer) {
|
//if inherits from a drawer base, use it
|
||||||
optsKey = 'custom';
|
if (drawerCandidate && drawerCandidate.prototype instanceof $.DrawerBase) {
|
||||||
//todo will raise error anyway...
|
Drawer = drawerCandidate;
|
||||||
|
drawerCandidate = 'custom';
|
||||||
|
} else if (typeof drawerCandidate === "string") {
|
||||||
|
Drawer = $.determineDrawer(drawerCandidate);
|
||||||
} else {
|
} else {
|
||||||
|
$.console.warn('Unsupported drawer! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase.');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// if the drawer is supported, create it and break the loop
|
// if the drawer is supported, create it and break the loop
|
||||||
if (Drawer.isSupported()){
|
if (Drawer.isSupported()) {
|
||||||
this.drawer = new Drawer({
|
this.drawer = new Drawer({
|
||||||
viewer: this,
|
viewer: this,
|
||||||
viewport: this.viewport,
|
viewport: this.viewport,
|
||||||
element: this.canvas,
|
element: this.canvas,
|
||||||
debugGridColor: this.debugGridColor,
|
debugGridColor: this.debugGridColor,
|
||||||
options: this.drawerOptions[optsKey],
|
options: this.drawerOptions[drawerCandidate],
|
||||||
});
|
});
|
||||||
this.drawerOptions.constructor = Drawer;
|
this.drawerOptions.constructor = Drawer;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!this.drawer){
|
||||||
|
|
||||||
}
|
|
||||||
if(this.drawer === null){
|
|
||||||
$.console.error('No drawer could be created!');
|
$.console.error('No drawer could be created!');
|
||||||
throw('Error with creating the selected drawer(s)');
|
throw('Error with creating the selected drawer(s)');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user