Bug 749538 - Check 24bpp/RGBX_8888 and 32bpp/RGBA_8888 when validating EGL Contexts. r=vlad

This commit is contained in:
Marshall Culpepper 2012-07-07 10:06:59 -04:00
Родитель d25eaaf52d
Коммит b5ce25615a
1 изменённых файлов: 26 добавлений и 3 удалений

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

@ -1498,6 +1498,14 @@ static const EGLint kEGLConfigAttribsRGB16[] = {
LOCAL_EGL_NONE
};
static const EGLint kEGLConfigAttribsRGB24[] = {
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_WINDOW_BIT,
LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
LOCAL_EGL_RED_SIZE, 8,
LOCAL_EGL_GREEN_SIZE, 8,
LOCAL_EGL_BLUE_SIZE, 8,
LOCAL_EGL_NONE
};
static const EGLint kEGLConfigAttribsRGBA32[] = {
LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_WINDOW_BIT,
@ -1513,10 +1521,24 @@ static bool
CreateConfig(EGLConfig* aConfig, PRInt32 depth)
{
EGLConfig configs[64];
const EGLint* attribs = depth == 16 ? kEGLConfigAttribsRGB16 :
kEGLConfigAttribsRGBA32;
const EGLint* attribs;
EGLint ncfg = ArrayLength(configs);
switch (depth) {
case 16:
attribs = kEGLConfigAttribsRGB16;
break;
case 24:
attribs = kEGLConfigAttribsRGB24;
break;
case 32:
attribs = kEGLConfigAttribsRGBA32;
break;
default:
NS_ERROR("Unknown pixel depth");
return false;
}
if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(), attribs,
configs, ncfg, &ncfg) ||
ncfg < 1) {
@ -1536,7 +1558,8 @@ CreateConfig(EGLConfig* aConfig, PRInt32 depth)
sEGLLibrary.fGetConfigAttrib(EGL_DISPLAY(), config,
LOCAL_EGL_ALPHA_SIZE, &a) &&
((depth == 16 && r == 5 && g == 6 && b == 5) ||
(depth == 24 && r == 8 && g == 8 && b == 8 && a == 8)))
(depth == 24 && r == 8 && g == 8 && b == 8) ||
(depth == 32 && r == 8 && g == 8 && b == 8 && a == 8)))
{
*aConfig = config;
return true;