Module: wine Branch: master Commit: 4124478b8526d04b0049aae980c0674230136cc7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4124478b8526d04b0049aae980...
Author: Ken Thomases ken@codeweavers.com Date: Wed Nov 27 15:33:19 2013 -0600
winemac: Clear OpenGL views to black the first time a context is attached.
This prevents VRAM garbage from being displayed before the program draws.
---
dlls/winemac.drv/cocoa_opengl.h | 2 ++ dlls/winemac.drv/cocoa_opengl.m | 33 ++++++++++++++++++++++++++++++++- dlls/winemac.drv/cocoa_window.m | 13 +++++++++++++ 3 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/dlls/winemac.drv/cocoa_opengl.h b/dlls/winemac.drv/cocoa_opengl.h index 60e8c16..2cdcdbd 100644 --- a/dlls/winemac.drv/cocoa_opengl.h +++ b/dlls/winemac.drv/cocoa_opengl.h @@ -25,8 +25,10 @@ { NSView* latentView; BOOL needsUpdate; + BOOL shouldClearToBlack; }
@property BOOL needsUpdate; +@property BOOL shouldClearToBlack;
@end diff --git a/dlls/winemac.drv/cocoa_opengl.m b/dlls/winemac.drv/cocoa_opengl.m index 85b3639..13b9ea3 100644 --- a/dlls/winemac.drv/cocoa_opengl.m +++ b/dlls/winemac.drv/cocoa_opengl.m @@ -30,7 +30,7 @@
@implementation WineOpenGLContext -@synthesize latentView, needsUpdate; +@synthesize latentView, needsUpdate, shouldClearToBlack;
- (void) dealloc { @@ -63,6 +63,32 @@ [self clearDrawable]; }
+ - (void) clearToBlackIfNeeded + { + if (shouldClearToBlack) + { + NSOpenGLContext* origContext = [NSOpenGLContext currentContext]; + + [self makeCurrentContext]; + + glPushAttrib(GL_COLOR_BUFFER_BIT | GL_SCISSOR_BIT); + glDrawBuffer(GL_FRONT_AND_BACK); + glDisable(GL_SCISSOR_TEST); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + glPopAttrib(); + glFlush(); + + if (origContext) + [origContext makeCurrentContext]; + else + [NSOpenGLContext clearCurrentContext]; + + shouldClearToBlack = FALSE; + } + } + @end
@@ -135,6 +161,9 @@ void macdrv_make_context_current(macdrv_opengl_context c, macdrv_view v) [context setLatentView:view];
[context makeCurrentContext]; + + if ([context view]) + [context clearToBlackIfNeeded]; } else { @@ -163,6 +192,8 @@ void macdrv_update_opengl_context(macdrv_opengl_context c) { [context setView:context.latentView]; context.latentView = nil; + + [context clearToBlackIfNeeded]; } else [context update]; diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 74fa191..6fa6ee8 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -154,6 +154,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif { NSMutableArray* glContexts; NSMutableArray* pendingGlContexts; + BOOL clearedGlSurface;
NSMutableAttributedString* markedText; NSRange markedTextSelection; @@ -221,7 +222,14 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif WineWindow* window = (WineWindow*)[self window];
for (WineOpenGLContext* context in pendingGlContexts) + { + if (!clearedGlSurface) + { + context.shouldClearToBlack = TRUE; + clearedGlSurface = TRUE; + } context.needsUpdate = TRUE; + } [glContexts addObjectsFromArray:pendingGlContexts]; [pendingGlContexts removeAllObjects];
@@ -298,6 +306,11 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif if ([[self window] windowNumber] > 0 && !NSIsEmptyRect([self visibleRect])) { [glContexts addObject:context]; + if (!clearedGlSurface) + { + context.shouldClearToBlack = TRUE; + clearedGlSurface = TRUE; + } context.needsUpdate = TRUE; } else