Changeset 224370 in webkit


Ignore:
Timestamp:
Nov 2, 2017 6:53:17 PM (6 years ago)
Author:
webkit@devinrousso.com
Message:

Web Inspector: Canvas Tab: show supported GL extensions for selected canvas
https://bugs.webkit.org/show_bug.cgi?id=179070
<rdar://problem/35278276>

Reviewed by Brian Burg.

Source/JavaScriptCore:

  • inspector/protocol/Canvas.json:

Add extensionEnabled event that is fired each time getExtension is called with a
different string on a WebGL context.

Source/WebCore:

Test: inspector/canvas/extensions.html

  • html/canvas/WebGL2RenderingContext.cpp:

(WebCore::WebGL2RenderingContext::getExtension):

  • html/canvas/WebGLRenderingContext.cpp:

(WebCore::WebGLRenderingContext::getExtension):
Rework common logic into a macro for readability and to simplify adding calls to
InspectorInstrumentation functions.

  • html/canvas/WebGLRenderingContextBase.h:
  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::extensionIsEnabled):

  • inspector/InspectorCanvasAgent.h:
  • inspector/InspectorCanvasAgent.cpp:

(WebCore::InspectorCanvasAgent::enable):
(WebCore::InspectorCanvasAgent::didEnableExtension):

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::didEnableExtension):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::didEnableExtensionImpl):

Source/WebInspectorUI:

  • Localizations/en.lproj/localizedStrings.js:
  • UserInterface/Protocol/CanvasObserver.js:

(WI.CanvasObserver.prototype.extensionEnabled):

  • UserInterface/Controllers/CanvasManager.js:

(WI.CanvasManager.prototype.extensionEnabled):

  • UserInterface/Models/Canvas.js:

(WI.Canvas.prototype.get extensions):
(WI.Canvas.prototype.enableExtension):
Maintain a Set of enabled extensions, and dispatch an event whenever an extension is enabled.

  • UserInterface/Views/CanvasDetailsSidebarPanel.css:

(.sidebar > .panel.details.canvas .details-section.canvas-extensions .content > ul):

  • UserInterface/Views/CanvasDetailsSidebarPanel.js:

(WI.CanvasDetailsSidebarPanel.prototype.set canvas):
(WI.CanvasDetailsSidebarPanel.prototype.initialLayout):
(WI.CanvasDetailsSidebarPanel.prototype.layout):
(WI.CanvasDetailsSidebarPanel.prototype._refreshAttributesSection):
(WI.CanvasDetailsSidebarPanel.prototype._refreshExtensionsSection):
Drive-by: hide Attributes section when the canvas has no attributes.

LayoutTests:

  • inspector/canvas/extensions-expected.txt: Added.
  • inspector/canvas/extensions.html: Added.
Location:
trunk
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r224369 r224370  
     12017-11-02  Devin Rousso  <webkit@devinrousso.com>
     2
     3        Web Inspector: Canvas Tab: show supported GL extensions for selected canvas
     4        https://bugs.webkit.org/show_bug.cgi?id=179070
     5        <rdar://problem/35278276>
     6
     7        Reviewed by Brian Burg.
     8
     9        * inspector/canvas/extensions-expected.txt: Added.
     10        * inspector/canvas/extensions.html: Added.
     11
    1122017-11-02  Youenn Fablet  <youenn@apple.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r224368 r224370  
     12017-11-02  Devin Rousso  <webkit@devinrousso.com>
     2
     3        Web Inspector: Canvas Tab: show supported GL extensions for selected canvas
     4        https://bugs.webkit.org/show_bug.cgi?id=179070
     5        <rdar://problem/35278276>
     6
     7        Reviewed by Brian Burg.
     8
     9        * inspector/protocol/Canvas.json:
     10        Add `extensionEnabled` event that is fired each time `getExtension` is called with a
     11        different string on a WebGL context.
     12
    1132017-11-02  Joseph Pecoraro  <pecoraro@apple.com>
    214
  • trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json

    r224142 r224370  
    172172        },
    173173        {
     174            "name": "extensionEnabled",
     175            "parameters": [
     176                { "name": "canvasId", "$ref": "CanvasId" },
     177                { "name": "extension", "type": "string", "description": "Name of the extension that was enabled." }
     178            ]
     179        },
     180        {
    174181            "name": "cssCanvasClientNodesChanged",
    175182            "parameters": [
  • trunk/Source/WebCore/ChangeLog

    r224369 r224370  
     12017-11-02  Devin Rousso  <webkit@devinrousso.com>
     2
     3        Web Inspector: Canvas Tab: show supported GL extensions for selected canvas
     4        https://bugs.webkit.org/show_bug.cgi?id=179070
     5        <rdar://problem/35278276>
     6
     7        Reviewed by Brian Burg.
     8
     9        Test: inspector/canvas/extensions.html
     10
     11        * html/canvas/WebGL2RenderingContext.cpp:
     12        (WebCore::WebGL2RenderingContext::getExtension):
     13        * html/canvas/WebGLRenderingContext.cpp:
     14        (WebCore::WebGLRenderingContext::getExtension):
     15        Rework common logic into a macro for readability and to simplify adding calls to
     16        InspectorInstrumentation functions.
     17
     18        * html/canvas/WebGLRenderingContextBase.h:
     19        * html/canvas/WebGLRenderingContextBase.cpp:
     20        (WebCore::WebGLRenderingContextBase::extensionIsEnabled):
     21
     22        * inspector/InspectorCanvasAgent.h:
     23        * inspector/InspectorCanvasAgent.cpp:
     24        (WebCore::InspectorCanvasAgent::enable):
     25        (WebCore::InspectorCanvasAgent::didEnableExtension):
     26
     27        * inspector/InspectorInstrumentation.h:
     28        (WebCore::InspectorInstrumentation::didEnableExtension):
     29        * inspector/InspectorInstrumentation.cpp:
     30        (WebCore::InspectorInstrumentation::didEnableExtensionImpl):
     31
    1322017-11-02  Youenn Fablet  <youenn@apple.com>
    233
  • trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp

    r224192 r224370  
    3636#include "HTMLVideoElement.h"
    3737#include "ImageData.h"
     38#include "InspectorInstrumentation.h"
    3839#include "OESTextureFloat.h"
    3940#include "OESTextureFloatLinear.h"
     
    10811082        return nullptr;
    10821083
    1083     if (equalIgnoringASCIICase(name, "EXT_texture_filter_anisotropic") || equalIgnoringASCIICase(name, "WEBKIT_EXT_texture_filter_anisotropic")) {
    1084         if (!m_extTextureFilterAnisotropic) {
    1085             m_extTextureFilterAnisotropic = enableSupportedExtension("GL_EXT_texture_filter_anisotropic")
    1086                 ? std::make_unique<EXTTextureFilterAnisotropic>(*this) : nullptr;
    1087         }
    1088         return m_extTextureFilterAnisotropic.get();
    1089     }
    1090     if (equalIgnoringASCIICase(name, "OES_texture_float")) {
    1091         if (!m_oesTextureFloat) {
    1092             m_oesTextureFloat = enableSupportedExtension("GL_OES_texture_float")
    1093                 ? std::make_unique<OESTextureFloat>(*this) : nullptr;
    1094         }
    1095         return m_oesTextureFloat.get();
    1096     }
    1097     if (equalIgnoringASCIICase(name, "OES_texture_float_linear")) {
    1098         if (!m_oesTextureFloatLinear) {
    1099             m_oesTextureFloatLinear = enableSupportedExtension("GL_OES_texture_float_linear")
    1100                 ? std::make_unique<OESTextureFloatLinear>(*this) : nullptr;
    1101         }
    1102         return m_oesTextureFloatLinear.get();
    1103     }
    1104     if (equalIgnoringASCIICase(name, "OES_texture_half_float")) {
    1105         if (!m_oesTextureHalfFloat) {
    1106             m_oesTextureHalfFloat = enableSupportedExtension("GL_OES_texture_half_float")
    1107                 ? std::make_unique<OESTextureHalfFloat>(*this) : nullptr;
    1108         }
    1109         return m_oesTextureHalfFloat.get();
    1110     }
    1111     if (equalIgnoringASCIICase(name, "OES_texture_half_float_linear")) {
    1112         if (!m_oesTextureHalfFloatLinear) {
    1113             m_oesTextureHalfFloatLinear = enableSupportedExtension("GL_OES_texture_half_float_linear")
    1114                 ? std::make_unique<OESTextureHalfFloatLinear>(*this) : nullptr;
    1115         }
    1116         return m_oesTextureHalfFloatLinear.get();
    1117     }
    1118     if (equalIgnoringASCIICase(name, "WEBGL_lose_context")) {
    1119         if (!m_webglLoseContext)
    1120             m_webglLoseContext = std::make_unique<WebGLLoseContext>(*this);
    1121         return m_webglLoseContext.get();
    1122     }
    1123     if (equalIgnoringASCIICase(name, "WEBKIT_WEBGL_compressed_texture_atc")) {
    1124         if (!m_webglCompressedTextureATC) {
    1125             if (WebGLCompressedTextureATC::supported(*this))
    1126                 m_webglCompressedTextureATC = std::make_unique<WebGLCompressedTextureATC>(*this);
    1127         }
    1128         return m_webglCompressedTextureATC.get();
    1129     }
    1130     if (equalIgnoringASCIICase(name, "WEBKIT_WEBGL_compressed_texture_pvrtc")) {
    1131         if (!m_webglCompressedTexturePVRTC) {
    1132             m_webglCompressedTexturePVRTC = WebGLCompressedTexturePVRTC::supported(*this)
    1133                 ? std::make_unique<WebGLCompressedTexturePVRTC>(*this) : nullptr;
    1134         }
    1135         return m_webglCompressedTexturePVRTC.get();
    1136     }
    1137     if (equalIgnoringASCIICase(name, "WEBGL_compressed_texture_s3tc")) {
    1138         if (!m_webglCompressedTextureS3TC) {
    1139             m_webglCompressedTextureS3TC = WebGLCompressedTextureS3TC::supported(*this)
    1140                 ? std::make_unique<WebGLCompressedTextureS3TC>(*this) : nullptr;
    1141         }
    1142         return m_webglCompressedTextureS3TC.get();
    1143     }
    1144     if (equalIgnoringASCIICase(name, "WEBGL_depth_texture")) {
    1145         if (!m_webglDepthTexture) {
    1146             m_webglDepthTexture = WebGLDepthTexture::supported(*graphicsContext3D())
    1147                 ? std::make_unique<WebGLDepthTexture>(*this) : nullptr;
    1148         }
    1149         return m_webglDepthTexture.get();
    1150     }
    1151     if (equalIgnoringASCIICase(name, "WEBGL_debug_renderer_info")) {
    1152         if (!m_webglDebugRendererInfo)
    1153             m_webglDebugRendererInfo = std::make_unique<WebGLDebugRendererInfo>(*this);
    1154         return m_webglDebugRendererInfo.get();
    1155     }
    1156     if (equalIgnoringASCIICase(name, "WEBGL_debug_shaders")) {
    1157         if (!m_webglDebugShaders) {
    1158             m_webglDebugShaders = m_context->getExtensions().supports(ASCIILiteral { "GL_ANGLE_translated_shader_source" })
    1159                 ? std::make_unique<WebGLDebugShaders>(*this) : nullptr;
    1160         }
    1161         return m_webglDebugShaders.get();
    1162     }
    1163 
     1084#define ENABLE_IF_REQUESTED(type, variable, nameLiteral, canEnable) \
     1085    if (equalIgnoringASCIICase(name, nameLiteral)) { \
     1086        if (!variable) { \
     1087            variable = (canEnable) ? std::make_unique<type>(*this) : nullptr; \
     1088            if (variable != nullptr) \
     1089                InspectorInstrumentation::didEnableExtension(*this, name); \
     1090        } \
     1091        return variable.get(); \
     1092    }
     1093
     1094    ENABLE_IF_REQUESTED(EXTTextureFilterAnisotropic, m_extTextureFilterAnisotropic, "EXT_texture_filter_anisotropic", enableSupportedExtension("GL_EXT_texture_filter_anisotropic"));
     1095    ENABLE_IF_REQUESTED(EXTTextureFilterAnisotropic, m_extTextureFilterAnisotropic, "WEBKIT_EXT_texture_filter_anisotropic", enableSupportedExtension("GL_OES_texture_float"));
     1096    ENABLE_IF_REQUESTED(OESTextureFloat, m_oesTextureFloat, "OES_texture_float", enableSupportedExtension("GL_OES_texture_float"));
     1097    ENABLE_IF_REQUESTED(OESTextureFloatLinear, m_oesTextureFloatLinear, "OES_texture_float_linear", enableSupportedExtension("GL_OES_texture_float_linear"));
     1098    ENABLE_IF_REQUESTED(OESTextureHalfFloat, m_oesTextureHalfFloat, "OES_texture_half_float", enableSupportedExtension("GL_OES_texture_half_float"));
     1099    ENABLE_IF_REQUESTED(OESTextureHalfFloatLinear, m_oesTextureHalfFloatLinear, "OES_texture_half_float_linear", enableSupportedExtension("GL_OES_texture_half_float_linear"));
     1100    ENABLE_IF_REQUESTED(WebGLLoseContext, m_webglLoseContext, "WEBGL_lose_context", true);
     1101    ENABLE_IF_REQUESTED(WebGLCompressedTextureATC, m_webglCompressedTextureATC, "WEBKIT_WEBGL_compressed_texture_atc", WebGLCompressedTextureATC::supported(*this));
     1102    ENABLE_IF_REQUESTED(WebGLCompressedTexturePVRTC, m_webglCompressedTexturePVRTC, "WEBKIT_WEBGL_compressed_texture_pvrtc", WebGLCompressedTexturePVRTC::supported(*this));
     1103    ENABLE_IF_REQUESTED(WebGLCompressedTextureS3TC, m_webglCompressedTextureS3TC, "WEBGL_compressed_texture_s3tc", WebGLCompressedTextureS3TC::supported(*this));
     1104    ENABLE_IF_REQUESTED(WebGLDepthTexture, m_webglDepthTexture, "WEBGL_depth_texture", WebGLDepthTexture::supported(*graphicsContext3D()));
     1105    ENABLE_IF_REQUESTED(WebGLDebugRendererInfo, m_webglDebugRendererInfo, "WEBGL_debug_renderer_info", true);
     1106    ENABLE_IF_REQUESTED(WebGLDebugShaders, m_webglDebugShaders, "WEBGL_debug_shaders", m_context->getExtensions().supports(ASCIILiteral { "GL_ANGLE_translated_shader_source" }));
    11641107    return nullptr;
    11651108}
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r223644 r224370  
    4141#include "HTMLVideoElement.h"
    4242#include "ImageData.h"
     43#include "InspectorInstrumentation.h"
    4344#include "OESElementIndexUint.h"
    4445#include "OESStandardDerivatives.h"
     
    9091    if (isContextLostOrPending())
    9192        return nullptr;
    92    
    93     if (equalIgnoringASCIICase(name, "EXT_blend_minmax")) {
    94         if (!m_extBlendMinMax) {
    95             m_extBlendMinMax = enableSupportedExtension("GL_EXT_blend_minmax")
    96                 ? std::make_unique<EXTBlendMinMax>(*this) : nullptr;
    97         }
    98         return m_extBlendMinMax.get();
    99     }
    100     if (equalIgnoringASCIICase(name, "EXT_sRGB")) {
    101         if (!m_extsRGB) {
    102             m_extsRGB = enableSupportedExtension("GL_EXT_sRGB")
    103                 ? std::make_unique<EXTsRGB>(*this) : nullptr;
    104         }
    105         return m_extsRGB.get();
    106     }
    107     if (equalIgnoringASCIICase(name, "EXT_frag_depth")) {
    108         if (!m_extFragDepth) {
    109             m_extFragDepth = enableSupportedExtension("GL_EXT_frag_depth")
    110                 ? std::make_unique<EXTFragDepth>(*this) : nullptr;
    111         }
    112         return m_extFragDepth.get();
    113     }
     93
     94#define ENABLE_IF_REQUESTED(type, variable, nameLiteral, canEnable) \
     95    if (equalIgnoringASCIICase(name, nameLiteral)) { \
     96        if (!variable) { \
     97            variable = (canEnable) ? std::make_unique<type>(*this) : nullptr; \
     98            if (variable != nullptr) \
     99                InspectorInstrumentation::didEnableExtension(*this, name); \
     100        } \
     101        return variable.get(); \
     102    }
     103
     104    ENABLE_IF_REQUESTED(EXTBlendMinMax, m_extBlendMinMax, "EXT_blend_minmax", enableSupportedExtension("GL_EXT_blend_minmax"));
     105    ENABLE_IF_REQUESTED(EXTsRGB, m_extsRGB, "EXT_sRGB", enableSupportedExtension("GL_EXT_sRGB"));
     106    ENABLE_IF_REQUESTED(EXTFragDepth, m_extFragDepth, "EXT_frag_depth", enableSupportedExtension("GL_EXT_frag_depth"));
    114107    if (equalIgnoringASCIICase(name, "EXT_shader_texture_lod")) {
    115108        if (!m_extShaderTextureLOD) {
     
    119112                m_context->getExtensions().ensureEnabled(ASCIILiteral { "GL_EXT_shader_texture_lod" });
    120113                m_extShaderTextureLOD = std::make_unique<EXTShaderTextureLOD>(*this);
     114                InspectorInstrumentation::didEnableExtension(*this, name);
    121115            }
    122116        }
    123117        return m_extShaderTextureLOD.get();
    124118    }
    125     if (equalIgnoringASCIICase(name, "EXT_texture_filter_anisotropic") || equalIgnoringASCIICase(name, "WEBKIT_EXT_texture_filter_anisotropic")) {
    126         if (!m_extTextureFilterAnisotropic) {
    127             m_extTextureFilterAnisotropic = enableSupportedExtension("GL_EXT_texture_filter_anisotropic")
    128                 ? std::make_unique<EXTTextureFilterAnisotropic>(*this) : nullptr;
    129         }
    130         return m_extTextureFilterAnisotropic.get();
    131     }
    132     if (equalIgnoringASCIICase(name, "OES_standard_derivatives")) {
    133         if (!m_oesStandardDerivatives) {
    134             m_oesStandardDerivatives = enableSupportedExtension("GL_OES_standard_derivatives")
    135                 ? std::make_unique<OESStandardDerivatives>(*this) : nullptr;
    136         }
    137         return m_oesStandardDerivatives.get();
    138     }
    139     if (equalIgnoringASCIICase(name, "OES_texture_float")) {
    140         if (!m_oesTextureFloat) {
    141             m_oesTextureFloat = enableSupportedExtension("GL_OES_texture_float")
    142                 ? std::make_unique<OESTextureFloat>(*this) : nullptr;
    143         }
    144         return m_oesTextureFloat.get();
    145     }
    146     if (equalIgnoringASCIICase(name, "OES_texture_float_linear")) {
    147         if (!m_oesTextureFloatLinear) {
    148             m_oesTextureFloatLinear = enableSupportedExtension("GL_OES_texture_float_linear")
    149                 ? std::make_unique<OESTextureFloatLinear>(*this) : nullptr;
    150         }
    151         return m_oesTextureFloatLinear.get();
    152     }
    153     if (equalIgnoringASCIICase(name, "OES_texture_half_float")) {
    154         if (!m_oesTextureHalfFloat) {
    155             m_oesTextureHalfFloat = enableSupportedExtension("GL_OES_texture_half_float")
    156                 ? std::make_unique<OESTextureHalfFloat>(*this) : nullptr;
    157         }
    158         return m_oesTextureHalfFloat.get();
    159     }
    160     if (equalIgnoringASCIICase(name, "OES_texture_half_float_linear")) {
    161         if (!m_oesTextureHalfFloatLinear) {
    162             m_oesTextureHalfFloatLinear = enableSupportedExtension("GL_OES_texture_half_float_linear")
    163                 ? std::make_unique<OESTextureHalfFloatLinear>(*this) : nullptr;
    164         }
    165         return m_oesTextureHalfFloatLinear.get();
    166     }
    167     if (equalIgnoringASCIICase(name, "OES_vertex_array_object")) {
    168         if (!m_oesVertexArrayObject) {
    169             m_oesVertexArrayObject = enableSupportedExtension("GL_OES_vertex_array_object")
    170                 ? std::make_unique<OESVertexArrayObject>(*this) : nullptr;
    171         }
    172         return m_oesVertexArrayObject.get();
    173     }
    174     if (equalIgnoringASCIICase(name, "OES_element_index_uint")) {
    175         if (!m_oesElementIndexUint) {
    176             m_oesElementIndexUint = enableSupportedExtension("GL_OES_element_index_uint")
    177                 ? std::make_unique<OESElementIndexUint>(*this) : nullptr;
    178         }
    179         return m_oesElementIndexUint.get();
    180     }
    181     if (equalIgnoringASCIICase(name, "WEBGL_lose_context")) {
    182         if (!m_webglLoseContext)
    183             m_webglLoseContext = std::make_unique<WebGLLoseContext>(*this);
    184         return m_webglLoseContext.get();
    185     }
    186     if (equalIgnoringASCIICase(name, "WEBKIT_WEBGL_compressed_texture_atc")) {
    187         if (!m_webglCompressedTextureATC) {
    188             m_webglCompressedTextureATC = WebGLCompressedTextureATC::supported(*this)
    189                 ? std::make_unique<WebGLCompressedTextureATC>(*this) : nullptr;
    190         }
    191         return m_webglCompressedTextureATC.get();
    192     }
    193     if (equalIgnoringASCIICase(name, "WEBKIT_WEBGL_compressed_texture_pvrtc")) {
    194         if (!m_webglCompressedTexturePVRTC) {
    195             m_webglCompressedTexturePVRTC = WebGLCompressedTexturePVRTC::supported(*this)
    196                 ? std::make_unique<WebGLCompressedTexturePVRTC>(*this) : nullptr;
    197         }
    198         return m_webglCompressedTexturePVRTC.get();
    199     }
    200     if (equalIgnoringASCIICase(name, "WEBGL_compressed_texture_s3tc")) {
    201         if (!m_webglCompressedTextureS3TC) {
    202             m_webglCompressedTextureS3TC = WebGLCompressedTextureS3TC::supported(*this)
    203                 ? std::make_unique<WebGLCompressedTextureS3TC>(*this) : nullptr;
    204         }
    205         return m_webglCompressedTextureS3TC.get();
    206     }
    207     if (equalIgnoringASCIICase(name, "WEBGL_depth_texture")) {
    208         if (!m_webglDepthTexture) {
    209             m_webglDepthTexture = WebGLDepthTexture::supported(*m_context)
    210                 ? std::make_unique<WebGLDepthTexture>(*this) : nullptr;
    211         }
    212         return m_webglDepthTexture.get();
    213     }
     119    ENABLE_IF_REQUESTED(EXTTextureFilterAnisotropic, m_extTextureFilterAnisotropic, "EXT_texture_filter_anisotropic", enableSupportedExtension("GL_EXT_texture_filter_anisotropic"));
     120    ENABLE_IF_REQUESTED(EXTTextureFilterAnisotropic, m_extTextureFilterAnisotropic, "WEBKIT_EXT_texture_filter_anisotropic", enableSupportedExtension("GL_EXT_texture_filter_anisotropic"));
     121    ENABLE_IF_REQUESTED(OESStandardDerivatives, m_oesStandardDerivatives, "OES_standard_derivatives", enableSupportedExtension("GL_OES_standard_derivatives"));
     122    ENABLE_IF_REQUESTED(OESTextureFloat, m_oesTextureFloat, "OES_texture_float", enableSupportedExtension("GL_OES_texture_float"));
     123    ENABLE_IF_REQUESTED(OESTextureFloatLinear, m_oesTextureFloatLinear, "OES_texture_float_linear", enableSupportedExtension("GL_OES_texture_float_linear"));
     124    ENABLE_IF_REQUESTED(OESTextureHalfFloat, m_oesTextureHalfFloat, "OES_texture_half_float", enableSupportedExtension("GL_OES_texture_half_float"));
     125    ENABLE_IF_REQUESTED(OESTextureHalfFloatLinear, m_oesTextureHalfFloatLinear, "OES_texture_half_float_linear", enableSupportedExtension("GL_OES_texture_half_float_linear"));
     126    ENABLE_IF_REQUESTED(OESVertexArrayObject, m_oesVertexArrayObject, "OES_vertex_array_object", enableSupportedExtension("GL_OES_vertex_array_object"));
     127    ENABLE_IF_REQUESTED(OESElementIndexUint, m_oesElementIndexUint, "OES_element_index_uint", enableSupportedExtension("GL_OES_element_index_uint"));
     128    ENABLE_IF_REQUESTED(WebGLLoseContext, m_webglLoseContext, "WEBGL_lose_context", true);
     129    ENABLE_IF_REQUESTED(WebGLCompressedTextureATC, m_webglCompressedTextureATC, "WEBKIT_WEBGL_compressed_texture_atc", WebGLCompressedTextureATC::supported(*this));
     130    ENABLE_IF_REQUESTED(WebGLCompressedTexturePVRTC, m_webglCompressedTexturePVRTC, "WEBKIT_WEBGL_compressed_texture_pvrtc", WebGLCompressedTexturePVRTC::supported(*this));
     131    ENABLE_IF_REQUESTED(WebGLCompressedTextureS3TC, m_webglCompressedTextureS3TC, "WEBGL_compressed_texture_s3tc", WebGLCompressedTextureS3TC::supported(*this));
     132    ENABLE_IF_REQUESTED(WebGLDepthTexture, m_webglDepthTexture, "WEBGL_depth_texture", WebGLDepthTexture::supported(*m_context));
    214133    if (equalIgnoringASCIICase(name, "WEBGL_draw_buffers")) {
    215134        if (!m_webglDrawBuffers) {
     
    219138                m_context->getExtensions().ensureEnabled(ASCIILiteral { "GL_EXT_draw_buffers" });
    220139                m_webglDrawBuffers = std::make_unique<WebGLDrawBuffers>(*this);
     140                InspectorInstrumentation::didEnableExtension(*this, name);
    221141            }
    222142        }
     
    230150                m_context->getExtensions().ensureEnabled(ASCIILiteral { "GL_ANGLE_instanced_arrays" });
    231151                m_angleInstancedArrays = std::make_unique<ANGLEInstancedArrays>(*this);
     152                InspectorInstrumentation::didEnableExtension(*this, name);
    232153            }
    233154        }
    234155        return m_angleInstancedArrays.get();
    235156    }
    236     if (equalIgnoringASCIICase(name, "WEBGL_debug_renderer_info")) {
    237         if (!m_webglDebugRendererInfo)
    238             m_webglDebugRendererInfo = std::make_unique<WebGLDebugRendererInfo>(*this);
    239         return m_webglDebugRendererInfo.get();
    240     }
    241     if (equalIgnoringASCIICase(name, "WEBGL_debug_shaders")) {
    242         if (!m_webglDebugShaders) {
    243             m_webglDebugShaders = m_context->getExtensions().supports(ASCIILiteral { "GL_ANGLE_translated_shader_source" })
    244                 ? std::make_unique<WebGLDebugShaders>(*this) : nullptr;
    245         }
    246         return m_webglDebugShaders.get();
    247     }
    248 
     157    ENABLE_IF_REQUESTED(WebGLDebugRendererInfo, m_webglDebugRendererInfo, "WEBGL_debug_renderer_info", true);
     158    ENABLE_IF_REQUESTED(WebGLDebugShaders, m_webglDebugShaders, "WEBGL_debug_shaders", m_context->getExtensions().supports(ASCIILiteral { "GL_ANGLE_translated_shader_source" }));
    249159    return nullptr;
    250160}
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r224236 r224370  
    27392739        return 0;
    27402740    return m_context->getVertexAttribOffset(index, pname);
     2741}
     2742
     2743bool WebGLRenderingContextBase::extensionIsEnabled(const String& name)
     2744{
     2745#define CHECK_EXTENSION(variable, nameLiteral) \
     2746    if (equalIgnoringASCIICase(name, nameLiteral)) \
     2747        return variable != nullptr;
     2748
     2749    CHECK_EXTENSION(m_extFragDepth, "EXT_frag_depth");
     2750    CHECK_EXTENSION(m_extBlendMinMax, "EXT_blend_minmax");
     2751    CHECK_EXTENSION(m_extsRGB, "EXT_sRGB");
     2752    CHECK_EXTENSION(m_extTextureFilterAnisotropic, "EXT_texture_filter_anisotropic");
     2753    CHECK_EXTENSION(m_extTextureFilterAnisotropic, "WEBKIT_EXT_texture_filter_anisotropic");
     2754    CHECK_EXTENSION(m_extShaderTextureLOD, "EXT_shader_texture_lod");
     2755    CHECK_EXTENSION(m_oesTextureFloat, "OES_texture_float");
     2756    CHECK_EXTENSION(m_oesTextureFloatLinear, "OES_texture_float_linear");
     2757    CHECK_EXTENSION(m_oesTextureHalfFloat, "OES_texture_half_float");
     2758    CHECK_EXTENSION(m_oesTextureHalfFloatLinear, "OES_texture_half_float_linear");
     2759    CHECK_EXTENSION(m_oesStandardDerivatives, "OES_standard_derivatives");
     2760    CHECK_EXTENSION(m_oesVertexArrayObject, "OES_vertex_array_object");
     2761    CHECK_EXTENSION(m_oesElementIndexUint, "OES_element_index_uint");
     2762    CHECK_EXTENSION(m_webglLoseContext, "WEBGL_lose_context");
     2763    CHECK_EXTENSION(m_webglDebugRendererInfo, "WEBGL_debug_renderer_info");
     2764    CHECK_EXTENSION(m_webglDebugShaders, "WEBGL_debug_shaders");
     2765    CHECK_EXTENSION(m_webglCompressedTextureATC, "WEBKIT_WEBGL_compressed_texture_atc");
     2766    CHECK_EXTENSION(m_webglCompressedTexturePVRTC, "WEBKIT_WEBGL_compressed_texture_pvrtc");
     2767    CHECK_EXTENSION(m_webglCompressedTextureS3TC, "WEBGL_compressed_texture_s3tc");
     2768    CHECK_EXTENSION(m_webglDepthTexture, "WEBGL_depth_texture");
     2769    CHECK_EXTENSION(m_webglDrawBuffers, "WEBGL_draw_buffers");
     2770    CHECK_EXTENSION(m_angleInstancedArrays, "ANGLE_instanced_arrays");
     2771    return false;
    27412772}
    27422773
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h

    r221971 r224370  
    211211    long long getVertexAttribOffset(GC3Duint index, GC3Denum pname);
    212212
     213    bool extensionIsEnabled(const String&);
     214
    213215    bool isPreservingDrawingBuffer() const { return m_attributes.preserveDrawingBuffer; }
    214216    void setPreserveDrawingBuffer(bool value) { m_attributes.preserveDrawingBuffer = value; }
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r224002 r224370  
    10141014
    10151015#if ENABLE(WEBGL)
     1016void InspectorInstrumentation::didEnableExtensionImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& context, const String& extension)
     1017{
     1018    if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
     1019        canvasAgent->didEnableExtension(context, extension);
     1020}
     1021
    10161022void InspectorInstrumentation::didCreateProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& context, WebGLProgram& program)
    10171023{
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r224002 r224370  
    251251    static void recordCanvasAction(CanvasRenderingContext&, const String&, Vector<RecordCanvasActionVariant>&& = { });
    252252    static void didFinishRecordingCanvasFrame(HTMLCanvasElement&, bool forceDispatch = false);
    253 
    254253#if ENABLE(WEBGL)
     254    static void didEnableExtension(WebGLRenderingContextBase&, const String&);
    255255    static void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
    256256    static void willDeleteProgram(WebGLRenderingContextBase&, WebGLProgram&);
     
    424424    static void didFinishRecordingCanvasFrameImpl(InstrumentingAgents&, HTMLCanvasElement&, bool forceDispatch = false);
    425425#if ENABLE(WEBGL)
     426    static void didEnableExtensionImpl(InstrumentingAgents&, WebGLRenderingContextBase&, const String&);
    426427    static void didCreateProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);
    427428    static void willDeleteProgramImpl(InstrumentingAgents&, WebGLProgram&);
     
    12031204
    12041205#if ENABLE(WEBGL)
     1206inline void InspectorInstrumentation::didEnableExtension(WebGLRenderingContextBase& context, const String& extension)
     1207{
     1208    FAST_RETURN_IF_NO_FRONTENDS(void());
     1209    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForDocument(context.canvas().document()))
     1210        didEnableExtensionImpl(*instrumentingAgents, context, extension);
     1211}
     1212
    12051213inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
    12061214{
  • trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp

    r224345 r224370  
    9696
    9797    const bool captureBacktrace = false;
    98     for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values())
     98    for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) {
    9999        m_frontendDispatcher->canvasAdded(inspectorCanvas->buildObjectForCanvas(m_instrumentingAgents, captureBacktrace));
     100
     101#if ENABLE(WEBGL)
     102        CanvasRenderingContext* context = inspectorCanvas->canvas().renderingContext();
     103        if (is<WebGLRenderingContextBase>(context)) {
     104            WebGLRenderingContextBase* contextWebGL = downcast<WebGLRenderingContextBase>(context);
     105            if (std::optional<Vector<String>> extensions = contextWebGL->getSupportedExtensions()) {
     106                for (const String& extension : *extensions) {
     107                    if (contextWebGL->extensionIsEnabled(extension))
     108                        m_frontendDispatcher->extensionEnabled(inspectorCanvas->identifier(), extension);
     109                }
     110            }
     111        }
     112#endif
     113    }
    100114
    101115#if ENABLE(WEBGL)
     
    509523
    510524#if ENABLE(WEBGL)
     525void InspectorCanvasAgent::didEnableExtension(WebGLRenderingContextBase& context, const String& extension)
     526{
     527    auto* inspectorCanvas = findInspectorCanvas(context.canvas());
     528    if (!inspectorCanvas)
     529        return;
     530
     531    m_frontendDispatcher->extensionEnabled(inspectorCanvas->identifier(), extension);
     532}
     533
    511534void InspectorCanvasAgent::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
    512535{
  • trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h

    r224345 r224370  
    8989    void didFinishRecordingCanvasFrame(HTMLCanvasElement&, bool forceDispatch = false);
    9090#if ENABLE(WEBGL)
     91    void didEnableExtension(WebGLRenderingContextBase&, const String&);
    9192    void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
    9293    void willDeleteProgram(WebGLProgram&);
  • trunk/Source/WebInspectorUI/ChangeLog

    r224368 r224370  
     12017-11-02  Devin Rousso  <webkit@devinrousso.com>
     2
     3        Web Inspector: Canvas Tab: show supported GL extensions for selected canvas
     4        https://bugs.webkit.org/show_bug.cgi?id=179070
     5        <rdar://problem/35278276>
     6
     7        Reviewed by Brian Burg.
     8
     9        * Localizations/en.lproj/localizedStrings.js:
     10
     11        * UserInterface/Protocol/CanvasObserver.js:
     12        (WI.CanvasObserver.prototype.extensionEnabled):
     13
     14        * UserInterface/Controllers/CanvasManager.js:
     15        (WI.CanvasManager.prototype.extensionEnabled):
     16
     17        * UserInterface/Models/Canvas.js:
     18        (WI.Canvas.prototype.get extensions):
     19        (WI.Canvas.prototype.enableExtension):
     20        Maintain a Set of enabled extensions, and dispatch an event whenever an extension is enabled.
     21
     22        * UserInterface/Views/CanvasDetailsSidebarPanel.css:
     23        (.sidebar > .panel.details.canvas .details-section.canvas-extensions .content > ul):
     24        * UserInterface/Views/CanvasDetailsSidebarPanel.js:
     25        (WI.CanvasDetailsSidebarPanel.prototype.set canvas):
     26        (WI.CanvasDetailsSidebarPanel.prototype.initialLayout):
     27        (WI.CanvasDetailsSidebarPanel.prototype.layout):
     28        (WI.CanvasDetailsSidebarPanel.prototype._refreshAttributesSection):
     29        (WI.CanvasDetailsSidebarPanel.prototype._refreshExtensionsSection):
     30        Drive-by: hide Attributes section when the canvas has no attributes.
     31
    1322017-11-02  Joseph Pecoraro  <pecoraro@apple.com>
    233
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r224368 r224370  
    396396localizedStrings["Expression"] = "Expression";
    397397localizedStrings["Extension Scripts"] = "Extension Scripts";
     398localizedStrings["Extensions"] = "Extensions";
    398399localizedStrings["Extra Scripts"] = "Extra Scripts";
    399400localizedStrings["Fade unexecuted code"] = "Fade unexecuted code";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js

    r224081 r224370  
    161161    }
    162162
     163    extensionEnabled(canvasIdentifier, extension)
     164    {
     165        // Called from WI.CanvasObserver.
     166
     167        let canvas = this._canvasIdentifierMap.get(canvasIdentifier);
     168        console.assert(canvas);
     169        if (!canvas)
     170            return;
     171
     172        canvas.enableExtension(extension);
     173    }
     174
    163175    programCreated(canvasIdentifier, programIdentifier)
    164176    {
  • trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js

    r224142 r224370  
    4040        this._cssCanvasName = cssCanvasName || "";
    4141        this._contextAttributes = contextAttributes || {};
     42        this._extensions = new Set;
    4243        this._memoryCost = memoryCost || NaN;
    4344        this._backtrace = backtrace || [];
     
    112113    get cssCanvasName() { return this._cssCanvasName; }
    113114    get contextAttributes() { return this._contextAttributes; }
     115    get extensions() { return this._extensions; }
    114116    get backtrace() { return this._backtrace; }
    115117    get shaderProgramCollection() { return this._shaderProgramCollection; }
     
    266268    }
    267269
     270    enableExtension(extension)
     271    {
     272        // Called from WI.CanvasManager.
     273
     274        this._extensions.add(extension);
     275
     276        this.dispatchEventToListeners(WI.Canvas.Event.ExtensionEnabled, {extension});
     277    }
     278
    268279    cssCanvasClientNodesChanged()
    269280    {
     
    300311WI.Canvas.Event = {
    301312    MemoryChanged: "canvas-memory-changed",
     313    ExtensionEnabled: "canvas-extension-enabled",
    302314    CSSCanvasClientNodesChanged: "canvas-css-canvas-client-nodes-changed",
    303315};
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js

    r220233 r224370  
    5353    }
    5454
     55    extensionEnabled(canvasId, extension)
     56    {
     57        WI.canvasManager.extensionEnabled(canvasId, extension);
     58    }
     59
    5560    programCreated(canvasId, programId)
    5661    {
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasDetailsSidebarPanel.css

    r224142 r224370  
    2828}
    2929
     30.sidebar > .panel.details.canvas .details-section.canvas-extensions .content > ul {
     31    margin: 4px 0;
     32    -webkit-padding-start: 22.5px;
     33}
     34
    3035.sidebar > .panel.details.canvas .details-section.canvas-backtrace .call-frame {
    3136    margin: 3px;
  • trunk/Source/WebInspectorUI/UserInterface/Views/CanvasDetailsSidebarPanel.js

    r224142 r224370  
    7878        if (this._canvas) {
    7979            this._canvas.removeEventListener(WI.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this);
     80            this._canvas.removeEventListener(WI.Canvas.Event.ExtensionEnabled, this._refreshExtensionsSection, this);
    8081            this._canvas.removeEventListener(WI.Canvas.Event.CSSCanvasClientNodesChanged, this._refreshCSSCanvasSection, this);
    8182        }
     
    8586        if (this._canvas) {
    8687            this._canvas.addEventListener(WI.Canvas.Event.MemoryChanged, this._canvasMemoryChanged, this);
     88            this._canvas.addEventListener(WI.Canvas.Event.ExtensionEnabled, this._refreshExtensionsSection, this);
    8789            this._canvas.addEventListener(WI.Canvas.Event.CSSCanvasClientNodesChanged, this._refreshCSSCanvasSection, this);
    8890        }
     
    118120        this._attributesDataGridRow = new WI.DetailsSectionDataGridRow(null, WI.UIString("No Attributes"));
    119121
    120         let attributesSection = new WI.DetailsSection("canvas-attributes", WI.UIString("Attributes"));
    121         attributesSection.groups = [new WI.DetailsSectionGroup([this._attributesDataGridRow])];
    122         this._sections.push(attributesSection);
     122        this._attributesSection = new WI.DetailsSection("canvas-attributes", WI.UIString("Attributes"));
     123        this._attributesSection.groups = [new WI.DetailsSectionGroup([this._attributesDataGridRow])];
     124        this._attributesSection.element.hidden = true;
     125        this._sections.push(this._attributesSection);
     126
     127        this._extensionsSection = new WI.DetailsSection("canvas-extensions", WI.UIString("Extensions"));
     128        this._extensionsSection.element.hidden = true;
     129        this._sections.push(this._extensionsSection);
    123130
    124131        this._cssCanvasClientsRow = new WI.DetailsSectionSimpleRow(WI.UIString("Nodes"));
     
    157164        this._refreshSourceSection();
    158165        this._refreshAttributesSection();
     166        this._refreshExtensionsSection();
    159167        this._refreshCSSCanvasSection();
    160168        this._refreshBacktraceSection();
     
    245253    _refreshAttributesSection()
    246254    {
    247         if (isEmptyObject(this._canvas.contextAttributes)) {
    248             // Remove the DataGrid to show the placeholder text.
    249             this._attributesDataGridRow.dataGrid = null;
    250             return;
    251         }
     255        let hasAttributes = !isEmptyObject(this._canvas.contextAttributes);
     256        this._attributesSection.element.hidden = !hasAttributes;
     257        if (!hasAttributes)
     258            return;
    252259
    253260        let dataGrid = this._attributesDataGridRow.dataGrid;
     
    270277    }
    271278
     279    _refreshExtensionsSection()
     280    {
     281        let hasEnabledExtensions = this._canvas.extensions.size > 0;
     282        this._extensionsSection.element.hidden = !hasEnabledExtensions;
     283        if (!hasEnabledExtensions)
     284            return;
     285
     286        let element = document.createElement("ul");
     287        for (let extension of this._canvas.extensions) {
     288            let listElement = element.appendChild(document.createElement("li"));
     289            listElement.textContent = extension;
     290        }
     291        this._extensionsSection.groups = [{element}];
     292    }
     293
    272294    _refreshCSSCanvasSection()
    273295    {
Note: See TracChangeset for help on using the changeset viewer.