aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2013-11-21 00:44:48 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-11-21 00:44:48 +0000
commit16e5b7de95fd4c8b5a7ecd8c08aef7fa24d10b91 (patch)
tree656fd2992afa1cfaec8ca6ce1aef558f52a4094c /emulator
parent223f27f9cf923747a6e0ea590a3483a23ab2abc7 (diff)
parent8ec69cad99dc499637625d2e021c163f991d2ccb (diff)
downloadsdk-16e5b7de95fd4c8b5a7ecd8c08aef7fa24d10b91.zip
sdk-16e5b7de95fd4c8b5a7ecd8c08aef7fa24d10b91.tar.gz
sdk-16e5b7de95fd4c8b5a7ecd8c08aef7fa24d10b91.tar.bz2
Merge "EglMacApi: Make sure that some returned EGL configs have alpha == 0"
Diffstat (limited to 'emulator')
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp10
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/MacNative.h1
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/MacNative.m28
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];