-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6574 from lvlte/heatmap_rendering_perf
Improve heatmap rendering performance when `zsmooth` is false
- Loading branch information
Showing
14 changed files
with
141 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Improve heatmap rendering performance when `zsmooth` is set to false [[#6574](https://github.com/plotly/plotly.js/pull/6574)], with thanks to @lvlte for the contribution! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
// Pixelated image rendering | ||
// The actual CSS declaration is prepended with fallbacks for older browsers. | ||
// NB. IE's `-ms-interpolation-mode` works only with <img> not with SVG <image> | ||
// https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering | ||
// https://caniuse.com/?search=image-rendering | ||
// http://phrogz.net/tmp/canvas_image_zoom.html | ||
|
||
exports.CSS_DECLARATIONS = [ | ||
['image-rendering', 'optimizeSpeed'], | ||
['image-rendering', '-moz-crisp-edges'], | ||
['image-rendering', '-o-crisp-edges'], | ||
['image-rendering', '-webkit-optimize-contrast'], | ||
['image-rendering', 'optimize-contrast'], | ||
['image-rendering', 'crisp-edges'], | ||
['image-rendering', 'pixelated'] | ||
]; | ||
|
||
exports.STYLE = exports.CSS_DECLARATIONS.map(function(d) { | ||
return d.join(': ') + '; '; | ||
}).join(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
var constants = require('../constants/pixelated_image'); | ||
var Drawing = require('../components/drawing'); | ||
var Lib = require('../lib'); | ||
|
||
var _supportsPixelated = null; | ||
|
||
/** | ||
* Check browser support for pixelated image rendering | ||
* | ||
* @return {boolean} | ||
*/ | ||
function supportsPixelatedImage() { | ||
if(_supportsPixelated !== null) { // only run the feature detection once | ||
return _supportsPixelated; | ||
} | ||
if(Lib.isIE()) { | ||
_supportsPixelated = false; | ||
} else { | ||
var declarations = Array.from(constants.CSS_DECLARATIONS).reverse(); | ||
var supports = window.CSS && window.CSS.supports || window.supportsCSS; | ||
if(typeof supports === 'function') { | ||
_supportsPixelated = declarations.some(function(d) { | ||
return supports.apply(null, d); | ||
}); | ||
} else { | ||
var image3 = Drawing.tester.append('image'); | ||
var cStyles = window.getComputedStyle(image3.node()); | ||
image3.attr('style', constants.STYLE); | ||
_supportsPixelated = declarations.some(function(d) { | ||
var value = d[1]; | ||
return cStyles.imageRendering === value || | ||
cStyles.imageRendering === value.toLowerCase(); | ||
}); | ||
image3.remove(); | ||
} | ||
} | ||
return _supportsPixelated; | ||
} | ||
|
||
module.exports = supportsPixelatedImage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.