diff options
author | Martin Storsjo <martin@martin.st> | 2013-09-25 14:14:27 +0300 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2013-09-25 14:14:27 +0300 |
commit | 8ec69cad99dc499637625d2e021c163f991d2ccb (patch) | |
tree | 8b3c65adb31e66b28268172954c28b92c0023c75 /emulator | |
parent | acbf16e065f27550c5baffe7e4fcd20ff974d435 (diff) | |
download | sdk-8ec69cad99dc499637625d2e021c163f991d2ccb.zip sdk-8ec69cad99dc499637625d2e021c163f991d2ccb.tar.gz sdk-8ec69cad99dc499637625d2e021c163f991d2ccb.tar.bz2 |
EglMacApi: Make sure that some returned EGL configs have alpha == 0
This is what the pixel format attribute lists in
MacPixelFormatsAttribs.m try to achieve, but despite this, alpha
is nonzero in every returned configuration on certain (all?)
machines (at least on 10.8.5 on a nvidia gpu). This means that
EGL won't return any configs at all with alpha == 0.
The default config chooser in GLSurfaceView requires a config with
alpha == 0. This means that previously, this view failed to start up
on the emulator on OS X, unless set up with a non-default config
chooser.
Change-Id: I2bf3e92a026c525a97d6746e491d920ce127787f
Diffstat (limited to 'emulator')
-rw-r--r-- | emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp | 10 | ||||
-rw-r--r-- | emulator/opengl/host/libs/Translator/EGL/MacNative.h | 1 | ||||
-rw-r--r-- | emulator/opengl/host/libs/Translator/EGL/MacNative.m | 28 |
3 files changed, 38 insertions, 1 deletions
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp b/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp index 31527af..eeaa25c 100644 --- a/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp +++ b/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp @@ -68,7 +68,15 @@ static EglConfig* pixelFormatToConfig(int index,int renderableType,EGLNativePixe getPixelFormatAttrib(*frmt,MAC_SAMPLES_PER_PIXEL,&samples); getPixelFormatAttrib(*frmt,MAC_COLOR_SIZE,&colorSize); - getPixelFormatAttrib(*frmt,MAC_ALPHA_SIZE,&alpha); + /* All configs can end up having an alpha channel even if none was requested. + * The default config chooser in GLSurfaceView will therefore not find any + * matching config. Thus, make sure alpha is zero (or at least signalled as + * zero to the calling EGL layer) for the configs where it was intended to + * be zero. */ + if (getPixelFormatDefinitionAlpha(index) == 0) + alpha = 0; + else + getPixelFormatAttrib(*frmt,MAC_ALPHA_SIZE,&alpha); getPixelFormatAttrib(*frmt,MAC_DEPTH_SIZE,&depth); getPixelFormatAttrib(*frmt,MAC_STENCIL_SIZE,&stencil); diff --git a/emulator/opengl/host/libs/Translator/EGL/MacNative.h b/emulator/opengl/host/libs/Translator/EGL/MacNative.h index 82ab667..c8a1df2 100644 --- a/emulator/opengl/host/libs/Translator/EGL/MacNative.h +++ b/emulator/opengl/host/libs/Translator/EGL/MacNative.h @@ -33,6 +33,7 @@ extern "C"{ int getNumPixelFormats(); void* getPixelFormat(int i); +int getPixelFormatDefinitionAlpha(int i); void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val); void* nsCreateContext(void* format,void* share); void nsWindowMakeCurrent(void* context,void* nativeWin); diff --git a/emulator/opengl/host/libs/Translator/EGL/MacNative.m b/emulator/opengl/host/libs/Translator/EGL/MacNative.m index 6828655..a2cea93 100644 --- a/emulator/opengl/host/libs/Translator/EGL/MacNative.m +++ b/emulator/opengl/host/libs/Translator/EGL/MacNative.m @@ -75,6 +75,34 @@ void* getPixelFormat(int i){ return [[NSOpenGLPixelFormat alloc] initWithAttributes:attrib_lists[i]]; } +int getPixelFormatDefinitionAlpha(int i) { + int size; + NSOpenGLPixelFormatAttribute** attrib_lists = getPixelFormatsAttributes(&size); + NSOpenGLPixelFormatAttribute* attribs = attrib_lists[i]; + while (*attribs) { + switch (*attribs) { + // These are the ones that take a value, according to the current + // NSOpenGLPixelFormat docs + case NSOpenGLPFAAuxBuffers: + case NSOpenGLPFAColorSize: + case NSOpenGLPFADepthSize: + case NSOpenGLPFAStencilSize: + case NSOpenGLPFAAccumSize: + case NSOpenGLPFARendererID: + case NSOpenGLPFAScreenMask: + attribs += 2; + break; + case NSOpenGLPFAAlphaSize: + return attribs[1]; + break; + // All other attributes are boolean attributes that don't take a value + default: + attribs++; + } + } + return 0; +} + void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val){ NSOpenGLPixelFormat *frmt = (NSOpenGLPixelFormat *)pixelFormat; [frmt getValues:val forAttribute:attrib forVirtualScreen:0]; |