2013-08-27 01:12:53 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "WebGLContext.h"
|
|
|
|
#include "WebGLContextUtils.h"
|
|
|
|
#include "WebGLExtensions.h"
|
2015-10-12 06:21:03 +03:00
|
|
|
#include "gfxPrefs.h"
|
2013-08-27 01:12:53 +04:00
|
|
|
#include "GLContext.h"
|
|
|
|
|
2013-08-27 01:12:53 +04:00
|
|
|
#include "nsString.h"
|
2017-07-18 21:41:00 +03:00
|
|
|
#include "nsContentUtils.h"
|
2013-09-07 06:13:37 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2016-11-16 22:10:22 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-08-27 01:12:53 +04:00
|
|
|
#include "AccessCheck.h"
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
namespace mozilla {
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
/*static*/ const char* WebGLContext::GetExtensionString(WebGLExtensionID ext) {
|
|
|
|
typedef EnumeratedArray<WebGLExtensionID, WebGLExtensionID::Max, const char*>
|
|
|
|
names_array_t;
|
2014-05-31 00:21:23 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
static names_array_t sExtensionNamesEnumeratedArray;
|
|
|
|
static bool initialized = false;
|
2014-05-31 00:21:23 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
if (!initialized) {
|
|
|
|
initialized = true;
|
2014-05-31 00:21:23 +04:00
|
|
|
|
|
|
|
#define WEBGL_EXTENSION_IDENTIFIER(x) \
|
2018-11-30 13:46:48 +03:00
|
|
|
sExtensionNamesEnumeratedArray[WebGLExtensionID::x] = #x;
|
|
|
|
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(ANGLE_instanced_arrays)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_blend_minmax)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_color_buffer_float)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_color_buffer_half_float)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_frag_depth)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_shader_texture_lod)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_sRGB)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_texture_compression_bptc)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_texture_compression_rgtc)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_texture_filter_anisotropic)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(EXT_disjoint_timer_query)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(MOZ_debug)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_element_index_uint)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_standard_derivatives)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_texture_float)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_texture_float_linear)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_texture_half_float)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_texture_half_float_linear)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(OES_vertex_array_object)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_color_buffer_float)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_astc)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_etc)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_etc1)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_pvrtc)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_s3tc)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_compressed_texture_s3tc_srgb)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_debug_renderer_info)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_debug_shaders)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_depth_texture)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_draw_buffers)
|
|
|
|
WEBGL_EXTENSION_IDENTIFIER(WEBGL_lose_context)
|
2014-05-31 00:21:23 +04:00
|
|
|
|
|
|
|
#undef WEBGL_EXTENSION_IDENTIFIER
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2014-04-26 06:34:07 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
return sExtensionNamesEnumeratedArray[ext];
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
bool WebGLContext::IsExtensionEnabled(WebGLExtensionID ext) const {
|
|
|
|
return mExtensions[ext];
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2016-11-16 22:10:22 +03:00
|
|
|
bool WebGLContext::IsExtensionSupported(dom::CallerType callerType,
|
2018-11-30 13:46:48 +03:00
|
|
|
WebGLExtensionID ext) const {
|
|
|
|
bool allowPrivilegedExts = false;
|
2014-02-12 02:37:05 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
// Chrome contexts need access to debug information even when
|
|
|
|
// webgl.disable-extensions is set. This is used in the graphics
|
|
|
|
// section of about:support
|
|
|
|
if (callerType == dom::CallerType::System) {
|
|
|
|
allowPrivilegedExts = true;
|
|
|
|
}
|
2014-02-12 02:37:05 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
if (gfxPrefs::WebGLPrivilegedExtensionsEnabled()) {
|
|
|
|
allowPrivilegedExts = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (allowPrivilegedExts) {
|
|
|
|
switch (ext) {
|
|
|
|
case WebGLExtensionID::EXT_disjoint_timer_query:
|
|
|
|
return WebGLExtensionDisjointTimerQuery::IsSupported(this);
|
|
|
|
case WebGLExtensionID::MOZ_debug:
|
|
|
|
return true;
|
|
|
|
case WebGLExtensionID::WEBGL_debug_renderer_info:
|
|
|
|
return true;
|
|
|
|
case WebGLExtensionID::WEBGL_debug_shaders:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
// For warnings-as-errors.
|
|
|
|
break;
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
return IsExtensionSupported(ext);
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const {
|
|
|
|
if (mDisableExtensions) return false;
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
// Extensions for both WebGL 1 and 2.
|
|
|
|
switch (ext) {
|
2015-11-25 07:15:29 +03:00
|
|
|
// In alphabetical order
|
2015-01-08 03:28:05 +03:00
|
|
|
// EXT_
|
2018-09-28 02:37:40 +03:00
|
|
|
case WebGLExtensionID::EXT_texture_compression_bptc:
|
2018-11-30 13:46:48 +03:00
|
|
|
return WebGLExtensionCompressedTextureBPTC::IsSupported(this);
|
2018-09-28 02:37:40 +03:00
|
|
|
|
|
|
|
case WebGLExtensionID::EXT_texture_compression_rgtc:
|
2018-11-30 13:46:48 +03:00
|
|
|
return WebGLExtensionCompressedTextureRGTC::IsSupported(this);
|
2018-09-28 02:37:40 +03:00
|
|
|
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_texture_filter_anisotropic:
|
2018-11-30 13:46:48 +03:00
|
|
|
return gl->IsExtensionSupported(
|
|
|
|
gl::GLContext::EXT_texture_filter_anisotropic);
|
2015-01-08 03:28:05 +03:00
|
|
|
|
|
|
|
// OES_
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::OES_texture_float_linear:
|
2018-11-30 13:46:48 +03:00
|
|
|
return gl->IsSupported(gl::GLFeature::texture_float_linear);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
2015-01-08 03:28:05 +03:00
|
|
|
// WEBGL_
|
2016-11-23 05:59:35 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_astc:
|
2018-11-30 13:46:48 +03:00
|
|
|
return WebGLExtensionCompressedTextureASTC::IsSupported(this);
|
2016-11-11 03:37:03 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc:
|
2018-11-30 13:46:48 +03:00
|
|
|
return gl->IsSupported(gl::GLFeature::ES3_compatibility) &&
|
|
|
|
!gl->IsANGLE();
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc1:
|
2018-11-30 13:46:48 +03:00
|
|
|
return gl->IsExtensionSupported(
|
|
|
|
gl::GLContext::OES_compressed_ETC1_RGB8_texture) &&
|
|
|
|
!gl->IsANGLE();
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_pvrtc:
|
2018-11-30 13:46:48 +03:00
|
|
|
return gl->IsExtensionSupported(
|
|
|
|
gl::GLContext::IMG_texture_compression_pvrtc);
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc:
|
2018-11-30 13:46:48 +03:00
|
|
|
return WebGLExtensionCompressedTextureS3TC::IsSupported(this);
|
2017-05-30 18:21:33 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc_srgb:
|
2018-11-30 13:46:48 +03:00
|
|
|
return WebGLExtensionCompressedTextureS3TC_SRGB::IsSupported(this);
|
2015-07-22 03:41:57 +03:00
|
|
|
case WebGLExtensionID::WEBGL_debug_renderer_info:
|
2018-11-30 13:46:48 +03:00
|
|
|
return Preferences::GetBool("webgl.enable-debug-renderer-info", false) &&
|
|
|
|
!nsContentUtils::ShouldResistFingerprinting();
|
2017-07-18 21:41:00 +03:00
|
|
|
case WebGLExtensionID::WEBGL_debug_shaders:
|
2018-11-30 13:46:48 +03:00
|
|
|
return !nsContentUtils::ShouldResistFingerprinting();
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_lose_context:
|
2018-11-30 13:46:48 +03:00
|
|
|
// We always support this extension.
|
|
|
|
return true;
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
default:
|
2018-11-30 13:46:48 +03:00
|
|
|
// For warnings-as-errors.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsWebGL2()) {
|
|
|
|
// WebGL2-only extensions
|
|
|
|
switch (ext) {
|
|
|
|
// EXT_
|
|
|
|
case WebGLExtensionID::EXT_color_buffer_float:
|
|
|
|
return WebGLExtensionEXTColorBufferFloat::IsSupported(this);
|
|
|
|
|
|
|
|
default:
|
|
|
|
// For warnings-as-errors.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// WebGL1-only extensions
|
|
|
|
switch (ext) {
|
|
|
|
// ANGLE_
|
|
|
|
case WebGLExtensionID::ANGLE_instanced_arrays:
|
|
|
|
return WebGLExtensionInstancedArrays::IsSupported(this);
|
|
|
|
|
|
|
|
// EXT_
|
|
|
|
case WebGLExtensionID::EXT_blend_minmax:
|
|
|
|
return WebGLExtensionBlendMinMax::IsSupported(this);
|
|
|
|
case WebGLExtensionID::EXT_color_buffer_half_float:
|
|
|
|
return WebGLExtensionColorBufferHalfFloat::IsSupported(this);
|
|
|
|
case WebGLExtensionID::EXT_frag_depth:
|
|
|
|
return WebGLExtensionFragDepth::IsSupported(this);
|
|
|
|
case WebGLExtensionID::EXT_shader_texture_lod:
|
|
|
|
return WebGLExtensionShaderTextureLod::IsSupported(this);
|
|
|
|
case WebGLExtensionID::EXT_sRGB:
|
|
|
|
return WebGLExtensionSRGB::IsSupported(this);
|
|
|
|
|
|
|
|
// OES_
|
|
|
|
case WebGLExtensionID::OES_element_index_uint:
|
|
|
|
return gl->IsSupported(gl::GLFeature::element_index_uint);
|
|
|
|
case WebGLExtensionID::OES_standard_derivatives:
|
|
|
|
return gl->IsSupported(gl::GLFeature::standard_derivatives);
|
|
|
|
case WebGLExtensionID::OES_texture_float:
|
|
|
|
return WebGLExtensionTextureFloat::IsSupported(this);
|
|
|
|
case WebGLExtensionID::OES_texture_half_float:
|
|
|
|
return WebGLExtensionTextureHalfFloat::IsSupported(this);
|
|
|
|
case WebGLExtensionID::OES_texture_half_float_linear:
|
|
|
|
return gl->IsSupported(gl::GLFeature::texture_half_float_linear);
|
|
|
|
|
|
|
|
case WebGLExtensionID::OES_vertex_array_object:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// WEBGL_
|
|
|
|
case WebGLExtensionID::WEBGL_color_buffer_float:
|
|
|
|
return WebGLExtensionColorBufferFloat::IsSupported(this);
|
|
|
|
case WebGLExtensionID::WEBGL_depth_texture:
|
|
|
|
// WEBGL_depth_texture supports DEPTH_STENCIL textures
|
|
|
|
if (!gl->IsSupported(gl::GLFeature::packed_depth_stencil)) return false;
|
|
|
|
|
|
|
|
return gl->IsSupported(gl::GLFeature::depth_texture) ||
|
|
|
|
gl->IsExtensionSupported(gl::GLContext::ANGLE_depth_texture);
|
|
|
|
case WebGLExtensionID::WEBGL_draw_buffers:
|
|
|
|
return WebGLExtensionDrawBuffers::IsSupported(this);
|
|
|
|
default:
|
2014-11-14 07:03:50 +03:00
|
|
|
// For warnings-as-errors.
|
|
|
|
break;
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
2014-06-14 20:07:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
if (gfxPrefs::WebGLDraftExtensionsEnabled()) {
|
|
|
|
/*
|
|
|
|
switch (ext) {
|
|
|
|
default:
|
|
|
|
// For warnings-as-errors.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*/
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
return false;
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
static bool CompareWebGLExtensionName(const nsACString& name,
|
|
|
|
const char* other) {
|
|
|
|
return name.Equals(other, nsCaseInsensitiveCStringComparator());
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
WebGLExtensionBase* WebGLContext::EnableSupportedExtension(
|
|
|
|
dom::CallerType callerType, WebGLExtensionID ext) {
|
|
|
|
if (!IsExtensionEnabled(ext)) {
|
|
|
|
if (!IsExtensionSupported(callerType, ext)) return nullptr;
|
2014-11-22 02:04:08 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
EnableExtension(ext);
|
|
|
|
}
|
2014-11-22 02:04:08 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
return mExtensions[ext];
|
2014-11-22 02:04:08 +03:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
void WebGLContext::GetExtension(JSContext* cx, const nsAString& wideName,
|
|
|
|
JS::MutableHandle<JSObject*> retval,
|
|
|
|
dom::CallerType callerType, ErrorResult& rv) {
|
|
|
|
retval.set(nullptr);
|
|
|
|
const FuncScope funcScope(*this, "getExtension");
|
|
|
|
if (IsContextLost()) return;
|
|
|
|
|
|
|
|
NS_LossyConvertUTF16toASCII name(wideName);
|
|
|
|
|
|
|
|
WebGLExtensionID ext = WebGLExtensionID::Unknown;
|
|
|
|
|
|
|
|
// step 1: figure what extension is wanted
|
|
|
|
for (size_t i = 0; i < size_t(WebGLExtensionID::Max); i++) {
|
|
|
|
WebGLExtensionID extension = WebGLExtensionID(i);
|
|
|
|
|
|
|
|
if (CompareWebGLExtensionName(name, GetExtensionString(extension))) {
|
|
|
|
ext = extension;
|
|
|
|
break;
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
if (ext == WebGLExtensionID::Unknown) return;
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
// step 2: check if the extension is supported
|
|
|
|
if (!IsExtensionSupported(callerType, ext)) return;
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
// step 3: if the extension hadn't been previously been created, create it
|
|
|
|
// now, thus enabling it
|
|
|
|
WebGLExtensionBase* extObj = EnableSupportedExtension(callerType, ext);
|
|
|
|
if (!extObj) return;
|
2014-11-22 02:04:08 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
// Step 4: Enable any implied extensions.
|
|
|
|
switch (ext) {
|
2014-11-22 02:04:08 +03:00
|
|
|
case WebGLExtensionID::OES_texture_float:
|
2018-11-30 13:46:48 +03:00
|
|
|
EnableSupportedExtension(callerType,
|
|
|
|
WebGLExtensionID::WEBGL_color_buffer_float);
|
|
|
|
break;
|
2014-11-22 02:04:08 +03:00
|
|
|
|
|
|
|
case WebGLExtensionID::OES_texture_half_float:
|
2018-11-30 13:46:48 +03:00
|
|
|
EnableSupportedExtension(callerType,
|
|
|
|
WebGLExtensionID::EXT_color_buffer_half_float);
|
|
|
|
break;
|
2014-11-22 02:04:08 +03:00
|
|
|
|
|
|
|
default:
|
2018-11-30 13:46:48 +03:00
|
|
|
break;
|
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
retval.set(WebGLObjectAsJSObject(cx, extObj, rv));
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
void WebGLContext::EnableExtension(WebGLExtensionID ext) {
|
|
|
|
MOZ_ASSERT(IsExtensionEnabled(ext) == false);
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
WebGLExtensionBase* obj = nullptr;
|
|
|
|
switch (ext) {
|
2015-01-08 03:28:05 +03:00
|
|
|
// ANGLE_
|
|
|
|
case WebGLExtensionID::ANGLE_instanced_arrays:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionInstancedArrays(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
|
|
|
|
// EXT_
|
|
|
|
case WebGLExtensionID::EXT_blend_minmax:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionBlendMinMax(this);
|
|
|
|
break;
|
2016-05-05 02:39:02 +03:00
|
|
|
case WebGLExtensionID::EXT_color_buffer_float:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionEXTColorBufferFloat(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_color_buffer_half_float:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionColorBufferHalfFloat(this);
|
|
|
|
break;
|
2015-05-27 14:12:00 +03:00
|
|
|
case WebGLExtensionID::EXT_disjoint_timer_query:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionDisjointTimerQuery(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_frag_depth:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionFragDepth(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_shader_texture_lod:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionShaderTextureLod(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_sRGB:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionSRGB(this);
|
|
|
|
break;
|
2018-09-28 02:37:40 +03:00
|
|
|
case WebGLExtensionID::EXT_texture_compression_bptc:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionCompressedTextureBPTC(this);
|
|
|
|
break;
|
2018-09-28 02:37:40 +03:00
|
|
|
case WebGLExtensionID::EXT_texture_compression_rgtc:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionCompressedTextureRGTC(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::EXT_texture_filter_anisotropic:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionTextureFilterAnisotropic(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
|
2017-01-31 05:58:52 +03:00
|
|
|
// MOZ_
|
2017-04-11 11:50:59 +03:00
|
|
|
case WebGLExtensionID::MOZ_debug:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionMOZDebug(this);
|
|
|
|
break;
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2015-01-08 03:28:05 +03:00
|
|
|
// OES_
|
|
|
|
case WebGLExtensionID::OES_element_index_uint:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionElementIndexUint(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::OES_standard_derivatives:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionStandardDerivatives(this);
|
|
|
|
break;
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::OES_texture_float:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionTextureFloat(this);
|
|
|
|
break;
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::OES_texture_float_linear:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionTextureFloatLinear(this);
|
|
|
|
break;
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::OES_texture_half_float:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionTextureHalfFloat(this);
|
|
|
|
break;
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::OES_texture_half_float_linear:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionTextureHalfFloatLinear(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::OES_vertex_array_object:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionVertexArray(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
|
|
|
|
// WEBGL_
|
2014-11-14 07:03:50 +03:00
|
|
|
case WebGLExtensionID::WEBGL_color_buffer_float:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionColorBufferFloat(this);
|
|
|
|
break;
|
2016-11-23 05:59:35 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_astc:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionCompressedTextureASTC(this);
|
|
|
|
break;
|
2016-11-11 03:37:03 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionCompressedTextureES3(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_etc1:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionCompressedTextureETC1(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_pvrtc:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionCompressedTexturePVRTC(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionCompressedTextureS3TC(this);
|
|
|
|
break;
|
2017-05-30 18:21:33 +03:00
|
|
|
case WebGLExtensionID::WEBGL_compressed_texture_s3tc_srgb:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionCompressedTextureS3TC_SRGB(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_debug_renderer_info:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionDebugRendererInfo(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_debug_shaders:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionDebugShaders(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_depth_texture:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionDepthTexture(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_draw_buffers:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionDrawBuffers(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
case WebGLExtensionID::WEBGL_lose_context:
|
2018-11-30 13:46:48 +03:00
|
|
|
obj = new WebGLExtensionLoseContext(this);
|
|
|
|
break;
|
2015-01-08 03:28:05 +03:00
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
default:
|
2018-11-30 13:46:48 +03:00
|
|
|
MOZ_ASSERT(false, "should not get there.");
|
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
mExtensions[ext] = obj;
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
void WebGLContext::GetSupportedExtensions(
|
|
|
|
dom::Nullable<nsTArray<nsString> >& retval, dom::CallerType callerType) {
|
|
|
|
retval.SetNull();
|
|
|
|
const FuncScope funcScope(*this, "getSupportedExtensions");
|
|
|
|
if (IsContextLost()) return;
|
|
|
|
|
|
|
|
nsTArray<nsString>& arr = retval.SetValue();
|
|
|
|
|
|
|
|
for (size_t i = 0; i < size_t(WebGLExtensionID::Max); i++) {
|
|
|
|
const auto extension = WebGLExtensionID(i);
|
|
|
|
if (extension == WebGLExtensionID::MOZ_debug)
|
|
|
|
continue; // Hide MOZ_debug from this list.
|
|
|
|
|
|
|
|
if (IsExtensionSupported(callerType, extension)) {
|
|
|
|
const char* extStr = GetExtensionString(extension);
|
|
|
|
arr.AppendElement(NS_ConvertUTF8toUTF16(extStr));
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-08-27 01:12:53 +04:00
|
|
|
}
|
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
} // namespace mozilla
|