MCPcopy Index your code
hub / github.com/gpujs/gpu.js / mergeSettings

Method mergeSettings

src/backend/kernel.js:231–269  ·  view source on GitHub ↗

* * @param {IDirectKernelSettings|IJSONSettings} settings

(settings)

Source from the content-addressed store, hash-verified

229 * @param {IDirectKernelSettings|IJSONSettings} settings
230 */
231 mergeSettings(settings) {
232 for (let p in settings) {
233 if (!settings.hasOwnProperty(p) || !this.hasOwnProperty(p)) continue;
234 switch (p) {
235 case 'output':
236 if (!Array.isArray(settings.output)) {
237 this.setOutput(settings.output); // Flatten output object
238 continue;
239 }
240 break;
241 case 'functions':
242 this.functions = [];
243 for (let i = 0; i < settings.functions.length; i++) {
244 this.addFunction(settings.functions[i]);
245 }
246 continue;
247 case 'graphical':
248 if (settings[p] && !settings.hasOwnProperty('precision')) {
249 this.precision = 'unsigned';
250 }
251 this[p] = settings[p];
252 continue;
253 case 'nativeFunctions':
254 if (!settings.nativeFunctions) continue;
255 this.nativeFunctions = [];
256 for (let i = 0; i < settings.nativeFunctions.length; i++) {
257 const s = settings.nativeFunctions[i];
258 const { name, source } = s;
259 this.addNativeFunction(name, source, s);
260 }
261 continue;
262 }
263 this[p] = settings[p];
264 }
265
266 if (!this.canvas) this.canvas = this.initCanvas();
267 if (!this.context) this.context = this.initContext();
268 if (!this.plugins) this.plugins = this.initPlugins(settings);
269 }
270 /**
271 * @desc Builds the Kernel, by compiling Fragment and Vertical Shaders,
272 * and instantiates the program.

Callers 3

deprecated.jsFile · 0.80
constructorMethod · 0.80
constructorMethod · 0.80

Calls 6

setOutputMethod · 0.95
addFunctionMethod · 0.95
addNativeFunctionMethod · 0.95
initCanvasMethod · 0.95
initContextMethod · 0.95
initPluginsMethod · 0.95

Tested by

no test coverage detected