19 lines
1.4 KiB
JavaScript
19 lines
1.4 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$gpu$texture$uploaders$gpuUploadImageSource = function(global, require, module, exports) {
|
|
var adapter = require("module$node_modules$pixi_DOT_js$lib$environment$adapter"), warn = require("module$node_modules$pixi_DOT_js$lib$utils$logging$warn");
|
|
"use strict";
|
|
exports.gpuUploadImageResource = {type:"image", upload(source, gpuTexture, gpu, originZOverride = 0) {
|
|
const resource = source.resource;
|
|
if (resource) {
|
|
if (globalThis.HTMLImageElement && resource instanceof HTMLImageElement) {
|
|
const canvas = adapter.DOMAdapter.get().createCanvas(resource.width, resource.height);
|
|
canvas.getContext("2d").drawImage(resource, 0, 0, resource.width, resource.height);
|
|
source.resource = canvas;
|
|
warn.warn("ImageSource: Image element passed, converting to canvas and replacing resource.");
|
|
}
|
|
gpu.device.queue.copyExternalImageToTexture({source:resource}, {texture:gpuTexture, origin:{x:0, y:0, z:originZOverride}, premultipliedAlpha:"premultiply-alpha-on-upload" === source.alphaMode}, {width:Math.min(gpuTexture.width, source.resourceWidth || source.pixelWidth), height:Math.min(gpuTexture.height, source.resourceHeight || source.pixelHeight)});
|
|
}
|
|
}};
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$gpu$texture$uploaders$gpuUploadImageSource.js.map
|