From fd04552fe3d2acfc487192f7c6696526bd8c9950 Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Wed, 27 Nov 2013 15:32:46 -0600 Subject: [PATCH] winemac: Move test for valid GL drawable into -[WineContentView addGLContext:]. Improves encapsulation. Avoids a round trip to the main thread. --- dlls/winemac.drv/cocoa_opengl.m | 9 ++------- dlls/winemac.drv/cocoa_window.m | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/dlls/winemac.drv/cocoa_opengl.m b/dlls/winemac.drv/cocoa_opengl.m index 45799dba539..85b36397d16 100644 --- a/dlls/winemac.drv/cocoa_opengl.m +++ b/dlls/winemac.drv/cocoa_opengl.m @@ -123,16 +123,11 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v) context.needsUpdate = FALSE; if (view) { - __block BOOL viewIsValidDrawable; - macdrv_add_view_opengl_context(v, c); - OnMainThread(^{ - viewIsValidDrawable = [[view window] windowNumber] > 0 && - !NSIsEmptyRect([view visibleRect]); - }); - if (viewIsValidDrawable) + if (context.needsUpdate) { + context.needsUpdate = FALSE; [context setView:view]; [context setLatentView:nil]; } diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index a29f20e5e0b..74fa1911fa1 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -294,8 +294,18 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif glContexts = [[NSMutableArray alloc] init]; if (!pendingGlContexts) pendingGlContexts = [[NSMutableArray alloc] init]; - [pendingGlContexts addObject:context]; - [self setNeedsDisplay:YES]; + + if ([[self window] windowNumber] > 0 && !NSIsEmptyRect([self visibleRect])) + { + [glContexts addObject:context]; + context.needsUpdate = TRUE; + } + else + { + [pendingGlContexts addObject:context]; + [self setNeedsDisplay:YES]; + } + [(WineWindow*)[self window] updateColorSpace]; } @@ -2407,7 +2417,7 @@ void macdrv_add_view_opengl_context(macdrv_view v, macdrv_opengl_context c) WineContentView* view = (WineContentView*)v; WineOpenGLContext *context = (WineOpenGLContext*)c; - OnMainThreadAsync(^{ + OnMainThread(^{ [view addGLContext:context]; }); -- 2.11.4.GIT