winemac: Clear OpenGL views to black the first time a context is attached.
This prevents VRAM garbage from being displayed before the program draws.
This commit is contained in:
parent
fd04552fe3
commit
4124478b85
|
@ -25,8 +25,10 @@ @interface WineOpenGLContext : NSOpenGLContext
|
|||
{
|
||||
NSView* latentView;
|
||||
BOOL needsUpdate;
|
||||
BOOL shouldClearToBlack;
|
||||
}
|
||||
|
||||
@property BOOL needsUpdate;
|
||||
@property BOOL shouldClearToBlack;
|
||||
|
||||
@end
|
||||
|
|
|
@ -30,7 +30,7 @@ @interface WineOpenGLContext ()
|
|||
|
||||
|
||||
@implementation WineOpenGLContext
|
||||
@synthesize latentView, needsUpdate;
|
||||
@synthesize latentView, needsUpdate, shouldClearToBlack;
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
|
@ -63,6 +63,32 @@ - (void) clearDrawableLeavingSurfaceOnScreen
|
|||
[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 @@ @interface WineContentView : NSView <NSTextInputClient>
|
|||
{
|
||||
NSMutableArray* glContexts;
|
||||
NSMutableArray* pendingGlContexts;
|
||||
BOOL clearedGlSurface;
|
||||
|
||||
NSMutableAttributedString* markedText;
|
||||
NSRange markedTextSelection;
|
||||
|
@ -221,7 +222,14 @@ - (void) drawRect:(NSRect)rect
|
|||
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 @@ - (void) addGLContext:(WineOpenGLContext*)context
|
|||
if ([[self window] windowNumber] > 0 && !NSIsEmptyRect([self visibleRect]))
|
||||
{
|
||||
[glContexts addObject:context];
|
||||
if (!clearedGlSurface)
|
||||
{
|
||||
context.shouldClearToBlack = TRUE;
|
||||
clearedGlSurface = TRUE;
|
||||
}
|
||||
context.needsUpdate = TRUE;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue