xml3d/xml3d.js — pull request #41 by K1ll3rF0x (2013-12-16 11:02:20+00:00)
Title: Feature/xflow multiplatform operators

This pull request implements multiplatform support for Xflow operators (related to: http://forge.fi-ware.eu/plugins/mediawiki/wiki/fiware/index.php/FIWARE.Feature.MiWi.3D-UI.DataflowProcessing.XFlowArchitecturalEnhancements.MultiPlatformNodes).

This is important groundwork for integrating WebCL and other platforms in the Xflow architecture in a more robust way. Basically, multiplatform operators provided by this pull request allow registering operators using the same operator name but a different platform. If no platform is defined during the registration phase, JavaScript platform will be used by default.
After this feature is merged in the develop branch we will start integrating the WebCL API in the Xflow platform and start adding multiplatform support in the other relevant places of the Xflow architecture.

* Tested with the current develop branch
* All unit tests passed
* Does not break any current usage examples or existing code

An example of registering a multiplatform operator :

```javascript
(function() {
Xflow.registerOperator("xflow.thresholdImage", {
outputs: [
{type: 'texture', name: 'output', sizeof: 'input'}
],
params: [
{type: 'texture', source: 'input'}
],

platform: Xflow.PLATFORM.JAVASCRIPT,

evaluate: function (output, input) {
var s = input.data,
d = output.data;

for (var i = 0; i < s.length; i += 4) {
d[i] = d[i + 1] = d[i + 2] = ((s[i] < 50) ? 0 : 255);
d[i + 3] = s[i + 3];
}

return true;
}
});

Xflow.registerOperator("xflow.thresholdImage", {
outputs: [
{type: 'texture', name: 'result', sizeof: 'image'}
],
params: [
{type: 'texture', source: 'image'}
],

platform: Xflow.PLATFORM.CL,

evaluate: function (result, image) {
// ** CL implementation of the same node **

return true;
}
}());
```