Bug 1071340 - Convert to STRONG_GLENUM: TexType, TexFormat, TexInternalFormat - r=djg

This commit is contained in:
Benoit Jacob 2014-09-23 13:48:27 -04:00
parent 9e98d8b0b8
commit 72649e9c80
10 changed files with 242 additions and 92 deletions

View File

@ -93,7 +93,7 @@ namespace gfx {
class SourceSurface;
}
WebGLTexelFormat GetWebGLTexelFormat(GLenum format, GLenum type);
WebGLTexelFormat GetWebGLTexelFormat(TexInternalFormat format, TexType type);
void AssertUintParamCorrect(gl::GLContext* gl, GLenum pname, GLuint shadow);
@ -221,7 +221,7 @@ public:
*/
static const char *EnumName(GLenum glenum);
bool IsTextureFormatCompressed(GLenum format);
bool IsTextureFormatCompressed(TexInternalFormat format);
void DummyFramebufferOperation(const char *info);
@ -1093,7 +1093,7 @@ protected:
bool ValidateCopyTexImage(GLenum format, WebGLTexImageFunc func);
bool ValidateTexImage(GLuint dims, TexImageTarget texImageTarget,
GLint level, GLint internalFormat,
GLint level, GLenum internalFormat,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
GLint border, GLenum format, GLenum type,
@ -1120,7 +1120,7 @@ protected:
uint32_t byteLength, WebGLTexImageFunc func);
static uint32_t GetBitsPerTexel(GLenum format, GLenum type);
static uint32_t GetBitsPerTexel(TexInternalFormat format, TexType type);
void Invalidate();
void DestroyResourcesAndContext();

View File

@ -595,7 +595,7 @@ WebGLContext::CopyTexSubImage2D(GLenum rawTexImgTarget,
tex->DoDeferredImageInitialization(texImageTarget, level);
}
return CopyTexSubImage2D_base(texImageTarget, level, imageInfo.WebGLFormat(), xoffset, yoffset, x, y, width, height, true);
return CopyTexSubImage2D_base(texImageTarget, level, imageInfo.WebGLFormat().get(), xoffset, yoffset, x, y, width, height, true);
}
@ -900,7 +900,7 @@ WebGLContext::GenerateMipmap(GLenum rawTarget)
if (!tex->IsFirstImagePowerOfTwo())
return ErrorInvalidOperation("generateMipmap: Level zero of texture does not have power-of-two width and height.");
GLenum webGLFormat = tex->ImageInfoAt(imageTarget, 0).WebGLFormat();
TexInternalFormat webGLFormat = tex->ImageInfoAt(imageTarget, 0).WebGLFormat();
if (IsTextureFormatCompressed(webGLFormat))
return ErrorInvalidOperation("generateMipmap: Texture data at level zero is compressed.");
@ -1177,7 +1177,7 @@ WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx,
switch (pname) {
case LOCAL_GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
if (IsExtensionEnabled(WebGLExtensionID::EXT_sRGB)) {
const GLenum webGLFormat =
const TexInternalFormat webGLFormat =
fba.Texture()->ImageInfoBase().WebGLFormat();
return (webGLFormat == LOCAL_GL_SRGB ||
webGLFormat == LOCAL_GL_SRGB_ALPHA) ?
@ -1219,9 +1219,9 @@ WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx,
return JS::NumberValue(uint32_t(LOCAL_GL_NONE));
uint32_t ret = LOCAL_GL_NONE;
GLenum type = fba.Texture()->ImageInfoAt(fba.ImageTarget(),
fba.MipLevel()).WebGLType();
switch (type) {
TexType type = fba.Texture()->ImageInfoAt(fba.ImageTarget(),
fba.MipLevel()).WebGLType();
switch (type.get()) {
case LOCAL_GL_UNSIGNED_BYTE:
case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:
@ -2409,7 +2409,7 @@ WebGLContext::RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei
bool hasExtensions = IsExtensionEnabled(WebGLExtensionID::OES_texture_half_float) &&
IsExtensionEnabled(WebGLExtensionID::EXT_color_buffer_half_float);
if (!hasExtensions)
return ErrorInvalidEnumInfo("renderbufferStorage: internalformat", target);
return ErrorInvalidEnumInfo("renderbufferStorage: internalformat", internalformat);
break;
}
case LOCAL_GL_RGB32F:
@ -2417,7 +2417,7 @@ WebGLContext::RenderbufferStorage(GLenum target, GLenum internalformat, GLsizei
bool hasExtensions = IsExtensionEnabled(WebGLExtensionID::OES_texture_float) &&
IsExtensionEnabled(WebGLExtensionID::WEBGL_color_buffer_float);
if (!hasExtensions)
return ErrorInvalidEnumInfo("renderbufferStorage: internalformat", target);
return ErrorInvalidEnumInfo("renderbufferStorage: internalformat", internalformat);
break;
}
default:
@ -4032,12 +4032,12 @@ BaseTypeAndSizeFromUniformType(GLenum uType, GLenum *baseType, GLint *unitSize)
}
WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum internalformat, GLenum type)
WebGLTexelFormat mozilla::GetWebGLTexelFormat(TexInternalFormat internalformat, TexType type)
{
//
// WEBGL_depth_texture
if (internalformat == LOCAL_GL_DEPTH_COMPONENT) {
switch (type) {
switch (type.get()) {
case LOCAL_GL_UNSIGNED_SHORT:
return WebGLTexelFormat::D16;
case LOCAL_GL_UNSIGNED_INT:
@ -4048,7 +4048,7 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum internalformat, GLenum type
}
if (internalformat == LOCAL_GL_DEPTH_STENCIL) {
switch (type) {
switch (type.get()) {
case LOCAL_GL_UNSIGNED_INT_24_8_EXT:
return WebGLTexelFormat::D24S8;
}
@ -4069,7 +4069,7 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum internalformat, GLenum type
}
if (type == LOCAL_GL_UNSIGNED_BYTE) {
switch (internalformat) {
switch (internalformat.get()) {
case LOCAL_GL_RGBA:
case LOCAL_GL_SRGB_ALPHA_EXT:
return WebGLTexelFormat::RGBA8;
@ -4089,7 +4089,7 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum internalformat, GLenum type
if (type == LOCAL_GL_FLOAT) {
// OES_texture_float
switch (internalformat) {
switch (internalformat.get()) {
case LOCAL_GL_RGBA:
case LOCAL_GL_RGBA32F:
return WebGLTexelFormat::RGBA32F;
@ -4110,7 +4110,7 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum internalformat, GLenum type
MOZ_CRASH("Invalid WebGL texture format/type?");
} else if (type == LOCAL_GL_HALF_FLOAT_OES) {
// OES_texture_half_float
switch (internalformat) {
switch (internalformat.get()) {
case LOCAL_GL_RGBA:
case LOCAL_GL_RGBA16F:
return WebGLTexelFormat::RGBA16F;
@ -4132,7 +4132,7 @@ WebGLTexelFormat mozilla::GetWebGLTexelFormat(GLenum internalformat, GLenum type
}
}
switch (type) {
switch (type.get()) {
case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
return WebGLTexelFormat::RGBA4444;
case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:

View File

@ -31,7 +31,7 @@ namespace mozilla {
using namespace gl;
bool
IsGLDepthFormat(GLenum webGLFormat)
IsGLDepthFormat(TexInternalFormat webGLFormat)
{
return (webGLFormat == LOCAL_GL_DEPTH_COMPONENT ||
webGLFormat == LOCAL_GL_DEPTH_COMPONENT16 ||
@ -39,14 +39,14 @@ IsGLDepthFormat(GLenum webGLFormat)
}
bool
IsGLDepthStencilFormat(GLenum webGLFormat)
IsGLDepthStencilFormat(TexInternalFormat webGLFormat)
{
return (webGLFormat == LOCAL_GL_DEPTH_STENCIL ||
webGLFormat == LOCAL_GL_DEPTH24_STENCIL8);
}
bool
FormatHasAlpha(GLenum webGLFormat)
FormatHasAlpha(TexInternalFormat webGLFormat)
{
return webGLFormat == LOCAL_GL_RGBA ||
webGLFormat == LOCAL_GL_LUMINANCE_ALPHA ||
@ -76,11 +76,11 @@ TexImageTargetToTexTarget(TexImageTarget texImageTarget)
}
}
GLComponents::GLComponents(GLenum format)
GLComponents::GLComponents(TexInternalFormat format)
{
mComponents = 0;
switch (format) {
switch (format.get()) {
case LOCAL_GL_RGBA:
case LOCAL_GL_RGBA4:
case LOCAL_GL_RGBA8:
@ -118,91 +118,99 @@ GLComponents::IsSubsetOf(const GLComponents& other) const
}
/**
* Convert WebGL/ES format and type into GL format and GL internal
* Convert WebGL/ES format and type into GL internal
* format valid for underlying driver.
*/
void
DriverFormatsFromFormatAndType(GLContext* gl, GLenum webGLFormat, GLenum webGLType,
DriverFormatsFromFormatAndType(GLContext* gl, TexInternalFormat webGLInternalFormat, TexType webGLType,
GLenum* out_driverInternalFormat, GLenum* out_driverFormat)
{
MOZ_ASSERT(out_driverInternalFormat, "out_driverInternalFormat can't be nullptr.");
MOZ_ASSERT(out_driverFormat, "out_driverFormat can't be nullptr.");
if (!out_driverInternalFormat || !out_driverFormat)
return;
MOZ_ASSERT(out_driverInternalFormat);
MOZ_ASSERT(out_driverFormat);
// ES2 requires that format == internalformat; floating-point is
// indicated purely by the type that's loaded. For desktop GL, we
// have to specify a floating point internal format.
if (gl->IsGLES()) {
*out_driverInternalFormat = webGLFormat;
*out_driverFormat = webGLFormat;
*out_driverFormat = *out_driverInternalFormat = webGLInternalFormat.get();
return;
}
GLenum format = webGLFormat;
GLenum internalFormat = LOCAL_GL_NONE;
GLenum format = LOCAL_GL_NONE;
if (format == LOCAL_GL_DEPTH_COMPONENT) {
if (webGLInternalFormat == LOCAL_GL_DEPTH_COMPONENT) {
format = LOCAL_GL_DEPTH_COMPONENT;
if (webGLType == LOCAL_GL_UNSIGNED_SHORT)
internalFormat = LOCAL_GL_DEPTH_COMPONENT16;
else if (webGLType == LOCAL_GL_UNSIGNED_INT)
internalFormat = LOCAL_GL_DEPTH_COMPONENT32;
} else if (format == LOCAL_GL_DEPTH_STENCIL) {
} else if (webGLInternalFormat == LOCAL_GL_DEPTH_STENCIL) {
format = LOCAL_GL_DEPTH_STENCIL;
if (webGLType == LOCAL_GL_UNSIGNED_INT_24_8_EXT)
internalFormat = LOCAL_GL_DEPTH24_STENCIL8;
} else {
switch (webGLType) {
switch (webGLType.get()) {
case LOCAL_GL_UNSIGNED_BYTE:
case LOCAL_GL_UNSIGNED_SHORT_4_4_4_4:
case LOCAL_GL_UNSIGNED_SHORT_5_5_5_1:
case LOCAL_GL_UNSIGNED_SHORT_5_6_5:
internalFormat = format;
format = internalFormat = webGLInternalFormat.get();
break;
case LOCAL_GL_FLOAT:
switch (format) {
switch (webGLInternalFormat.get()) {
case LOCAL_GL_RGBA:
format = LOCAL_GL_RGBA;
internalFormat = LOCAL_GL_RGBA32F;
break;
case LOCAL_GL_RGB:
format = LOCAL_GL_RGB;
internalFormat = LOCAL_GL_RGB32F;
break;
case LOCAL_GL_ALPHA:
format = LOCAL_GL_ALPHA;
internalFormat = LOCAL_GL_ALPHA32F_ARB;
break;
case LOCAL_GL_LUMINANCE:
format = LOCAL_GL_LUMINANCE;
internalFormat = LOCAL_GL_LUMINANCE32F_ARB;
break;
case LOCAL_GL_LUMINANCE_ALPHA:
format = LOCAL_GL_LUMINANCE_ALPHA;
internalFormat = LOCAL_GL_LUMINANCE_ALPHA32F_ARB;
break;
}
break;
case LOCAL_GL_HALF_FLOAT_OES:
switch (format) {
switch (webGLInternalFormat.get()) {
case LOCAL_GL_RGBA:
format = LOCAL_GL_RGBA;
internalFormat = LOCAL_GL_RGBA16F;
break;
case LOCAL_GL_RGB:
format = LOCAL_GL_RGB;
internalFormat = LOCAL_GL_RGB16F;
break;
case LOCAL_GL_ALPHA:
format = LOCAL_GL_ALPHA;
internalFormat = LOCAL_GL_ALPHA16F_ARB;
break;
case LOCAL_GL_LUMINANCE:
format = LOCAL_GL_LUMINANCE;
internalFormat = LOCAL_GL_LUMINANCE16F_ARB;
break;
case LOCAL_GL_LUMINANCE_ALPHA:
format = LOCAL_GL_LUMINANCE_ALPHA;
internalFormat = LOCAL_GL_LUMINANCE_ALPHA16F_ARB;
break;
}
@ -218,20 +226,19 @@ DriverFormatsFromFormatAndType(GLContext* gl, GLenum webGLFormat, GLenum webGLTy
// format -> internalformat
// GL_RGB GL_SRGB_EXT
// GL_RGBA GL_SRGB_ALPHA_EXT
switch (format) {
switch (webGLInternalFormat.get()) {
case LOCAL_GL_SRGB:
internalFormat = format;
format = LOCAL_GL_RGB;
internalFormat = LOCAL_GL_SRGB;
break;
case LOCAL_GL_SRGB_ALPHA:
internalFormat = format;
format = LOCAL_GL_RGBA;
internalFormat = LOCAL_GL_SRGB_ALPHA;
break;
}
}
MOZ_ASSERT(format != LOCAL_GL_NONE && internalFormat != LOCAL_GL_NONE,
MOZ_ASSERT(webGLInternalFormat != LOCAL_GL_NONE && internalFormat != LOCAL_GL_NONE,
"Coding mistake -- bad format/type passed?");
*out_driverInternalFormat = internalFormat;
@ -239,13 +246,14 @@ DriverFormatsFromFormatAndType(GLContext* gl, GLenum webGLFormat, GLenum webGLTy
}
GLenum
DriverTypeFromType(GLContext* gl, GLenum webGLType)
DriverTypeFromType(GLContext* gl, TexType webGLType)
{
GLenum type = webGLType.get();
if (gl->IsGLES())
return webGLType;
return type;
// convert type for half float if not on GLES2
GLenum type = webGLType;
if (type == LOCAL_GL_HALF_FLOAT_OES) {
if (gl->IsSupported(gl::GLFeature::texture_half_float)) {
return LOCAL_GL_HALF_FLOAT;
@ -254,7 +262,7 @@ DriverTypeFromType(GLContext* gl, GLenum webGLType)
}
}
return webGLType;
return type;
}
void
@ -484,9 +492,9 @@ WebGLContext::EnumName(GLenum glenum)
bool
WebGLContext::IsTextureFormatCompressed(GLenum format)
WebGLContext::IsTextureFormatCompressed(TexInternalFormat format)
{
switch (format) {
switch (format.get()) {
case LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:

View File

@ -13,12 +13,12 @@
namespace mozilla {
bool IsGLDepthFormat(GLenum webGLFormat);
bool IsGLDepthStencilFormat(GLenum webGLFormat);
bool FormatHasAlpha(GLenum webGLFormat);
void DriverFormatsFromFormatAndType(gl::GLContext* gl, GLenum webGLFormat, GLenum webGLType,
bool IsGLDepthFormat(TexInternalFormat webGLFormat);
bool IsGLDepthStencilFormat(TexInternalFormat webGLFormat);
bool FormatHasAlpha(TexInternalFormat webGLFormat);
void DriverFormatsFromFormatAndType(gl::GLContext* gl, TexInternalFormat webGLFormat, TexType webGLType,
GLenum* out_driverInternalFormat, GLenum* out_driverFormat);
GLenum DriverTypeFromType(gl::GLContext* gl, GLenum webGLType);
GLenum DriverTypeFromType(gl::GLContext* gl, TexType webGLType);
// For use with the different texture calls, i.e.
// TexImage2D, CopyTex[Sub]Image2D, ...
@ -51,7 +51,7 @@ struct GLComponents
: mComponents(0)
{ }
explicit GLComponents(GLenum aFormat);
explicit GLComponents(TexInternalFormat aFormat);
// Returns true iff other has all (or more) of
// the components present in this GLComponents

View File

@ -1039,13 +1039,8 @@ WebGLContext::ValidateTexSubImageSize(GLint xoffset, GLint yoffset, GLint /*zoff
* ValidateTexImageFormatAndType().
*/
uint32_t
WebGLContext::GetBitsPerTexel(GLenum format, GLenum type)
WebGLContext::GetBitsPerTexel(TexInternalFormat format, TexType type)
{
// If there is no defined format or type, we're not taking up any memory
if (!format || !type) {
return 0;
}
/* Known fixed-sized types */
if (type == LOCAL_GL_UNSIGNED_SHORT_4_4_4_4 ||
type == LOCAL_GL_UNSIGNED_SHORT_5_5_5_1 ||
@ -1058,7 +1053,7 @@ WebGLContext::GetBitsPerTexel(GLenum format, GLenum type)
return 32;
int bitsPerComponent = 0;
switch (type) {
switch (type.get()) {
case LOCAL_GL_UNSIGNED_BYTE:
bitsPerComponent = 8;
break;
@ -1079,7 +1074,7 @@ WebGLContext::GetBitsPerTexel(GLenum format, GLenum type)
break;
}
switch (format) {
switch (format.get()) {
// Uncompressed formats
case LOCAL_GL_ALPHA:
case LOCAL_GL_LUMINANCE:
@ -1309,7 +1304,7 @@ WebGLContext::ValidateCopyTexImage(GLenum format, WebGLTexImageFunc func)
// TODO: Texture dims is here for future expansion in WebGL 2.0
bool
WebGLContext::ValidateTexImage(GLuint dims, TexImageTarget texImageTarget,
GLint level, GLint internalFormat,
GLint level, GLenum internalFormat,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
GLint border, GLenum format, GLenum type,
@ -1339,7 +1334,7 @@ WebGLContext::ValidateTexImage(GLuint dims, TexImageTarget texImageTarget,
* (e.g., GL_FLOAT requires GL_OES_texture_float) are filtered
* elsewhere.
*/
if ((GLint) format != internalFormat) {
if (format != internalFormat) {
ErrorInvalidOperation("%s: format does not match internalformat", info);
return false;
}

View File

@ -64,17 +64,23 @@ WebGLFramebuffer::Attachment::IsDeleteRequested() const
: false;
}
bool
WebGLFramebuffer::Attachment::IsDefined() const
{
return Renderbuffer() ||
(Texture() && Texture()->HasImageInfoAt(ImageTarget(), 0));
}
bool
WebGLFramebuffer::Attachment::HasAlpha() const
{
MOZ_ASSERT(HasImage());
GLenum format = 0;
if (Texture() && Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel))
format = Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel).WebGLFormat();
return FormatHasAlpha(Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel).WebGLFormat());
else if (Renderbuffer())
format = Renderbuffer()->InternalFormat();
return FormatHasAlpha(format);
return FormatHasAlpha(Renderbuffer()->InternalFormat());
else return false;
}
GLenum
@ -88,7 +94,7 @@ WebGLFramebuffer::GetFormatForAttachment(const WebGLFramebuffer::Attachment& att
MOZ_ASSERT(tex.HasImageInfoAt(attachment.ImageTarget(), 0));
const WebGLTexture::ImageInfo& imgInfo = tex.ImageInfoAt(attachment.ImageTarget(), 0);
return imgInfo.WebGLFormat();
return imgInfo.WebGLFormat().get();
}
if (attachment.Renderbuffer())
@ -102,7 +108,7 @@ WebGLFramebuffer::Attachment::IsReadableFloat() const
{
const WebGLTexture* tex = Texture();
if (tex && tex->HasImageInfoAt(mTexImageTarget, mTexImageLevel)) {
GLenum type = tex->ImageInfoAt(mTexImageTarget, mTexImageLevel).WebGLType();
GLenum type = tex->ImageInfoAt(mTexImageTarget, mTexImageLevel).WebGLType().get();
switch (type) {
case LOCAL_GL_FLOAT:
case LOCAL_GL_HALF_FLOAT_OES:
@ -322,7 +328,7 @@ WebGLFramebuffer::Attachment::IsComplete() const
MOZ_ASSERT(Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel));
const WebGLTexture::ImageInfo& imageInfo =
Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel);
GLenum webGLFormat = imageInfo.WebGLFormat();
GLenum webGLFormat = imageInfo.WebGLFormat().get();
if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT)
return IsValidFBOTextureDepthFormat(webGLFormat);

View File

@ -49,9 +49,7 @@ public:
explicit Attachment(GLenum aAttachmentPoint = LOCAL_GL_COLOR_ATTACHMENT0);
~Attachment();
bool IsDefined() const {
return Texture() || Renderbuffer();
}
bool IsDefined() const;
bool IsDeleteRequested() const;

View File

@ -162,13 +162,37 @@ public:
}
};
#define STRONG_GLENUM_BEGIN(NAME) \
template<typename Details>
bool operator==(GLenum a, StrongGLenum<Details> b)
{
return a == b.get();
}
template<typename Details>
bool operator!=(GLenum a, StrongGLenum<Details> b)
{
return a != b.get();
}
template<typename Details>
bool operator==(StrongGLenum<Details> a, GLenum b)
{
return a.get() == b;
}
template<typename Details>
bool operator!=(StrongGLenum<Details> a, GLenum b)
{
return a.get() != b;
}
#define STRONG_GLENUM_BEGIN(NAME) \
const uint16_t NAME##Values[] = {
#define STRONG_GLENUM_VALUE(VALUE) LOCAL_GL_##VALUE
#define STRONG_GLENUM_END(NAME) \
}; \
#define STRONG_GLENUM_END(NAME) \
}; \
struct NAME##Details { \
static size_t valuesCount() { return MOZ_ARRAY_LENGTH(NAME##Values); } \
static const uint16_t* values() { return NAME##Values; } \
@ -198,4 +222,123 @@ STRONG_GLENUM_BEGIN(TexTarget)
STRONG_GLENUM_VALUE(TEXTURE_CUBE_MAP),
STRONG_GLENUM_END(TexTarget)
STRONG_GLENUM_BEGIN(TexType)
STRONG_GLENUM_VALUE(NONE),
STRONG_GLENUM_VALUE(BYTE),
STRONG_GLENUM_VALUE(UNSIGNED_BYTE),
STRONG_GLENUM_VALUE(SHORT),
STRONG_GLENUM_VALUE(UNSIGNED_SHORT),
STRONG_GLENUM_VALUE(INT),
STRONG_GLENUM_VALUE(UNSIGNED_INT),
STRONG_GLENUM_VALUE(FLOAT),
STRONG_GLENUM_VALUE(HALF_FLOAT),
STRONG_GLENUM_VALUE(UNSIGNED_SHORT_4_4_4_4),
STRONG_GLENUM_VALUE(UNSIGNED_SHORT_5_5_5_1),
STRONG_GLENUM_VALUE(UNSIGNED_SHORT_5_6_5),
STRONG_GLENUM_VALUE(UNSIGNED_INT_2_10_10_10_REV),
STRONG_GLENUM_VALUE(UNSIGNED_INT_24_8),
STRONG_GLENUM_VALUE(UNSIGNED_INT_10F_11F_11F_REV),
STRONG_GLENUM_VALUE(UNSIGNED_INT_5_9_9_9_REV),
STRONG_GLENUM_VALUE(HALF_FLOAT_OES),
STRONG_GLENUM_VALUE(FLOAT_32_UNSIGNED_INT_24_8_REV),
STRONG_GLENUM_END(TexType)
STRONG_GLENUM_BEGIN(TexFormat)
STRONG_GLENUM_VALUE(NONE),
STRONG_GLENUM_VALUE(DEPTH_COMPONENT),
STRONG_GLENUM_VALUE(RED),
STRONG_GLENUM_VALUE(ALPHA),
STRONG_GLENUM_VALUE(RGB),
STRONG_GLENUM_VALUE(RGBA),
STRONG_GLENUM_VALUE(LUMINANCE),
STRONG_GLENUM_VALUE(LUMINANCE_ALPHA),
STRONG_GLENUM_VALUE(RG),
STRONG_GLENUM_VALUE(SRGB),
STRONG_GLENUM_VALUE(SRGB_ALPHA),
STRONG_GLENUM_VALUE(RG_INTEGER),
STRONG_GLENUM_VALUE(DEPTH_STENCIL),
STRONG_GLENUM_VALUE(RED_INTEGER),
STRONG_GLENUM_VALUE(RGB_INTEGER),
STRONG_GLENUM_VALUE(RGBA_INTEGER),
STRONG_GLENUM_END(TexFormat)
STRONG_GLENUM_BEGIN(TexInternalFormat)
STRONG_GLENUM_VALUE(NONE),
STRONG_GLENUM_VALUE(DEPTH_COMPONENT),
STRONG_GLENUM_VALUE(ALPHA),
STRONG_GLENUM_VALUE(RGB),
STRONG_GLENUM_VALUE(RGBA),
STRONG_GLENUM_VALUE(LUMINANCE),
STRONG_GLENUM_VALUE(LUMINANCE_ALPHA),
STRONG_GLENUM_VALUE(RGB8),
STRONG_GLENUM_VALUE(RGBA4),
STRONG_GLENUM_VALUE(RGB5_A1),
STRONG_GLENUM_VALUE(RGBA8),
STRONG_GLENUM_VALUE(RGB10_A2),
STRONG_GLENUM_VALUE(DEPTH_COMPONENT16),
STRONG_GLENUM_VALUE(DEPTH_COMPONENT24),
STRONG_GLENUM_VALUE(R8),
STRONG_GLENUM_VALUE(RG8),
STRONG_GLENUM_VALUE(R16F),
STRONG_GLENUM_VALUE(R32F),
STRONG_GLENUM_VALUE(RG16F),
STRONG_GLENUM_VALUE(RG32F),
STRONG_GLENUM_VALUE(R8I),
STRONG_GLENUM_VALUE(R8UI),
STRONG_GLENUM_VALUE(R16I),
STRONG_GLENUM_VALUE(R16UI),
STRONG_GLENUM_VALUE(R32I),
STRONG_GLENUM_VALUE(R32UI),
STRONG_GLENUM_VALUE(RG8I),
STRONG_GLENUM_VALUE(RG8UI),
STRONG_GLENUM_VALUE(RG16I),
STRONG_GLENUM_VALUE(RG16UI),
STRONG_GLENUM_VALUE(RG32I),
STRONG_GLENUM_VALUE(RG32UI),
STRONG_GLENUM_VALUE(COMPRESSED_RGB_S3TC_DXT1_EXT),
STRONG_GLENUM_VALUE(COMPRESSED_RGBA_S3TC_DXT1_EXT),
STRONG_GLENUM_VALUE(COMPRESSED_RGBA_S3TC_DXT3_EXT),
STRONG_GLENUM_VALUE(COMPRESSED_RGBA_S3TC_DXT5_EXT),
STRONG_GLENUM_VALUE(DEPTH_STENCIL),
STRONG_GLENUM_VALUE(ATC_RGBA_INTERPOLATED_ALPHA),
STRONG_GLENUM_VALUE(RGBA32F),
STRONG_GLENUM_VALUE(RGB32F),
STRONG_GLENUM_VALUE(RGBA16F),
STRONG_GLENUM_VALUE(RGB16F),
STRONG_GLENUM_VALUE(DEPTH24_STENCIL8),
STRONG_GLENUM_VALUE(COMPRESSED_RGB_PVRTC_4BPPV1),
STRONG_GLENUM_VALUE(COMPRESSED_RGB_PVRTC_2BPPV1),
STRONG_GLENUM_VALUE(COMPRESSED_RGBA_PVRTC_4BPPV1),
STRONG_GLENUM_VALUE(COMPRESSED_RGBA_PVRTC_2BPPV1),
STRONG_GLENUM_VALUE(R11F_G11F_B10F),
STRONG_GLENUM_VALUE(RGB9_E5),
STRONG_GLENUM_VALUE(SRGB),
STRONG_GLENUM_VALUE(SRGB8),
STRONG_GLENUM_VALUE(SRGB_ALPHA),
STRONG_GLENUM_VALUE(SRGB8_ALPHA8),
STRONG_GLENUM_VALUE(ATC_RGB),
STRONG_GLENUM_VALUE(ATC_RGBA_EXPLICIT_ALPHA),
STRONG_GLENUM_VALUE(DEPTH_COMPONENT32F),
STRONG_GLENUM_VALUE(DEPTH32F_STENCIL8),
STRONG_GLENUM_VALUE(RGB565),
STRONG_GLENUM_VALUE(ETC1_RGB8_OES),
STRONG_GLENUM_VALUE(RGBA32UI),
STRONG_GLENUM_VALUE(RGB32UI),
STRONG_GLENUM_VALUE(RGBA16UI),
STRONG_GLENUM_VALUE(RGB16UI),
STRONG_GLENUM_VALUE(RGBA8UI),
STRONG_GLENUM_VALUE(RGB8UI),
STRONG_GLENUM_VALUE(RGBA32I),
STRONG_GLENUM_VALUE(RGB32I),
STRONG_GLENUM_VALUE(RGBA16I),
STRONG_GLENUM_VALUE(RGB16I),
STRONG_GLENUM_VALUE(RGBA8I),
STRONG_GLENUM_VALUE(RGB8I),
STRONG_GLENUM_VALUE(R8_SNORM),
STRONG_GLENUM_VALUE(RG8_SNORM),
STRONG_GLENUM_VALUE(RGB8_SNORM),
STRONG_GLENUM_VALUE(RGBA8_SNORM),
STRONG_GLENUM_VALUE(RGB10_A2UI),
STRONG_GLENUM_END(TexInternalFormat)
#endif

View File

@ -138,7 +138,7 @@ WebGLTexture::Bind(TexTarget aTexTarget) {
void
WebGLTexture::SetImageInfo(TexImageTarget aTexImageTarget, GLint aLevel,
GLsizei aWidth, GLsizei aHeight,
GLenum aFormat, GLenum aType, WebGLImageDataStatus aStatus)
TexInternalFormat aFormat, TexType aType, WebGLImageDataStatus aStatus)
{
MOZ_ASSERT(TexImageTargetToTexTarget(aTexImageTarget) == mTarget);
if (TexImageTargetToTexTarget(aTexImageTarget) != mTarget)
@ -459,7 +459,7 @@ ClearByMask(WebGLContext* context, GLbitfield mask)
static bool
ClearWithTempFB(WebGLContext* context, GLuint tex,
TexImageTarget texImageTarget, GLint level,
GLenum baseInternalFormat,
TexInternalFormat baseInternalFormat,
GLsizei width, GLsizei height)
{
if (texImageTarget != LOCAL_GL_TEXTURE_2D)
@ -472,7 +472,7 @@ ClearWithTempFB(WebGLContext* context, GLuint tex,
gl::ScopedBindFramebuffer autoFB(gl, fb.FB());
GLbitfield mask = 0;
switch (baseInternalFormat) {
switch (baseInternalFormat.get()) {
case LOCAL_GL_LUMINANCE:
case LOCAL_GL_LUMINANCE_ALPHA:
case LOCAL_GL_ALPHA:
@ -542,8 +542,8 @@ WebGLTexture::DoDeferredImageInitialization(TexImageTarget imageTarget, GLint le
mContext->MakeContextCurrent();
// Try to clear with glCLear.
GLenum format = imageInfo.mWebGLFormat;
GLenum type = imageInfo.mWebGLType;
TexInternalFormat format = imageInfo.mWebGLFormat;
TexType type = imageInfo.mWebGLType;
WebGLTexelFormat texelformat = GetWebGLTexelFormat(format, type);
bool cleared = ClearWithTempFB(mContext, GLName(),

View File

@ -74,8 +74,8 @@ public:
ImageInfo(GLsizei width,
GLsizei height,
GLenum webGLFormat,
GLenum webGLType,
TexInternalFormat webGLFormat,
TexType webGLType,
WebGLImageDataStatus status)
: WebGLRectangleObject(width, height)
, mWebGLFormat(webGLFormat)
@ -114,16 +114,16 @@ public:
* It can be converted to a value to be passed to driver with
* DriverFormatsFromFormatAndType().
*/
GLenum WebGLFormat() const { return mWebGLFormat; }
TexInternalFormat WebGLFormat() const { return mWebGLFormat; }
/*! This is the type passed from JS to WebGL.
* It can be converted to a value to be passed to driver with
* DriverTypeFromType().
*/
GLenum WebGLType() const { return mWebGLType; }
TexType WebGLType() const { return mWebGLType; }
protected:
GLenum mWebGLFormat; //!< This is the WebGL/GLES format
GLenum mWebGLType; //!< This is the WebGL/GLES type
TexInternalFormat mWebGLFormat; //!< This is the WebGL/GLES format
TexType mWebGLType; //!< This is the WebGL/GLES type
WebGLImageDataStatus mImageDataStatus;
friend class WebGLTexture;
@ -225,7 +225,7 @@ public:
void SetImageInfo(TexImageTarget aTarget, GLint aLevel,
GLsizei aWidth, GLsizei aHeight,
GLenum aFormat, GLenum aType, WebGLImageDataStatus aStatus);
TexInternalFormat aFormat, TexType aType, WebGLImageDataStatus aStatus);
void SetMinFilter(GLenum aMinFilter) {
mMinFilter = aMinFilter;