am 87043c4e: Merge "opengl translator: added EGL_RENDERABLE_TYPE attrib"

* commit '87043c4e67c68cff7566265f4c4acb86482bf174':
  opengl translator: added EGL_RENDERABLE_TYPE attrib
This commit is contained in:
David Turner
2011-06-06 09:03:55 -07:00
committed by Android Git Automerger
10 changed files with 36 additions and 20 deletions

View File

@@ -27,6 +27,7 @@ EglConfig::EglConfig(EGLint red_size,
EGLint max_pbuffer_height,
EGLint max_pbuffer_size,
EGLBoolean native_renderable,
EGLint renderable_type,
EGLint native_visual_id,
EGLint native_visual_type,
EGLint samples_per_pixel,
@@ -55,6 +56,7 @@ EglConfig::EglConfig(EGLint red_size,
m_max_swap_interval(MAX_SWAP_INTERVAL),
m_min_swap_interval(MIN_SWAP_INTERVAL),
m_native_renderable(native_renderable),
m_renderable_type(renderable_type),
m_native_visual_id(native_visual_id),
m_native_visual_type(native_visual_type),
m_sample_buffers_num(samples_per_pixel > 0 ?1:0),
@@ -85,6 +87,7 @@ EglConfig::EglConfig(EGLint red_size,
m_max_swap_interval(conf.m_max_swap_interval),
m_min_swap_interval(conf.m_min_swap_interval),
m_native_renderable(conf.m_native_renderable),
m_renderable_type(conf.m_renderable_type),
m_native_visual_id(conf.m_native_visual_id),
m_native_visual_type(conf.m_native_visual_type),
m_sample_buffers_num(conf.m_sample_buffers_num),
@@ -158,6 +161,8 @@ bool EglConfig::getConfAttrib(EGLint attrib,EGLint* val) const {
case EGL_NATIVE_VISUAL_TYPE:
*val = m_native_visual_type;
break;
case EGL_RENDERABLE_TYPE:
*val = m_renderable_type;
case EGL_SAMPLE_BUFFERS:
*val = m_sample_buffers_num;
break;
@@ -279,6 +284,9 @@ bool EglConfig::choosen(const EglConfig& dummy) {
if(dummy.m_surface_type != EGL_DONT_CARE &&
((dummy.m_surface_type & m_surface_type) != dummy.m_surface_type)) return false;
if(dummy.m_renderable_type != EGL_DONT_CARE &&
((dummy.m_renderable_type & m_renderable_type) != dummy.m_renderable_type)) return false;
//passed all checks
return true;
}

View File

@@ -45,6 +45,7 @@ public:
EGLint max_pbuffer_height,
EGLint max_pbuffer_size,
EGLBoolean native_renderable,
EGLint renderable_type,
EGLint native_visual_id,
EGLint native_visual_type,
EGLint samples_per_pixel,
@@ -78,6 +79,7 @@ private:
const EGLint m_max_swap_interval;
const EGLint m_min_swap_interval;
const EGLBoolean m_native_renderable;
const EGLint m_renderable_type;
const EGLint m_native_visual_id;
const EGLint m_native_visual_type;
const EGLint m_sample_buffers_num;

View File

@@ -35,10 +35,10 @@ EglDisplay::~EglDisplay() {
EGLNativeDisplayType EglDisplay::nativeType(){return m_dpy;}
void EglDisplay::initialize() {
void EglDisplay::initialize(int renderableType) {
android::Mutex::Autolock mutex(m_lock);
m_initialized = true;
initConfigurations();
initConfigurations(renderableType);
m_configInitialized = true;
}
@@ -55,9 +55,9 @@ static bool compareEglConfigsPtrs(EglConfig* first,EglConfig* second) {
return *first < *second ;
}
void EglDisplay::initConfigurations() {
void EglDisplay::initConfigurations(int renderableType) {
if(m_configInitialized) return;
EglOS::queryConfigs(m_dpy,m_configs);
EglOS::queryConfigs(m_dpy,renderableType,m_configs);
m_configs.sort(compareEglConfigsPtrs);
}

View File

@@ -58,7 +58,7 @@ public:
ObjectNameManager* getManager(GLESVersion ver){ return &m_manager[ver];}
~EglDisplay();
void initialize();
void initialize(int renderableType);
void terminate();
bool isInitialize();
@@ -67,7 +67,7 @@ public:
bool destroyImageKHR(EGLImageKHR img);
private:
void initConfigurations();
void initConfigurations(int renderableType);
EGLNativeDisplayType m_dpy;
bool m_initialized;

View File

@@ -179,6 +179,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay display, EGLint *major, E
if(minor) *minor = MINOR;
__translator_getGLESIfaceFunc func = NULL;
int renderableType = EGL_OPENGL_ES_BIT;
if(!g_eglInfo->getIface(GLES_1_1)) {
func = loadIfaces(LIB_GLES_CM_NAME);
@@ -192,13 +193,13 @@ EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay display, EGLint *major, E
if(!g_eglInfo->getIface(GLES_2_0)) {
func = loadIfaces(LIB_GLES_V2_NAME);
if(func){
renderableType |= EGL_OPENGL_ES2_BIT;
g_eglInfo->setIface(func(&s_eglIface),GLES_2_0);
} else {
fprintf(stderr,"could not find ifaces for GLES 2.0\n");
return EGL_FALSE;
}
}
dpy->initialize();
dpy->initialize(renderableType);
return EGL_TRUE;
}
@@ -253,6 +254,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
//selection defaults
EGLint surface_type = EGL_WINDOW_BIT;
EGLint renderable_type = EGL_OPENGL_ES_BIT;
EGLBoolean bind_to_tex_rgb = EGL_DONT_CARE;
EGLBoolean bind_to_tex_rgba = EGL_DONT_CARE;
EGLenum caveat = EGL_DONT_CARE;
@@ -362,6 +364,9 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
case EGL_NATIVE_RENDERABLE:
native_renderable = attrib_list[i+1];
break;
case EGL_RENDERABLE_TYPE:
renderable_type = attrib_list[i+1];
break;
case EGL_NATIVE_VISUAL_TYPE:
native_visual_type = attrib_list[i+1];
break;
@@ -424,7 +429,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
}
EGLNativePixelFormatType tmpfrmt = PIXEL_FORMAT_INITIALIZER;
EglConfig dummy(red_size,green_size,blue_size,alpha_size,caveat,config_id,depth_size,
frame_buffer_level,0,0,0,native_renderable,0,native_visual_type,
frame_buffer_level,0,0,0,native_renderable,renderable_type,0,native_visual_type,
samples_per_pixel,stencil_size,surface_type,transparent_type,
trans_red_val,trans_green_val,trans_blue_val,tmpfrmt);

View File

@@ -26,11 +26,11 @@ bool releaseDisplay(EGLNativeDisplayType dpy) {
return false;
}
EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,EGLNativePixelFormatType* frmt){
EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,int renderableType,EGLNativePixelFormatType* frmt){
return NULL;
}
void queryConfigs(EGLNativeDisplayType dpy,ConfigsList& listOut) {
void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listOut) {
}
bool validNativeWin(EGLNativeDisplayType dpy, EGLNativeWindowType win) {

View File

@@ -32,7 +32,7 @@
namespace EglOS{
void queryConfigs(EGLNativeDisplayType dpy,ConfigsList& listOut);
void queryConfigs(EGLNativeDisplayType dpy,int renderable_type,ConfigsList& listOut);
bool releasePbuffer(EGLNativeDisplayType dis,EGLNativePbufferType pb);
bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx);
bool releaseDisplay(EGLNativeDisplayType dpy);

View File

@@ -34,6 +34,7 @@ bool EglValidate::confAttrib(EGLint attrib) {
case EGL_MAX_PBUFFER_PIXELS:
case EGL_MAX_SWAP_INTERVAL:
case EGL_MIN_SWAP_INTERVAL:
case EGL_RENDERABLE_TYPE:
case EGL_NATIVE_RENDERABLE:
case EGL_NATIVE_VISUAL_ID:
case EGL_NATIVE_VISUAL_TYPE:

View File

@@ -224,7 +224,7 @@ bool releaseDisplay(EGLNativeDisplayType dpy) {
EglConfig* pixelFormatToConfig(EGLNativeDisplayType display,EGLNativePixelFormatType* frmt,int index){
EglConfig* pixelFormatToConfig(EGLNativeDisplayType display,int renderableType,EGLNativePixelFormatType* frmt,int index){
EGLint red,green,blue,alpha,depth,stencil;
EGLint supportedSurfaces,visualType,visualId;
@@ -287,12 +287,12 @@ EglConfig* pixelFormatToConfig(EGLNativeDisplayType display,EGLNativePixelFormat
alpha = frmt->cAlphaBits;
depth = frmt->cDepthBits;
stencil = frmt->cStencilBits;
return new EglConfig(red,green,blue,alpha,caveat,(EGLint)index,depth,level,pMaxWidth,pMaxHeight,pMaxPixels,renderable,
return new EglConfig(red,green,blue,alpha,caveat,(EGLint)index,depth,level,pMaxWidth,pMaxHeight,pMaxPixels,renderable,renderableType,
visualId,visualType,samples,stencil,supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt);
}
void queryConfigs(EGLNativeDisplayType display,ConfigsList& listOut) {
void queryConfigs(EGLNativeDisplayType display,int renderableType,ConfigsList& listOut) {
PIXELFORMATDESCRIPTOR pfd;
int iPixelFormat = 1;
HDC dpy = display->getCurrentDC();
@@ -304,7 +304,7 @@ void queryConfigs(EGLNativeDisplayType display,ConfigsList& listOut) {
//inserting rest of formats
for(iPixelFormat;iPixelFormat < nFormats; iPixelFormat++) {
DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
EglConfig* pConfig = pixelFormatToConfig(display,&pfd,iPixelFormat);
EglConfig* pConfig = pixelFormatToConfig(display,renderableType,&pfd,iPixelFormat);
if(pConfig) listOut.push_back(pConfig);
}

View File

@@ -68,7 +68,7 @@ bool releaseDisplay(EGLNativeDisplayType dpy) {
return XCloseDisplay(dpy);
}
EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,EGLNativePixelFormatType* frmt){
EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,int renderableType,EGLNativePixelFormatType* frmt){
int bSize,red,green,blue,alpha,depth,stencil;
int supportedSurfaces,visualType,visualId;
@@ -133,15 +133,15 @@ EglConfig* pixelFormatToConfig(EGLNativeDisplayType dpy,EGLNativePixelFormatType
return new EglConfig(red,green,blue,alpha,caveat,configId,depth,level,pMaxWidth,pMaxHeight,
pMaxPixels,renderable,visualId,visualType,samples,stencil,
pMaxPixels,renderable,renderableType,visualId,visualType,samples,stencil,
supportedSurfaces,transparentType,tRed,tGreen,tBlue,*frmt);
}
void queryConfigs(EGLNativeDisplayType dpy,ConfigsList& listOut) {
void queryConfigs(EGLNativeDisplayType dpy,int renderableType,ConfigsList& listOut) {
int n;
EGLNativePixelFormatType* frmtList = glXGetFBConfigs(dpy,0,&n);
for(int i =0 ;i < n ; i++) {
EglConfig* conf = pixelFormatToConfig(dpy,&frmtList[i]);
EglConfig* conf = pixelFormatToConfig(dpy,renderableType,&frmtList[i]);
if(conf) listOut.push_back(conf);
}
XFree(frmtList);