Title: [135711] trunk/Source/WebCore
Revision
135711
Author
commit-qu...@webkit.org
Date
2012-11-26 05:55:16 -0800 (Mon, 26 Nov 2012)

Log Message

Web Inspector: [WebGL] Save WebGL extensions and restore on replay
https://bugs.webkit.org/show_bug.cgi?id=103141

Patch by Andrey Adaikin <aand...@chromium.org> on 2012-11-26
Reviewed by Yury Semikhatsky.

Save WebGL extensions that were enabled by the application, and restore it before the replay.
Drive-by: remove redundant if- checks in WebGL custom function wrappers (similar to 2D canvas).

* inspector/InjectedScriptCanvasModuleSource.js:
(.):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135710 => 135711)


--- trunk/Source/WebCore/ChangeLog	2012-11-26 13:54:02 UTC (rev 135710)
+++ trunk/Source/WebCore/ChangeLog	2012-11-26 13:55:16 UTC (rev 135711)
@@ -1,3 +1,16 @@
+2012-11-26  Andrey Adaikin  <aand...@chromium.org>
+
+        Web Inspector: [WebGL] Save WebGL extensions and restore on replay
+        https://bugs.webkit.org/show_bug.cgi?id=103141
+
+        Reviewed by Yury Semikhatsky.
+
+        Save WebGL extensions that were enabled by the application, and restore it before the replay.
+        Drive-by: remove redundant if- checks in WebGL custom function wrappers (similar to 2D canvas).
+
+        * inspector/InjectedScriptCanvasModuleSource.js:
+        (.):
+
 2012-11-26  Allan Sandfeld Jensen  <allan.jen...@digia.com>
 
         HitTestResult should not be a HitTestLocation

Modified: trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js (135710 => 135711)


--- trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js	2012-11-26 13:54:02 UTC (rev 135710)
+++ trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js	2012-11-26 13:55:16 UTC (rev 135711)
@@ -1189,9 +1189,10 @@
     },
 
     /**
+     * Handles: texParameteri, texParameterf
      * @param {Call} call
      */
-    pushCall_texParameterf: function(call)
+    pushCall_texParameter: function(call)
     {
         var args = call.args();
         var pname = args[1];
@@ -1203,6 +1204,7 @@
     },
 
     /**
+     * Handles: copyTexImage2D, copyTexSubImage2D
      * copyTexImage2D and copyTexSubImage2D define a texture image with pixels from the current framebuffer.
      * @param {Call} call
      */
@@ -1223,9 +1225,6 @@
     __proto__: WebGLBoundResource.prototype
 }
 
-WebGLTextureResource.prototype.pushCall_texParameteri = WebGLTextureResource.prototype.pushCall_texParameterf;
-WebGLTextureResource.prototype.pushCall_copyTexSubImage2D = WebGLTextureResource.prototype.pushCall_copyTexImage2D;
-
 /**
  * @constructor
  * @extends {Resource}
@@ -1456,6 +1455,8 @@
     this._replayContextCallback = replayContextCallback;
     /** @type {Object.<number, boolean>} */
     this._customErrors = null;
+    /** @type {!Object.<string, boolean>} */
+    this._extensions = {};
 }
 
 /**
@@ -1633,6 +1634,14 @@
     },
 
     /**
+     * @param {string} name
+     */
+    addExtension: function(name)
+    {
+        this._extensions[name] = true;
+    },
+
+    /**
      * @override
      * @param {Object} data
      * @param {Cache} cache
@@ -1641,6 +1650,7 @@
     {
         var gl = this.wrappedObject();
         data.replayContextCallback = this._replayContextCallback;
+        data.extensions = TypeUtils.cloneObject(this._extensions);
 
         var originalErrors = this.getAllErrors();
 
@@ -1696,10 +1706,15 @@
     {
         this._replayContextCallback = data.replayContextCallback;
         this._customErrors = null;
+        this._extensions = TypeUtils.cloneObject(data.extensions) || {};
 
         var gl = /** @type {!WebGLRenderingContext} */ (Resource.wrappedObject(this._replayContextCallback()));
         this.setWrappedObject(gl);
 
+        // Enable corresponding WebGL extensions.
+        for (var name in this._extensions)
+            gl.getExtension(name);
+
         var glState = data.glState;
         gl.bindFramebuffer(gl.FRAMEBUFFER, /** @type {WebGLFramebuffer} */ (ReplayableResource.replay(glState.FRAMEBUFFER_BINDING, cache)));
         gl.bindRenderbuffer(gl.RENDERBUFFER, /** @type {WebGLRenderbuffer} */ (ReplayableResource.replay(glState.RENDERBUFFER_BINDING, cache)));
@@ -1853,45 +1868,54 @@
 
             /**
              * @param {string} methodName
+             * @param {function(this:Resource, Call)=} pushCallFunc
              */
-            function customWrapFunction(methodName)
+            function stateModifyingWrapFunction(methodName, pushCallFunc)
             {
-                var customPushCall = "pushCall_" + methodName;
-                /**
-                 * @param {Object|number} target
-                 * @this Resource.WrapFunction
-                 */
-                wrapFunctions[methodName] = function(target)
-                {
-                    var resource = this._resource.currentBinding(target);
-                    if (!resource)
-                        return;
-                    if (resource[customPushCall])
-                        resource[customPushCall].call(resource, this.call());
-                    else
-                        resource.pushCall(this.call());
+                if (pushCallFunc) {
+                    /**
+                     * @param {Object|number} target
+                     * @this Resource.WrapFunction
+                     */
+                    wrapFunctions[methodName] = function(target)
+                    {
+                        var resource = this._resource.currentBinding(target);
+                        if (resource)
+                            pushCallFunc.call(resource, this.call());
+                    }
+                } else {
+                    /**
+                     * @param {Object|number} target
+                     * @this Resource.WrapFunction
+                     */
+                    wrapFunctions[methodName] = function(target)
+                    {
+                        var resource = this._resource.currentBinding(target);
+                        if (resource)
+                            resource.pushCall(this.call());
+                    }
                 }
             }
-            customWrapFunction("attachShader");
-            customWrapFunction("bindAttribLocation");
-            customWrapFunction("compileShader");
-            customWrapFunction("detachShader");
-            customWrapFunction("linkProgram");
-            customWrapFunction("shaderSource");
-            customWrapFunction("bufferData");
-            customWrapFunction("bufferSubData");
-            customWrapFunction("compressedTexImage2D");
-            customWrapFunction("compressedTexSubImage2D");
-            customWrapFunction("copyTexImage2D");
-            customWrapFunction("copyTexSubImage2D");
-            customWrapFunction("generateMipmap");
-            customWrapFunction("texImage2D");
-            customWrapFunction("texSubImage2D");
-            customWrapFunction("texParameterf");
-            customWrapFunction("texParameteri");
-            customWrapFunction("framebufferRenderbuffer");
-            customWrapFunction("framebufferTexture2D");
-            customWrapFunction("renderbufferStorage");
+            stateModifyingWrapFunction("attachShader");
+            stateModifyingWrapFunction("bindAttribLocation");
+            stateModifyingWrapFunction("compileShader");
+            stateModifyingWrapFunction("detachShader");
+            stateModifyingWrapFunction("linkProgram");
+            stateModifyingWrapFunction("shaderSource");
+            stateModifyingWrapFunction("bufferData");
+            stateModifyingWrapFunction("bufferSubData");
+            stateModifyingWrapFunction("compressedTexImage2D");
+            stateModifyingWrapFunction("compressedTexSubImage2D");
+            stateModifyingWrapFunction("copyTexImage2D", WebGLTextureResource.prototype.pushCall_copyTexImage2D);
+            stateModifyingWrapFunction("copyTexSubImage2D", WebGLTextureResource.prototype.pushCall_copyTexImage2D);
+            stateModifyingWrapFunction("generateMipmap");
+            stateModifyingWrapFunction("texImage2D");
+            stateModifyingWrapFunction("texSubImage2D");
+            stateModifyingWrapFunction("texParameterf", WebGLTextureResource.prototype.pushCall_texParameter);
+            stateModifyingWrapFunction("texParameteri", WebGLTextureResource.prototype.pushCall_texParameter);
+            stateModifyingWrapFunction("framebufferRenderbuffer");
+            stateModifyingWrapFunction("framebufferTexture2D");
+            stateModifyingWrapFunction("renderbufferStorage");
 
             /** @this Resource.WrapFunction */
             wrapFunctions["getError"] = function()
@@ -1907,6 +1931,15 @@
                 }
             }
 
+            /**
+             * @param {string} name
+             * @this Resource.WrapFunction
+             */
+            wrapFunctions["getExtension"] = function(name)
+            {
+                this._resource.addExtension(name);
+            }
+
             WebGLRenderingContextResource._wrapFunctions = wrapFunctions;
         }
         return wrapFunctions;
@@ -2253,7 +2286,7 @@
 
             /**
              * @param {string} methodName
-             * @param {Function=} func
+             * @param {function(this:Resource, Call)=} func
              */
             function stateModifyingWrapFunction(methodName, func)
             {
@@ -2273,9 +2306,9 @@
             }
 
             for (var i = 0, methodName; methodName = CanvasRenderingContext2DResource.TransformationMatrixMethods[i]; ++i)
-                stateModifyingWrapFunction(methodName, methodName === "setTransform" ? this.pushCall_setTransform : null);
+                stateModifyingWrapFunction(methodName, methodName === "setTransform" ? this.pushCall_setTransform : undefined);
             for (var i = 0, methodName; methodName = CanvasRenderingContext2DResource.PathMethods[i]; ++i)
-                stateModifyingWrapFunction(methodName, methodName === "beginPath" ? this.pushCall_beginPath : null);
+                stateModifyingWrapFunction(methodName, methodName === "beginPath" ? this.pushCall_beginPath : undefined);
 
             stateModifyingWrapFunction("save", this.pushCall_save);
             stateModifyingWrapFunction("restore", this.pushCall_restore);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to