summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authorpetersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-29 03:06:39 +0000
committerpetersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-29 03:06:39 +0000
commit3f23fa23395460adbb7e9bfc7ee552042ca8f474 (patch)
treedfcf7638a8ad9f4d95425068cd4f6dde8b546df2 /o3d
parente327e4ebb9574b5be5a6433530b4f19882b08b17 (diff)
downloadchromium_src-3f23fa23395460adbb7e9bfc7ee552042ca8f474.zip
chromium_src-3f23fa23395460adbb7e9bfc7ee552042ca8f474.tar.gz
chromium_src-3f23fa23395460adbb7e9bfc7ee552042ca8f474.tar.bz2
This is a change that Daniel Horn did as part of this:
http://codereview.chromium.org/3072008 I don't see why it can't be a separate, short changelist. Review URL: http://codereview.chromium.org/3215005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57810 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/samples/o3d-webgl/effect.js59
1 files changed, 25 insertions, 34 deletions
diff --git a/o3d/samples/o3d-webgl/effect.js b/o3d/samples/o3d-webgl/effect.js
index f45dab0..7427670 100644
--- a/o3d/samples/o3d-webgl/effect.js
+++ b/o3d/samples/o3d-webgl/effect.js
@@ -260,11 +260,8 @@ o3d.Effect.prototype.loadPixelShaderFromString =
o3d.Effect.prototype.loadFromFXString =
function(shaderString) {
var splitIndex = shaderString.indexOf('// #o3d SplitMarker');
- var vertexShaderString = shaderString.substr(0, splitIndex);
- var pixelShaderString = shaderString.substr(splitIndex);
- var result = this.loadVertexShaderFromString(vertexShaderString) &&
- this.loadPixelShaderFromString(pixelShaderString);
- return result;
+ return this.loadVertexShaderFromString(shaderString.substr(0, splitIndex)) &&
+ this.loadPixelShaderFromString(shaderString.substr(splitIndex));
};
@@ -538,51 +535,45 @@ o3d.Effect.prototype.getStreamInfo = function() {
* @private
*/
o3d.Effect.prototype.searchForParams_ = function(object_list) {
- var filled_map = {};
- for (var name in this.uniforms_) {
- filled_map[name] = false;
+ var unfilledMap = {};
+ for (var uniformName in this.uniforms_) {
+ unfilledMap[uniformName] = true;
}
this.gl.useProgram(this.program_);
o3d.Param.texture_index_ = 0;
- for (var i = 0; i < object_list.length; ++i) {
+ var object_list_length = object_list.length;
+ for (var i = 0; i < object_list_length; ++i) {
var obj = object_list[i];
for (var name in this.uniforms_) {
- var uniformInfo = this.uniforms_[name];
- if (filled_map[name]) {
- continue;
- }
- var param = obj.getParam(name);
- if (param) {
- if (uniformInfo.kind == o3d.Effect.ARRAY) {
- param.applyToLocations(this.gl, uniformInfo.locations);
- } else {
- if (uniformInfo.info.type == this.gl.SAMPLER_CUBE) {
- param.applyToLocation(this.gl, uniformInfo.location, true);
+ if (unfilledMap[name]) {
+ var uniformInfo = this.uniforms_[name];
+ var param = obj.getParam(name);
+ if (param) {
+ if (uniformInfo.kind == o3d.Effect.ARRAY) {
+ param.applyToLocations(this.gl, uniformInfo.locations);
} else {
param.applyToLocation(this.gl, uniformInfo.location);
}
+ delete unfilledMap[name];
}
- filled_map[name] = true;
}
}
}
this.updateHelperConstants_(this.gl.displayInfo.width,
this.gl.displayInfo.height);
- filled_map[o3d.Effect.HELPER_CONSTANT_NAME] = true;
- for (var name in this.uniforms_) {
- if (!filled_map[name]) {
- if (this.uniforms_[name].info.type == this.gl.SAMPLER_2D) {
- if (this.gl.client.reportErrors_()) {
- this.gl.client.error_callback("Missing ParamSampler");
- }
- var defaultParamSampler = o3d.ParamSampler.defaultParamSampler_;
- defaultParamSampler.gl = this.gl;
- defaultParamSampler.applyToLocation(this.gl,
- this.uniforms_[name].location);
- } else {
- throw ('Uniform param not filled: "'+ name + '"');
+ delete unfilledMap[o3d.Effect.HELPER_CONSTANT_NAME];
+ for (var name in unfilledMap) {
+ if (this.uniforms_[name].info.type == this.gl.SAMPLER_2D) {
+ if (this.gl.client.reportErrors_()) {
+ this.gl.client.error_callback("Missing ParamSampler");
}
+ var defaultParamSampler = o3d.ParamSampler.defaultParamSampler_;
+ defaultParamSampler.gl = this.gl;
+ defaultParamSampler.applyToLocation(this.gl,
+ this.uniforms_[name].location);
+ } else {
+ throw ('Uniform param not filled: "'+ name + '"');
}
}
};