haikuwebkit/Source/WebCore/html/canvas/WebGLCompressedTextureS3TCs...

67 lines
2.7 KiB
C++
Raw Permalink Normal View History

Implement WEBGL_compressed_texture_s3tc_srgb extension https://bugs.webkit.org/show_bug.cgi?id=215973 Patch by James Darpinian <jdarpinian@chromium.org> on 2020-08-31 Reviewed by Dean Jackson. Source/ThirdParty/ANGLE: * src/libANGLE/renderer/gl/formatutilsgl.cpp: (rx::nativegl::ExtAndVersionOrExt): (rx::nativegl::BuildInternalFormatInfoMap): Source/WebCore: Tested by webgl/2.0.0/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html * CMakeLists.txt: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSDOMConvertWebGL.cpp: (WebCore::convertToJSValue): * html/canvas/WebGLCompressedTextureS3TCsRGB.cpp: Added. (WebCore::WebGLCompressedTextureS3TCsRGB::WebGLCompressedTextureS3TCsRGB): (WebCore::WebGLCompressedTextureS3TCsRGB::getName const): (WebCore::WebGLCompressedTextureS3TCsRGB::supported): * html/canvas/WebGLCompressedTextureS3TCsRGB.h: Added. * html/canvas/WebGLCompressedTextureS3TCsRGB.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/ExtensionsGL.h: Canonical link: https://commits.webkit.org/228800@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266364 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 18:59:08 +00:00
/*
* Copyright (C) 2020 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 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 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 "WebGLCompressedTextureS3TCsRGB.h"
#include "ExtensionsGL.h"
#include "WebGLRenderingContextBase.h"
CrashTracer: com.apple.WebKit.WebContent at WebCore: WebCore::WebGLRenderingContext::getExtension https://bugs.webkit.org/show_bug.cgi?id=216337 <rdar://problem/68421590> Reviewed by Sam Weinig. Bug 215599 added IsoHeap storage to WebGLExtension, but didn't add it to any of the subclasses. This causes a crash in ::getExtension because allocation of the new instance fails. Add WTF_MAKE_ISO_ALLOCATED_IMPL to the .cpp files, and WTF_MAKE_ISO_ALLOCATED to the .h files. This should have been detected by on-device testing, since a debug build would have asserted because the size passed into the constructor was different from the actual size of the class. * html/canvas/ANGLEInstancedArrays.cpp: * html/canvas/ANGLEInstancedArrays.h: * html/canvas/EXTBlendMinMax.cpp: * html/canvas/EXTBlendMinMax.h: * html/canvas/EXTColorBufferFloat.cpp: * html/canvas/EXTColorBufferFloat.h: * html/canvas/EXTColorBufferHalfFloat.cpp: * html/canvas/EXTColorBufferHalfFloat.h: * html/canvas/EXTFragDepth.cpp: * html/canvas/EXTFragDepth.h: * html/canvas/EXTShaderTextureLOD.cpp: * html/canvas/EXTShaderTextureLOD.h: * html/canvas/EXTTextureFilterAnisotropic.cpp: * html/canvas/EXTTextureFilterAnisotropic.h: * html/canvas/EXTsRGB.cpp: * html/canvas/EXTsRGB.h: * html/canvas/OESElementIndexUint.cpp: * html/canvas/OESElementIndexUint.h: * html/canvas/OESStandardDerivatives.cpp: * html/canvas/OESStandardDerivatives.h: * html/canvas/OESTextureFloat.cpp: * html/canvas/OESTextureFloat.h: * html/canvas/OESTextureFloatLinear.cpp: * html/canvas/OESTextureFloatLinear.h: * html/canvas/OESTextureHalfFloat.cpp: * html/canvas/OESTextureHalfFloat.h: * html/canvas/OESTextureHalfFloatLinear.cpp: * html/canvas/OESTextureHalfFloatLinear.h: * html/canvas/OESVertexArrayObject.cpp: * html/canvas/OESVertexArrayObject.h: * html/canvas/WebGLColorBufferFloat.cpp: * html/canvas/WebGLColorBufferFloat.h: * html/canvas/WebGLCompressedTextureASTC.cpp: * html/canvas/WebGLCompressedTextureASTC.h: * html/canvas/WebGLCompressedTextureATC.cpp: * html/canvas/WebGLCompressedTextureATC.h: * html/canvas/WebGLCompressedTextureETC.cpp: * html/canvas/WebGLCompressedTextureETC.h: * html/canvas/WebGLCompressedTextureETC1.cpp: * html/canvas/WebGLCompressedTextureETC1.h: * html/canvas/WebGLCompressedTexturePVRTC.cpp: * html/canvas/WebGLCompressedTexturePVRTC.h: * html/canvas/WebGLCompressedTextureS3TC.cpp: * html/canvas/WebGLCompressedTextureS3TC.h: * html/canvas/WebGLCompressedTextureS3TCsRGB.cpp: * html/canvas/WebGLCompressedTextureS3TCsRGB.h: * html/canvas/WebGLDebugRendererInfo.cpp: * html/canvas/WebGLDebugRendererInfo.h: * html/canvas/WebGLDebugShaders.cpp: * html/canvas/WebGLDebugShaders.h: * html/canvas/WebGLDepthTexture.cpp: * html/canvas/WebGLDepthTexture.h: * html/canvas/WebGLDrawBuffers.cpp: * html/canvas/WebGLDrawBuffers.h: * html/canvas/WebGLLoseContext.cpp: * html/canvas/WebGLLoseContext.h: Canonical link: https://commits.webkit.org/229169@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 02:47:05 +00:00
#include <wtf/IsoMallocInlines.h>
Implement WEBGL_compressed_texture_s3tc_srgb extension https://bugs.webkit.org/show_bug.cgi?id=215973 Patch by James Darpinian <jdarpinian@chromium.org> on 2020-08-31 Reviewed by Dean Jackson. Source/ThirdParty/ANGLE: * src/libANGLE/renderer/gl/formatutilsgl.cpp: (rx::nativegl::ExtAndVersionOrExt): (rx::nativegl::BuildInternalFormatInfoMap): Source/WebCore: Tested by webgl/2.0.0/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html * CMakeLists.txt: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSDOMConvertWebGL.cpp: (WebCore::convertToJSValue): * html/canvas/WebGLCompressedTextureS3TCsRGB.cpp: Added. (WebCore::WebGLCompressedTextureS3TCsRGB::WebGLCompressedTextureS3TCsRGB): (WebCore::WebGLCompressedTextureS3TCsRGB::getName const): (WebCore::WebGLCompressedTextureS3TCsRGB::supported): * html/canvas/WebGLCompressedTextureS3TCsRGB.h: Added. * html/canvas/WebGLCompressedTextureS3TCsRGB.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/ExtensionsGL.h: Canonical link: https://commits.webkit.org/228800@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266364 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 18:59:08 +00:00
namespace WebCore {
CrashTracer: com.apple.WebKit.WebContent at WebCore: WebCore::WebGLRenderingContext::getExtension https://bugs.webkit.org/show_bug.cgi?id=216337 <rdar://problem/68421590> Reviewed by Sam Weinig. Bug 215599 added IsoHeap storage to WebGLExtension, but didn't add it to any of the subclasses. This causes a crash in ::getExtension because allocation of the new instance fails. Add WTF_MAKE_ISO_ALLOCATED_IMPL to the .cpp files, and WTF_MAKE_ISO_ALLOCATED to the .h files. This should have been detected by on-device testing, since a debug build would have asserted because the size passed into the constructor was different from the actual size of the class. * html/canvas/ANGLEInstancedArrays.cpp: * html/canvas/ANGLEInstancedArrays.h: * html/canvas/EXTBlendMinMax.cpp: * html/canvas/EXTBlendMinMax.h: * html/canvas/EXTColorBufferFloat.cpp: * html/canvas/EXTColorBufferFloat.h: * html/canvas/EXTColorBufferHalfFloat.cpp: * html/canvas/EXTColorBufferHalfFloat.h: * html/canvas/EXTFragDepth.cpp: * html/canvas/EXTFragDepth.h: * html/canvas/EXTShaderTextureLOD.cpp: * html/canvas/EXTShaderTextureLOD.h: * html/canvas/EXTTextureFilterAnisotropic.cpp: * html/canvas/EXTTextureFilterAnisotropic.h: * html/canvas/EXTsRGB.cpp: * html/canvas/EXTsRGB.h: * html/canvas/OESElementIndexUint.cpp: * html/canvas/OESElementIndexUint.h: * html/canvas/OESStandardDerivatives.cpp: * html/canvas/OESStandardDerivatives.h: * html/canvas/OESTextureFloat.cpp: * html/canvas/OESTextureFloat.h: * html/canvas/OESTextureFloatLinear.cpp: * html/canvas/OESTextureFloatLinear.h: * html/canvas/OESTextureHalfFloat.cpp: * html/canvas/OESTextureHalfFloat.h: * html/canvas/OESTextureHalfFloatLinear.cpp: * html/canvas/OESTextureHalfFloatLinear.h: * html/canvas/OESVertexArrayObject.cpp: * html/canvas/OESVertexArrayObject.h: * html/canvas/WebGLColorBufferFloat.cpp: * html/canvas/WebGLColorBufferFloat.h: * html/canvas/WebGLCompressedTextureASTC.cpp: * html/canvas/WebGLCompressedTextureASTC.h: * html/canvas/WebGLCompressedTextureATC.cpp: * html/canvas/WebGLCompressedTextureATC.h: * html/canvas/WebGLCompressedTextureETC.cpp: * html/canvas/WebGLCompressedTextureETC.h: * html/canvas/WebGLCompressedTextureETC1.cpp: * html/canvas/WebGLCompressedTextureETC1.h: * html/canvas/WebGLCompressedTexturePVRTC.cpp: * html/canvas/WebGLCompressedTexturePVRTC.h: * html/canvas/WebGLCompressedTextureS3TC.cpp: * html/canvas/WebGLCompressedTextureS3TC.h: * html/canvas/WebGLCompressedTextureS3TCsRGB.cpp: * html/canvas/WebGLCompressedTextureS3TCsRGB.h: * html/canvas/WebGLDebugRendererInfo.cpp: * html/canvas/WebGLDebugRendererInfo.h: * html/canvas/WebGLDebugShaders.cpp: * html/canvas/WebGLDebugShaders.h: * html/canvas/WebGLDepthTexture.cpp: * html/canvas/WebGLDepthTexture.h: * html/canvas/WebGLDrawBuffers.cpp: * html/canvas/WebGLDrawBuffers.h: * html/canvas/WebGLLoseContext.cpp: * html/canvas/WebGLLoseContext.h: Canonical link: https://commits.webkit.org/229169@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 02:47:05 +00:00
WTF_MAKE_ISO_ALLOCATED_IMPL(WebGLCompressedTextureS3TCsRGB);
Implement WEBGL_compressed_texture_s3tc_srgb extension https://bugs.webkit.org/show_bug.cgi?id=215973 Patch by James Darpinian <jdarpinian@chromium.org> on 2020-08-31 Reviewed by Dean Jackson. Source/ThirdParty/ANGLE: * src/libANGLE/renderer/gl/formatutilsgl.cpp: (rx::nativegl::ExtAndVersionOrExt): (rx::nativegl::BuildInternalFormatInfoMap): Source/WebCore: Tested by webgl/2.0.0/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html * CMakeLists.txt: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSDOMConvertWebGL.cpp: (WebCore::convertToJSValue): * html/canvas/WebGLCompressedTextureS3TCsRGB.cpp: Added. (WebCore::WebGLCompressedTextureS3TCsRGB::WebGLCompressedTextureS3TCsRGB): (WebCore::WebGLCompressedTextureS3TCsRGB::getName const): (WebCore::WebGLCompressedTextureS3TCsRGB::supported): * html/canvas/WebGLCompressedTextureS3TCsRGB.h: Added. * html/canvas/WebGLCompressedTextureS3TCsRGB.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/ExtensionsGL.h: Canonical link: https://commits.webkit.org/228800@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266364 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-08-31 18:59:08 +00:00
WebGLCompressedTextureS3TCsRGB::WebGLCompressedTextureS3TCsRGB(WebGLRenderingContextBase& context)
: WebGLExtension(context)
{
auto& extensions = context.graphicsContextGL()->getExtensions();
extensions.ensureEnabled("GL_EXT_texture_compression_s3tc_srgb");
context.addCompressedTextureFormat(ExtensionsGL::COMPRESSED_SRGB_S3TC_DXT1_EXT);
context.addCompressedTextureFormat(ExtensionsGL::COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT);
context.addCompressedTextureFormat(ExtensionsGL::COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT);
context.addCompressedTextureFormat(ExtensionsGL::COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT);
}
WebGLCompressedTextureS3TCsRGB::~WebGLCompressedTextureS3TCsRGB() = default;
WebGLExtension::ExtensionName WebGLCompressedTextureS3TCsRGB::getName() const
{
return WebGLCompressedTextureS3TCsRGBName;
}
bool WebGLCompressedTextureS3TCsRGB::supported(WebGLRenderingContextBase& context)
{
auto& extensions = context.graphicsContextGL()->getExtensions();
return extensions.supports("GL_EXT_texture_compression_s3tc_srgb");
}
} // namespace WebCore
#endif // ENABLE(WEBGL)