From 916b4f5276413f1348769f87605fee412068f8cb Mon Sep 17 00:00:00 2001 From: "U-ADRIAN-PC\\Adrian" Date: Tue, 15 Mar 2016 20:00:51 -0400 Subject: [PATCH] Fix warning messages on pixel inspector and depth inspector --- src/content_script/depth_inspector.js | 41 +++++++++++---------------- src/content_script/pixel_inspector.js | 20 +++++++++++-- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/content_script/depth_inspector.js b/src/content_script/depth_inspector.js index 9791655..495c671 100644 --- a/src/content_script/depth_inspector.js +++ b/src/content_script/depth_inspector.js @@ -127,28 +127,7 @@ glpDepthInspector.prototype.disable = function() { this.gl.useProgram(newProgram); this.copyUniforms(currentProgram, newProgram); } -} - -glpDepthInspector.prototype.bindFrameBuffer = function(enable) { - this.framebufferIsBound = !!enable; - this.toggleByBuffer(!!enable); -} - -glpDepthInspector.prototype.bindRenderBuffer = function(enable) { - this.renderbufferIsBound = !!enable; - this.toggleByBuffer(!!enable); -} - -glpDepthInspector.prototype.toggleByBuffer = function(enable) { - if (!this.enabled) { - return; - } - - if (!this.framebufferIsBound && !this.renderbufferIsBound) { - this.enable(); - } else { - this.disable(); - } + this.locationMap = {} } /** @@ -273,15 +252,27 @@ glpDepthInspector.prototype.uniforms = function(args) { var program = args[0]; var location = args[1]; if (this.programs.indexOf(program.__uuid) >= 0) { + // the program is a pixel inspector + // lets check if the location is from the original program + // if so, switch the location + // else, switch the program to the original program if (location in this.locationMap[program.__uuid]) { - // the program is the pixel inspector version and we're using the original location args[1] = this.locationMap[program.__uuid][location.__uuid]; } else { + args[0] = this.originalPrograms[program.__uuid]; } } else { // the program is not a pixel inspector - // if they're using the wrong location, lets just swap programs - args[0] = this.gl.getParameter(this.gl.CURRENT_PROGRAM); + // lets check if the location is from the original program + // if so, switch programs and location + if (program.__uuid in this.locationMap){ + if (this.locationMap[program.__uuid] && location.__uuid in this.locationMap[program.__uuid]) { + args[0] = this.gl.getParameter(this.gl.CURRENT_PROGRAM); + } else { + args[1] = this.locationMap[program.__uuid][location.__uuid]; + } + } + //else switch program was never called and no changes need to be made } } return args; diff --git a/src/content_script/pixel_inspector.js b/src/content_script/pixel_inspector.js index 3059a90..cc69e46 100644 --- a/src/content_script/pixel_inspector.js +++ b/src/content_script/pixel_inspector.js @@ -144,6 +144,8 @@ glpPixelInspector.prototype.disable = function() { this.gl.useProgram(newProgram); this.copyUniforms(currentProgram, newProgram); } + + this.locationMap = {} } /** @@ -307,15 +309,27 @@ glpPixelInspector.prototype.uniforms = function(args) { var program = args[0]; var location = args[1]; if (this.programs.indexOf(program.__uuid) >= 0) { + // the program is a pixel inspector + // lets check if the location is from the original program + // if so, switch the location + // else, switch the program to the original program if (location in this.locationMap[program.__uuid]) { - // the program is the pixel inspector version and we're using the original location args[1] = this.locationMap[program.__uuid][location.__uuid]; } else { + args[0] = this.originalPrograms[program.__uuid]; } } else { // the program is not a pixel inspector - // if they're using the wrong location, lets just swap programs - args[0] = this.gl.getParameter(this.gl.CURRENT_PROGRAM); + // lets check if the location is from the original program + // if so, switch programs and location + if (program.__uuid in this.locationMap){ + if (this.locationMap[program.__uuid] && location.__uuid in this.locationMap[program.__uuid]) { + args[0] = this.gl.getParameter(this.gl.CURRENT_PROGRAM); + } else { + args[1] = this.locationMap[program.__uuid][location.__uuid]; + } + } + //else switch program was never called and no changes need to be made } } return args;