diff --git a/changelog.txt b/changelog.txt index 8e30cacb..c1615913 100644 --- a/changelog.txt +++ b/changelog.txt @@ -35,6 +35,7 @@ OPENSEADRAGON CHANGELOG * Button: 'enter', 'exit', 'press', 'release', 'focus', 'blur', 'click' * Fixed: IE 10 not reading DZI file correctly in certain circumstances (#218) * Fix for non-canvas tile rendering at large size (#264) +* Drawer now uses an HTML5 canvas element if it's available. Can be overridden with Viewer.useCanvas option (#191) 0.9.131: diff --git a/src/drawer.js b/src/drawer.js index 0cc436d6..91771e5a 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -46,10 +46,7 @@ var DEVICE_SCREEN = $.getWindowSize(), ( BROWSER == $.BROWSERS.IE && BROWSER_VERSION >= 9 ) ), - USE_CANVAS = SUBPIXEL_RENDERING && - !( DEVICE_SCREEN.x <= 400 || DEVICE_SCREEN.y <= 400 ) && - !( navigator.appVersion.match( 'Mobile' ) ) && - $.isFunction( document.createElement( "canvas" ).getContext ); + USE_CANVAS = $.supportsCanvas; //console.error( 'USE_CANVAS ' + USE_CANVAS ); @@ -124,6 +121,10 @@ $.Drawer = function( options ) { }, options ); + if ( this.viewer ) { + USE_CANVAS = $.supportsCanvas && this.viewer.useCanvas; + } + this.container = $.getElement( this.element ); this.canvas = $.makeNeutralElement( USE_CANVAS ? "canvas" : "div" ); this.context = USE_CANVAS ? this.canvas.getContext( "2d" ) : null; diff --git a/src/openseadragon.js b/src/openseadragon.js index 0c0a01ca..0edb9b33 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -386,6 +386,19 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ }; + /* + * Detect canvas support + */ + var canvasElement = document.createElement( 'canvas' ); + /** + * True if the browser supports the HTML5 canvas element + * @name $.supportsCanvas + * @property + */ + $.supportsCanvas = !!( $.isFunction( canvasElement.getContext ) && + canvasElement.getContext( '2d' ) ); + + }( OpenSeadragon )); /** @@ -559,6 +572,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ imageLoaderLimit: 0, maxImageCacheCount: 200, timeout: 30000, + useCanvas: true, // Use canvas element for drawing if available //INTERFACE RESOURCE SETTINGS prefixUrl: "/images/",