mirror of
https://github.com/gpujs/gpu.js.git
synced 2025-12-08 20:35:56 +00:00
fix: typescript to include video and KernelValues fix: Duplicate image in unit test fix: Bump and build
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
const { assert, skip, test, module: describe } = require('qunit');
|
|
const { GPU } = require('../../src');
|
|
|
|
describe('image');
|
|
function imageArgumentTest(mode, done) {
|
|
const gpu = new GPU({ mode });
|
|
const image = document.createElement('img');
|
|
image.src = 'jellyfish-1.jpeg';
|
|
image.onload = function() {
|
|
const imageKernel = gpu.createKernel(function(image) {
|
|
const pixel = image[this.thread.y][this.thread.x];
|
|
this.color(pixel[0], pixel[1], pixel[2], pixel[3]);
|
|
}, {
|
|
graphical: true,
|
|
output : [image.width, image.height]
|
|
});
|
|
imageKernel(image);
|
|
assert.equal(true, true, 'does not throw');
|
|
gpu.destroy();
|
|
done();
|
|
};
|
|
}
|
|
|
|
(typeof Image !== 'undefined' ? test : skip)('image argument auto', t => {
|
|
imageArgumentTest(null, t.async());
|
|
});
|
|
|
|
(typeof Image !== 'undefined' ? test : skip)('image argument gpu', t => {
|
|
imageArgumentTest('gpu', t.async());
|
|
});
|
|
|
|
(GPU.isWebGLSupported && typeof Image !== 'undefined' ? test : skip)('image argument webgl', t => {
|
|
imageArgumentTest('webgl', t.async());
|
|
});
|
|
|
|
(GPU.isWebGL2Supported && typeof Image !== 'undefined' ? test : skip)('image argument webgl2', t => {
|
|
imageArgumentTest('webgl2', t.async());
|
|
});
|
|
|
|
(typeof Image !== 'undefined' ? test : skip)('image argument cpu', t => {
|
|
imageArgumentTest('cpu', t.async());
|
|
});
|