Bug 728017 - Implement WEBGL_compressed_texture_s3tc - r=bjacob

This commit is contained in:
Jon Buckley 2012-05-08 13:29:31 -04:00
parent 7c47d2d653
commit 56d33b746c
17 changed files with 313 additions and 77 deletions

View File

@ -69,6 +69,7 @@ CPPSRCS = \
DocumentRendererParent.cpp \
DocumentRendererChild.cpp \
ImageData.cpp \
WebGLExtensionCompressedTextureS3TC.cpp \
$(NULL)
ifdef MOZ_WEBGL

View File

@ -883,10 +883,13 @@ bool WebGLContext::IsExtensionSupported(WebGLExtensionID ei)
case WebGL_EXT_texture_filter_anisotropic:
isSupported = gl->IsExtensionSupported(GLContext::EXT_texture_filter_anisotropic);
break;
case WebGL_MOZ_WEBGL_lose_context:
case WebGL_WEBGL_lose_context:
// We always support this extension.
isSupported = true;
break;
case WebGL_WEBGL_compressed_texture_s3tc:
isSupported = gl->IsExtensionSupported(GLContext::EXT_texture_compression_s3tc);
break;
default:
isSupported = false;
}
@ -927,8 +930,12 @@ WebGLContext::GetExtension(const nsAString& aName)
ei = WebGL_EXT_texture_filter_anisotropic;
}
else if (aName.EqualsLiteral("MOZ_WEBGL_lose_context")) {
if (IsExtensionSupported(WebGL_MOZ_WEBGL_lose_context))
ei = WebGL_MOZ_WEBGL_lose_context;
if (IsExtensionSupported(WebGL_WEBGL_lose_context))
ei = WebGL_WEBGL_lose_context;
}
else if (aName.EqualsLiteral("MOZ_WEBGL_compressed_texture_s3tc")) {
if (IsExtensionSupported(WebGL_WEBGL_compressed_texture_s3tc))
ei = WebGL_WEBGL_compressed_texture_s3tc;
}
if (ei != WebGLExtensionID_Max) {
@ -940,9 +947,12 @@ WebGLContext::GetExtension(const nsAString& aName)
case WebGL_EXT_texture_filter_anisotropic:
mEnabledExtensions[ei] = new WebGLExtensionTextureFilterAnisotropic(this);
break;
case WebGL_MOZ_WEBGL_lose_context:
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:
@ -1518,8 +1528,10 @@ WebGLContext::GetSupportedExtensions(Nullable< nsTArray<nsString> > &retval)
arr.AppendElement(NS_LITERAL_STRING("OES_standard_derivatives"));
if (IsExtensionSupported(WebGL_EXT_texture_filter_anisotropic))
arr.AppendElement(NS_LITERAL_STRING("MOZ_EXT_texture_filter_anisotropic"));
if (IsExtensionSupported(WebGL_MOZ_WEBGL_lose_context))
if (IsExtensionSupported(WebGL_WEBGL_lose_context))
arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_lose_context"));
if (IsExtensionSupported(WebGL_WEBGL_compressed_texture_s3tc))
arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_compressed_texture_s3tc"));
}
NS_IMETHODIMP

View File

@ -571,6 +571,7 @@ class WebGLContext :
{
friend class WebGLMemoryMultiReporterWrapper;
friend class WebGLExtensionLoseContext;
friend class WebGLExtensionCompressedTextureS3TC;
friend class WebGLContextUserData;
friend class WebGLMemoryPressureObserver;
@ -1195,7 +1196,8 @@ protected:
WebGL_OES_texture_float,
WebGL_OES_standard_derivatives,
WebGL_EXT_texture_filter_anisotropic,
WebGL_MOZ_WEBGL_lose_context,
WebGL_WEBGL_lose_context,
WebGL_WEBGL_compressed_texture_s3tc,
WebGLExtensionID_Max
};
nsAutoTArray<nsRefPtr<WebGLExtension>, WebGLExtensionID_Max> mEnabledExtensions;
@ -1205,6 +1207,8 @@ protected:
}
bool IsExtensionSupported(WebGLExtensionID ei);
nsTArray<WebGLenum> mCompressedTextureFormats;
bool InitAndValidateGL();
bool ValidateBuffers(PRInt32* maxAllowedCount, const char *info);
bool ValidateCapabilityEnum(WebGLenum cap, const char *info);
@ -1227,7 +1231,11 @@ protected:
bool ValidateGLSLCharacter(PRUnichar c);
bool ValidateGLSLString(const nsAString& string, const char *info);
static PRUint32 GetTexelSize(WebGLenum format, WebGLenum type);
bool ValidateTexImage2DTarget(WebGLenum target, WebGLsizei width, WebGLsizei height, const char* info);
bool ValidateCompressedTextureSize(WebGLint level, WebGLenum format, WebGLsizei width, WebGLsizei height, uint32_t byteLength, const char* info);
bool ValidateLevelWidthHeightForTarget(WebGLenum target, WebGLint level, WebGLsizei width, WebGLsizei height, const char* info);
static PRUint32 GetBitsPerTexel(WebGLenum format, WebGLenum type);
void Invalidate();
void DestroyResourcesAndContext();
@ -1713,8 +1721,8 @@ public:
PRInt64 MemoryUsage() const {
if (!mIsDefined)
return 0;
PRInt64 texelSize = WebGLContext::GetTexelSize(mFormat, mType);
return PRInt64(mWidth) * PRInt64(mHeight) * texelSize;
PRInt64 texelSizeInBits = WebGLContext::GetBitsPerTexel(mFormat, mType);
return PRInt64(mWidth) * PRInt64(mHeight) * texelSizeInBits / 8;
}
WebGLenum Format() const { return mFormat; }
WebGLenum Type() const { return mType; }

View File

@ -46,7 +46,6 @@
#include "gfxImageSurface.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
//#include "nsIDOMHTMLCanvasElement.h"
#include "nsContentUtils.h"
#include "nsDOMError.h"
@ -2483,7 +2482,8 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
return JS::Int32Value(0);
case LOCAL_GL_COMPRESSED_TEXTURE_FORMATS:
{
JSObject* obj = Uint32Array::Create(cx, 0);
PRUint32 length = mCompressedTextureFormats.Length();
JSObject* obj = Uint32Array::Create(cx, length, mCompressedTextureFormats.Elements());
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@ -5082,11 +5082,37 @@ WebGLContext::CompressedTexImage2D(WebGLenum target, WebGLint level, WebGLenum i
return;
}
WebGLTexture *tex = activeBoundTextureForTarget(target);
if (!tex)
return ErrorInvalidOperation("compressedTexImage2D: no texture is bound to this target");
if (!ValidateTexImage2DTarget(target, width, height, "compressedTexImage2D")) {
return;
}
return ErrorInvalidEnum("compressedTexImage2D: compressed textures are not supported");
WebGLTexture *tex = activeBoundTextureForTarget(target);
if (!tex) {
ErrorInvalidOperation("compressedTexImage2D: no texture is bound to this target");
return;
}
if (!mCompressedTextureFormats.Contains(internalformat)) {
ErrorInvalidEnum("compressedTexImage2D: compressed texture format 0x%x is not supported", internalformat);
return;
}
if (!ValidateLevelWidthHeightForTarget(target, level, width, height, "compressedTexImage2D")) {
return;
}
if (border) {
ErrorInvalidValue("compressedTexImage2D: border is not 0");
return;
}
uint32_t byteLength = view.mLength;
if (!ValidateCompressedTextureSize(level, internalformat, width, height, byteLength, "compressedTexImage2D")) {
return;
}
gl->fCompressedTexImage2D(target, level, internalformat, width, height, border, byteLength, view.mData);
tex->SetImageInfo(target, level, width, height, internalformat, LOCAL_GL_UNSIGNED_BYTE);
}
NS_IMETHODIMP
@ -5113,12 +5139,82 @@ WebGLContext::CompressedTexSubImage2D(WebGLenum target, WebGLint level, WebGLint
return;
}
WebGLTexture *tex = activeBoundTextureForTarget(target);
if (!tex) {
return ErrorInvalidOperation("compressedTexSubImage2D: no texture is bound to this target");
switch (target) {
case LOCAL_GL_TEXTURE_2D:
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
break;
default:
return ErrorInvalidEnumInfo("texSubImage2D: target", target);
}
return ErrorInvalidEnum("compressedTexSubImage2D: compressed textures are not supported");
WebGLTexture *tex = activeBoundTextureForTarget(target);
if (!tex) {
ErrorInvalidOperation("compressedTexSubImage2D: no texture is bound to this target");
return;
}
if (!mCompressedTextureFormats.Contains(format)) {
ErrorInvalidEnum("compressedTexSubImage2D: compressed texture format 0x%x is not supported", format);
return;
}
if (!ValidateLevelWidthHeightForTarget(target, level, width, height, "compressedTexSubImage2D")) {
return;
}
uint32_t byteLength = view.mLength;
if (!ValidateCompressedTextureSize(level, format, width, height, byteLength, "compressedTexSubImage2D")) {
return;
}
size_t face = WebGLTexture::FaceForTarget(target);
if (!tex->HasImageInfoAt(level, face)) {
ErrorInvalidOperation("compressedTexSubImage2D: no texture image previously defined for this level and face");
return;
}
const WebGLTexture::ImageInfo &imageInfo = tex->ImageInfoAt(level, face);
if (!CanvasUtils::CheckSaneSubrectSize(xoffset, yoffset, width, height, imageInfo.Width(), imageInfo.Height())) {
ErrorInvalidValue("compressedTexSubImage2D: subtexture rectangle out of bounds");
return;
}
switch (format) {
case LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
{
if (xoffset < 0 || xoffset % 4 != 0) {
ErrorInvalidOperation("compressedTexSubImage2D: xoffset is not a multiple of 4");
return;
}
if (yoffset < 0 || yoffset % 4 != 0) {
ErrorInvalidOperation("compressedTexSubImage2D: yoffset is not a multiple of 4");
return;
}
if (width % 4 != 0 && width != imageInfo.Width()) {
ErrorInvalidOperation("compressedTexSubImage2D: width is not a multiple of 4 or equal to texture width");
return;
}
if (height % 4 != 0 && height != imageInfo.Height()) {
ErrorInvalidOperation("compressedTexSubImage2D: height is not a multiple of 4 or equal to texture height");
return;
}
break;
}
}
gl->fCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, byteLength, view.mData);
return;
}
NS_IMETHODIMP
@ -5457,20 +5553,8 @@ WebGLContext::TexImage2D_base(WebGLenum target, WebGLint level, WebGLenum intern
int jsArrayType, // a TypedArray format enum, or -1 if not relevant
WebGLTexelFormat srcFormat, bool srcPremultiplied)
{
switch (target) {
case LOCAL_GL_TEXTURE_2D:
break;
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
if (width != height)
return ErrorInvalidValue("texImage2D: with cube map targets, width and height must be equal");
break;
default:
return ErrorInvalidEnumInfo("texImage2D: target", target);
if (!ValidateTexImage2DTarget(target, width, height, "texImage2D")) {
return;
}
switch (format) {
@ -5487,19 +5571,9 @@ WebGLContext::TexImage2D_base(WebGLenum target, WebGLint level, WebGLenum intern
if (format != internalformat)
return ErrorInvalidOperation("texImage2D: format does not match internalformat");
WebGLsizei maxTextureSize = MaxTextureSizeForTarget(target);
if (level < 0)
return ErrorInvalidValue("texImage2D: level must be >= 0");
if (!(maxTextureSize >> level))
return ErrorInvalidValue("texImage2D: 2^level exceeds maximum texture size");
if (width < 0 || height < 0)
return ErrorInvalidValue("texImage2D: width and height must be >= 0");
if (width > maxTextureSize || height > maxTextureSize)
return ErrorInvalidValue("texImage2D: width or height exceeds maximum texture size");
if (!ValidateLevelWidthHeightForTarget(target, level, width, height, "texImage2D")) {
return;
}
if (level >= 1) {
if (!(is_pot_assuming_nonnegative(width) &&
@ -5738,19 +5812,9 @@ WebGLContext::TexSubImage2D_base(WebGLenum target, WebGLint level,
return ErrorInvalidEnumInfo("texSubImage2D: target", target);
}
WebGLsizei maxTextureSize = MaxTextureSizeForTarget(target);
if (level < 0)
return ErrorInvalidValue("texSubImage2D: level must be >= 0");
if (!(maxTextureSize >> level))
return ErrorInvalidValue("texSubImage2D: 2^level exceeds maximum texture size");
if (width < 0 || height < 0)
return ErrorInvalidValue("texSubImage2D: width and height must be >= 0");
if (width > maxTextureSize || height > maxTextureSize)
return ErrorInvalidValue("texSubImage2D: width or height exceeds maximum texture size");
if (!ValidateLevelWidthHeightForTarget(target, level, width, height, "texSubImage2D")) {
return;
}
if (level >= 1) {
if (!(is_pot_assuming_nonnegative(width) &&

View File

@ -57,3 +57,4 @@ DOMCI_DATA(WebGLExtension, void)
DOMCI_DATA(WebGLExtensionStandardDerivatives, void)
DOMCI_DATA(WebGLExtensionTextureFilterAnisotropic, void)
DOMCI_DATA(WebGLExtensionLoseContext, void)
DOMCI_DATA(WebGLExtensionCompressedTextureS3TC, void)

View File

@ -371,10 +371,118 @@ bool WebGLContext::ValidateGLSLString(const nsAString& string, const char *info)
return true;
}
PRUint32 WebGLContext::GetTexelSize(WebGLenum format, WebGLenum type)
bool WebGLContext::ValidateTexImage2DTarget(WebGLenum target, WebGLsizei width, WebGLsizei height,
const char* info)
{
switch (target) {
case LOCAL_GL_TEXTURE_2D:
break;
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
if (width != height) {
ErrorInvalidValue("%s: with cube map targets, width and height must be equal", info);
return false;
}
break;
default:
ErrorInvalidEnum("%s: invalid target enum 0x%x", info, target);
return false;
}
return true;
}
bool WebGLContext::ValidateCompressedTextureSize(WebGLint level, WebGLenum format, WebGLsizei width,
WebGLsizei height, uint32_t byteLength, const char* info)
{
CheckedUint32 calculated_byteLength = 0;
CheckedUint32 checked_byteLength = byteLength;
if (!checked_byteLength.valid()) {
ErrorInvalidValue("%s: data length out of bounds", info);
return false;
}
switch (format) {
case LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
{
calculated_byteLength = ((CheckedUint32(width) + 3) / 4) * ((CheckedUint32(height) + 3) / 4) * 8;
if (!calculated_byteLength.valid() || !(checked_byteLength == calculated_byteLength)) {
ErrorInvalidValue("%s: data size does not match dimensions", info);
return false;
}
break;
}
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
{
calculated_byteLength = ((CheckedUint32(width) + 3) / 4) * ((CheckedUint32(height) + 3) / 4) * 16;
if (!calculated_byteLength.valid() || !(checked_byteLength == calculated_byteLength)) {
ErrorInvalidValue("%s: data size does not match dimensions", info);
return false;
}
break;
}
}
switch (format) {
case LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
{
if (level == 0 && width % 4 == 0 && height % 4 == 0) {
return true;
}
if (level > 0
&& (width == 0 || width == 1 || width == 2 || width % 4 == 0)
&& (height == 0 || height == 1 || height == 2 || height % 4 == 0))
{
return true;
}
}
}
ErrorInvalidOperation("%s: level parameter does not match width and height", info);
return false;
}
bool WebGLContext::ValidateLevelWidthHeightForTarget(WebGLenum target, WebGLint level, WebGLsizei width,
WebGLsizei height, const char* info)
{
WebGLsizei maxTextureSize = MaxTextureSizeForTarget(target);
if (level < 0) {
ErrorInvalidValue("%s: level must be >= 0", info);
return false;
}
if (!(maxTextureSize >> level)) {
ErrorInvalidValue("%s: 2^level exceeds maximum texture size");
return false;
}
if (width < 0 || height < 0) {
ErrorInvalidValue("%s: width and height must be >= 0");
return false;
}
if (width > maxTextureSize || height > maxTextureSize) {
ErrorInvalidValue("%s: width or height exceeds maximum texture size");
return false;
}
return true;
}
PRUint32 WebGLContext::GetBitsPerTexel(WebGLenum format, WebGLenum type)
{
if (type == LOCAL_GL_UNSIGNED_BYTE || type == LOCAL_GL_FLOAT) {
int multiplier = type == LOCAL_GL_FLOAT ? 4 : 1;
int multiplier = type == LOCAL_GL_FLOAT ? 32 : 8;
switch (format) {
case LOCAL_GL_ALPHA:
case LOCAL_GL_LUMINANCE:
@ -385,6 +493,12 @@ PRUint32 WebGLContext::GetTexelSize(WebGLenum format, WebGLenum type)
return 3 * multiplier;
case LOCAL_GL_RGBA:
return 4 * multiplier;
case LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return 4;
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
return 8;
default:
break;
}
@ -392,7 +506,7 @@ PRUint32 WebGLContext::GetTexelSize(WebGLenum format, WebGLenum type)
type == LOCAL_GL_UNSIGNED_SHORT_5_5_5_1 ||
type == LOCAL_GL_UNSIGNED_SHORT_5_6_5)
{
return 2;
return 16;
}
NS_ABORT();

View File

@ -36,14 +36,9 @@
*
* ***** END LICENSE BLOCK ***** */
#include <stdarg.h>
#include "WebGLContext.h"
#include "WebGLExtensions.h"
#include "nsContentUtils.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
WebGLExtensionLoseContext::WebGLExtensionLoseContext(WebGLContext* context) :

View File

@ -36,14 +36,9 @@
*
* ***** END LICENSE BLOCK ***** */
#include <stdarg.h>
#include "WebGLContext.h"
#include "WebGLExtensions.h"
#include "nsContentUtils.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
WebGLExtensionStandardDerivatives::WebGLExtensionStandardDerivatives(WebGLContext* context) :

View File

@ -36,14 +36,9 @@
*
* ***** END LICENSE BLOCK ***** */
#include <stdarg.h>
#include "WebGLContext.h"
#include "WebGLExtensions.h"
#include "nsContentUtils.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
WebGLExtensionTextureFilterAnisotropic::WebGLExtensionTextureFilterAnisotropic(WebGLContext* context) :

View File

@ -77,6 +77,18 @@ public:
NS_DECL_NSIWEBGLEXTENSION
};
class WebGLExtensionCompressedTextureS3TC :
public nsIWebGLExtensionCompressedTextureS3TC,
public WebGLExtension
{
public:
WebGLExtensionCompressedTextureS3TC(WebGLContext* context);
virtual ~WebGLExtensionCompressedTextureS3TC();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIWEBGLEXTENSION
};
}
#endif // WEBGLEXTENSIONS_H_

View File

@ -1546,6 +1546,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(WebGLExtensionLoseContext, WebGLExtensionSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS |
nsIXPCScriptable::WANT_ADDPROPERTY)
NS_DEFINE_CLASSINFO_DATA(WebGLExtensionCompressedTextureS3TC, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS |
nsIXPCScriptable::WANT_ADDPROPERTY)
NS_DEFINE_CLASSINFO_DATA(PaintRequest, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -4250,6 +4253,10 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtensionLoseContext)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(WebGLExtensionCompressedTextureS3TC, nsIWebGLExtensionCompressedTextureS3TC)
DOM_CLASSINFO_MAP_ENTRY(nsIWebGLExtensionCompressedTextureS3TC)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(PaintRequest, nsIDOMPaintRequest)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPaintRequest)
DOM_CLASSINFO_MAP_END

View File

@ -489,6 +489,7 @@ DOMCI_CLASS(WebGLExtension)
DOMCI_CLASS(WebGLExtensionStandardDerivatives)
DOMCI_CLASS(WebGLExtensionTextureFilterAnisotropic)
DOMCI_CLASS(WebGLExtensionLoseContext)
DOMCI_CLASS(WebGLExtensionCompressedTextureS3TC)
DOMCI_CLASS(PaintRequest)
DOMCI_CLASS(PaintRequestList)

View File

@ -178,6 +178,16 @@ interface nsIWebGLExtensionTextureFilterAnisotropic : nsIWebGLExtension
const WebGLenum MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
};
[scriptable, builtinclass, uuid(a1508b6f-f2ab-44cf-bbb4-3cfb339e1e8a)]
interface nsIWebGLExtensionCompressedTextureS3TC : nsIWebGLExtension
{
/* Compressed Texture Formats */
const WebGLenum COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
const WebGLenum COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
const WebGLenum COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
const WebGLenum COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
};
[scriptable, builtinclass, uuid(a1fdfb76-6a08-4a1a-b0c9-d92ef3357cb9)]
interface nsIDOMWebGLRenderingContext : nsISupports
{

View File

@ -100,6 +100,7 @@ static const char *sExtensionNames[] = {
"GL_EXT_unpack_subimage",
"GL_OES_standard_derivatives",
"GL_EXT_texture_filter_anisotropic",
"GL_EXT_texture_compression_s3tc",
"GL_EXT_framebuffer_blit",
"GL_ANGLE_framebuffer_blit",
"GL_EXT_framebuffer_multisample",
@ -145,6 +146,8 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
{ (PRFuncPtr*) &mSymbols.fClearColor, { "ClearColor", NULL } },
{ (PRFuncPtr*) &mSymbols.fClearStencil, { "ClearStencil", NULL } },
{ (PRFuncPtr*) &mSymbols.fColorMask, { "ColorMask", NULL } },
{ (PRFuncPtr*) &mSymbols.fCompressedTexImage2D, {"CompressedTexImage2D", NULL} },
{ (PRFuncPtr*) &mSymbols.fCompressedTexSubImage2D, {"CompressedTexSubImage2D", NULL} },
{ (PRFuncPtr*) &mSymbols.fCullFace, { "CullFace", NULL } },
{ (PRFuncPtr*) &mSymbols.fDetachShader, { "DetachShader", "DetachShaderARB", NULL } },
{ (PRFuncPtr*) &mSymbols.fDepthFunc, { "DepthFunc", NULL } },

View File

@ -1620,6 +1620,7 @@ public:
EXT_unpack_subimage,
OES_standard_derivatives,
EXT_texture_filter_anisotropic,
EXT_texture_compression_s3tc,
EXT_framebuffer_blit,
ANGLE_framebuffer_blit,
EXT_framebuffer_multisample,
@ -2209,6 +2210,18 @@ public:
AFTER_GL_CALL;
}
void fCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *pixels) {
BEFORE_GL_CALL;
mSymbols.fCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pixels);
AFTER_GL_CALL;
}
void fCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *pixels) {
BEFORE_GL_CALL;
mSymbols.fCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, pixels);
AFTER_GL_CALL;
}
void fCullFace(GLenum mode) {
BEFORE_GL_CALL;
mSymbols.fCullFace(mode);

View File

@ -101,6 +101,10 @@ struct GLContextSymbols
PFNGLCLEARSTENCILPROC fClearStencil;
typedef void (GLAPIENTRY * PFNGLCOLORMASKPROC) (realGLboolean red, realGLboolean green, realGLboolean blue, realGLboolean alpha);
PFNGLCOLORMASKPROC fColorMask;
typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *pixels);
PFNGLCOMPRESSEDTEXIMAGE2D fCompressedTexImage2D;
typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *pixels);
PFNGLCOMPRESSEDTEXSUBIMAGE2D fCompressedTexSubImage2D;
typedef void (GLAPIENTRY * PFNGLCULLFACEPROC) (GLenum mode);
PFNGLCULLFACEPROC fCullFace;
typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);

View File

@ -508,6 +508,7 @@ irregularFilenames = {
'nsIWebGLExtensionStandardDerivatives' : 'nsIDOMWebGLRenderingContext',
'nsIWebGLExtensionTextureFilterAnisotropic' : 'nsIDOMWebGLRenderingContext',
'nsIWebGLExtensionLoseContext' : 'nsIDOMWebGLRenderingContext',
'nsIWebGLExtensionCompressedTextureS3TC' : 'nsIDOMWebGLRenderingContext',
'nsIIndexedDatabaseUsageCallback': 'nsIIndexedDatabaseManager',