Module: wine Branch: master Commit: 2128125cbfe2893e65b1093b583b15084261f265 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2128125cbfe2893e65b1093b58...
Author: Ken Thomases ken@codeweavers.com Date: Thu Feb 2 15:16:27 2017 -0600
winemac: Reattach OpenGL contexts to a view after it has been hidden and unhidden.
Hiding a view seems to semi-detach any attached OpenGL contexts such that rendering no longer works. There's no GL surface for the view. Calling -[NSOpenGLContext update] is not sufficient to reattach the context. So, fully detach the contexts and reattach them.
Signed-off-by: Ken Thomases ken@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winemac.drv/cocoa_opengl.h | 2 ++ dlls/winemac.drv/cocoa_opengl.m | 15 +++++++++++++-- dlls/winemac.drv/cocoa_window.m | 35 ++++++++++++++++++++++++++++------- 3 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_opengl.h b/dlls/winemac.drv/cocoa_opengl.h index e7e1686..bcd257f 100644 --- a/dlls/winemac.drv/cocoa_opengl.h +++ b/dlls/winemac.drv/cocoa_opengl.h @@ -25,12 +25,14 @@ { NSView* latentView; BOOL needsUpdate; + BOOL needsReattach; BOOL shouldClearToBlack;
GLint backing_size[2]; }
@property BOOL needsUpdate; +@property BOOL needsReattach; @property BOOL shouldClearToBlack;
@end diff --git a/dlls/winemac.drv/cocoa_opengl.m b/dlls/winemac.drv/cocoa_opengl.m index debeb78..5a097a1 100644 --- a/dlls/winemac.drv/cocoa_opengl.m +++ b/dlls/winemac.drv/cocoa_opengl.m @@ -35,7 +35,7 @@
@implementation WineOpenGLContext -@synthesize latentView, needsUpdate, shouldClearToBlack; +@synthesize latentView, needsUpdate, needsReattach, shouldClearToBlack;
- (void) dealloc { @@ -215,6 +215,7 @@ [self setLatentView:nil]; } needsUpdate = FALSE; + needsReattach = FALSE; }
@end @@ -279,6 +280,7 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v, CGRect if (context.needsUpdate) { context.needsUpdate = FALSE; + context.needsReattach = FALSE; if (context.view) [context setView:[[context class] dummyView]]; [context wine_updateBackingSize:&r.size]; @@ -328,7 +330,9 @@ void macdrv_update_opengl_context(macdrv_opengl_context c)
if (context.needsUpdate) { + BOOL reattach = context.needsReattach; context.needsUpdate = FALSE; + context.needsReattach = FALSE; if (context.latentView) { [context setView:context.latentView]; @@ -339,7 +343,14 @@ void macdrv_update_opengl_context(macdrv_opengl_context c) } else { - [context update]; + if (reattach) + { + NSView* view = [[context.view retain] autorelease]; + [context clearDrawableLeavingSurfaceOnScreen]; + context.view = view; + } + else + [context update]; [context resetSurfaceIfBackingSizeChanged]; } } diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 57587d9..118bf3c 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -500,10 +500,19 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi [(WineWindow*)[self window] updateForGLSubviews]; }
- - (void) updateGLContexts + - (void) updateGLContexts:(BOOL)reattach { for (WineOpenGLContext* context in glContexts) + { context.needsUpdate = TRUE; + if (reattach) + context.needsReattach = TRUE; + } + } + + - (void) updateGLContexts + { + [self updateGLContexts:NO]; }
- (BOOL) hasGLContext @@ -605,6 +614,23 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi return NO; }
+ - (void) viewDidHide + { + [super viewDidHide]; + if ([self hasGLContext]) + [self invalidateHasGLDescendant]; + } + + - (void) viewDidUnhide + { + [super viewDidUnhide]; + if ([self hasGLContext]) + { + [self updateGLContexts:YES]; + [self invalidateHasGLDescendant]; + } + } + - (void) completeText:(NSString*)text { macdrv_event* event; @@ -651,12 +677,6 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi [super willRemoveSubview:subview]; }
- - (void) setHidden:(BOOL)hidden - { - [super setHidden:hidden]; - [self invalidateHasGLDescendant]; - } - /* * ---------- NSTextInputClient methods ---------- */ @@ -3432,6 +3452,7 @@ void macdrv_set_view_hidden(macdrv_view v, int hidden)
OnMainThreadAsync(^{ [view setHidden:hidden]; + [(WineWindow*)view.window updateForGLSubviews]; });
[pool release];