winemac: Move test for valid GL drawable into -[WineContentView addGLContext:].

Improves encapsulation.  Avoids a round trip to the main thread.
This commit is contained in:
Ken Thomases 2013-11-27 15:32:46 -06:00 committed by Alexandre Julliard
parent 6d0d018bfa
commit fd04552fe3
2 changed files with 15 additions and 10 deletions

View File

@ -123,16 +123,11 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v)
context.needsUpdate = FALSE; context.needsUpdate = FALSE;
if (view) if (view)
{ {
__block BOOL viewIsValidDrawable;
macdrv_add_view_opengl_context(v, c); macdrv_add_view_opengl_context(v, c);
OnMainThread(^{ if (context.needsUpdate)
viewIsValidDrawable = [[view window] windowNumber] > 0 &&
!NSIsEmptyRect([view visibleRect]);
});
if (viewIsValidDrawable)
{ {
context.needsUpdate = FALSE;
[context setView:view]; [context setView:view];
[context setLatentView:nil]; [context setLatentView:nil];
} }

View File

@ -294,8 +294,18 @@ - (void) addGLContext:(WineOpenGLContext*)context
glContexts = [[NSMutableArray alloc] init]; glContexts = [[NSMutableArray alloc] init];
if (!pendingGlContexts) if (!pendingGlContexts)
pendingGlContexts = [[NSMutableArray alloc] init]; 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]; [(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; WineContentView* view = (WineContentView*)v;
WineOpenGLContext *context = (WineOpenGLContext*)c; WineOpenGLContext *context = (WineOpenGLContext*)c;
OnMainThreadAsync(^{ OnMainThread(^{
[view addGLContext:context]; [view addGLContext:context];
}); });