Skip to content

Commit

Permalink
Quartz: Restore 1.2.14 behaviour of letting apps draw from background…
Browse files Browse the repository at this point in the history
… thread.

Strictly speaking, this isn't encouraged, but it's a regression.
  • Loading branch information
icculus committed Jan 3, 2012
1 parent af90e20 commit 6a9ef50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/video/quartz/SDL_QuartzVideo.h
Expand Up @@ -93,6 +93,7 @@ typedef struct SDL_PrivateVideoData {
const void *save_mode; /* original mode of the display */
CGDirectPaletteRef palette; /* palette of an 8-bit display */
NSOpenGLContext *gl_context; /* OpenGL rendering context */
NSGraphicsContext *nsgfx_context; /* Cocoa graphics context */
Uint32 width, height, bpp; /* frequently used data about the display */
Uint32 flags; /* flags for current mode, for teardown purposes */
Uint32 video_set; /* boolean; indicates if video was set correctly */
Expand Down Expand Up @@ -132,6 +133,7 @@ typedef struct SDL_PrivateVideoData {
#define allow_screensaver (this->hidden->allow_screensaver)
#define palette (this->hidden->palette)
#define gl_context (this->hidden->gl_context)
#define nsgfx_context (this->hidden->nsgfx_context)
#define device_width (this->hidden->width)
#define device_height (this->hidden->height)
#define device_bpp (this->hidden->bpp)
Expand Down
13 changes: 8 additions & 5 deletions src/video/quartz/SDL_QuartzVideo.m
Expand Up @@ -1149,9 +1149,8 @@ other blitting while waiting on the VBL (and hence results in higher framerates)
}

if (qz_window != nil) {
NSGraphicsContext *ctx;
ctx = [NSGraphicsContext graphicsContextWithWindow:qz_window];
[NSGraphicsContext setCurrentContext:ctx];
nsgfx_context = [NSGraphicsContext graphicsContextWithWindow:qz_window];
[NSGraphicsContext setCurrentContext:nsgfx_context];
}

/* Setup the new pixel format */
Expand Down Expand Up @@ -1507,8 +1506,12 @@ static void QZ_UpdateRects (_THIS, int numRects, SDL_Rect *rects)
}

else {
CGContextRef cgc = (CGContextRef)
[[NSGraphicsContext currentContext] graphicsPort];
NSGraphicsContext *ctx = [NSGraphicsContext currentContext];
if (ctx != nsgfx_context) { /* uhoh, you might be rendering from another thread... */
[NSGraphicsContext setCurrentContext:nsgfx_context];
ctx = nsgfx_context;
}
CGContextRef cgc = (CGContextRef) [ctx graphicsPort];
QZ_DrawResizeIcon (this);
CGContextFlush (cg_context);
CGImageRef image = CGBitmapContextCreateImage (cg_context);
Expand Down

0 comments on commit 6a9ef50

Please sign in to comment.