Use EGL_NATIVE_VISUAL_ID to select EGLConfig

EGLUtils::selectConfigForPixelFormat() now uses EGL_NATIVE_VISUAL_ID
to select a config with the proper format. this is more robust and
future proof.

Change-Id: I7245d904adab1e339f062b9b498ddd9324cfe7a4
This commit is contained in:
Mathias Agopian 2011-01-16 17:57:20 -08:00
parent 0b181742aa
commit d5ea3db6a3

View File

@ -66,12 +66,6 @@ status_t EGLUtils::selectConfigForPixelFormat(
if (outConfig == NULL)
return BAD_VALUE;
int err;
PixelFormatInfo fbFormatInfo;
if ((err = getPixelFormatInfo(PixelFormat(format), &fbFormatInfo)) < 0) {
return err;
}
// Get all the "potential match" configs...
if (eglGetConfigs(dpy, NULL, 0, &numConfigs) == EGL_FALSE)
return BAD_VALUE;
@ -81,23 +75,14 @@ status_t EGLUtils::selectConfigForPixelFormat(
free(configs);
return BAD_VALUE;
}
const int fbSzA = fbFormatInfo.getSize(PixelFormatInfo::INDEX_ALPHA);
const int fbSzR = fbFormatInfo.getSize(PixelFormatInfo::INDEX_RED);
const int fbSzG = fbFormatInfo.getSize(PixelFormatInfo::INDEX_GREEN);
const int fbSzB = fbFormatInfo.getSize(PixelFormatInfo::INDEX_BLUE);
int i;
EGLConfig config = NULL;
for (i=0 ; i<n ; i++) {
EGLint r,g,b,a;
EGLConfig curr = configs[i];
eglGetConfigAttrib(dpy, curr, EGL_RED_SIZE, &r);
eglGetConfigAttrib(dpy, curr, EGL_GREEN_SIZE, &g);
eglGetConfigAttrib(dpy, curr, EGL_BLUE_SIZE, &b);
eglGetConfigAttrib(dpy, curr, EGL_ALPHA_SIZE, &a);
if (fbSzA == a && fbSzR == r && fbSzG == g && fbSzB == b) {
config = curr;
EGLint nativeVisualId = 0;
eglGetConfigAttrib(dpy, configs[i], EGL_NATIVE_VISUAL_ID, &nativeVisualId);
if (nativeVisualId>0 && format == nativeVisualId) {
config = configs[i];
break;
}
}