⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 282984 in webkit


Ignore:
Timestamp:
Sep 23, 2021, 12:19:42 PM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Graphics: add instrumentation for new CanvasRenderingContext2DSettings
https://bugs.webkit.org/show_bug.cgi?id=225180
<rdar://problem/77587429>

Reviewed by BJ Burg.

Source/JavaScriptCore:

  • inspector/protocol/Canvas.json:

Add colorSpace and desynchronized to Canvas.ContextAttributes.

Source/WebCore:

  • inspector/InspectorCanvas.cpp:

(WebCore::buildObjectForCanvasContextAttributes): Added.
(WebCore::InspectorCanvas::buildObjectForCanvas):
(WebCore::InspectorCanvas::buildInitialState):
Unify the two cases where we fetch canvas attributes into a single method so that both get
the same data. This means that the canvas recorder now also uses Canvas.ContextAttributes.

LayoutTests:

  • inspector/canvas/context-attributes-expected.txt:
  • inspector/canvas/recording-2d-frameCount-expected.txt:
  • inspector/canvas/recording-2d-full-expected.txt:
  • inspector/canvas/recording-2d-memoryLimit-expected.txt:
  • inspector/canvas/recording-bitmaprenderer-frameCount-expected.txt:
  • inspector/canvas/recording-bitmaprenderer-full-expected.txt:
  • inspector/canvas/recording-bitmaprenderer-memoryLimit-expected.txt:
  • inspector/canvas/recording-html-2d-expected.txt:
  • inspector/canvas/recording-webgl-frameCount-expected.txt:
  • inspector/canvas/recording-webgl-full-expected.txt:
  • inspector/canvas/recording-webgl-memoryLimit-expected.txt:
  • inspector/canvas/recording-webgl-snapshots-expected.txt:
  • inspector/canvas/recording-webgl2-frameCount-expected.txt:
  • inspector/canvas/recording-webgl2-full-expected.txt:
  • inspector/canvas/recording-webgl2-memoryLimit-expected.txt:
  • inspector/canvas/recording-webgl2-snapshots-expected.txt:
Location:
trunk
Files:
1 added
21 edited
8 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r282983 r282984  
     12021-09-23  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Graphics: add instrumentation for new `CanvasRenderingContext2DSettings`
     4        https://bugs.webkit.org/show_bug.cgi?id=225180
     5        <rdar://problem/77587429>
     6
     7        Reviewed by BJ Burg.
     8
     9        * inspector/canvas/context-attributes-expected.txt:
     10        * inspector/canvas/recording-2d-frameCount-expected.txt:
     11        * inspector/canvas/recording-2d-full-expected.txt:
     12        * inspector/canvas/recording-2d-memoryLimit-expected.txt:
     13        * inspector/canvas/recording-bitmaprenderer-frameCount-expected.txt:
     14        * inspector/canvas/recording-bitmaprenderer-full-expected.txt:
     15        * inspector/canvas/recording-bitmaprenderer-memoryLimit-expected.txt:
     16        * inspector/canvas/recording-html-2d-expected.txt:
     17        * inspector/canvas/recording-webgl-frameCount-expected.txt:
     18        * inspector/canvas/recording-webgl-full-expected.txt:
     19        * inspector/canvas/recording-webgl-memoryLimit-expected.txt:
     20        * inspector/canvas/recording-webgl-snapshots-expected.txt:
     21        * inspector/canvas/recording-webgl2-frameCount-expected.txt:
     22        * inspector/canvas/recording-webgl2-full-expected.txt:
     23        * inspector/canvas/recording-webgl2-memoryLimit-expected.txt:
     24        * inspector/canvas/recording-webgl2-snapshots-expected.txt:
     25
    1262021-09-23  Eric Hutchison  <ehutchison@apple.com>
    227
  • trunk/LayoutTests/inspector/canvas/context-attributes-expected.txt

    r249809 r282984  
    66Added canvas.
    77PASS: Canvas context should be "2D".
    8 {}
     8{
     9  "colorSpace": "srgb",
     10  "desynchronized": false
     11}
    912
    1013-- Running test case: CreateBitmapRendererCanvasContext
  • trunk/LayoutTests/inspector/canvas/recording-2d-frameCount-expected.txt

    r274101 r282984  
    3232    setPath: [""]
    3333  parameters:
     34    0: {"colorSpace":"srgb","desynchronized":false}
    3435  content: <filtered>
    3536frames:
  • trunk/LayoutTests/inspector/canvas/recording-2d-full-expected.txt

    r274101 r282984  
    3232    setPath: [""]
    3333  parameters:
     34    0: {"colorSpace":"srgb","desynchronized":false}
    3435  content: <filtered>
    3536frames:
  • trunk/LayoutTests/inspector/canvas/recording-2d-memoryLimit-expected.txt

    r274101 r282984  
    3232    setPath: [""]
    3333  parameters:
     34    0: {"colorSpace":"srgb","desynchronized":false}
    3435  content: <filtered>
    3536frames:
  • trunk/LayoutTests/inspector/canvas/recording-bitmaprenderer-frameCount-expected.txt

    r249509 r282984  
    99    height: 2
    1010  parameters:
     11    0: {"alpha":true}
    1112  content: <filtered>
    1213frames:
  • trunk/LayoutTests/inspector/canvas/recording-bitmaprenderer-full-expected.txt

    r249509 r282984  
    99    height: 2
    1010  parameters:
     11    0: {"alpha":true}
    1112  content: <filtered>
    1213frames:
  • trunk/LayoutTests/inspector/canvas/recording-bitmaprenderer-memoryLimit-expected.txt

    r249509 r282984  
    99    height: 2
    1010  parameters:
     11    0: {"alpha":true}
    1112  content: <filtered>
    1213frames:
  • trunk/LayoutTests/inspector/canvas/recording-html-2d-expected.txt

    r277547 r282984  
    3030canvas.height = 2;
    3131
    32 let context = canvas.getContext("2d");
     32let context = canvas.getContext("2d", objects[0]);
    3333
    3434let frames = [
    3535    function initialState() {
    36         context.drawImage(objects[0], 0, 0);
     36        context.drawImage(objects[1], 0, 0);
    3737
    3838        context.direction = "ltr";
     
    6161        context.webkitLineDashOffset = 0;
    6262        if ("setPath" in context)
    63             context.setPath(objects[1]);
     63            context.setPath(objects[2]);
    6464        context.save();
    6565
     
    8989        context.webkitLineDashOffset = 0;
    9090        if ("setPath" in context)
    91             context.setPath(objects[2]);
     91            context.setPath(objects[3]);
    9292        context.save();
    9393
     
    117117        context.webkitLineDashOffset = 0;
    118118        if ("setPath" in context)
    119             context.setPath(objects[3]);
     119            context.setPath(objects[4]);
    120120    },
    121121    function startRecording() {
     
    126126        context.fillStyle;
    127127        context.fillStyle = "test";
    128         context.fillStyle = objects[4];
    129128        context.fillStyle = objects[5];
    130129        context.fillStyle = objects[6];
    131130        context.fillStyle = objects[7];
     131        context.fillStyle = objects[8];
    132132    },
    133133    function frame2() {
     
    138138    },
    139139    function frame4() {
    140         context.drawImage(objects[8], 11, 12);
     140        context.drawImage(objects[9], 11, 12);
    141141    },
    142142    function frame5() {
    143         context.createImageData(objects[9]);
     143        context.createImageData(objects[10]);
    144144    },
    145145    function frame6() {
    146         context.drawImage(objects[10], 11, 12);
     146        context.drawImage(objects[11], 11, 12);
    147147    },
    148148    function frame7() {
    149         context.setTransform(objects[11]);
     149        context.setTransform(objects[12]);
    150150    },
    151151    function frame8() {
    152         // context.drawFocusIfNeeded(objects[12], "Element");
     152        // context.drawFocusIfNeeded(objects[13], "Element");
    153153    },
    154154    function stopRecording() {
     
    218218}
    219219
    220 rebuildImage(0, <filtered>);
    221 rebuildPath2D(1, "");
     220rebuildImage(1, <filtered>);
    222221rebuildPath2D(2, "");
    223222rebuildPath2D(3, "");
    224 rebuildCanvasGradient(4, {"type":"linear-gradient","points":[1,2,3,4],"stops":[{"offset":1,"color":"rgb(255, 0, 0)"},{"offset":1,"color":"rgb(0, 0, 255)"}]});
    225 rebuildCanvasGradient(5, {"type":"radial-gradient","points":[1,2,3,4,5,6],"stops":[]});
    226 rebuildCanvasGradient(6, {"type":"conic-gradient","points":[2,3,1],"stops":[{"offset":1,"color":"rgb(0, 128, 0)"}]});
    227 rebuildCanvasPattern(7, {"image":<filtered>,"repeat":"no-repeat"});
    228 rebuildImage(8, <filtered>);
    229 rebuildImageData(9, {"data":[0,0,0,0,0,0,0,0],"width":1,"height":2});
    230 rebuildImageBitmap(10, <filtered>);
    231 rebuildDOMMatrix(11, "matrix(1, 2, 3, 4, 5, 6)");
    232 rebuildPath2D(12, "M1 2");
     223rebuildPath2D(4, "");
     224rebuildCanvasGradient(5, {"type":"linear-gradient","points":[1,2,3,4],"stops":[{"offset":1,"color":"rgb(255, 0, 0)"},{"offset":1,"color":"rgb(0, 0, 255)"}]});
     225rebuildCanvasGradient(6, {"type":"radial-gradient","points":[1,2,3,4,5,6],"stops":[]});
     226rebuildCanvasGradient(7, {"type":"conic-gradient","points":[2,3,1],"stops":[{"offset":1,"color":"rgb(0, 128, 0)"}]});
     227rebuildCanvasPattern(8, {"image":<filtered>,"repeat":"no-repeat"});
     228rebuildImage(9, <filtered>);
     229rebuildImageData(10, {"data":[0,0,0,0,0,0,0,0],"width":1,"height":2});
     230rebuildImageBitmap(11, <filtered>);
     231rebuildDOMMatrix(12, "matrix(1, 2, 3, 4, 5, 6)");
     232rebuildPath2D(13, "M1 2");
    233233
    234234Promise.all(promises).then(function() {
  • trunk/LayoutTests/inspector/canvas/recording-webgl-frameCount-expected.txt

    r246016 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"default","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/inspector/canvas/recording-webgl-full-expected.txt

    r265841 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"default","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/inspector/canvas/recording-webgl-memoryLimit-expected.txt

    r246016 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"default","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots-expected.txt

    r242225 r282984  
    99    height: 150
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"default","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/inspector/canvas/recording-webgl2-frameCount-expected.txt

    r265711 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"default","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/inspector/canvas/recording-webgl2-full-expected.txt

    r273865 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"default","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/inspector/canvas/recording-webgl2-memoryLimit-expected.txt

    r265711 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"default","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/inspector/canvas/recording-webgl2-snapshots-expected.txt

    r265711 r282984  
    99    height: 150
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"default","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/platform/mac-wk1/inspector/canvas/recording-webgl-frameCount-expected.txt

    r282983 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"low-power","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/platform/mac-wk1/inspector/canvas/recording-webgl-full-expected.txt

    r282983 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"low-power","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/platform/mac-wk1/inspector/canvas/recording-webgl-memoryLimit-expected.txt

    r282983 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"low-power","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/platform/mac-wk1/inspector/canvas/recording-webgl-snapshots-expected.txt

    r282983 r282984  
    99    height: 150
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"low-power","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/platform/mac-wk1/inspector/canvas/recording-webgl2-frameCount-expected.txt

    r282983 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"low-power","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/platform/mac-wk1/inspector/canvas/recording-webgl2-full-expected.txt

    r282983 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"low-power","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/platform/mac-wk1/inspector/canvas/recording-webgl2-memoryLimit-expected.txt

    r282983 r282984  
    99    height: 2
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"low-power","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/LayoutTests/platform/mac-wk1/inspector/canvas/recording-webgl2-snapshots-expected.txt

    r282983 r282984  
    99    height: 150
    1010  parameters:
    11     0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"failIfMajorPerformanceCaveat":false}
     11    0: {"alpha":true,"depth":true,"stencil":false,"antialias":true,"premultipliedAlpha":true,"preserveDrawingBuffer":false,"powerPreference":"low-power","failIfMajorPerformanceCaveat":false}
    1212  content: <filtered>
    1313frames:
  • trunk/Source/JavaScriptCore/ChangeLog

    r282968 r282984  
     12021-09-23  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Graphics: add instrumentation for new `CanvasRenderingContext2DSettings`
     4        https://bugs.webkit.org/show_bug.cgi?id=225180
     5        <rdar://problem/77587429>
     6
     7        Reviewed by BJ Burg.
     8
     9        * inspector/protocol/Canvas.json:
     10        Add `colorSpace` and `desynchronized` to `Canvas.ContextAttributes`.
     11
    1122021-09-23  Ross Kirsling  <ross.kirsling@sony.com>
    213
  • trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json

    r280467 r282984  
    4040            "properties": [
    4141                { "name": "alpha", "type": "boolean", "optional": true, "description": "WebGL, WebGL2, ImageBitmapRenderingContext" },
     42                { "name": "colorSpace", "type": "string", "optional": true, "description": "2D" },
     43                { "name": "desynchronized", "type": "boolean", "optional": true, "description": "2D" },
    4244                { "name": "depth", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
    4345                { "name": "stencil", "type": "boolean", "optional": true, "description": "WebGL, WebGL2" },
  • trunk/Source/WebCore/ChangeLog

    r282975 r282984  
     12021-09-23  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Graphics: add instrumentation for new `CanvasRenderingContext2DSettings`
     4        https://bugs.webkit.org/show_bug.cgi?id=225180
     5        <rdar://problem/77587429>
     6
     7        Reviewed by BJ Burg.
     8
     9        * inspector/InspectorCanvas.cpp:
     10        (WebCore::buildObjectForCanvasContextAttributes): Added.
     11        (WebCore::InspectorCanvas::buildObjectForCanvas):
     12        (WebCore::InspectorCanvas::buildInitialState):
     13        Unify the two cases where we fetch canvas attributes into a single method so that both get
     14        the same data. This means that the canvas recorder now also uses `Canvas.ContextAttributes`.
     15
    1162021-09-23  Antoine Quint  <graouts@webkit.org>
    217
  • trunk/Source/WebCore/inspector/InspectorCanvas.cpp

    r280968 r282984  
    814814}
    815815
     816static RefPtr<Inspector::Protocol::Canvas::ContextAttributes> buildObjectForCanvasContextAttributes(CanvasRenderingContext& context)
     817{
     818    if (is<CanvasRenderingContext2D>(context)) {
     819        auto attributes = downcast<CanvasRenderingContext2D>(context).getContextAttributes();
     820        auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create()
     821            .release();
     822        switch (attributes.colorSpace) {
     823        case PredefinedColorSpace::SRGB:
     824            contextAttributesPayload->setColorSpace("srgb"_s);
     825            break;
     826
     827#if ENABLE(PREDEFINED_COLOR_SPACE_DISPLAY_P3)
     828        case PredefinedColorSpace::DisplayP3:
     829            contextAttributesPayload->setColorSpace("display-p3"_s);
     830            break;
     831#endif
     832        }
     833        contextAttributesPayload->setDesynchronized(attributes.desynchronized);
     834        return contextAttributesPayload;
     835    }
     836
     837    if (is<ImageBitmapRenderingContext>(context)) {
     838        auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create()
     839            .release();
     840        contextAttributesPayload->setAlpha(downcast<ImageBitmapRenderingContext>(context).hasAlpha());
     841        return contextAttributesPayload;
     842    }
     843
     844#if ENABLE(WEBGL)
     845    if (is<WebGLRenderingContextBase>(context)) {
     846        const auto& attributes = downcast<WebGLRenderingContextBase>(context).getContextAttributes();
     847        if (!attributes)
     848            return nullptr;
     849
     850        auto contextAttributesPayload = Inspector::Protocol::Canvas::ContextAttributes::create()
     851            .release();
     852        contextAttributesPayload->setAlpha(attributes->alpha);
     853        contextAttributesPayload->setDepth(attributes->depth);
     854        contextAttributesPayload->setStencil(attributes->stencil);
     855        contextAttributesPayload->setAntialias(attributes->antialias);
     856        contextAttributesPayload->setPremultipliedAlpha(attributes->premultipliedAlpha);
     857        contextAttributesPayload->setPreserveDrawingBuffer(attributes->preserveDrawingBuffer);
     858        switch (attributes->powerPreference) {
     859        case WebGLPowerPreference::Default:
     860            contextAttributesPayload->setPowerPreference("default"_s);
     861            break;
     862        case WebGLPowerPreference::LowPower:
     863            contextAttributesPayload->setPowerPreference("low-power"_s);
     864            break;
     865        case WebGLPowerPreference::HighPerformance:
     866            contextAttributesPayload->setPowerPreference("high-performance"_s);
     867            break;
     868        }
     869        contextAttributesPayload->setFailIfMajorPerformanceCaveat(attributes->failIfMajorPerformanceCaveat);
     870        return contextAttributesPayload;
     871    }
     872#endif // ENABLE(WEBGL)
     873
     874    return nullptr;
     875}
     876
    816877Ref<Protocol::Canvas::Canvas> InspectorCanvas::buildObjectForCanvas(bool captureBacktrace)
    817878{
     
    857918    }
    858919
    859     using ContextAttributesType = RefPtr<Protocol::Canvas::ContextAttributes>;
    860920    auto contextAttributes = WTF::switchOn(m_context,
    861         [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) -> ContextAttributesType {
    862             auto& context = contextWrapper.get();
    863             if (is<ImageBitmapRenderingContext>(context)) {
    864                 auto contextAttributesPayload = Protocol::Canvas::ContextAttributes::create()
    865                     .release();
    866                 contextAttributesPayload->setAlpha(downcast<ImageBitmapRenderingContext>(context).hasAlpha());
    867                 return contextAttributesPayload;
    868             }
    869 
    870 #if ENABLE(WEBGL)
    871             if (is<WebGLRenderingContextBase>(context)) {
    872                 if (const auto& attributes = downcast<WebGLRenderingContextBase>(context).getContextAttributes()) {
    873                     auto contextAttributesPayload = Protocol::Canvas::ContextAttributes::create()
    874                         .release();
    875                     contextAttributesPayload->setAlpha(attributes->alpha);
    876                     contextAttributesPayload->setDepth(attributes->depth);
    877                     contextAttributesPayload->setStencil(attributes->stencil);
    878                     contextAttributesPayload->setAntialias(attributes->antialias);
    879                     contextAttributesPayload->setPremultipliedAlpha(attributes->premultipliedAlpha);
    880                     contextAttributesPayload->setPreserveDrawingBuffer(attributes->preserveDrawingBuffer);
    881                     switch (attributes->powerPreference) {
    882                     case WebGLPowerPreference::Default:
    883                         contextAttributesPayload->setPowerPreference("default");
    884                         break;
    885                     case WebGLPowerPreference::LowPower:
    886                         contextAttributesPayload->setPowerPreference("low-power");
    887                         break;
    888                     case WebGLPowerPreference::HighPerformance:
    889                         contextAttributesPayload->setPowerPreference("high-performance");
    890                         break;
    891                     }
    892                     contextAttributesPayload->setFailIfMajorPerformanceCaveat(attributes->failIfMajorPerformanceCaveat);
    893                     return contextAttributesPayload;
    894                 }
    895             }
    896 #endif
    897             return nullptr;
     921        [] (std::reference_wrapper<CanvasRenderingContext> contextWrapper) {
     922            return buildObjectForCanvasContextAttributes(contextWrapper);
    898923        },
    899924        [] (Monostate) {
     
    12301255        }
    12311256    }
    1232 #if ENABLE(WEBGL)
    1233     else if (is<WebGLRenderingContextBase>(context)) {
    1234         auto& contextWebGLBase = downcast<WebGLRenderingContextBase>(*context);
    1235         if (std::optional<WebGLContextAttributes> webGLContextAttributes = contextWebGLBase.getContextAttributes()) {
    1236             auto webGLContextAttributesPayload = JSON::Object::create();
    1237             webGLContextAttributesPayload->setBoolean("alpha"_s, webGLContextAttributes->alpha);
    1238             webGLContextAttributesPayload->setBoolean("depth"_s, webGLContextAttributes->depth);
    1239             webGLContextAttributesPayload->setBoolean("stencil"_s, webGLContextAttributes->stencil);
    1240             webGLContextAttributesPayload->setBoolean("antialias"_s, webGLContextAttributes->antialias);
    1241             webGLContextAttributesPayload->setBoolean("premultipliedAlpha"_s, webGLContextAttributes->premultipliedAlpha);
    1242             webGLContextAttributesPayload->setBoolean("preserveDrawingBuffer"_s, webGLContextAttributes->preserveDrawingBuffer);
    1243             webGLContextAttributesPayload->setBoolean("failIfMajorPerformanceCaveat"_s, webGLContextAttributes->failIfMajorPerformanceCaveat);
    1244             parametersPayload->addItem(WTFMove(webGLContextAttributesPayload));
    1245         }
    1246     }
    1247 #endif
     1257
     1258    if (auto contextAttributes = buildObjectForCanvasContextAttributes(*context))
     1259        parametersPayload->addItem(contextAttributes.releaseNonNull());
    12481260
    12491261    initialStatePayload->setAttributes(WTFMove(attributesPayload));
Note: See TracChangeset for help on using the changeset viewer.