Changeset 219208 in webkit


Ignore:
Timestamp:
Jul 6, 2017 11:35:58 AM (7 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Support getting the content of WebGL/WebGL2 contexts
https://bugs.webkit.org/show_bug.cgi?id=173569
<rdar://problem/33112420>

Reviewed by Joseph Pecoraro.

Source/WebCore:

Tests: inspector/canvas/requestContent-2d.html

inspector/canvas/requestContent-webgl.html
inspector/canvas/requestContent-webgl2.html

  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::clearIfComposited):

  • html/canvas/WebGLRenderingContextBase.h:

(WebCore::WebGLRenderingContextBase::preventBufferClearForInspector):
(WebCore::WebGLRenderingContextBase::setPreventBufferClearForInspector):
Add a flag that will prevent the context buffer from being cleared, allowing it to be copied
within a toDataURL call. This is currently only used by InspectorCanvasAgent::requestContent.

  • inspector/InspectorCanvasAgent.cpp:

(WebCore::InspectorCanvasAgent::requestContent):
Since toDataURL attempts to force the canvas to redraw, we can preserve the buffer after it
finishes drawing so that it can be copied, instead of it normally being swapped out.

LayoutTests:

  • inspector/canvas/requestContent-2d-expected.txt: Added.
  • inspector/canvas/requestContent-2d.html: Added.
  • inspector/canvas/requestContent-webgl-expected.txt: Added.
  • inspector/canvas/requestContent-webgl.html: Added.
  • inspector/canvas/requestContent-webgl2-expected.txt: Added.
  • inspector/canvas/requestContent-webgl2.html: Added.
  • inspector/canvas/requestContent-expected.txt: Removed.
  • inspector/canvas/requestContent.html: Removed.
  • platform/gtk/TestExpectations:
  • platform/win/TestExpectations:

Split the existing canvas content tests into one for each context type. This allows
platforms that don't support certain context types to ignore just those tests (e.g. WebGL2).

Location:
trunk
Files:
6 added
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r219206 r219208  
     12017-07-06  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Support getting the content of WebGL/WebGL2 contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=173569
     5        <rdar://problem/33112420>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * inspector/canvas/requestContent-2d-expected.txt: Added.
     10        * inspector/canvas/requestContent-2d.html: Added.
     11        * inspector/canvas/requestContent-webgl-expected.txt: Added.
     12        * inspector/canvas/requestContent-webgl.html: Added.
     13        * inspector/canvas/requestContent-webgl2-expected.txt: Added.
     14        * inspector/canvas/requestContent-webgl2.html: Added.
     15        * inspector/canvas/requestContent-expected.txt: Removed.
     16        * inspector/canvas/requestContent.html: Removed.
     17        * platform/gtk/TestExpectations:
     18        * platform/win/TestExpectations:
     19        Split the existing canvas content tests into one for each context type. This allows
     20        platforms that don't support certain context types to ignore just those tests (e.g. WebGL2).
     21
    1222017-07-06  Carlos Alberto Lopez Perez  <clopez@igalia.com>
    223
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r219206 r219208  
    596596webkit.org/b/166536 fast/canvas/webgl/webgl2-texture-upload-enums.html [ Skip ]
    597597webkit.org/b/166536 inspector/canvas/create-context-webgl2.html [ Skip ]
     598webkit.org/b/166536 inspector/canvas/requestContent-webgl2.html [ Skip ]
    598599webkit.org/b/166536 inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ]
    599600
  • trunk/LayoutTests/platform/win/TestExpectations

    r219150 r219208  
    19141914inspector/canvas/create-context-webgl.html [ Skip ]
    19151915inspector/canvas/create-context-webgl2.html [ Skip ]
     1916inspector/canvas/requestContent-webgl.html [ Skip ]
     1917inspector/canvas/requestContent-webgl2.html [ Skip ]
    19161918inspector/canvas/resolveCanvasContext-webgl.html [ Skip ]
    19171919inspector/canvas/resolveCanvasContext-webgl2.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r219207 r219208  
     12017-07-06  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Support getting the content of WebGL/WebGL2 contexts
     4        https://bugs.webkit.org/show_bug.cgi?id=173569
     5        <rdar://problem/33112420>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        Tests: inspector/canvas/requestContent-2d.html
     10               inspector/canvas/requestContent-webgl.html
     11               inspector/canvas/requestContent-webgl2.html
     12
     13        * html/canvas/WebGLRenderingContextBase.cpp:
     14        (WebCore::WebGLRenderingContextBase::clearIfComposited):
     15        * html/canvas/WebGLRenderingContextBase.h:
     16        (WebCore::WebGLRenderingContextBase::preventBufferClearForInspector):
     17        (WebCore::WebGLRenderingContextBase::setPreventBufferClearForInspector):
     18        Add a flag that will prevent the context buffer from being cleared, allowing it to be copied
     19        within a toDataURL call. This is currently only used by InspectorCanvasAgent::requestContent.
     20
     21        * inspector/InspectorCanvasAgent.cpp:
     22        (WebCore::InspectorCanvasAgent::requestContent):
     23        Since toDataURL attempts to force the canvas to redraw, we can preserve the buffer after it
     24        finishes drawing so that it can be copied, instead of it normally being swapped out.
     25
    1262017-07-06  Chris Dumez  <cdumez@apple.com>
    227
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r218603 r219208  
    732732
    733733    if (!m_context->layerComposited() || m_layerCleared
    734         || m_attributes.preserveDrawingBuffer || (mask && m_framebufferBinding))
     734        || m_attributes.preserveDrawingBuffer || (mask && m_framebufferBinding)
     735        || m_preventBufferClearForInspector)
    735736        return false;
    736737
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h

    r218603 r219208  
    211211    void setPreserveDrawingBuffer(bool value) { m_attributes.preserveDrawingBuffer = value; }
    212212
     213    bool preventBufferClearForInspector() const { return m_preventBufferClearForInspector; }
     214    void setPreventBufferClearForInspector(bool value) { m_preventBufferClearForInspector = value; }
     215
    213216    virtual void hint(GC3Denum target, GC3Denum mode) = 0;
    214217    GC3Dboolean isBuffer(WebGLBuffer*);
     
    571574    int m_numGLErrorsToConsoleAllowed;
    572575
     576    bool m_preventBufferClearForInspector { false };
     577
    573578    // A WebGLRenderingContext can be created in a state where it appears as
    574579    // a valid and active context, but will not execute any important operations
  • trunk/Source/WebCore/inspector/InspectorCanvasAgent.cpp

    r219150 r219208  
    150150        }
    151151        *content = result.releaseReturnValue();
    152     } else {
    153         // FIXME: <https://webkit.org/b/173569> Web Inspector: Support getting the content of WebGL/WebGL2/WebGPU contexts
     152    }
     153#if ENABLE(WEBGL)
     154    else if (is<WebGLRenderingContextBase>(context)) {
     155        WebGLRenderingContextBase* gl = downcast<WebGLRenderingContextBase>(context);
     156
     157        gl->setPreventBufferClearForInspector(true);
     158        ExceptionOr<String> result = canvasEntry->element->toDataURL(ASCIILiteral("image/png"));
     159        gl->setPreventBufferClearForInspector(false);
     160
     161        if (result.hasException()) {
     162            errorString = result.releaseException().releaseMessage();
     163            return;
     164        }
     165        *content = result.releaseReturnValue();
     166    }
     167#endif
     168    // FIXME: <https://webkit.org/b/173621> Web Inspector: Support getting the content of WebGPU contexts
     169    else
    154170        errorString = ASCIILiteral("Unsupported canvas context type");
    155     }
    156171}
    157172
Note: See TracChangeset for help on using the changeset viewer.