Move support check from display to browser
This commit is contained in:
committed by
Lauri Kasanen
parent
c755008d15
commit
37c17ddbf9
@@ -8,14 +8,7 @@
|
|||||||
|
|
||||||
import * as Log from './util/logging.js';
|
import * as Log from './util/logging.js';
|
||||||
import Base64 from "./base64.js";
|
import Base64 from "./base64.js";
|
||||||
|
import { supportsImageMetadata } from './util/browser.js';
|
||||||
let SUPPORTS_IMAGEDATA_CONSTRUCTOR = false;
|
|
||||||
try {
|
|
||||||
new ImageData(new Uint8ClampedArray(4), 1, 1);
|
|
||||||
SUPPORTS_IMAGEDATA_CONSTRUCTOR = true;
|
|
||||||
} catch (ex) {
|
|
||||||
// ignore failure
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class Display {
|
export default class Display {
|
||||||
constructor(target) {
|
constructor(target) {
|
||||||
@@ -581,7 +574,7 @@ export default class Display {
|
|||||||
_rgbxImageData(x, y, width, height, arr, offset) {
|
_rgbxImageData(x, y, width, height, arr, offset) {
|
||||||
// NB(directxman12): arr must be an Type Array view
|
// NB(directxman12): arr must be an Type Array view
|
||||||
let img;
|
let img;
|
||||||
if (SUPPORTS_IMAGEDATA_CONSTRUCTOR) {
|
if (supportsImageMetadata) {
|
||||||
img = new ImageData(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4), width, height);
|
img = new ImageData(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4), width, height);
|
||||||
} else {
|
} else {
|
||||||
img = this._drawCtx.createImageData(width, height);
|
img = this._drawCtx.createImageData(width, height);
|
||||||
|
|||||||
@@ -49,6 +49,15 @@ export function supportsCursorURIs() {
|
|||||||
return _cursor_uris_supported;
|
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() {
|
export function isMac() {
|
||||||
return navigator && !!(/mac/i).exec(navigator.platform);
|
return navigator && !!(/mac/i).exec(navigator.platform);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user