mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 765137 - 3/3 - WebGL: more cleanup and renaming around extensions - r=jgilbert
This commit is contained in:
parent
ca958a1d97
commit
c52c12fbb8
@ -76,7 +76,7 @@ WebGLContext::WebGLContext()
|
||||
: gl(nsnull)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
mEnabledExtensions.SetLength(WebGLExtensionID_Max);
|
||||
mExtensions.SetLength(WebGLExtensionID_number_of_extensions);
|
||||
|
||||
mGeneration = 0;
|
||||
mInvalidated = false;
|
||||
@ -840,24 +840,24 @@ WebGLContext::MozGetUnderlyingParamString(PRUint32 pname, nsAString& retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool WebGLContext::IsExtensionSupported(WebGLExtensionID ei)
|
||||
bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext)
|
||||
{
|
||||
bool isSupported = false;
|
||||
|
||||
switch (ei) {
|
||||
case WebGL_OES_standard_derivatives:
|
||||
case WebGL_WEBGL_lose_context:
|
||||
switch (ext) {
|
||||
case OES_standard_derivatives:
|
||||
case WEBGL_lose_context:
|
||||
// We always support these extensions.
|
||||
isSupported = true;
|
||||
break;
|
||||
case WebGL_OES_texture_float:
|
||||
case OES_texture_float:
|
||||
isSupported = gl->IsExtensionSupported(gl->IsGLES2() ? GLContext::OES_texture_float
|
||||
: GLContext::ARB_texture_float);
|
||||
break;
|
||||
case WebGL_EXT_texture_filter_anisotropic:
|
||||
case EXT_texture_filter_anisotropic:
|
||||
isSupported = gl->IsExtensionSupported(GLContext::EXT_texture_filter_anisotropic);
|
||||
break;
|
||||
case WebGL_WEBGL_compressed_texture_s3tc:
|
||||
case WEBGL_compressed_texture_s3tc:
|
||||
if (gl->IsExtensionSupported(GLContext::EXT_texture_compression_s3tc)) {
|
||||
isSupported = true;
|
||||
} else if (gl->IsExtensionSupported(GLContext::EXT_texture_compression_dxt1) &&
|
||||
@ -892,64 +892,68 @@ WebGLContext::GetExtension(const nsAString& aName)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
WebGLExtensionID ei = WebGLExtensionID_Max;
|
||||
WebGLExtensionID ext = WebGLExtensionID_unknown_extension;
|
||||
|
||||
if (aName.Equals(NS_LITERAL_STRING("OES_texture_float"),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (IsExtensionSupported(WebGL_OES_texture_float))
|
||||
ei = WebGL_OES_texture_float;
|
||||
if (IsExtensionSupported(OES_texture_float))
|
||||
ext = OES_texture_float;
|
||||
}
|
||||
else if (aName.Equals(NS_LITERAL_STRING("OES_standard_derivatives"),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (IsExtensionSupported(WebGL_OES_standard_derivatives))
|
||||
ei = WebGL_OES_standard_derivatives;
|
||||
if (IsExtensionSupported(OES_standard_derivatives))
|
||||
ext = OES_standard_derivatives;
|
||||
}
|
||||
else if (aName.Equals(NS_LITERAL_STRING("MOZ_EXT_texture_filter_anisotropic"),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (IsExtensionSupported(WebGL_EXT_texture_filter_anisotropic))
|
||||
ei = WebGL_EXT_texture_filter_anisotropic;
|
||||
if (IsExtensionSupported(EXT_texture_filter_anisotropic))
|
||||
ext = EXT_texture_filter_anisotropic;
|
||||
}
|
||||
else if (aName.Equals(NS_LITERAL_STRING("MOZ_WEBGL_lose_context"),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (IsExtensionSupported(WebGL_WEBGL_lose_context))
|
||||
ei = WebGL_WEBGL_lose_context;
|
||||
if (IsExtensionSupported(WEBGL_lose_context))
|
||||
ext = WEBGL_lose_context;
|
||||
}
|
||||
else if (aName.Equals(NS_LITERAL_STRING("MOZ_WEBGL_compressed_texture_s3tc"),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (IsExtensionSupported(WebGL_WEBGL_compressed_texture_s3tc))
|
||||
ei = WebGL_WEBGL_compressed_texture_s3tc;
|
||||
if (IsExtensionSupported(WEBGL_compressed_texture_s3tc))
|
||||
ext = WEBGL_compressed_texture_s3tc;
|
||||
}
|
||||
|
||||
if (ei != WebGLExtensionID_Max) {
|
||||
if (!IsExtensionEnabled(ei)) {
|
||||
switch (ei) {
|
||||
case WebGL_OES_standard_derivatives:
|
||||
mEnabledExtensions[ei] = new WebGLExtensionStandardDerivatives(this);
|
||||
break;
|
||||
case WebGL_EXT_texture_filter_anisotropic:
|
||||
mEnabledExtensions[ei] = new WebGLExtensionTextureFilterAnisotropic(this);
|
||||
break;
|
||||
case WebGL_WEBGL_lose_context:
|
||||
mEnabledExtensions[ei] = new WebGLExtensionLoseContext(this);
|
||||
break;
|
||||
case WebGL_WEBGL_compressed_texture_s3tc:
|
||||
mEnabledExtensions[ei] = new WebGLExtensionCompressedTextureS3TC(this);
|
||||
break;
|
||||
// create an extension for any types that don't
|
||||
// have any additional tokens or methods
|
||||
default:
|
||||
mEnabledExtensions[ei] = new WebGLExtension(this);
|
||||
break;
|
||||
}
|
||||
if (ext == WebGLExtensionID_unknown_extension) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (!mExtensions[ext]) {
|
||||
switch (ext) {
|
||||
case OES_standard_derivatives:
|
||||
mExtensions[ext] = new WebGLExtensionStandardDerivatives(this);
|
||||
break;
|
||||
case EXT_texture_filter_anisotropic:
|
||||
mExtensions[ext] = new WebGLExtensionTextureFilterAnisotropic(this);
|
||||
break;
|
||||
case WEBGL_lose_context:
|
||||
mExtensions[ext] = new WebGLExtensionLoseContext(this);
|
||||
break;
|
||||
case WEBGL_compressed_texture_s3tc:
|
||||
mExtensions[ext] = new WebGLExtensionCompressedTextureS3TC(this);
|
||||
break;
|
||||
default:
|
||||
// create a generic WebGLExtension object for any extensions that don't
|
||||
// have any additional tokens or methods. We still need these to be separate
|
||||
// objects in case the user might extend the corresponding JS objects with custom
|
||||
// properties.
|
||||
mExtensions[ext] = new WebGLExtension(this);
|
||||
break;
|
||||
}
|
||||
return mEnabledExtensions[ei];
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
return mExtensions[ext];
|
||||
}
|
||||
|
||||
void
|
||||
@ -1216,13 +1220,13 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(WebGLContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCanvasElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mEnabledExtensions)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mExtensions)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(WebGLContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mCanvasElement, nsINode)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mEnabledExtensions)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mExtensions)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
@ -1502,15 +1506,15 @@ WebGLContext::GetSupportedExtensions(Nullable< nsTArray<nsString> > &retval)
|
||||
|
||||
nsTArray<nsString>& arr = retval.SetValue();
|
||||
|
||||
if (IsExtensionSupported(WebGL_OES_texture_float))
|
||||
if (IsExtensionSupported(OES_texture_float))
|
||||
arr.AppendElement(NS_LITERAL_STRING("OES_texture_float"));
|
||||
if (IsExtensionSupported(WebGL_OES_standard_derivatives))
|
||||
if (IsExtensionSupported(OES_standard_derivatives))
|
||||
arr.AppendElement(NS_LITERAL_STRING("OES_standard_derivatives"));
|
||||
if (IsExtensionSupported(WebGL_EXT_texture_filter_anisotropic))
|
||||
if (IsExtensionSupported(EXT_texture_filter_anisotropic))
|
||||
arr.AppendElement(NS_LITERAL_STRING("MOZ_EXT_texture_filter_anisotropic"));
|
||||
if (IsExtensionSupported(WebGL_WEBGL_lose_context))
|
||||
if (IsExtensionSupported(WEBGL_lose_context))
|
||||
arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_lose_context"));
|
||||
if (IsExtensionSupported(WebGL_WEBGL_compressed_texture_s3tc))
|
||||
if (IsExtensionSupported(WEBGL_compressed_texture_s3tc))
|
||||
arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_compressed_texture_s3tc"));
|
||||
}
|
||||
|
||||
|
@ -1156,19 +1156,23 @@ protected:
|
||||
|
||||
// extensions
|
||||
enum WebGLExtensionID {
|
||||
WebGL_OES_texture_float,
|
||||
WebGL_OES_standard_derivatives,
|
||||
WebGL_EXT_texture_filter_anisotropic,
|
||||
WebGL_WEBGL_lose_context,
|
||||
WebGL_WEBGL_compressed_texture_s3tc,
|
||||
WebGLExtensionID_Max
|
||||
OES_texture_float,
|
||||
OES_standard_derivatives,
|
||||
EXT_texture_filter_anisotropic,
|
||||
WEBGL_lose_context,
|
||||
WEBGL_compressed_texture_s3tc,
|
||||
WebGLExtensionID_number_of_extensions,
|
||||
WebGLExtensionID_unknown_extension
|
||||
};
|
||||
nsAutoTArray<nsRefPtr<WebGLExtension>, WebGLExtensionID_Max> mEnabledExtensions;
|
||||
bool IsExtensionEnabled(WebGLExtensionID ext) const {
|
||||
NS_ABORT_IF_FALSE(ext >= 0 && ext < WebGLExtensionID_Max, "bogus index!");
|
||||
return mEnabledExtensions[ext] != nsnull;
|
||||
nsAutoTArray<nsRefPtr<WebGLExtension>, WebGLExtensionID_number_of_extensions> mExtensions;
|
||||
|
||||
// returns true if the extension has been enabled by calling getExtension.
|
||||
bool IsExtensionEnabled(WebGLExtensionID ext) {
|
||||
return mExtensions[ext];
|
||||
}
|
||||
bool IsExtensionSupported(WebGLExtensionID ei);
|
||||
|
||||
// returns true if the extension is supported (as returned by getSupportedExtensions)
|
||||
bool IsExtensionSupported(WebGLExtensionID ext);
|
||||
|
||||
nsTArray<WebGLenum> mCompressedTextureFormats;
|
||||
|
||||
|
@ -2423,7 +2423,7 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
|
||||
return JS::Int32Value(i);
|
||||
}
|
||||
case LOCAL_GL_FRAGMENT_SHADER_DERIVATIVE_HINT:
|
||||
if (mEnabledExtensions[WebGL_OES_standard_derivatives]) {
|
||||
if (IsExtensionEnabled(OES_standard_derivatives)) {
|
||||
GLint i = 0;
|
||||
gl->fGetIntegerv(pname, &i);
|
||||
return JS::Int32Value(i);
|
||||
@ -2470,7 +2470,7 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
|
||||
|
||||
// float
|
||||
case LOCAL_GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
|
||||
if (mEnabledExtensions[WebGL_EXT_texture_filter_anisotropic]) {
|
||||
if (IsExtensionEnabled(EXT_texture_filter_anisotropic)) {
|
||||
GLfloat f = 0.f;
|
||||
gl->fGetFloatv(pname, &f);
|
||||
return JS::DoubleValue(f);
|
||||
@ -3114,7 +3114,7 @@ void WebGLContext::TexParameter_base(WebGLenum target, WebGLenum pname,
|
||||
}
|
||||
break;
|
||||
case LOCAL_GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
||||
if (mEnabledExtensions[WebGL_EXT_texture_filter_anisotropic]) {
|
||||
if (IsExtensionEnabled(EXT_texture_filter_anisotropic)) {
|
||||
if (floatParamPtr && floatParam < 1.f)
|
||||
paramValueInvalid = true;
|
||||
else if (intParamPtr && intParam < 1)
|
||||
@ -3198,7 +3198,7 @@ WebGLContext::GetTexParameter(WebGLenum target, WebGLenum pname)
|
||||
return JS::NumberValue(uint32_t(i));
|
||||
}
|
||||
case LOCAL_GL_TEXTURE_MAX_ANISOTROPY_EXT:
|
||||
if (mEnabledExtensions[WebGL_EXT_texture_filter_anisotropic]) {
|
||||
if (IsExtensionEnabled(EXT_texture_filter_anisotropic)) {
|
||||
GLfloat f = 0.f;
|
||||
gl->fGetTexParameterfv(target, pname, &f);
|
||||
return JS::DoubleValue(f);
|
||||
@ -3529,7 +3529,7 @@ WebGLContext::Hint(WebGLenum target, WebGLenum mode)
|
||||
isValid = true;
|
||||
break;
|
||||
case LOCAL_GL_FRAGMENT_SHADER_DERIVATIVE_HINT:
|
||||
if (mEnabledExtensions[WebGL_OES_standard_derivatives])
|
||||
if (IsExtensionEnabled(OES_standard_derivatives))
|
||||
isValid = true;
|
||||
break;
|
||||
}
|
||||
@ -4918,7 +4918,7 @@ WebGLContext::CompileShader(WebGLShader *shader)
|
||||
resources.MaxTextureImageUnits = mGLMaxTextureImageUnits;
|
||||
resources.MaxFragmentUniformVectors = mGLMaxFragmentUniformVectors;
|
||||
resources.MaxDrawBuffers = 1;
|
||||
if (mEnabledExtensions[WebGL_OES_standard_derivatives])
|
||||
if (IsExtensionEnabled(OES_standard_derivatives))
|
||||
resources.OES_standard_derivatives = 1;
|
||||
|
||||
// We're storing an actual instance of StripComments because, if we don't, the
|
||||
|
@ -486,7 +486,7 @@ bool WebGLContext::ValidateTexFormatAndType(WebGLenum format, WebGLenum type, in
|
||||
uint32_t *texelSize, const char *info)
|
||||
{
|
||||
if (type == LOCAL_GL_UNSIGNED_BYTE ||
|
||||
(IsExtensionEnabled(WebGL_OES_texture_float) && type == LOCAL_GL_FLOAT))
|
||||
(IsExtensionEnabled(OES_texture_float) && type == LOCAL_GL_FLOAT))
|
||||
{
|
||||
if (jsArrayType != -1) {
|
||||
if ((type == LOCAL_GL_UNSIGNED_BYTE && jsArrayType != js::ArrayBufferView::TYPE_UINT8) ||
|
||||
|
Loading…
Reference in New Issue
Block a user