B2G/gecko/browser/devtools/tilt/TiltGL.jsm
/**
   * Caches shader attributes and uniforms as properties for a program object.
   *
   * @param {Object} aContext
   *                 a WebGL context
   * @param {Object} aProperties
   *                 an object containing the following properties:
   *         {Array} attributes: optional, an array of attributes as strings
   *         {Array} uniforms: optional, an array of uniforms as strings
   * @param {WebGLProgram} aProgram
   *                       the shader program used for caching
   *
   * @return {WebGLProgram} the same program
   */
Caches shader attributes and uniforms as properties for a program object.
@param {Object} aContext
a WebGL context
@param {Object} aProperties
an object containing the following properties:
{Array} attributes: optional, an array of attributes as strings
{Array} uniforms: optional, an array of uniforms as strings
@param {WebGLProgram} aProgram
the shader program used for caching

@return {WebGLProgram} the same program
Caches shader attributes and uniforms as properties for a program object . @param { Object } aContext a WebGL context @param { Object } aProperties an object containing the following properties : { Array } attributes : optional an array of attributes as strings { Array } uniforms : optional an array of uniforms as strings @param { WebGLProgram } aProgram the shader program used for caching @return { WebGLProgram } the same program
function TGLPU_cache(aContext, aProperties, aProgram)
  {
    aProperties = aProperties || {};
    aProgram.attributes = {};
    aProgram.uniforms = {};
    Object.defineProperty(aProgram.attributes, "length",
      { value: 0, writable: true, enumerable: false, configurable: true });
    Object.defineProperty(aProgram.uniforms, "length",
      { value: 0, writable: true, enumerable: false, configurable: true });
    let attr = aProperties.attributes;
    let unif = aProperties.uniforms;
    if (attr) {
      for (let i = 0, len = attr.length; i < len; i++) {
        let param = attr[i];
        let loc = aContext.getAttribLocation(aProgram, param);
        if ("number" === typeof loc && loc > -1) {
          if (aProgram.attributes[param] === undefined) {
            aProgram.attributes[param] = loc;
            aProgram.attributes.length++;
          }
        }
      }
    }
    if (unif) {
      for (let i = 0, len = unif.length; i < len; i++) {
        let param = unif[i];
        let loc = aContext.getUniformLocation(aProgram, param);
        if ("object" === typeof loc && loc) {
          if (aProgram.uniforms[param] === undefined) {
            aProgram.uniforms[param] = loc;
            aProgram.uniforms.length++;
          }
        }
      }
    }
    return aProgram;
  }
function TGLPU_cache ( aContext , aProperties , aProgram ) { aProperties = aProperties || { } ; aProgram . attributes = { } ; aProgram . uniforms = { } ; Object . defineProperty ( aProgram . attributes , "length" , { value : 0 , writable : true , enumerable : false , configurable : true } ) ; Object . defineProperty ( aProgram . uniforms , "length" , { value : 0 , writable : true , enumerable : false , configurable : true } ) ; let attr = aProperties . attributes ; let unif = aProperties . uniforms ; if ( attr ) { for ( let i = 0 , len = attr . length ; i < len ; i ++ ) { let param = attr [ i ] ; let loc = aContext . getAttribLocation ( aProgram , param ) ; if ( "number" === typeof loc && loc > - 1 ) { if ( aProgram . attributes [ param ] === undefined ) { aProgram . attributes [ param ] = loc ; aProgram . attributes . length ++ ; } } } } if ( unif ) { for ( let i = 0 , len = unif . length ; i < len ; i ++ ) { let param = unif [ i ] ; let loc = aContext . getUniformLocation ( aProgram , param ) ; if ( "object" === typeof loc && loc ) { if ( aProgram . uniforms [ param ] === undefined ) { aProgram . uniforms [ param ] = loc ; aProgram . uniforms . length ++ ; } } } } return aProgram ; }
Caches shader attributes and uniforms as properties for a program object.
Caches shader attributes and uniforms as properties for a program object .
// make sure the properties parameter is a valid object // make sure the attributes and uniforms cache objects are created // try to get a shader attribute from the program // if we get an attribute location, store it // bind the new parameter only if it was not already defined // try to get a shader uniform from the program // if we get a uniform object, store it // bind the new parameter only if it was not already defined