opengl translator: Mac fixes for unbind context
Mac specific bug fix to support unbinding a context.
Removed NSOpenGLContext:clearDrawable call before binding
an NSView to the context to avoid re-paint of the view which
causes flash effect.
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
index 8ff8fae..492589d 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
@@ -117,7 +117,7 @@
bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) {
int r,g,b;
bool ret = nsGetWinDims(win,width,height);
-
+
cfg->getConfAttrib(EGL_RED_SIZE,&r);
cfg->getConfAttrib(EGL_GREEN_SIZE,&g);
cfg->getConfAttrib(EGL_BLUE_SIZE,&b);
@@ -156,6 +156,17 @@
}
bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){
+
+ // check for unbind
+ if (ctx == NULL && read == NULL && draw == NULL) {
+ nsWindowMakeCurrent(NULL, NULL);
+ return true;
+ }
+ else if (ctx == NULL || read == NULL || draw == NULL) {
+ // error !
+ return false;
+ }
+
//dont supporting diffrent read & draw surfaces on Mac
if(read->native() != draw->native()) return false;
switch(draw->type()){
diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m
index e240bc1..225a79f 100644
--- a/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m
+++ b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m
@@ -33,7 +33,7 @@
void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val){
NSOpenGLPixelFormat *frmt = (NSOpenGLPixelFormat *)pixelFormat;
- [frmt getValues:val forAttribute:attrib forVirtualScreen:0];
+ [frmt getValues:val forAttribute:attrib forVirtualScreen:0];
}
void* nsCreateContext(void* format,void* share){
@@ -60,12 +60,9 @@
NSView* win = (NSView *)nativeWin;
if(ctx == nil){
[NSOpenGLContext clearCurrentContext];
- } else {
- if(win != nil){
- [ctx clearDrawable];
- [ctx setView: win];
- [ctx makeCurrentContext];
- }
+ } else if (win != nil) {
+ [ctx setView: win];
+ [ctx makeCurrentContext];
}
}
@@ -93,11 +90,11 @@
void* nsCreatePBuffer(GLenum target,GLenum format,int maxMip,int width,int height){
- return [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:target
- textureInternalFormat:format
- textureMaxMipMapLevel:maxMip
+ return [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:target
+ textureInternalFormat:format
+ textureMaxMipMapLevel:maxMip
pixelsWide:width pixelsHigh:height];
-
+
}
void nsDestroyPBuffer(void* pbuffer){
@@ -129,7 +126,7 @@
int depth = (limit != 0) ? NSBitsPerPixelFromDepth(limit):
NSBitsPerPixelFromDepth(defaultLimit);
return depth >= colorSize;
-
+
}
}
return false;