Move support check from display to browser

pull/36/head
Juanjo Diaz 6 years ago committed by Lauri Kasanen
parent c755008d15
commit 37c17ddbf9

@ -8,14 +8,7 @@
import * as Log from './util/logging.js';
import Base64 from "./base64.js";
let SUPPORTS_IMAGEDATA_CONSTRUCTOR = false;
try {
new ImageData(new Uint8ClampedArray(4), 1, 1);
SUPPORTS_IMAGEDATA_CONSTRUCTOR = true;
} catch (ex) {
// ignore failure
}
import { supportsImageMetadata } from './util/browser.js';
export default class Display {
constructor(target) {
@ -581,7 +574,7 @@ export default class Display {
_rgbxImageData(x, y, width, height, arr, offset) {
// NB(directxman12): arr must be an Type Array view
let img;
if (SUPPORTS_IMAGEDATA_CONSTRUCTOR) {
if (supportsImageMetadata) {
img = new ImageData(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4), width, height);
} else {
img = this._drawCtx.createImageData(width, height);

@ -49,6 +49,15 @@ export function supportsCursorURIs() {
return _cursor_uris_supported;
}
let _supportsImageMetadata = false;
try {
new ImageData(new Uint8ClampedArray(4), 1, 1);
_supportsImageMetadata = true;
} catch (ex) {
// ignore failure
}
export const supportsImageMetadata = _supportsImageMetadata;
export function isMac() {
return navigator && !!(/mac/i).exec(navigator.platform);
}

Loading…
Cancel
Save