forked from gpujs/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.js
More file actions
42 lines (36 loc) · 1.29 KB
/
image.js
File metadata and controls
42 lines (36 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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());
});