From 946c98fd196802755e9e13a9c5db75650a564466 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 13 Oct 2011 03:33:28 +0200 Subject: JOGL/OSX: Properly utilize NSOpenGLContext update() via ContextUpdater, which only holds the 'update' state now. Avoid calling updater() for every makeCurrent(), but if view's frame has changed only. This solves the pixel flickering experienced on OSX. - GLContextImpl:update() -> drawableUpdatedNotify() w/ comments - ContextUpdater holds context, view, old view frame and the update state. It doesn't issue NSOpenGLContext update() by itself, but allows querying and clearing the update flag. - MacOSXOnscreenCGLContext impl drawableUpdatedNotify() - register via ContextUpdater, and use it if available. --- .../native/macosx/MacOSXWindowSystemInterface.m | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/jogl/native/macosx/MacOSXWindowSystemInterface.m') diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index 86d875502..aab70791c 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -590,7 +590,8 @@ Bool deleteContext(void* nsJContext) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [nsContext clearDrawable]; - [nsContext release]; // freezes for a few seconds if ctx is shared + // [nsContext release]; // FIXME: JAU: freezes for a few seconds if ctx is shared + // [nsContext dealloc]; [pool release]; return true; } @@ -624,15 +625,25 @@ void copyContext(void* destContext, void* srcContext, int mask) { [dst copyAttributesFromContext: src withMask: mask]; } -void* updateContextRegister(void* nsJContext, void* view) { +void* updateContextRegister(void* nsJContext, void* nsJView) { NSOpenGLContext *nsContext = (NSOpenGLContext*)nsJContext; - NSView *nsView = (NSView*)view; + NSView *nsView = (NSView*)nsJView; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - ContextUpdater *contextUpdater = [[ContextUpdater alloc] init]; - [contextUpdater registerFor:nsContext with:nsView]; + ContextUpdater *contextUpdater = [[ContextUpdater alloc] initWithContext: nsContext view: nsView]; [pool release]; - return NULL; + return contextUpdater; +} + +Bool updateContextNeedsUpdate(void* updater) { + ContextUpdater *contextUpdater = (ContextUpdater *)updater; + BOOL res; + + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + res = [contextUpdater needsUpdate]; + [pool release]; + + return ( res == TRUE ) ? true : false; } void updateContextUnregister(void* updater) { -- cgit v1.2.3