Bug 958369 - 1/5 - Make GLFeature a typed enum - r=jgilbert

This commit is contained in:
Benoit Jacob 2014-01-10 13:55:23 -05:00
Родитель bba51d87ca
Коммит b05e26dc69
3 изменённых файлов: 49 добавлений и 55 удалений

Просмотреть файл

@ -72,7 +72,7 @@ WebGLContext::InitWebGL2()
WEBGL_depth_texture,
WEBGL_draw_buffers
};
const GLFeature::Enum sFeatureRequiredArr[] = {
const GLFeature sFeatureRequiredArr[] = {
GLFeature::blend_minmax,
GLFeature::instanced_non_arrays,
GLFeature::transform_feedback

Просмотреть файл

@ -81,12 +81,7 @@ namespace mozilla {
namespace mozilla {
namespace gl {
/** GLFeature::Enum
* We don't use typed enum to keep the implicit integer conversion.
* This enum should be sorted by name.
*/
namespace GLFeature {
enum Enum {
MOZ_BEGIN_ENUM_CLASS(GLFeature)
bind_buffer_offset,
blend_minmax,
depth_texture,
@ -115,8 +110,7 @@ namespace GLFeature {
transform_feedback,
vertex_array_object,
EnumMax
};
}
MOZ_END_ENUM_CLASS(GLFeature)
MOZ_BEGIN_ENUM_CLASS(ContextProfile, uint8_t)
Unknown = 0,
@ -473,15 +467,15 @@ protected:
* by the context version/profile
*/
public:
bool IsSupported(GLFeature::Enum feature) const {
return mAvailableFeatures[feature];
bool IsSupported(GLFeature feature) const {
return mAvailableFeatures[size_t(feature)];
}
static const char* GetFeatureName(GLFeature::Enum feature);
static const char* GetFeatureName(GLFeature feature);
private:
std::bitset<GLFeature::EnumMax> mAvailableFeatures;
std::bitset<size_t(GLFeature::EnumMax)> mAvailableFeatures;
/**
* Init features regarding OpenGL extension and context version and profile
@ -491,7 +485,7 @@ private:
/**
* Mark the feature and associated extensions as unsupported
*/
void MarkUnsupported(GLFeature::Enum feature);
void MarkUnsupported(GLFeature feature);
// -----------------------------------------------------------------------------
// Robustness handling

Просмотреть файл

@ -325,7 +325,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
};
static inline const FeatureInfo&
GetFeatureInfo(GLFeature::Enum feature)
GetFeatureInfo(GLFeature feature)
{
static_assert(MOZ_ARRAY_LENGTH(sFeatureInfoArr) == size_t(GLFeature::EnumMax),
"Mismatched lengths for sFeatureInfoInfos and GLFeature enums");
@ -333,11 +333,11 @@ GetFeatureInfo(GLFeature::Enum feature)
MOZ_ASSERT(feature < GLFeature::EnumMax,
"GLContext::GetFeatureInfoInfo : unknown <feature>");
return sFeatureInfoArr[feature];
return sFeatureInfoArr[size_t(feature)];
}
static inline uint32_t
ProfileVersionForFeature(GLFeature::Enum feature, ContextProfile profile)
ProfileVersionForFeature(GLFeature feature, ContextProfile profile)
{
MOZ_ASSERT(profile != ContextProfile::Unknown,
"GLContext::ProfileVersionForFeature : unknown <profile>");
@ -352,7 +352,7 @@ ProfileVersionForFeature(GLFeature::Enum feature, ContextProfile profile)
}
static inline bool
IsFeatureIsPartOfProfileVersion(GLFeature::Enum feature,
IsFeatureIsPartOfProfileVersion(GLFeature feature,
ContextProfile profile, unsigned int version)
{
unsigned int profileVersion = ProfileVersionForFeature(feature, profile);
@ -365,7 +365,7 @@ IsFeatureIsPartOfProfileVersion(GLFeature::Enum feature,
}
const char*
GLContext::GetFeatureName(GLFeature::Enum feature)
GLContext::GetFeatureName(GLFeature feature)
{
return GetFeatureInfo(feature).mName;
}
@ -391,16 +391,16 @@ CanReadSRGBFromFBOTexture(GLContext* gl)
void
GLContext::InitFeatures()
{
for (size_t i = 0; i < GLFeature::EnumMax; i++)
for (size_t feature_index = 0; feature_index < size_t(GLFeature::EnumMax); feature_index++)
{
GLFeature::Enum feature = GLFeature::Enum(i);
GLFeature feature = GLFeature(feature_index);
if (IsFeatureIsPartOfProfileVersion(feature, mProfile, mVersion)) {
mAvailableFeatures[feature] = true;
mAvailableFeatures[feature_index] = true;
continue;
}
mAvailableFeatures[feature] = false;
mAvailableFeatures[feature_index] = false;
const FeatureInfo& featureInfo = GetFeatureInfo(feature);
@ -413,7 +413,7 @@ GLContext::InitFeatures()
}
if (IsExtensionSupported(featureInfo.mExtensions[j])) {
mAvailableFeatures[feature] = true;
mAvailableFeatures[feature_index] = true;
break;
}
}
@ -427,15 +427,15 @@ GLContext::InitFeatures()
(IsExtensionSupported(ARB_framebuffer_sRGB) ||
IsExtensionSupported(EXT_framebuffer_sRGB));
mAvailableFeatures[GLFeature::sRGB] =
mAvailableFeatures[size_t(GLFeature::sRGB)] =
aresRGBExtensionsAvailable &&
CanReadSRGBFromFBOTexture(this);
}
void
GLContext::MarkUnsupported(GLFeature::Enum feature)
GLContext::MarkUnsupported(GLFeature feature)
{
mAvailableFeatures[feature] = false;
mAvailableFeatures[size_t(feature)] = false;
const FeatureInfo& featureInfo = GetFeatureInfo(feature);