Commit 4124478b authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Clear OpenGL views to black the first time a context is attached.

This prevents VRAM garbage from being displayed before the program draws.
parent fd04552f
......@@ -25,8 +25,10 @@
{
NSView* latentView;
BOOL needsUpdate;
BOOL shouldClearToBlack;
}
@property BOOL needsUpdate;
@property BOOL shouldClearToBlack;
@end
......@@ -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];
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment