Skip to content

Commit

Permalink
Enable ImageBitmap if interface is present (#4584)
Browse files Browse the repository at this point in the history
  • Loading branch information
slimbuck authored Aug 23, 2022
1 parent 6fa2d01 commit 0756e07
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/resources/parser/texture/img.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { path } from '../../../core/path.js';
import { http } from '../../../net/http.js';

import {
PIXELFORMAT_R8_G8_B8, PIXELFORMAT_R8_G8_B8_A8, TEXHINT_ASSET,
DEVICETYPE_WEBGPU
PIXELFORMAT_R8_G8_B8, PIXELFORMAT_R8_G8_B8_A8, TEXHINT_ASSET
} from '../../../graphics/constants.js';
import { Texture } from '../../../graphics/texture.js';

Expand All @@ -22,13 +21,7 @@ class ImgParser {
// by default don't try cross-origin, because some browsers send different cookies (e.g. safari) if this is set.
this.crossOrigin = registry.prefix ? 'anonymous' : null;
this.maxRetries = 0;
// As of today (9 Jul 2021) ImageBitmap only works on Chrome:
// - Firefox doesn't support options parameter to createImageBitmap (see https://bugzilla.mozilla.org/show_bug.cgi?id=1533680)
// - Safari supports ImageBitmap only as experimental feature.
// this.useImageBitmap = typeof ImageBitmap !== 'undefined' && /Firefox/.test(navigator.userAgent) === false;
// WebGPUTexture expects ImageBitmap.
const isWebGPU = registry?._loader?._app?.graphicsDevice?.deviceType === DEVICETYPE_WEBGPU;
this.useImageBitmap = isWebGPU;
this.useImageBitmap = typeof ImageBitmap !== 'undefined';
}

load(url, callback, asset) {
Expand Down Expand Up @@ -133,12 +126,8 @@ class ImgParser {
createImageBitmap(blob, {
premultiplyAlpha: 'none'
})
.then(function (imageBitmap) {
callback(null, imageBitmap);
})
.catch(function (e) {
callback(e);
});
.then(imageBitmap => callback(null, imageBitmap))
.catch(e => callback(e));
}
});
}
Expand Down

0 comments on commit 0756e07

Please sign in to comment.