]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Move support check from display to browser
authorJuanjo Diaz <juanjo.diazmo@gmail.com>
Wed, 27 Feb 2019 08:13:50 +0000 (10:13 +0200)
committerJuanjo Diaz <juanjo.diazmo@gmail.com>
Wed, 27 Feb 2019 08:13:50 +0000 (10:13 +0200)
core/display.js
core/util/browser.js

index 59ddb340bb3d0bfcf0a992c094c699bee6a6d277..73e038736aa18d989ebf2809c1ca3e32a13bc252 100644 (file)
@@ -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) {
@@ -573,7 +566,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);
index 026a31ab8d28f60427b70f3ee09e56b37152867c..78e104de5415d13d43bcc55552c1188276ac226d 100644 (file)
@@ -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);
 }