forked from xml3d/xml3d.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult.js
More file actions
162 lines (132 loc) · 4.07 KB
/
result.js
File metadata and controls
162 lines (132 loc) · 4.07 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
(function(){
/**
* Content of this file:
* Result classes of an Xflow graph which are received through Requests.
*/
/**
* Abstract Result structure containing a (processed) result of the Xflow graph.
* @abstract
* @param {Xflow.DataNode} dataNode
* @param {Array.<string>} filter
*/
Xflow.Result = function(){
this.loading = false;
this.valid = false;
this._listeners = [];
this._requests = [];
};
var Result = Xflow.Result;
/**
* @param {function(Xflow.Result, Xflow.RESULT_STATE)} callback
*/
Result.prototype.addListener = function(callback){
this._listeners.push(callback);
};
/**
* @param {function(Xflow.Result, Xflow.RESULT_STATE)} callback
*/
Result.prototype.removeListener = function(callback){
Array.erase(this._listeners, callback);
};
/**
* @param {function(Xflow.Result, Xflow.RESULT_STATE)} callback
*/
Result.prototype._addRequest = function(request){
this._requests.push(request);
};
/**
* @param {function(Xflow.Result, Xflow.RESULT_STATE)} callback
*/
Result.prototype._removeRequest = function(request){
Array.erase(this._requests, request);
};
Result.prototype._notifyChanged = function(state){
this.valid = false;
for(var i = 0; i < this._requests.length; ++i){
this._requests[i]._onResultChanged(state);
}
Xflow._listCallback(this, state);
}
Result.prototype._onListedCallback = function(state){
for(var i = 0; i < this._listeners.length; ++i){
this._listeners[i](this, state);
}
}
/**
* ComputeResult contains a named map of typed values.
* @constructor
* @extends {Xflow.Result}
*/
Xflow.ComputeResult = function(){
Xflow.Result.call(this);
this._outputNames = [];
/** @type {Object.<string,DataEntry>} */
this._dataEntries = {};
};
Xflow.createClass(Xflow.ComputeResult, Xflow.Result);
var ComputeResult = Xflow.ComputeResult;
Object.defineProperty(ComputeResult.prototype, "outputNames", {
set: function(v){
throw new Error("outputNames is readonly");
},
get: function(){ return this._outputNames; }
});
ComputeResult.prototype.getOutputData = function(name){
return this._dataEntries[name];
};
/**
* @returns {Object.<string,DataEntry>}
*/
ComputeResult.prototype.getOutputMap = function() {
return this._dataEntries;
};
/**
* VertexShaderResult is used to generate a VertexShader that includes dataflow processing
* @constructor
* @extends {Xflow.Result}
*/
Xflow.VertexShaderResult = function(){
Xflow.Result.call(this);
this._shaderInputNames = null;
this._program = null;
this._programData = null;
};
Xflow.createClass(Xflow.VertexShaderResult, Xflow.Result);
var VertexShaderResult = Xflow.VertexShaderResult;
Object.defineProperty(VertexShaderResult.prototype, "shaderInputNames", {
set: function(v){
throw new Error("shaderInputNames is readonly");
},
get: function(){ return this._program._shaderInputNames; }
});
Object.defineProperty(VertexShaderResult.prototype, "shaderOutputNames", {
set: function(v){
throw new Error("shaderOutputNames is readonly");
},
get: function(){ return this._program._shaderOutputNames; }
});
VertexShaderResult.prototype.getShaderInputData = function(name){
return this._program.getInputData(name, this._programData);
};
VertexShaderResult.prototype.isShaderInputUniform = function(name){
return this._program.isInputUniform(name);
}
VertexShaderResult.prototype.isShaderOutputUniform = function(name){
return this._program.isOutputUniform(name);
}
VertexShaderResult.prototype.getShaderOutputType = function(name){
return this._program.getShaderOutputType(name);
}
VertexShaderResult.prototype.getShaderOutputSourceName = function(name){
return this._program.getShaderOutputSourceName(name);
}
VertexShaderResult.prototype.getUniformOutputData = function(name){
return this._program.getUniformOutputData(name, this._programData);
}
VertexShaderResult.prototype.isShaderOutputNull = function(name){
return this._program.isOutputNull(name);
}
VertexShaderResult.prototype.getGLSLCode = function(){
return this._program._glslCode;
}
})();