Optimize contexts for reading frequently

This was a recommendation from Edge.
Docs here: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently
This commit is contained in:
Daniel Imms
2022-09-24 06:58:01 -07:00
parent 1431210ecd
commit d62b4531c3
2 changed files with 7 additions and 2 deletions
+3 -1
View File
@@ -89,7 +89,9 @@ export class ColorManager implements IColorManager {
const canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
const ctx = canvas.getContext('2d');
const ctx = canvas.getContext('2d', {
willReadFrequently: true
});
if (!ctx) {
throw new Error('Could not get rendering context');
}