src/wtf/trace/providers/webglprovider.js
function instrumentExtensionObject(ctx, name, object) {
    var proto = object.constructor.prototype;

    // We do this check only for known extensions, as Firefox will return a
    // generic 'Object' for others and that will break everything.
    function checkInstrumented() {
      if (proto['__gl_wrapped__']) {
        return false;
      }
      Object.defineProperty(proto, '__gl_wrapped__', {
        'configurable': true,
        'enumerable': false,
        'value': true
      });
      contextRestoreFns.push(function() {
        delete proto['__gl_wrapped__'];
      });
      return true;
    };

    switch (name) {
      case 'ANGLE_instanced_arrays':
        if (checkInstrumented()) {
          wrapInstancedArraysExtension(ctx, proto);
        }
        return true;
      case 'OES_vertex_array_object':
        if (checkInstrumented()) {
          wrapVertexArrayObjectExtension(ctx, proto);
        }
        return true;
      case 'WEBGL_lose_context':
        if (checkInstrumented()) {
          wrapLoseContextExtension(ctx, proto);
        }
        return true;
      case 'WEBGL_draw_buffers':
        // http://www.khronos.org/registry/webgl/extensions/WEBGL_draw_buffers/
      case 'WEBGL_security_sensitive_resources':
        // http://www.khronos.org/registry/webgl/extensions/WEBGL_security_sensitive_resources/
      case 'WEBGL_shared_resources':
        // http://www.khronos.org/registry/webgl/extensions/WEBGL_shared_resources/
        // Don't support these yet, so report them as not present.
        return false;
      default:
        return true;
    }
  }
function instrumentExtensionObject(ctx, name, object) {
    var proto = object.constructor.prototype;

    // We do this check only for known extensions, as Firefox will return a
    // generic 'Object' for others and that will break everything.
    function checkInstrumented() {
      if (proto['__gl_wrapped__']) {
        return false;
      }
      Object.defineProperty(proto, '__gl_wrapped__', {
        'configurable': true,
        'enumerable': false,
        'value': true
      });
      contextRestoreFns.push(function() {
        delete proto['__gl_wrapped__'];
      });
      return true;
    };

    switch (name) {
      case 'ANGLE_instanced_arrays':
        if (checkInstrumented()) {
          wrapInstancedArraysExtension(ctx, proto);
        }
        return true;
      case 'OES_vertex_array_object':
        if (checkInstrumented()) {
          wrapVertexArrayObjectExtension(ctx, proto);
        }
        return true;
      case 'WEBGL_lose_context':
        if (checkInstrumented()) {
          wrapLoseContextExtension(ctx, proto);
        }
        return true;
      case 'WEBGL_draw_buffers':
        // http://www.khronos.org/registry/webgl/extensions/WEBGL_draw_buffers/
      case 'WEBGL_security_sensitive_resources':
        // http://www.khronos.org/registry/webgl/extensions/WEBGL_security_sensitive_resources/
      case 'WEBGL_shared_resources':
        // http://www.khronos.org/registry/webgl/extensions/WEBGL_shared_resources/
        // Don't support these yet, so report them as not present.
        return false;
      default:
        return true;
    }
  }
function instrumentExtensionObject ( ctx , name , object ) { var proto = object . constructor . prototype ; // We do this check only for known extensions, as Firefox will return a // generic 'Object' for others and that will break everything. function checkInstrumented ( ) { if ( proto [ '__gl_wrapped__' ] ) { return false ; } Object . defineProperty ( proto , '__gl_wrapped__' , { 'configurable' : true , 'enumerable' : false , 'value' : true } ) ; contextRestoreFns . push ( function ( ) { delete proto [ '__gl_wrapped__' ] ; } ) ; return true ; } ; switch ( name ) { case 'ANGLE_instanced_arrays' : if ( checkInstrumented ( ) ) { wrapInstancedArraysExtension ( ctx , proto ) ; } return true ; case 'OES_vertex_array_object' : if ( checkInstrumented ( ) ) { wrapVertexArrayObjectExtension ( ctx , proto ) ; } return true ; case 'WEBGL_lose_context' : if ( checkInstrumented ( ) ) { wrapLoseContextExtension ( ctx , proto ) ; } return true ; case 'WEBGL_draw_buffers' : // http://www.khronos.org/registry/webgl/extensions/WEBGL_draw_buffers/ case 'WEBGL_security_sensitive_resources' : // http://www.khronos.org/registry/webgl/extensions/WEBGL_security_sensitive_resources/ case 'WEBGL_shared_resources' : // http://www.khronos.org/registry/webgl/extensions/WEBGL_shared_resources/ // Don't support these yet, so report them as not present. return false ; default : return true ; } }
Wraps an extension object.
This should be called for each extension object as it is returned from
getExtension so that its prototype can be instrumented, as required.
@param {!WebGLRenderingContext} ctx Target context.
@param {string} name Extension name.
@param {!Object} object Extension object.
@return {boolean} True if the extension is supported.
Wraps an extension object . This should be called for each extension object as it is returned from getExtension so that its prototype can be instrumented as required .