Title: [284279] branches/safari-612-branch/Source
Revision
284279
Author
[email protected]
Date
2021-10-15 15:37:24 -0700 (Fri, 15 Oct 2021)

Log Message

Cherry-pick r283572. rdar://problem/83953133

    Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
    https://bugs.webkit.org/show_bug.cgi?id=231205

    Reviewed by Devin Rousso.

    Source/_javascript_Core:

    Use an enum instead of strings for color space values sent to the frontend.

    * inspector/protocol/Canvas.json:
    * inspector/scripts/codegen/generator.py:

    Source/WebCore:

    Use an enum instead of strings for color space values sent to the frontend.

    * inspector/InspectorCanvas.cpp:
    (WebCore::buildObjectForCanvasContextAttributes):

    Source/WebInspectorUI:

    For canvas context's with a color space attribute, show the color space next to the context type in the header
    of each context card in the Graphics tab.

    * UserInterface/Models/Canvas.js:
    (WI.Canvas.displayNameForColorSpace):
    * UserInterface/Views/CanvasContentView.js:
    (WI.CanvasContentView.prototype.initialLayout):
    * UserInterface/Views/CanvasOverviewContentView.css:
    (.content-view.canvas-overview > .content-view.canvas > header > .titles > :matches(.subtitle, .color-space),):
    (.content-view.canvas-overview > .content-view.canvas > header .color-space::before):

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

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/_javascript_Core/ChangeLog (284278 => 284279)


--- branches/safari-612-branch/Source/_javascript_Core/ChangeLog	2021-10-15 22:36:55 UTC (rev 284278)
+++ branches/safari-612-branch/Source/_javascript_Core/ChangeLog	2021-10-15 22:37:24 UTC (rev 284279)
@@ -1,3 +1,53 @@
+2021-10-15  Russell Epstein  <[email protected]>
+
+        Cherry-pick r283572. rdar://problem/83953133
+
+    Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
+    https://bugs.webkit.org/show_bug.cgi?id=231205
+    
+    Reviewed by Devin Rousso.
+    
+    Source/_javascript_Core:
+    
+    Use an enum instead of strings for color space values sent to the frontend.
+    
+    * inspector/protocol/Canvas.json:
+    * inspector/scripts/codegen/generator.py:
+    
+    Source/WebCore:
+    
+    Use an enum instead of strings for color space values sent to the frontend.
+    
+    * inspector/InspectorCanvas.cpp:
+    (WebCore::buildObjectForCanvasContextAttributes):
+    
+    Source/WebInspectorUI:
+    
+    For canvas context's with a color space attribute, show the color space next to the context type in the header
+    of each context card in the Graphics tab.
+    
+    * UserInterface/Models/Canvas.js:
+    (WI.Canvas.displayNameForColorSpace):
+    * UserInterface/Views/CanvasContentView.js:
+    (WI.CanvasContentView.prototype.initialLayout):
+    * UserInterface/Views/CanvasOverviewContentView.css:
+    (.content-view.canvas-overview > .content-view.canvas > header > .titles > :matches(.subtitle, .color-space),):
+    (.content-view.canvas-overview > .content-view.canvas > header .color-space::before):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283572 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-05  Patrick Angle  <[email protected]>
+
+            Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
+            https://bugs.webkit.org/show_bug.cgi?id=231205
+
+            Reviewed by Devin Rousso.
+
+            Use an enum instead of strings for color space values sent to the frontend.
+
+            * inspector/protocol/Canvas.json:
+            * inspector/scripts/codegen/generator.py:
+
 2021-08-26  Yusuke Suzuki  <[email protected]>
 
         Intl.DateTimeFormat incorrectly parses patterns with 'h' literal

Modified: branches/safari-612-branch/Source/_javascript_Core/inspector/protocol/Canvas.json (284278 => 284279)


--- branches/safari-612-branch/Source/_javascript_Core/inspector/protocol/Canvas.json	2021-10-15 22:36:55 UTC (rev 284278)
+++ branches/safari-612-branch/Source/_javascript_Core/inspector/protocol/Canvas.json	2021-10-15 22:37:24 UTC (rev 284279)
@@ -16,6 +16,11 @@
             "description": "Unique shader program identifier."
         },
         {
+            "id": "ColorSpace",
+            "type": "string",
+            "enum": ["srgb", "display-p3"]
+        },
+        {
             "id": "ContextType",
             "type": "string",
             "enum": ["canvas-2d", "bitmaprenderer", "webgl", "webgl2"],
@@ -39,6 +44,8 @@
             "description": "Drawing surface attributes.",
             "properties": [
                 { "name": "alpha", "type": "boolean", "optional": true, "description": "WebGL, WebGL2, ImageBitmapRenderingContext" },
+                { "name": "colorSpace", "$ref": "ColorSpace", "optional": true, "description": "2D" },
+                { "name": "desynchronized", "type": "boolean", "optional": true, "description": "2D" },
                 { "name": "depth", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
                 { "name": "stencil", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
                 { "name": "antialias", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },

Modified: branches/safari-612-branch/Source/_javascript_Core/inspector/scripts/codegen/generator.py (284278 => 284279)


--- branches/safari-612-branch/Source/_javascript_Core/inspector/scripts/codegen/generator.py	2021-10-15 22:36:55 UTC (rev 284278)
+++ branches/safari-612-branch/Source/_javascript_Core/inspector/scripts/codegen/generator.py	2021-10-15 22:37:24 UTC (rev 284279)
@@ -42,7 +42,8 @@
 def ucfirst(str):
     return str[:1].upper() + str[1:]
 
-_ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS = set(['2D', 'API', 'CSS', 'DOM', 'HTML', 'JIT', 'XHR', 'XML', 'IOS', 'MacOS', '_javascript_', 'ServiceWorker'])
+
+_ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS = set(['2D', 'API', 'CSS', 'DOM', 'HTML', 'JIT', 'SRGB', 'XHR', 'XML', 'IOS', 'MacOS', '_javascript_', 'ServiceWorker'])
 _ALWAYS_SPECIALCASED_ENUM_VALUE_LOOKUP_TABLE = dict([(s.upper(), s) for s in _ALWAYS_SPECIALCASED_ENUM_VALUE_SUBSTRINGS])
 
 _ENUM_IDENTIFIER_RENAME_MAP = {

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (284278 => 284279)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-15 22:36:55 UTC (rev 284278)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-15 22:37:24 UTC (rev 284279)
@@ -1,5 +1,55 @@
 2021-10-15  Russell Epstein  <[email protected]>
 
+        Cherry-pick r283572. rdar://problem/83953133
+
+    Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
+    https://bugs.webkit.org/show_bug.cgi?id=231205
+    
+    Reviewed by Devin Rousso.
+    
+    Source/_javascript_Core:
+    
+    Use an enum instead of strings for color space values sent to the frontend.
+    
+    * inspector/protocol/Canvas.json:
+    * inspector/scripts/codegen/generator.py:
+    
+    Source/WebCore:
+    
+    Use an enum instead of strings for color space values sent to the frontend.
+    
+    * inspector/InspectorCanvas.cpp:
+    (WebCore::buildObjectForCanvasContextAttributes):
+    
+    Source/WebInspectorUI:
+    
+    For canvas context's with a color space attribute, show the color space next to the context type in the header
+    of each context card in the Graphics tab.
+    
+    * UserInterface/Models/Canvas.js:
+    (WI.Canvas.displayNameForColorSpace):
+    * UserInterface/Views/CanvasContentView.js:
+    (WI.CanvasContentView.prototype.initialLayout):
+    * UserInterface/Views/CanvasOverviewContentView.css:
+    (.content-view.canvas-overview > .content-view.canvas > header > .titles > :matches(.subtitle, .color-space),):
+    (.content-view.canvas-overview > .content-view.canvas > header .color-space::before):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283572 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-05  Patrick Angle  <[email protected]>
+
+            Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
+            https://bugs.webkit.org/show_bug.cgi?id=231205
+
+            Reviewed by Devin Rousso.
+
+            Use an enum instead of strings for color space values sent to the frontend.
+
+            * inspector/InspectorCanvas.cpp:
+            (WebCore::buildObjectForCanvasContextAttributes):
+
+2021-10-15  Russell Epstein  <[email protected]>
+
         Cherry-pick r283033. rdar://problem/83953190
 
     [IOS 15] Video track does not get unmuted in case of tab was inactive less than ~500 ms

Modified: branches/safari-612-branch/Source/WebCore/inspector/InspectorCanvas.cpp (284278 => 284279)


--- branches/safari-612-branch/Source/WebCore/inspector/InspectorCanvas.cpp	2021-10-15 22:36:55 UTC (rev 284278)
+++ branches/safari-612-branch/Source/WebCore/inspector/InspectorCanvas.cpp	2021-10-15 22:37:24 UTC (rev 284279)
@@ -813,6 +813,67 @@
     return m_frameCount && m_framesCaptured >= m_frameCount.value();
 }
 
+static RefPtr<Inspector::Protocol::Canvas::ContextAttributes> buildObjectForCanvasContextAttributes(CanvasRenderingContext& context)
+{
+    if (is<CanvasRenderingContext2D>(context)) {
+        auto attributes = downcast<CanvasRenderingContext2D>(context).getContextAttributes();
+        auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create()
+            .release();
+        switch (attributes.colorSpace) {
+        case PredefinedColorSpace::SRGB:
+            contextAttributesPayload->setColorSpace(Protocol::Canvas::ColorSpace::SRGB);
+            break;
+
+#if ENABLE(PREDEFINED_COLOR_SPACE_DISPLAY_P3)
+        case PredefinedColorSpace::DisplayP3:
+            contextAttributesPayload->setColorSpace(Protocol::Canvas::ColorSpace::DisplayP3);
+            break;
+#endif
+        }
+        contextAttributesPayload->setDesynchronized(attributes.desynchronized);
+        return contextAttributesPayload;
+    }
+
+    if (is<ImageBitmapRenderingContext>(context)) {
+        auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create()
+            .release();
+        contextAttributesPayload->setAlpha(downcast<ImageBitmapRenderingContext>(context).hasAlpha());
+        return contextAttributesPayload;
+    }
+
+#if ENABLE(WEBGL)
+    if (is<WebGLRenderingContextBase>(context)) {
+        const auto& attributes = downcast<WebGLRenderingContextBase>(context).getContextAttributes();
+        if (!attributes)
+            return nullptr;
+
+        auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create()
+            .release();
+        contextAttributesPayload->setAlpha(attributes->alpha);
+        contextAttributesPayload->setDepth(attributes->depth);
+        contextAttributesPayload->setStencil(attributes->stencil);
+        contextAttributesPayload->setAntialias(attributes->antialias);
+        contextAttributesPayload->setPremultipliedAlpha(attributes->premultipliedAlpha);
+        contextAttributesPayload->setPreserveDrawingBuffer(attributes->preserveDrawingBuffer);
+        switch (attributes->powerPreference) {
+        case WebGLPowerPreference::Default:
+            contextAttributesPayload->setPowerPreference("default"_s);
+            break;
+        case WebGLPowerPreference::LowPower:
+            contextAttributesPayload->setPowerPreference("low-power"_s);
+            break;
+        case WebGLPowerPreference::HighPerformance:
+            contextAttributesPayload->setPowerPreference("high-performance"_s);
+            break;
+        }
+        contextAttributesPayload->setFailIfMajorPerformanceCaveat(attributes->failIfMajorPerformanceCaveat);
+        return contextAttributesPayload;
+    }
+#endif // ENABLE(WEBGL)
+
+    return nullptr;
+}
+
 Ref<Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(bool captureBacktrace)
 {
     using ContextTypeType = std::optional<Protocol::Canvas::ContextType>;

Modified: branches/safari-612-branch/Source/WebInspectorUI/ChangeLog (284278 => 284279)


--- branches/safari-612-branch/Source/WebInspectorUI/ChangeLog	2021-10-15 22:36:55 UTC (rev 284278)
+++ branches/safari-612-branch/Source/WebInspectorUI/ChangeLog	2021-10-15 22:37:24 UTC (rev 284279)
@@ -1,3 +1,59 @@
+2021-10-15  Russell Epstein  <[email protected]>
+
+        Cherry-pick r283572. rdar://problem/83953133
+
+    Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
+    https://bugs.webkit.org/show_bug.cgi?id=231205
+    
+    Reviewed by Devin Rousso.
+    
+    Source/_javascript_Core:
+    
+    Use an enum instead of strings for color space values sent to the frontend.
+    
+    * inspector/protocol/Canvas.json:
+    * inspector/scripts/codegen/generator.py:
+    
+    Source/WebCore:
+    
+    Use an enum instead of strings for color space values sent to the frontend.
+    
+    * inspector/InspectorCanvas.cpp:
+    (WebCore::buildObjectForCanvasContextAttributes):
+    
+    Source/WebInspectorUI:
+    
+    For canvas context's with a color space attribute, show the color space next to the context type in the header
+    of each context card in the Graphics tab.
+    
+    * UserInterface/Models/Canvas.js:
+    (WI.Canvas.displayNameForColorSpace):
+    * UserInterface/Views/CanvasContentView.js:
+    (WI.CanvasContentView.prototype.initialLayout):
+    * UserInterface/Views/CanvasOverviewContentView.css:
+    (.content-view.canvas-overview > .content-view.canvas > header > .titles > :matches(.subtitle, .color-space),):
+    (.content-view.canvas-overview > .content-view.canvas > header .color-space::before):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283572 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-05  Patrick Angle  <[email protected]>
+
+            Web Inspector: Show color space for canvases in the Graphics tab on the overview cards
+            https://bugs.webkit.org/show_bug.cgi?id=231205
+
+            Reviewed by Devin Rousso.
+
+            For canvas context's with a color space attribute, show the color space next to the context type in the header
+            of each context card in the Graphics tab.
+
+            * UserInterface/Models/Canvas.js:
+            (WI.Canvas.displayNameForColorSpace):
+            * UserInterface/Views/CanvasContentView.js:
+            (WI.CanvasContentView.prototype.initialLayout):
+            * UserInterface/Views/CanvasOverviewContentView.css:
+            (.content-view.canvas-overview > .content-view.canvas > header > .titles > :matches(.subtitle, .color-space),):
+            (.content-view.canvas-overview > .content-view.canvas > header .color-space::before):
+
 2021-10-07  Alan Coon  <[email protected]>
 
         Cherry-pick r282616. rdar://problem/83955758

Modified: branches/safari-612-branch/Source/WebInspectorUI/UserInterface/Models/Canvas.js (284278 => 284279)


--- branches/safari-612-branch/Source/WebInspectorUI/UserInterface/Models/Canvas.js	2021-10-15 22:36:55 UTC (rev 284278)
+++ branches/safari-612-branch/Source/WebInspectorUI/UserInterface/Models/Canvas.js	2021-10-15 22:37:24 UTC (rev 284279)
@@ -112,6 +112,19 @@
         return null;
     }
 
+    static displayNameForColorSpace(colorSpace)
+    {
+        switch(colorSpace) {
+        case WI.Canvas.ColorSpace.SRGB:
+            return WI.unlocalizedString("sRGB");
+        case WI.Canvas.ColorSpace.DisplayP3:
+            return WI.unlocalizedString("Display P3");
+        }
+
+        console.assert(false, "Unknown canvas color space", colorSpace);
+        return null;
+    }
+
     static resetUniqueDisplayNameNumbers()
     {
         Canvas._nextContextUniqueDisplayNameNumber = 1;
@@ -454,6 +467,11 @@
     WebMetal: "webmetal",
 };
 
+WI.Canvas.ColorSpace = {
+    SRGB: "srgb",
+    DisplayP3: "display-p3",
+};
+
 WI.Canvas.RecordingState = {
     Inactive: "canvas-recording-state-inactive",
     ActiveFrontend: "canvas-recording-state-active-frontend",

Modified: branches/safari-612-branch/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js (284278 => 284279)


--- branches/safari-612-branch/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js	2021-10-15 22:36:55 UTC (rev 284278)
+++ branches/safari-612-branch/Source/WebInspectorUI/UserInterface/Views/CanvasContentView.js	2021-10-15 22:37:24 UTC (rev 284279)
@@ -105,6 +105,12 @@
             subtitle.className = "subtitle";
             subtitle.textContent = WI.Canvas.displayNameForContextType(this.representedObject.contextType);
 
+            if (this.representedObject.contextAttributes.colorSpace) {
+                let subtitle = titles.appendChild(document.createElement("span"));
+                subtitle.className = "color-space";
+                subtitle.textContent = "(" + WI.Canvas.displayNameForColorSpace(this.representedObject.contextAttributes.colorSpace) + ")";
+            }
+
             let navigationBar = new WI.NavigationBar;
 
             if (this.representedObject.contextType === WI.Canvas.ContextType.Canvas2D || this.representedObject.contextType === WI.Canvas.ContextType.BitmapRenderer || this.representedObject.contextType === WI.Canvas.ContextType.WebGL || this.representedObject.contextType === WI.Canvas.ContextType.WebGL2) {

Modified: branches/safari-612-branch/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.css (284278 => 284279)


--- branches/safari-612-branch/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.css	2021-10-15 22:36:55 UTC (rev 284278)
+++ branches/safari-612-branch/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.css	2021-10-15 22:37:24 UTC (rev 284279)
@@ -76,7 +76,7 @@
     color: var(--text-color-gray-dark);
 }
 
-.content-view.canvas-overview > .content-view.canvas > header > .titles > .subtitle,
+.content-view.canvas-overview > .content-view.canvas > header > .titles > :matches(.subtitle, .color-space),
 .content-view.canvas-overview > .content-view.canvas > footer .memory-cost {
     color: var(--text-color-gray-medium);
 }
@@ -85,6 +85,10 @@
     content: "\00A0\2014\00A0"; /* &nbsp;&mdash;&nbsp; */;
 }
 
+.content-view.canvas-overview > .content-view.canvas > header .color-space::before {
+    content: "\00A0"; /* &nbsp; */;
+}
+
 .content-view.canvas-overview > .content-view.canvas.recording-active > header > .titles > .title {
     color: white;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to