[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx:[767] trunk/fuse/fusepb/views/DisplayOpenGLVi
Brought to you by:
fredm
From: <fr...@us...> - 2013-12-25 12:41:07
|
Revision: 767 http://sourceforge.net/p/fuse-for-macosx/code/767 Author: fredm Date: 2013-12-25 12:41:05 +0000 (Wed, 25 Dec 2013) Log Message: ----------- Make sure we lock the view if we are going to access the OpenGL context as the displaylink callback is not on the main thread where resizing-related drawing will occur, also cover the screen texture swap. Expect to resolve [#14]. Modified Paths: -------------- trunk/fuse/fusepb/views/DisplayOpenGLView.m Modified: trunk/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- trunk/fuse/fusepb/views/DisplayOpenGLView.m 2013-12-25 12:38:34 UTC (rev 766) +++ trunk/fuse/fusepb/views/DisplayOpenGLView.m 2013-12-25 12:41:05 UTC (rev 767) @@ -1295,7 +1295,10 @@ long rowbytes = size.width * 4; rowbytes = (rowbytes + 3)& ~3; // ctx rowbytes is always multiple of 4, per glGrab unsigned char* bitmap = malloc(rowbytes * size.height); - + + // Stuffing around with OpenGL context - lock view while we do + [view_lock lock]; + [[NSOpenGLContext currentContext] makeCurrentContext]; glFinish(); // finish any pending OpenGL commands glPushAttrib(GL_ALL_ATTRIB_BITS); // reset all properties that affect glReadPixels, in case app was using them @@ -1342,6 +1345,8 @@ glReadPixels(0, 0, size.width, size.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, bitmap); glPopAttrib(); + [view_lock unlock]; + [self lockFocus]; // create a CGImageRef from the memory block CGDataProviderDirectCallbacks gProviderCallbacks = { 0, get_byte_pointer, NULL, NULL, NULL }; @@ -1409,11 +1414,17 @@ if( buffered_screen.dirty->count > 0 ) { + // Make sure we lock the view if we are going to update the textures so + // there is no concurrent access to the OpenGL context as the displaylink + // callback is not on the main thread where resizing-related drawing will + // occur, also cover the screen texture swap + [view_lock lock]; + if (screenTex[currentScreenTex].dirty) pig_dirty_copy( &workdirty, screenTex[currentScreenTex].dirty ); - + currentScreenTex = !currentScreenTex; - + pig_dirty_copy( &screenTex[currentScreenTex].dirty, buffered_screen.dirty ); if( workdirty ) @@ -1429,7 +1440,7 @@ buffered_screen.dirty->count = 0; pig_dirty_close( workdirty ); - + [[self openGLContext] makeCurrentContext]; /* Bind, update and draw new image */ @@ -1441,6 +1452,7 @@ GL_UNSIGNED_SHORT_1_5_5_5_REV, screenTex[currentScreenTex].pixels ); + [view_lock unlock]; } [buffered_screen_lock unlock]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |