Web Inspector: Canvas: enable WebGL2 for inspector page
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Apr 2019 16:34:21 +0000 (16:34 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Apr 2019 16:34:21 +0000 (16:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196932
<rdar://problem/49916213>

Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

* UserInterface/Models/RecordingAction.js:
(WI.RecordingAction._prototypeForType):
(WI.RecordingAction.prototype.process.getContent):
Add additional checks for `ImageBitmapRenderingContext` and `WebGLRenderingContext`.

Source/WebKit:

* WebProcess/WebPage/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::WebInspectorUI):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244427 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/RecordingAction.js
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebInspectorUI.cpp

index d1cf661..e0316fa 100644 (file)
@@ -1,3 +1,16 @@
+2019-04-18  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Canvas: enable WebGL2 for inspector page
+        https://bugs.webkit.org/show_bug.cgi?id=196932
+        <rdar://problem/49916213>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/RecordingAction.js:
+        (WI.RecordingAction._prototypeForType):
+        (WI.RecordingAction.prototype.process.getContent):
+        Add additional checks for `ImageBitmapRenderingContext` and `WebGLRenderingContext`.
+
 2019-04-17  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Navigating to resource sometimes shows different resource
index cfb26c6..738bb28 100644 (file)
@@ -160,12 +160,20 @@ WI.RecordingAction = class RecordingAction extends WI.Object
 
     static _prototypeForType(type)
     {
-        if (type === WI.Recording.Type.Canvas2D)
+        switch (type) {
+        case WI.Recording.Type.Canvas2D:
             return CanvasRenderingContext2D.prototype;
-        if (type === WI.Recording.Type.CanvasBitmapRenderer)
-            return ImageBitmapRenderingContext.prototype;
-        if (type === WI.Recording.Type.CanvasWebGL)
-            return WebGLRenderingContext.prototype;
+        case WI.Recording.Type.CanvasBitmapRenderer:
+            if (window.ImageBitmapRenderingContext)
+                return ImageBitmapRenderingContext.prototype;
+            break;
+        case WI.Recording.Type.CanvasWebGL:
+            if (window.WebGLRenderingContext)
+                return WebGLRenderingContext.prototype;
+            break;
+        }
+
+        WI.reportInternalError("Unknown recording type: " + type);
         return null;
     }
 
@@ -211,7 +219,7 @@ WI.RecordingAction = class RecordingAction extends WI.Object
             if (context instanceof CanvasRenderingContext2D)
                 return context.getImageData(0, 0, context.canvas.width, context.canvas.height).data;
 
-            if (context instanceof WebGLRenderingContext || (window.WebGL2RenderingContext && context instanceof WebGL2RenderingContext)) {
+            if ((window.WebGLRenderingContext && context instanceof WebGLRenderingContext) || (window.WebGL2RenderingContext && context instanceof WebGL2RenderingContext)) {
                 let pixels = new Uint8Array(context.drawingBufferWidth * context.drawingBufferHeight * 4);
                 context.readPixels(0, 0, context.canvas.width, context.canvas.height, context.RGBA, context.UNSIGNED_BYTE, pixels);
                 return pixels;
index 630e48b..27041b6 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-18  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Canvas: enable WebGL2 for inspector page
+        https://bugs.webkit.org/show_bug.cgi?id=196932
+        <rdar://problem/49916213>
+
+        Reviewed by Timothy Hatcher.
+
+        * WebProcess/WebPage/WebInspectorUI.cpp:
+        (WebKit::WebInspectorUI::WebInspectorUI):
+
 2019-04-17  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: InspectorFrontendHost::inspectionLevel returns wrong value for inspector3
index 02ccd57..c9652e9 100644 (file)
@@ -53,6 +53,9 @@ WebInspectorUI::WebInspectorUI(WebPage& page)
 {
     RuntimeEnabledFeatures::sharedFeatures().setInspectorAdditionsEnabled(true);
     RuntimeEnabledFeatures::sharedFeatures().setImageBitmapOffscreenCanvasEnabled(true);
+#if ENABLE(WEBGL2)
+    RuntimeEnabledFeatures::sharedFeatures().setWebGL2Enabled(true);
+#endif
 }
 
 void WebInspectorUI::establishConnection(uint64_t inspectedPageIdentifier, bool underTest, unsigned inspectionLevel)