Please support WEBGL_compressed_texture_etc1 extension (and possibly WEBGL_compressed...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2019 01:38:26 +0000 (01:38 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2019 01:38:26 +0000 (01:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197900

Patch by Kenneth Russell <kbr@chromium.org> on 2019-11-07
Reviewed by Dean Jackson.

Support the ETC1 and ETC2 compressed texture formats in WebKit's WebGL
implementation.

Tested by changing the code to allocate an OpenGL ES 3.0 context for WebGL,
and running in the iOS Simulator. The WebGL conformance tests
webgl-compressed-texture-etc.html and webgl-compressed-texture-etc1.html all
pass with these changes.

When an ANGLE backend is supported on iOS, these extensions will
automatically be supported, and some of the new validation code can be
removed.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMConvertWebGL.cpp:
(WebCore::convertToJSValue):
* html/canvas/WebGL2RenderingContext.cpp:
(WebCore::WebGL2RenderingContext::getExtension):
(WebCore::WebGL2RenderingContext::getSupportedExtensions):
* html/canvas/WebGLCompressedTextureETC.cpp: Added.
(WebCore::WebGLCompressedTextureETC::WebGLCompressedTextureETC):
(WebCore::WebGLCompressedTextureETC::getName const):
(WebCore::WebGLCompressedTextureETC::supported):
* html/canvas/WebGLCompressedTextureETC.h: Added.
* html/canvas/WebGLCompressedTextureETC.idl: Added.
* html/canvas/WebGLCompressedTextureETC1.cpp: Added.
(WebCore::WebGLCompressedTextureETC1::WebGLCompressedTextureETC1):
(WebCore::WebGLCompressedTextureETC1::getName const):
(WebCore::WebGLCompressedTextureETC1::supported):
* html/canvas/WebGLCompressedTextureETC1.h: Added.
* html/canvas/WebGLCompressedTextureETC1.idl: Added.
* html/canvas/WebGLExtension.h:
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::getExtension):
(WebCore::WebGLRenderingContext::getSupportedExtensions):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::extensionIsEnabled):
(WebCore::WebGLRenderingContextBase::validateCompressedTexFuncData):
(WebCore::WebGLRenderingContextBase::validateCompressedTexDimensions):
(WebCore::WebGLRenderingContextBase::validateCompressedTexSubDimensions):
* html/canvas/WebGLRenderingContextBase.h:
* platform/graphics/Extensions3D.h:
* platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
(WebCore::GraphicsContext3D::GraphicsContext3D):
* platform/graphics/opengl/Extensions3DOpenGL.cpp:
(WebCore::Extensions3DOpenGL::supportsExtension):

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

22 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources-input.xcfilelist
Source/WebCore/DerivedSources-output.xcfilelist
Source/WebCore/DerivedSources.make
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSDOMConvertWebGL.cpp
Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
Source/WebCore/html/canvas/WebGLCompressedTextureETC.cpp [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLCompressedTextureETC.h [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLCompressedTextureETC.idl [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLCompressedTextureETC1.cpp [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLCompressedTextureETC1.h [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLCompressedTextureETC1.idl [new file with mode: 0644]
Source/WebCore/html/canvas/WebGLExtension.h
Source/WebCore/html/canvas/WebGLRenderingContext.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.h
Source/WebCore/platform/graphics/Extensions3D.h
Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm
Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp

index f336845..7967c74 100644 (file)
@@ -1314,6 +1314,8 @@ if (ENABLE_WEBGL)
         html/canvas/WebGLBuffer.cpp
         html/canvas/WebGLCompressedTextureASTC.cpp
         html/canvas/WebGLCompressedTextureATC.cpp
+        html/canvas/WebGLCompressedTextureETC.cpp
+        html/canvas/WebGLCompressedTextureETC1.cpp
         html/canvas/WebGLCompressedTexturePVRTC.cpp
         html/canvas/WebGLCompressedTextureS3TC.cpp
         html/canvas/WebGLContextEvent.cpp
@@ -1363,6 +1365,8 @@ if (ENABLE_WEBGL)
         html/canvas/WebGLBuffer.idl
         html/canvas/WebGLCompressedTextureASTC.idl
         html/canvas/WebGLCompressedTextureATC.idl
+        html/canvas/WebGLCompressedTextureETC.idl
+        html/canvas/WebGLCompressedTextureETC1.idl
         html/canvas/WebGLCompressedTexturePVRTC.idl
         html/canvas/WebGLCompressedTextureS3TC.idl
         html/canvas/WebGLContextAttributes.idl
index 037416c..f31fb71 100644 (file)
@@ -1,3 +1,61 @@
+2019-11-07  Kenneth Russell  <kbr@chromium.org>
+
+        Please support WEBGL_compressed_texture_etc1 extension (and possibly WEBGL_compressed_texture_etc too)
+        https://bugs.webkit.org/show_bug.cgi?id=197900
+
+        Reviewed by Dean Jackson.
+
+        Support the ETC1 and ETC2 compressed texture formats in WebKit's WebGL
+        implementation.
+
+        Tested by changing the code to allocate an OpenGL ES 3.0 context for WebGL,
+        and running in the iOS Simulator. The WebGL conformance tests
+        webgl-compressed-texture-etc.html and webgl-compressed-texture-etc1.html all
+        pass with these changes.
+
+        When an ANGLE backend is supported on iOS, these extensions will
+        automatically be supported, and some of the new validation code can be
+        removed.
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSDOMConvertWebGL.cpp:
+        (WebCore::convertToJSValue):
+        * html/canvas/WebGL2RenderingContext.cpp:
+        (WebCore::WebGL2RenderingContext::getExtension):
+        (WebCore::WebGL2RenderingContext::getSupportedExtensions):
+        * html/canvas/WebGLCompressedTextureETC.cpp: Added.
+        (WebCore::WebGLCompressedTextureETC::WebGLCompressedTextureETC):
+        (WebCore::WebGLCompressedTextureETC::getName const):
+        (WebCore::WebGLCompressedTextureETC::supported):
+        * html/canvas/WebGLCompressedTextureETC.h: Added.
+        * html/canvas/WebGLCompressedTextureETC.idl: Added.
+        * html/canvas/WebGLCompressedTextureETC1.cpp: Added.
+        (WebCore::WebGLCompressedTextureETC1::WebGLCompressedTextureETC1):
+        (WebCore::WebGLCompressedTextureETC1::getName const):
+        (WebCore::WebGLCompressedTextureETC1::supported):
+        * html/canvas/WebGLCompressedTextureETC1.h: Added.
+        * html/canvas/WebGLCompressedTextureETC1.idl: Added.
+        * html/canvas/WebGLExtension.h:
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore::WebGLRenderingContext::getExtension):
+        (WebCore::WebGLRenderingContext::getSupportedExtensions):
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::extensionIsEnabled):
+        (WebCore::WebGLRenderingContextBase::validateCompressedTexFuncData):
+        (WebCore::WebGLRenderingContextBase::validateCompressedTexDimensions):
+        (WebCore::WebGLRenderingContextBase::validateCompressedTexSubDimensions):
+        * html/canvas/WebGLRenderingContextBase.h:
+        * platform/graphics/Extensions3D.h:
+        * platform/graphics/cocoa/GraphicsContext3DCocoa.mm:
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+        * platform/graphics/opengl/Extensions3DOpenGL.cpp:
+        (WebCore::Extensions3DOpenGL::supportsExtension):
+
 2019-11-07  Ryosuke Niwa  <rniwa@webkit.org>
 
         WindowEventLoop should be shared among similar origin documents
index b31a250..f29279e 100644 (file)
@@ -825,6 +825,8 @@ $(PROJECT_DIR)/html/canvas/WebGLActiveInfo.idl
 $(PROJECT_DIR)/html/canvas/WebGLBuffer.idl
 $(PROJECT_DIR)/html/canvas/WebGLCompressedTextureASTC.idl
 $(PROJECT_DIR)/html/canvas/WebGLCompressedTextureATC.idl
+$(PROJECT_DIR)/html/canvas/WebGLCompressedTextureETC.idl
+$(PROJECT_DIR)/html/canvas/WebGLCompressedTextureETC1.idl
 $(PROJECT_DIR)/html/canvas/WebGLCompressedTexturePVRTC.idl
 $(PROJECT_DIR)/html/canvas/WebGLCompressedTextureS3TC.idl
 $(PROJECT_DIR)/html/canvas/WebGLContextAttributes.idl
index 539491e..859aa34 100644 (file)
@@ -1927,6 +1927,10 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureASTC.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureASTC.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureATC.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureATC.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureETC.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureETC.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureETC1.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureETC1.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTexturePVRTC.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTexturePVRTC.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGLCompressedTextureS3TC.cpp
index 16174e5..fd72366 100644 (file)
@@ -829,6 +829,8 @@ JS_BINDING_IDLS = \
     $(WebCore)/html/canvas/WebGLBuffer.idl \
     $(WebCore)/html/canvas/WebGLCompressedTextureASTC.idl \
     $(WebCore)/html/canvas/WebGLCompressedTextureATC.idl \
+    $(WebCore)/html/canvas/WebGLCompressedTextureETC.idl \
+    $(WebCore)/html/canvas/WebGLCompressedTextureETC1.idl \
     $(WebCore)/html/canvas/WebGLCompressedTexturePVRTC.idl \
     $(WebCore)/html/canvas/WebGLCompressedTextureS3TC.idl \
     $(WebCore)/html/canvas/WebGLContextAttributes.idl \
index 35fd422..84ede5c 100644 (file)
@@ -1287,6 +1287,8 @@ html/canvas/WebGL2RenderingContext.cpp
 html/canvas/WebGLBuffer.cpp
 html/canvas/WebGLCompressedTextureASTC.cpp
 html/canvas/WebGLCompressedTextureATC.cpp
+html/canvas/WebGLCompressedTextureETC.cpp
+html/canvas/WebGLCompressedTextureETC1.cpp
 html/canvas/WebGLCompressedTexturePVRTC.cpp
 html/canvas/WebGLCompressedTextureS3TC.cpp
 html/canvas/WebGLContextEvent.cpp
@@ -3556,6 +3558,8 @@ JSWebGLActiveInfo.cpp
 JSWebGLBuffer.cpp
 JSWebGLCompressedTextureASTC.cpp
 JSWebGLCompressedTextureATC.cpp
+JSWebGLCompressedTextureETC.cpp
+JSWebGLCompressedTextureETC1.cpp
 JSWebGLCompressedTexturePVRTC.cpp
 JSWebGLCompressedTextureS3TC.cpp
 JSWebGLContextAttributes.cpp
index b7ec33c..13032ec 100644 (file)
                6C4C96DF1AD4483500365672 /* JSReadableStreamBYOBRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500365672 /* JSReadableStreamBYOBRequest.h */; };
                6C4C96DF1AD4483500365A50 /* JSReadableStreamDefaultController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500365A50 /* JSReadableStreamDefaultController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6C638895A96CCEE50C8C946C /* CachedResourceRequestInitiators.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               6E0B90692321A68D006223B2 /* WebGLCompressedTextureETC1.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E0B90652321A68C006223B2 /* WebGLCompressedTextureETC1.h */; };
                6E0E569C183BFFE600E0E8D5 /* FloatRoundedRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
                6E21C6C01126338500A7BE02 /* GraphicsContext3D.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */; };
+               6E242B2B23359405002CADD4 /* JSWebGLCompressedTextureETC1.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E242B2A233593D8002CADD4 /* JSWebGLCompressedTextureETC1.h */; };
+               6E242B2C23359409002CADD4 /* JSWebGLCompressedTextureETC.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E242B28233593D7002CADD4 /* JSWebGLCompressedTextureETC.h */; };
                6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextureS3TC.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAD3714733F4000E42306 /* JSWebGLCompressedTextureS3TC.h */; };
                6E3FAD3914733F4000E42307 /* JSWebGLDepthTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAD3714733F4000E42307 /* JSWebGLDepthTexture.h */; };
                6E3FAD3914733F4011E42307 /* JSWebGLDebugRendererInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E3FAD3714733F4011E42307 /* JSWebGLDebugRendererInfo.h */; };
                6E72F550229DCD1700B3E151 /* Extensions3DANGLE.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E27F244229C9F8D00F1F632 /* Extensions3DANGLE.h */; };
                6E72F551229DCD1A00B3E151 /* TemporaryANGLESetting.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E290863229DB970000986E2 /* TemporaryANGLESetting.h */; };
                6E84E9E117668BF100815B68 /* RasterShape.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E84E9DF17668BAD00815B68 /* RasterShape.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               6E8ACDED23345CBC0024AAF5 /* WebGLCompressedTextureETC.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E8ACDEB23345CAF0024AAF5 /* WebGLCompressedTextureETC.h */; };
                6EBF0E4912A8926100DB1709 /* OESTextureFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EBF0E4612A8926100DB1709 /* OESTextureFloat.h */; };
                6EBF0E5512A8929800DB1709 /* WebGLExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EBF0E5312A8929800DB1709 /* WebGLExtension.h */; };
                6EBF0E7712A9868800DB1709 /* JSOESTextureFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EBF0E7512A9868800DB1709 /* JSOESTextureFloat.h */; };
                6C4C96DB1AD4483500365A50 /* JSReadableStreamDefaultController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamDefaultController.h; sourceTree = "<group>"; };
                6C638893A96CCEE50C8C946C /* CachedResourceRequestInitiators.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedResourceRequestInitiators.h; sourceTree = "<group>"; };
                6C638894A96CCEE50C8C946C /* CachedResourceRequestInitiators.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CachedResourceRequestInitiators.cpp; sourceTree = "<group>"; };
+               6E0B90652321A68C006223B2 /* WebGLCompressedTextureETC1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLCompressedTextureETC1.h; sourceTree = "<group>"; };
+               6E0B90672321A68C006223B2 /* WebGLCompressedTextureETC1.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLCompressedTextureETC1.idl; sourceTree = "<group>"; };
+               6E0B90682321A68D006223B2 /* WebGLCompressedTextureETC1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLCompressedTextureETC1.cpp; sourceTree = "<group>"; };
                6E0E5699183BFFE600E0E8D5 /* FloatRoundedRect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatRoundedRect.cpp; sourceTree = "<group>"; };
                6E0E569A183BFFE600E0E8D5 /* FloatRoundedRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatRoundedRect.h; sourceTree = "<group>"; };
                6E21C6BF1126338500A7BE02 /* GraphicsContext3D.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3D.cpp; sourceTree = "<group>"; };
                6E21C6C11126339900A7BE02 /* GraphicsContext3DCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DCG.cpp; sourceTree = "<group>"; };
+               6E242B26233593D7002CADD4 /* JSWebGLCompressedTextureETC.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebGLCompressedTextureETC.cpp; path = ../../../../../../WebKitBuild/Debug/DerivedSources/WebCore/JSWebGLCompressedTextureETC.cpp; sourceTree = "<group>"; };
+               6E242B28233593D7002CADD4 /* JSWebGLCompressedTextureETC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = JSWebGLCompressedTextureETC.h; path = ../../../../../../WebKitBuild/Debug/DerivedSources/WebCore/JSWebGLCompressedTextureETC.h; sourceTree = "<group>"; };
+               6E242B29233593D7002CADD4 /* JSWebGLCompressedTextureETC1.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebGLCompressedTextureETC1.cpp; path = ../../../../../../WebKitBuild/Debug/DerivedSources/WebCore/JSWebGLCompressedTextureETC1.cpp; sourceTree = "<group>"; };
+               6E242B2A233593D8002CADD4 /* JSWebGLCompressedTextureETC1.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = JSWebGLCompressedTextureETC1.h; path = ../../../../../../WebKitBuild/Debug/DerivedSources/WebCore/JSWebGLCompressedTextureETC1.h; sourceTree = "<group>"; };
                6E27F2422298CE4B00F1F632 /* GraphicsContext3DANGLE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DANGLE.cpp; sourceTree = "<group>"; };
                6E27F243229C9F8400F1F632 /* Extensions3DANGLE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Extensions3DANGLE.cpp; sourceTree = "<group>"; };
                6E27F244229C9F8D00F1F632 /* Extensions3DANGLE.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Extensions3DANGLE.h; sourceTree = "<group>"; };
                6E67D2A81280E8BD008758F7 /* Extensions3D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Extensions3D.h; sourceTree = "<group>"; };
                6E84E9DE17668BAD00815B68 /* RasterShape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RasterShape.cpp; sourceTree = "<group>"; };
                6E84E9DF17668BAD00815B68 /* RasterShape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RasterShape.h; sourceTree = "<group>"; };
+               6E8ACDE923345CAF0024AAF5 /* WebGLCompressedTextureETC.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLCompressedTextureETC.cpp; sourceTree = "<group>"; };
+               6E8ACDEB23345CAF0024AAF5 /* WebGLCompressedTextureETC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGLCompressedTextureETC.h; sourceTree = "<group>"; };
+               6E8ACDEC23345CB00024AAF5 /* WebGLCompressedTextureETC.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGLCompressedTextureETC.idl; sourceTree = "<group>"; };
                6EBF0E4512A8926100DB1709 /* OESTextureFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OESTextureFloat.cpp; sourceTree = "<group>"; };
                6EBF0E4612A8926100DB1709 /* OESTextureFloat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OESTextureFloat.h; sourceTree = "<group>"; };
                6EBF0E4712A8926100DB1709 /* OESTextureFloat.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OESTextureFloat.idl; sourceTree = "<group>"; };
                                7E66E23116D6EB6C00F7E7FF /* WebGLCompressedTextureATC.cpp */,
                                7E66E23216D6EB6C00F7E7FF /* WebGLCompressedTextureATC.h */,
                                7EA30F6216DFD62700257D0B /* WebGLCompressedTextureATC.idl */,
+                               6E8ACDE923345CAF0024AAF5 /* WebGLCompressedTextureETC.cpp */,
+                               6E8ACDEB23345CAF0024AAF5 /* WebGLCompressedTextureETC.h */,
+                               6E8ACDEC23345CB00024AAF5 /* WebGLCompressedTextureETC.idl */,
+                               6E0B90682321A68D006223B2 /* WebGLCompressedTextureETC1.cpp */,
+                               6E0B90652321A68C006223B2 /* WebGLCompressedTextureETC1.h */,
+                               6E0B90672321A68C006223B2 /* WebGLCompressedTextureETC1.idl */,
                                7E66E23117E6EB6C00F7E7FF /* WebGLCompressedTexturePVRTC.cpp */,
                                7E66E23217E6EB6C00F7E7FF /* WebGLCompressedTexturePVRTC.h */,
                                7EA30F6217EFD62700257D0B /* WebGLCompressedTexturePVRTC.idl */,
                                49C7B9811042D2D30009D447 /* JSWebGLBuffer.h */,
                                7EA30F6716DFFE7500257D0B /* JSWebGLCompressedTextureATC.cpp */,
                                7EA30F6816DFFE7500257D0B /* JSWebGLCompressedTextureATC.h */,
+                               6E242B26233593D7002CADD4 /* JSWebGLCompressedTextureETC.cpp */,
+                               6E242B28233593D7002CADD4 /* JSWebGLCompressedTextureETC.h */,
+                               6E242B29233593D7002CADD4 /* JSWebGLCompressedTextureETC1.cpp */,
+                               6E242B2A233593D8002CADD4 /* JSWebGLCompressedTextureETC1.h */,
                                7EA30F6717EFFE7500257D0B /* JSWebGLCompressedTexturePVRTC.cpp */,
                                7EA30F6817EFFE7500257D0B /* JSWebGLCompressedTexturePVRTC.h */,
                                6E3FAD3614733F4000E42306 /* JSWebGLCompressedTextureS3TC.cpp */,
                                A7D20F63107F406900A80392 /* JSWebGLActiveInfo.h in Headers */,
                                49C7B9941042D2D30009D447 /* JSWebGLBuffer.h in Headers */,
                                7EA30F6A16DFFE7500257D0B /* JSWebGLCompressedTextureATC.h in Headers */,
+                               6E242B2C23359409002CADD4 /* JSWebGLCompressedTextureETC.h in Headers */,
+                               6E242B2B23359405002CADD4 /* JSWebGLCompressedTextureETC1.h in Headers */,
                                7EA30F6A17EFFE7500257D0B /* JSWebGLCompressedTexturePVRTC.h in Headers */,
                                6E3FAD3914733F4000E42306 /* JSWebGLCompressedTextureS3TC.h in Headers */,
                                6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */,
                                49C7B9C91042D32F0009D447 /* WebGLBuffer.h in Headers */,
                                D08B00E420A282590004BC0A /* WebGLCompressedTextureASTC.h in Headers */,
                                7E66E23416D6EB6C00F7E7FF /* WebGLCompressedTextureATC.h in Headers */,
+                               6E8ACDED23345CBC0024AAF5 /* WebGLCompressedTextureETC.h in Headers */,
+                               6E0B90692321A68D006223B2 /* WebGLCompressedTextureETC1.h in Headers */,
                                7E66E23417E6EB6C00F7E7FF /* WebGLCompressedTexturePVRTC.h in Headers */,
                                6E3FAE8F14733FDB00E42306 /* WebGLCompressedTextureS3TC.h in Headers */,
                                6E4E91AF10F7FB3100A2779C /* WebGLContextAttributes.h in Headers */,
index 900e0f7..78a4ae6 100644 (file)
@@ -45,6 +45,8 @@
 #include "JSWebGLBuffer.h"
 #include "JSWebGLCompressedTextureASTC.h"
 #include "JSWebGLCompressedTextureATC.h"
+#include "JSWebGLCompressedTextureETC.h"
+#include "JSWebGLCompressedTextureETC1.h"
 #include "JSWebGLCompressedTexturePVRTC.h"
 #include "JSWebGLCompressedTextureS3TC.h"
 #include "JSWebGLDebugRendererInfo.h"
@@ -176,6 +178,10 @@ JSValue convertToJSValue(JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject&
         return toJS(&lexicalGlobalObject, &globalObject, static_cast<WebGLDebugShaders&>(extension));
     case WebGLExtension::WebGLCompressedTextureATCName:
         return toJS(&lexicalGlobalObject, &globalObject, static_cast<WebGLCompressedTextureATC&>(extension));
+    case WebGLExtension::WebGLCompressedTextureETCName:
+        return toJS(&lexicalGlobalObject, &globalObject, static_cast<WebGLCompressedTextureETC&>(extension));
+    case WebGLExtension::WebGLCompressedTextureETC1Name:
+        return toJS(&lexicalGlobalObject, &globalObject, static_cast<WebGLCompressedTextureETC1&>(extension));
     case WebGLExtension::WebGLCompressedTexturePVRTCName:
         return toJS(&lexicalGlobalObject, &globalObject, static_cast<WebGLCompressedTexturePVRTC&>(extension));
     case WebGLExtension::WebGLCompressedTextureS3TCName:
index cd47212..4baf3aa 100644 (file)
@@ -45,6 +45,8 @@
 #include "WebGLActiveInfo.h"
 #include "WebGLCompressedTextureASTC.h"
 #include "WebGLCompressedTextureATC.h"
+#include "WebGLCompressedTextureETC.h"
+#include "WebGLCompressedTextureETC1.h"
 #include "WebGLCompressedTexturePVRTC.h"
 #include "WebGLCompressedTextureS3TC.h"
 #include "WebGLDebugRendererInfo.h"
@@ -1373,10 +1375,12 @@ WebGLExtension* WebGL2RenderingContext::getExtension(const String& name)
     ENABLE_IF_REQUESTED(OESTextureHalfFloat, m_oesTextureHalfFloat, "OES_texture_half_float", enableSupportedExtension("GL_OES_texture_half_float"_s));
     ENABLE_IF_REQUESTED(OESTextureHalfFloatLinear, m_oesTextureHalfFloatLinear, "OES_texture_half_float_linear", enableSupportedExtension("GL_OES_texture_half_float_linear"_s));
     ENABLE_IF_REQUESTED(WebGLLoseContext, m_webglLoseContext, "WEBGL_lose_context", true);
+    ENABLE_IF_REQUESTED(WebGLCompressedTextureASTC, m_webglCompressedTextureASTC, "WEBGL_compressed_texture_astc", WebGLCompressedTextureASTC::supported(*this));
     ENABLE_IF_REQUESTED(WebGLCompressedTextureATC, m_webglCompressedTextureATC, "WEBKIT_WEBGL_compressed_texture_atc", WebGLCompressedTextureATC::supported(*this));
+    ENABLE_IF_REQUESTED(WebGLCompressedTextureETC, m_webglCompressedTextureETC, "WEBGL_compressed_texture_etc", WebGLCompressedTextureETC::supported(*this));
+    ENABLE_IF_REQUESTED(WebGLCompressedTextureETC1, m_webglCompressedTextureETC1, "WEBGL_compressed_texture_etc1", WebGLCompressedTextureETC1::supported(*this));
     ENABLE_IF_REQUESTED(WebGLCompressedTexturePVRTC, m_webglCompressedTexturePVRTC, "WEBKIT_WEBGL_compressed_texture_pvrtc", WebGLCompressedTexturePVRTC::supported(*this));
     ENABLE_IF_REQUESTED(WebGLCompressedTextureS3TC, m_webglCompressedTextureS3TC, "WEBGL_compressed_texture_s3tc", WebGLCompressedTextureS3TC::supported(*this));
-    ENABLE_IF_REQUESTED(WebGLCompressedTextureASTC, m_webglCompressedTextureASTC, "WEBGL_compressed_texture_astc", WebGLCompressedTextureASTC::supported(*this));
     ENABLE_IF_REQUESTED(WebGLDepthTexture, m_webglDepthTexture, "WEBGL_depth_texture", WebGLDepthTexture::supported(*graphicsContext3D()));
     ENABLE_IF_REQUESTED(WebGLDebugRendererInfo, m_webglDebugRendererInfo, "WEBGL_debug_renderer_info", true);
     ENABLE_IF_REQUESTED(WebGLDebugShaders, m_webglDebugShaders, "WEBGL_debug_shaders", m_context->getExtensions().supports("GL_ANGLE_translated_shader_source"_s));
@@ -1404,14 +1408,18 @@ Optional<Vector<String>> WebGL2RenderingContext::getSupportedExtensions()
         result.append("OES_texture_half_float_linear"_s);
     if (extensions.supports("GL_EXT_texture_filter_anisotropic"_s))
         result.append("WEBKIT_EXT_texture_filter_anisotropic"_s);
+    if (WebGLCompressedTextureASTC::supported(*this))
+        result.append("WEBGL_compressed_texture_astc"_s);
     if (WebGLCompressedTextureATC::supported(*this))
         result.append("WEBKIT_WEBGL_compressed_texture_atc"_s);
+    if (WebGLCompressedTextureETC::supported(*this))
+        result.append("WEBGL_compressed_texture_etc"_s);
+    if (WebGLCompressedTextureETC1::supported(*this))
+        result.append("WEBGL_compressed_texture_etc1"_s);
     if (WebGLCompressedTexturePVRTC::supported(*this))
         result.append("WEBKIT_WEBGL_compressed_texture_pvrtc"_s);
     if (WebGLCompressedTextureS3TC::supported(*this))
         result.append("WEBGL_compressed_texture_s3tc"_s);
-    if (WebGLCompressedTextureASTC::supported(*this))
-        result.append("WEBGL_compressed_texture_astc"_s);
     if (WebGLDepthTexture::supported(*graphicsContext3D()))
         result.append("WEBGL_depth_texture"_s);
     result.append("WEBGL_lose_context"_s);
diff --git a/Source/WebCore/html/canvas/WebGLCompressedTextureETC.cpp b/Source/WebCore/html/canvas/WebGLCompressedTextureETC.cpp
new file mode 100644 (file)
index 0000000..f4c94a6
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEBGL)
+#include "WebGLCompressedTextureETC.h"
+
+#include "Extensions3D.h"
+#include "WebGLRenderingContextBase.h"
+
+namespace WebCore {
+
+WebGLCompressedTextureETC::WebGLCompressedTextureETC(WebGLRenderingContextBase& context)
+    : WebGLExtension(context)
+{
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_ANGLE_compressed_texture_etc");
+
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_R11_EAC);
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_SIGNED_R11_EAC);
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RG11_EAC);
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_SIGNED_RG11_EAC);
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGB8_ETC2);
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_SRGB8_ETC2);
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_RGBA8_ETC2_EAC);
+    context.addCompressedTextureFormat(Extensions3D::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
+}
+
+WebGLCompressedTextureETC::~WebGLCompressedTextureETC() = default;
+
+WebGLExtension::ExtensionName WebGLCompressedTextureETC::getName() const
+{
+    return WebGLCompressedTextureETCName;
+}
+
+bool WebGLCompressedTextureETC::supported(WebGLRenderingContextBase& context)
+{
+    return context.graphicsContext3D()->getExtensions().supports("GL_ANGLE_compressed_texture_etc");
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/html/canvas/WebGLCompressedTextureETC.h b/Source/WebCore/html/canvas/WebGLCompressedTextureETC.h
new file mode 100644 (file)
index 0000000..7a338ad
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGL)
+
+#include "WebGLExtension.h"
+
+namespace WebCore {
+
+class WebGLCompressedTextureETC final : public WebGLExtension {
+public:
+    explicit WebGLCompressedTextureETC(WebGLRenderingContextBase&);
+    virtual ~WebGLCompressedTextureETC();
+
+    static bool supported(WebGLRenderingContextBase&);
+    ExtensionName getName() const override;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/html/canvas/WebGLCompressedTextureETC.idl b/Source/WebCore/html/canvas/WebGLCompressedTextureETC.idl
new file mode 100644 (file)
index 0000000..1953faa
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc/
+
+[
+    Conditional=WEBGL,
+    DoNotCheckConstants,
+    GenerateIsReachable=ImplWebGLRenderingContext,
+    NoInterfaceObject,
+] interface WebGLCompressedTextureETC {
+    /* Compressed Texture Format */
+    const unsigned long COMPRESSED_R11_EAC                        = 0x9270;
+    const unsigned long COMPRESSED_SIGNED_R11_EAC                 = 0x9271;
+    const unsigned long COMPRESSED_RG11_EAC                       = 0x9272;
+    const unsigned long COMPRESSED_SIGNED_RG11_EAC                = 0x9273;
+    const unsigned long COMPRESSED_RGB8_ETC2                      = 0x9274;
+    const unsigned long COMPRESSED_SRGB8_ETC2                     = 0x9275;
+    const unsigned long COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2  = 0x9276;
+    const unsigned long COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277;
+    const unsigned long COMPRESSED_RGBA8_ETC2_EAC                 = 0x9278;
+    const unsigned long COMPRESSED_SRGB8_ALPHA8_ETC2_EAC          = 0x9279;
+};
diff --git a/Source/WebCore/html/canvas/WebGLCompressedTextureETC1.cpp b/Source/WebCore/html/canvas/WebGLCompressedTextureETC1.cpp
new file mode 100644 (file)
index 0000000..bdc3bee
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(WEBGL)
+#include "WebGLCompressedTextureETC1.h"
+
+#include "Extensions3D.h"
+#include "WebGLRenderingContextBase.h"
+
+namespace WebCore {
+
+WebGLCompressedTextureETC1::WebGLCompressedTextureETC1(WebGLRenderingContextBase& context)
+    : WebGLExtension(context)
+{
+    context.graphicsContext3D()->getExtensions().ensureEnabled("GL_OES_compressed_ETC1_RGB8_texture");
+
+    context.addCompressedTextureFormat(Extensions3D::ETC1_RGB8_OES);
+}
+
+WebGLCompressedTextureETC1::~WebGLCompressedTextureETC1() = default;
+
+WebGLExtension::ExtensionName WebGLCompressedTextureETC1::getName() const
+{
+    return WebGLCompressedTextureETC1Name;
+}
+
+bool WebGLCompressedTextureETC1::supported(WebGLRenderingContextBase& context)
+{
+    return context.graphicsContext3D()->getExtensions().supports("GL_OES_compressed_ETC1_RGB8_texture");
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/html/canvas/WebGLCompressedTextureETC1.h b/Source/WebCore/html/canvas/WebGLCompressedTextureETC1.h
new file mode 100644 (file)
index 0000000..0f76a48
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGL)
+
+#include "WebGLExtension.h"
+
+namespace WebCore {
+
+class WebGLCompressedTextureETC1 final : public WebGLExtension {
+public:
+    explicit WebGLCompressedTextureETC1(WebGLRenderingContextBase&);
+    virtual ~WebGLCompressedTextureETC1();
+
+    static bool supported(WebGLRenderingContextBase&);
+    ExtensionName getName() const override;
+};
+
+} // namespace WebCore
+
+#endif
diff --git a/Source/WebCore/html/canvas/WebGLCompressedTextureETC1.idl b/Source/WebCore/html/canvas/WebGLCompressedTextureETC1.idl
new file mode 100644 (file)
index 0000000..f3c3c65
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2019 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/
+
+[
+    Conditional=WEBGL,
+    DoNotCheckConstants,
+    GenerateIsReachable=ImplWebGLRenderingContext,
+    NoInterfaceObject,
+] interface WebGLCompressedTextureETC1 {
+    /* Compressed Texture Formats */
+    const unsigned long COMPRESSED_RGB_ETC1_WEBGL = 0x8D64;
+};
index 2a1a34c..02a1e81 100644 (file)
@@ -55,6 +55,8 @@ public:
         WebGLDrawBuffersName,
         OESElementIndexUintName,
         WebGLCompressedTextureATCName,
+        WebGLCompressedTextureETCName,
+        WebGLCompressedTextureETC1Name,
         WebGLCompressedTexturePVRTCName,
         WebGLCompressedTextureASTCName,
         ANGLEInstancedArraysName,
index e5fde70..befa80a 100644 (file)
@@ -51,6 +51,8 @@
 #include "RenderBox.h"
 #include "WebGLCompressedTextureASTC.h"
 #include "WebGLCompressedTextureATC.h"
+#include "WebGLCompressedTextureETC.h"
+#include "WebGLCompressedTextureETC1.h"
 #include "WebGLCompressedTexturePVRTC.h"
 #include "WebGLCompressedTextureS3TC.h"
 #include "WebGLDebugRendererInfo.h"
@@ -148,10 +150,12 @@ WebGLExtension* WebGLRenderingContext::getExtension(const String& name)
     ENABLE_IF_REQUESTED(OESVertexArrayObject, m_oesVertexArrayObject, "OES_vertex_array_object", enableSupportedExtension("GL_OES_vertex_array_object"_s));
     ENABLE_IF_REQUESTED(OESElementIndexUint, m_oesElementIndexUint, "OES_element_index_uint", enableSupportedExtension("GL_OES_element_index_uint"_s));
     ENABLE_IF_REQUESTED(WebGLLoseContext, m_webglLoseContext, "WEBGL_lose_context", true);
+    ENABLE_IF_REQUESTED(WebGLCompressedTextureASTC, m_webglCompressedTextureASTC, "WEBGL_compressed_texture_astc", WebGLCompressedTextureASTC::supported(*this));
     ENABLE_IF_REQUESTED(WebGLCompressedTextureATC, m_webglCompressedTextureATC, "WEBKIT_WEBGL_compressed_texture_atc", WebGLCompressedTextureATC::supported(*this));
+    ENABLE_IF_REQUESTED(WebGLCompressedTextureETC, m_webglCompressedTextureETC, "WEBGL_compressed_texture_etc", WebGLCompressedTextureETC::supported(*this));
+    ENABLE_IF_REQUESTED(WebGLCompressedTextureETC1, m_webglCompressedTextureETC1, "WEBGL_compressed_texture_etc1", WebGLCompressedTextureETC1::supported(*this));
     ENABLE_IF_REQUESTED(WebGLCompressedTexturePVRTC, m_webglCompressedTexturePVRTC, "WEBKIT_WEBGL_compressed_texture_pvrtc", WebGLCompressedTexturePVRTC::supported(*this));
     ENABLE_IF_REQUESTED(WebGLCompressedTextureS3TC, m_webglCompressedTextureS3TC, "WEBGL_compressed_texture_s3tc", WebGLCompressedTextureS3TC::supported(*this));
-    ENABLE_IF_REQUESTED(WebGLCompressedTextureASTC, m_webglCompressedTextureASTC, "WEBGL_compressed_texture_astc", WebGLCompressedTextureASTC::supported(*this));
     ENABLE_IF_REQUESTED(WebGLDepthTexture, m_webglDepthTexture, "WEBGL_depth_texture", WebGLDepthTexture::supported(*m_context));
     if (equalIgnoringASCIICase(name, "WEBGL_draw_buffers")) {
         if (!m_webglDrawBuffers) {
@@ -217,14 +221,18 @@ Optional<Vector<String>> WebGLRenderingContext::getSupportedExtensions()
     if (m_context->getExtensions().supports("GL_OES_element_index_uint"_s))
         result.append("OES_element_index_uint"_s);
     result.append("WEBGL_lose_context"_s);
+    if (WebGLCompressedTextureASTC::supported(*this))
+        result.append("WEBGL_compressed_texture_astc"_s);
     if (WebGLCompressedTextureATC::supported(*this))
         result.append("WEBKIT_WEBGL_compressed_texture_atc"_s);
+    if (WebGLCompressedTextureETC::supported(*this))
+        result.append("WEBGL_compressed_texture_etc"_s);
+    if (WebGLCompressedTextureETC1::supported(*this))
+        result.append("WEBGL_compressed_texture_etc1"_s);
     if (WebGLCompressedTexturePVRTC::supported(*this))
         result.append("WEBKIT_WEBGL_compressed_texture_pvrtc"_s);
     if (WebGLCompressedTextureS3TC::supported(*this))
         result.append("WEBGL_compressed_texture_s3tc"_s);
-    if (WebGLCompressedTextureASTC::supported(*this))
-        result.append("WEBGL_compressed_texture_astc"_s);
     if (WebGLDepthTexture::supported(*m_context))
         result.append("WEBGL_depth_texture"_s);
     if (supportsDrawBuffers())
index 14a7095..211c6da 100644 (file)
@@ -3091,7 +3091,10 @@ bool WebGLRenderingContextBase::extensionIsEnabled(const String& name)
     CHECK_EXTENSION(m_webglLoseContext, "WEBGL_lose_context");
     CHECK_EXTENSION(m_webglDebugRendererInfo, "WEBGL_debug_renderer_info");
     CHECK_EXTENSION(m_webglDebugShaders, "WEBGL_debug_shaders");
+    CHECK_EXTENSION(m_webglCompressedTextureASTC, "WEBKIT_WEBGL_compressed_texture_astc");
     CHECK_EXTENSION(m_webglCompressedTextureATC, "WEBKIT_WEBGL_compressed_texture_atc");
+    CHECK_EXTENSION(m_webglCompressedTextureETC, "WEBKIT_WEBGL_compressed_texture_etc");
+    CHECK_EXTENSION(m_webglCompressedTextureETC1, "WEBKIT_WEBGL_compressed_texture_etc1");
     CHECK_EXTENSION(m_webglCompressedTexturePVRTC, "WEBKIT_WEBGL_compressed_texture_pvrtc");
     CHECK_EXTENSION(m_webglCompressedTextureS3TC, "WEBGL_compressed_texture_s3tc");
     CHECK_EXTENSION(m_webglDepthTexture, "WEBGL_depth_texture");
@@ -5562,19 +5565,21 @@ bool WebGLRenderingContextBase::validateCompressedTexFuncData(const char* functi
     const GC3Denum ASTCEnumStartRGBA = Extensions3D::COMPRESSED_RGBA_ASTC_4x4_KHR;
     const GC3Denum ASTCEnumStartSRGB8 = Extensions3D::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
 
+    const int kEACAndETC2BlockSize = 4;
+
     switch (format) {
     case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT:
     case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT:
     case Extensions3D::COMPRESSED_ATC_RGB_AMD:
-        {
-            const int kBlockSize = 8;
-            const int kBlockWidth = 4;
-            const int kBlockHeight = 4;
-            int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
-            int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
-            bytesRequired = numBlocksAcross * numBlocksDown * kBlockSize;
-        }
+    case Extensions3D::ETC1_RGB8_OES: {
+        const int kBlockSize = 8;
+        const int kBlockWidth = 4;
+        const int kBlockHeight = 4;
+        int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
+        int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
+        bytesRequired = numBlocksAcross * numBlocksDown * kBlockSize;
         break;
+    }
     case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT:
     case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT:
     case Extensions3D::COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD:
@@ -5638,6 +5643,36 @@ bool WebGLRenderingContextBase::validateCompressedTexFuncData(const char* functi
     case Extensions3D::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
         bytesRequired = calculateBytesForASTC(width, height, ASTCParameters[format - ASTCEnumStartSRGB8]);
         break;
+    case Extensions3D::COMPRESSED_R11_EAC:
+    case Extensions3D::COMPRESSED_SIGNED_R11_EAC:
+    case Extensions3D::COMPRESSED_RGB8_ETC2:
+    case Extensions3D::COMPRESSED_SRGB8_ETC2:
+    case Extensions3D::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+    case Extensions3D::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: {
+        Checked<unsigned, RecordOverflow> checkedBytesRequired = (width + kEACAndETC2BlockSize - 1) / kEACAndETC2BlockSize;
+        checkedBytesRequired *= (height + kEACAndETC2BlockSize - 1) / kEACAndETC2BlockSize;
+        checkedBytesRequired *= 8;
+        if (checkedBytesRequired.hasOverflowed()) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "too large dimensions");
+            return false;
+        }
+        bytesRequired = checkedBytesRequired.unsafeGet();
+        break;
+    }
+    case Extensions3D::COMPRESSED_RG11_EAC:
+    case Extensions3D::COMPRESSED_SIGNED_RG11_EAC:
+    case Extensions3D::COMPRESSED_RGBA8_ETC2_EAC:
+    case Extensions3D::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: {
+        Checked<unsigned, RecordOverflow> checkedBytesRequired = (width + kEACAndETC2BlockSize - 1) / kEACAndETC2BlockSize;
+        checkedBytesRequired *= (height + kEACAndETC2BlockSize - 1) / kEACAndETC2BlockSize;
+        checkedBytesRequired *= 16;
+        if (checkedBytesRequired.hasOverflowed()) {
+            synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "too large dimensions");
+            return false;
+        }
+        bytesRequired = checkedBytesRequired.unsafeGet();
+        break;
+    }
     default:
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid format");
         return false;
@@ -5708,7 +5743,18 @@ bool WebGLRenderingContextBase::validateCompressedTexDimensions(const char* func
     case Extensions3D::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
     case Extensions3D::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
     case Extensions3D::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
-        // No height and width restrictions on ASTC.
+    case Extensions3D::ETC1_RGB8_OES:
+    case Extensions3D::COMPRESSED_R11_EAC:
+    case Extensions3D::COMPRESSED_SIGNED_R11_EAC:
+    case Extensions3D::COMPRESSED_RG11_EAC:
+    case Extensions3D::COMPRESSED_SIGNED_RG11_EAC:
+    case Extensions3D::COMPRESSED_RGB8_ETC2:
+    case Extensions3D::COMPRESSED_SRGB8_ETC2:
+    case Extensions3D::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+    case Extensions3D::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+    case Extensions3D::COMPRESSED_RGBA8_ETC2_EAC:
+    case Extensions3D::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+        // No height and width restrictions on ASTC, ETC1 or ETC2.
         return true;
     default:
         return false;
@@ -5756,6 +5802,34 @@ bool WebGLRenderingContextBase::validateCompressedTexSubDimensions(const char* f
         }
         return validateCompressedTexDimensions(functionName, target, level, width, height, format);
     }
+    case Extensions3D::ETC1_RGB8_OES:
+        // Not supported for ETC1_RGB8_OES textures.
+        return false;
+    case Extensions3D::COMPRESSED_R11_EAC:
+    case Extensions3D::COMPRESSED_SIGNED_R11_EAC:
+    case Extensions3D::COMPRESSED_RG11_EAC:
+    case Extensions3D::COMPRESSED_SIGNED_RG11_EAC:
+    case Extensions3D::COMPRESSED_RGB8_ETC2:
+    case Extensions3D::COMPRESSED_SRGB8_ETC2:
+    case Extensions3D::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+    case Extensions3D::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+    case Extensions3D::COMPRESSED_RGBA8_ETC2_EAC:
+    case Extensions3D::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: {
+        if (target == GraphicsContext3D::TEXTURE_3D) {
+            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "not supported on TEXTURE_3D textures");
+            return false;
+        }
+        const int kBlockSize = 4;
+        int texWidth = tex->getWidth(target, level);
+        int texHeight = tex->getHeight(target, level);
+        if ((xoffset % kBlockSize) || (yoffset % kBlockSize)
+            || ((width % kBlockSize) && xoffset + width != texWidth)
+            || ((height % kBlockSize) && yoffset + height != texHeight)) {
+            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "dimensions must match existing texture level dimensions");
+            return false;
+        }
+        return true;
+    }
     default:
         return false;
     }
index 4b5eedc..59a0c07 100644 (file)
@@ -77,6 +77,8 @@ class WebGLContextGroup;
 class WebGLContextObject;
 class WebGLCompressedTextureASTC;
 class WebGLCompressedTextureATC;
+class WebGLCompressedTextureETC;
+class WebGLCompressedTextureETC1;
 class WebGLCompressedTexturePVRTC;
 class WebGLCompressedTextureS3TC;
 class WebGLDebugRendererInfo;
@@ -385,6 +387,8 @@ protected:
     friend class WebGLDebugShaders;
     friend class WebGLCompressedTextureASTC;
     friend class WebGLCompressedTextureATC;
+    friend class WebGLCompressedTextureETC;
+    friend class WebGLCompressedTextureETC1;
     friend class WebGLCompressedTexturePVRTC;
     friend class WebGLCompressedTextureS3TC;
     friend class WebGLRenderingContextErrorMessageCallback;
@@ -613,6 +617,8 @@ protected:
     std::unique_ptr<WebGLDebugShaders> m_webglDebugShaders;
     std::unique_ptr<WebGLCompressedTextureASTC> m_webglCompressedTextureASTC;
     std::unique_ptr<WebGLCompressedTextureATC> m_webglCompressedTextureATC;
+    std::unique_ptr<WebGLCompressedTextureETC> m_webglCompressedTextureETC;
+    std::unique_ptr<WebGLCompressedTextureETC1> m_webglCompressedTextureETC1;
     std::unique_ptr<WebGLCompressedTexturePVRTC> m_webglCompressedTexturePVRTC;
     std::unique_ptr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC;
     std::unique_ptr<WebGLDepthTexture> m_webglDepthTexture;
index 06ca5e2..78f2a03 100644 (file)
@@ -158,6 +158,18 @@ public:
         // GL_OES_compressed_ETC1_RGB8_texture
         ETC1_RGB8_OES = 0x8D64,
 
+        // WEBGL_compressed_texture_etc
+        COMPRESSED_R11_EAC = 0x9270,
+        COMPRESSED_SIGNED_R11_EAC = 0x9271,
+        COMPRESSED_RG11_EAC = 0x9272,
+        COMPRESSED_SIGNED_RG11_EAC = 0x9273,
+        COMPRESSED_RGB8_ETC2 = 0x9274,
+        COMPRESSED_SRGB8_ETC2 = 0x9275,
+        COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276,
+        COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277,
+        COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
+        COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
+
         // GL_IMG_texture_compression_pvrtc
         COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00,
         COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01,
index 7f61ef6..1d8bc3e 100644 (file)
@@ -243,7 +243,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         attribs.append(static_cast<CGLPixelFormatAttribute>(4));
     }
 
-    if (attrs.isWebGL2) {
+    if (m_attrs.isWebGL2) {
         // FIXME: Instead of backing a WebGL2 GraphicsContext3D with a OpenGL 4 context, we should instead back it with ANGLE.
         // Use an OpenGL 4 context for now until the ANGLE backend is ready.
         attribs.append(kCGLPFAOpenGLProfile);
@@ -278,7 +278,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
         return;
     }
 
-    m_isForWebGL2 = attrs.isWebGL2;
+    m_isForWebGL2 = m_attrs.isWebGL2;
 
     CGLSetCurrentContext(m_contextObj);
 
@@ -326,7 +326,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attrs, HostWind
     }
 
     std::vector<EGLint> contextAttributes;
-    if (attrs.isWebGL2) {
+    if (m_attrs.isWebGL2) {
         contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
         contextAttributes.push_back(3);
     } else {
index 13119ff..61c0c6e 100644 (file)
@@ -227,9 +227,15 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
 #endif
     }
 
-#if PLATFORM(IOS_FAMILY)
+#if PLATFORM(IOS_FAMILY) || PLATFORM(IOS_FAMILY_SIMULATOR)
     if (name == "GL_EXT_packed_depth_stencil")
         return m_availableExtensions.contains("GL_OES_packed_depth_stencil");
+
+    if (name == "GL_OES_compressed_ETC1_RGB8_texture"
+        || name == "GL_ANGLE_compressed_texture_etc") {
+        // Implicitly enabled with ES 3.0 contexts.
+        return m_context->m_isForWebGL2;
+    }
 #endif
 
     return m_availableExtensions.contains(name);