Index: src/video/quartz/SDL_QuartzVideo.h =================================================================== --- src/video/quartz/SDL_QuartzVideo.h (revision 4707) +++ src/video/quartz/SDL_QuartzVideo.h (working copy) @@ -93,7 +93,8 @@ Uint32 warp_flag; /* boolean; notify to event loop that a warp just occured */ Uint32 warp_ticks; /* timestamp when the warp occured */ NSWindow *window; /* Cocoa window to implement the SDL window */ - NSQuickDrawView *view; /* the window's view; draw 2D and OpenGL into this view */ + NSView *view; /* the window's view; draw 2D and OpenGL into this view */ + CGContextRef cg_context; /* CoreGraphics rendering context */ SDL_Surface *resize_icon; /* icon for the resize badge, we have to draw it by hand */ SDL_GrabMode current_grab_mode; /* default value is SDL_GRAB_OFF */ SDL_Rect **client_mode_list; /* resolution list to pass back to client */ @@ -113,7 +114,8 @@ Uint8 *current_buffer; /* the buffer being copied to the screen */ BOOL quit_thread; /* used to quit the async blitting thread */ SInt32 system_version; /* used to dis-/enable workarounds depending on the system version */ - + +#if SDL_LEGACY_QUICKDRAW ImageDescriptionHandle yuv_idh; MatrixRecordPtr yuv_matrix; DecompressorComponent yuv_codec; @@ -121,6 +123,7 @@ PlanarPixmapInfoYUV420 *yuv_pixmap; Sint16 yuv_width, yuv_height; CGrafPtr yuv_port; +#endif void *opengl_library; /* dynamically loaded OpenGL library. */ } SDL_PrivateVideoData; @@ -139,6 +142,7 @@ #define mode_flags (this->hidden->flags) #define qz_window (this->hidden->window) #define window_view (this->hidden->view) +#define cg_context (this->hidden->cg_context) #define video_set (this->hidden->video_set) #define warp_ticks (this->hidden->warp_ticks) #define warp_flag (this->hidden->warp_flag) @@ -156,6 +160,7 @@ #define cursor_should_be_visible (this->hidden->cursor_should_be_visible) #define cursor_visible (this->hidden->cursor_visible) #define sw_buffers (this->hidden->sw_buffers) +#define sw_contexts (this->hidden->sw_contexts) #define thread (this->hidden->thread) #define sem1 (this->hidden->sem1) #define sem2 (this->hidden->sem2) Index: src/video/quartz/SDL_QuartzGL.m =================================================================== --- src/video/quartz/SDL_QuartzGL.m (revision 4713) +++ src/video/quartz/SDL_QuartzGL.m (working copy) @@ -45,7 +45,8 @@ @implementation NSOpenGLContext (CGLContextAccess) - (CGLContextObj) cglContext; { - return _contextAuxiliary; +return NULL; // !!! FIXME + //return _contextAuxiliary; } @end Index: src/video/quartz/SDL_QuartzWindow.h =================================================================== --- src/video/quartz/SDL_QuartzWindow.h (revision 4707) +++ src/video/quartz/SDL_QuartzWindow.h (working copy) @@ -29,7 +29,7 @@ - (void)appDidHide:(NSNotification*)note; - (void)appWillUnhide:(NSNotification*)note; - (void)appDidUnhide:(NSNotification*)note; -- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag; +- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag; @end /* Delegate for our NSWindow to send SDLQuit() on close */ Index: src/video/quartz/SDL_QuartzWM.m =================================================================== --- src/video/quartz/SDL_QuartzWM.m (revision 4707) +++ src/video/quartz/SDL_QuartzWM.m (working copy) @@ -171,11 +171,7 @@ else { *p = [ window_view convertPoint:*p toView: nil ]; - - /* We need a workaround in OpenGL mode */ - if ( SDL_VideoSurface->flags & SDL_OPENGL ) { - p->y = [window_view frame].size.height - p->y; - } + p->y = [window_view frame].size.height - p->y; } } @@ -189,11 +185,7 @@ else { *p = [ window_view convertPoint:*p fromView: nil ]; - - /* We need a workaround in OpenGL mode */ - if ( SDL_VideoSurface != NULL && (SDL_VideoSurface->flags & SDL_OPENGL) ) { - p->y = [window_view frame].size.height - p->y; - } + p->y = [window_view frame].size.height - p->y; } } Index: src/video/quartz/SDL_QuartzYUV.m =================================================================== --- src/video/quartz/SDL_QuartzYUV.m (revision 4707) +++ src/video/quartz/SDL_QuartzYUV.m (working copy) @@ -48,10 +48,15 @@ } static int QZ_DisplayYUV (_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst) { - +#if SDL_LEGACY_QUICKDRAW OSErr err; CodecFlags flags; + int h; + char *p_dst, *p_src; + PixMapHandle hPixMap; + long theRowBytes; + if (dst->x != 0 || dst->y != 0) { SDL_SetError ("Need a dst at (0,0)"); @@ -81,27 +86,40 @@ codecFlagUseImageBuffer, &flags, nil ) != noErr ) ) { SDL_SetError ("DecompressSequenceFrameS failed"); + return TRUE; } - return err != noErr; + /* TODO: use CGContextDrawImage here too! Create two CGContextRefs the same way we + create two buffers, replace current_buffer with current_context and set it + appropriately in QZ_FlipDoubleBuffer. Use CTM instead of the above + SetIdentityMatrix thing. */ + hPixMap = GetGWorldPixMap(yuv_port); + p_src = GetPixBaseAddr(hPixMap); + theRowBytes = QTGetPixMapHandleRowBytes(hPixMap); + p_dst = SDL_VideoSurface->pixels + SDL_VideoSurface->offset; + for (h = dst->h; h--; ) { + SDL_memcpy (p_dst, p_src, dst->w * 4); + p_src += theRowBytes; + p_dst += SDL_VideoSurface->pitch; + } + SDL_Flip (SDL_VideoSurface); +#endif + return FALSE; } static void QZ_FreeHWYUV (_THIS, SDL_Overlay *overlay) { - +#if SDL_LEGACY_QUICKDRAW CDSequenceEnd (yuv_seq); ExitMovies(); + DisposeGWorld(yuv_port); SDL_free (overlay->hwfuncs); SDL_free (overlay->pitches); SDL_free (overlay->pixels); - if (SDL_VideoSurface->flags & SDL_FULLSCREEN) { - [ qz_window close ]; - qz_window = nil; - } - SDL_free (yuv_matrix); DisposeHandle ((Handle)yuv_idh); +#endif } /* check for 16 byte alignment, bail otherwise */ @@ -112,11 +130,12 @@ SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height, Uint32 format, SDL_Surface *display) { - + SDL_Overlay *overlay = NULL; +#if SDL_LEGACY_QUICKDRAW Uint32 codec; OSStatus err; CGrafPtr port; - SDL_Overlay *overlay; + Rect theBounds = {0, 0}; if (format == SDL_YV12_OVERLAY || format == SDL_IYUV_OVERLAY) { @@ -150,50 +169,21 @@ SDL_SetError ("Could not find QuickTime codec for format"); return NULL; } - - if (SDL_VideoSurface->flags & SDL_FULLSCREEN) { - - /* - Acceleration requires a window to be present. - A CGrafPtr that points to the screen isn't good enough - */ - NSRect content = NSMakeRect (0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h); - - qz_window = [ [ SDL_QuartzWindow alloc ] - initWithContentRect:content - styleMask:NSBorderlessWindowMask - backing:NSBackingStoreBuffered defer:NO ]; - - if (qz_window == nil) { - SDL_SetError ("Could not create the Cocoa window"); - return NULL; - } - - [ qz_window setContentView:[ [ NSQuickDrawView alloc ] init ] ]; - [ qz_window setReleasedWhenClosed:YES ]; - [ qz_window center ]; - [ qz_window setAcceptsMouseMovedEvents:YES ]; - [ qz_window setLevel:CGShieldingWindowLevel() ]; - [ qz_window makeKeyAndOrderFront:nil ]; - - port = [ [ qz_window contentView ] qdPort ]; - SetPort (port); - - /* - BUG: would like to remove white flash when window kicks in - { - Rect r; - SetRect (&r, 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h); - PaintRect (&r); - QDFlushPortBuffer (port, nil); - } - */ + + theBounds.right = width; + theBounds.bottom = height; + yuv_port = NULL; + + err = QTNewGWorld(&yuv_port, k32ARGBPixelFormat, &theBounds, + NULL, NULL, 0); + + if (err != noErr) { + SDL_SetError ("Could not init QuickTime world"); + return NULL; } - else { - port = [ window_view qdPort ]; - SetPort (port); - } + LockPixels(GetGWorldPixMap(yuv_port)); + SetIdentityMatrix (yuv_matrix); HLock ((Handle)yuv_idh); @@ -219,7 +209,7 @@ yuv_idh, NULL, 0, - port, + yuv_port, NULL, NULL, yuv_matrix, @@ -231,11 +221,13 @@ if (err != noErr) { SDL_SetError ("Error trying to start YUV codec."); + DisposeGWorld(yuv_port); return NULL; } overlay = (SDL_Overlay*) SDL_malloc (sizeof(*overlay)); if (overlay == NULL) { + DisposeGWorld(yuv_port); SDL_OutOfMemory(); return NULL; } @@ -263,6 +255,7 @@ plane3 = 1; /* V plane maps to plane 2 */ } else { + DisposeGWorld(yuv_port); SDL_SetError("Unsupported YUV format"); return NULL; } @@ -270,6 +263,7 @@ pixels = (Uint8**) SDL_malloc (sizeof(*pixels) * 3); pitches = (Uint16*) SDL_malloc (sizeof(*pitches) * 3); if (pixels == NULL || pitches == NULL) { + DisposeGWorld(yuv_port); SDL_OutOfMemory(); return NULL; } @@ -280,6 +274,7 @@ SDL_malloc (sizeof(PlanarPixmapInfoYUV420) + (width * height * 2)); if (yuv_pixmap == NULL) { + DisposeGWorld(yuv_port); SDL_OutOfMemory (); return NULL; } @@ -314,6 +309,7 @@ overlay->hwfuncs = SDL_malloc (sizeof(*overlay->hwfuncs)); if (overlay->hwfuncs == NULL) { + DisposeGWorld(yuv_port); SDL_OutOfMemory(); return NULL; } @@ -325,6 +321,7 @@ yuv_width = overlay->w; yuv_height = overlay->h; +#endif return overlay; } Index: src/video/quartz/SDL_QuartzVideo.m =================================================================== --- src/video/quartz/SDL_QuartzVideo.m (revision 4707) +++ src/video/quartz/SDL_QuartzVideo.m (working copy) @@ -38,7 +38,8 @@ @implementation NSScreen (NSScreenAccess) - (void) setFrame:(NSRect)frame; { - _frame = frame; +// !!! FIXME +// _frame = frame; } @end @@ -52,6 +53,8 @@ - (void) doCommandBySelector:(SEL) myselector {} @end +/* absent in 10.3.9. */ +CG_EXTERN CGImageRef CGBitmapContextCreateImage (CGContextRef); /* Bootstrap functions */ static int QZ_Available (); @@ -79,8 +82,6 @@ static void QZ_DoubleBufferUpdate (_THIS, int num_rects, SDL_Rect *rects); static void QZ_DirectUpdate (_THIS, int num_rects, SDL_Rect *rects); -static int QZ_LockWindow (_THIS, SDL_Surface *surface); -static void QZ_UnlockWindow (_THIS, SDL_Surface *surface); static void QZ_UpdateRects (_THIS, int num_rects, SDL_Rect *rects); static void QZ_VideoQuit (_THIS); @@ -371,6 +372,12 @@ this->LockHWSurface = NULL; this->UnlockHWSurface = NULL; + if (cg_context) { + CGContextFlush (cg_context); + CGContextRelease (cg_context); + cg_context = nil; + } + /* Release fullscreen resources */ if ( mode_flags & SDL_FULLSCREEN ) { @@ -487,7 +494,8 @@ current->flags |= SDL_FULLSCREEN; current->flags |= SDL_HWSURFACE; current->flags |= SDL_PREALLOC; - + /* current->hwdata = (void *) CGDisplayGetDrawingContext (display_id); */ + this->UpdateRects = QZ_DirectUpdate; this->LockHWSurface = QZ_LockHWSurface; this->UnlockHWSurface = QZ_UnlockHWSurface; @@ -538,6 +546,7 @@ and with no valid window/view in FULLSCREEN, SDL wouldn't update its cursor. ) */ /* Check for user-specified window and view */ +#if SDL_LEGACY_QUICKDRAW { char *windowPtrString = getenv ("SDL_NSWindowPointer"); char *viewPtrString = getenv ("SDL_NSQuickDrawViewPointer"); @@ -561,12 +570,13 @@ [ qz_window retain ]; } } +#endif /* Check if we should recreate the window */ if (qz_window == nil) { /* Manually create a window, avoids having a nib file resource */ qz_window = [ [ SDL_QuartzWindow alloc ] initWithContentRect:contentRect - styleMask:nil + styleMask:0 backing:NSBackingStoreBuffered defer:NO ]; @@ -695,6 +705,7 @@ } /* Check for user-specified window and view */ +#if SDL_LEGACY_QUICKDRAW { char *windowPtrString = getenv ("SDL_NSWindowPointer"); char *viewPtrString = getenv ("SDL_NSQuickDrawViewPointer"); @@ -727,7 +738,8 @@ current->flags |= SDL_NOFRAME; } } - +#endif + /* Check if we should recreate the window */ if (qz_window == nil) { @@ -809,46 +821,34 @@ } /* For 2D, we set the subview to an NSQuickDrawView */ else { - short qdbpp = 0; + CGColorSpaceRef cgColorspace; /* Only recreate the view if it doesn't already exist */ if (window_view == nil) { - window_view = [ [ NSQuickDrawView alloc ] initWithFrame:contentRect ]; + window_view = [ [ NSView alloc ] initWithFrame:contentRect ]; [ window_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ]; [ [ qz_window contentView ] addSubview:window_view ]; [ window_view release ]; [ qz_window makeKeyAndOrderFront:nil ]; } - LockPortBits ( [ window_view qdPort ] ); - current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ window_view qdPort ] ) ); - current->pitch = GetPixRowBytes ( GetPortPixMap ( [ window_view qdPort ] ) ); - qdbpp = GetPixDepth ( GetPortPixMap ( [ window_view qdPort ] ) ); - UnlockPortBits ( [ window_view qdPort ] ); - - /* QuickDraw may give a 16-bit shadow surface on 8-bit displays! */ - *bpp = qdbpp; - + cgColorspace = CGColorSpaceCreateDeviceRGB(); + current->pitch = 4 * current->w; + current->pixels = SDL_malloc (current->h * current->pitch); + + cg_context = CGBitmapContextCreate (current->pixels, current->w, current->h, + 8, current->pitch, cgColorspace, + kCGImageAlphaNoneSkipFirst); + CGColorSpaceRelease (cgColorspace); + current->flags |= SDL_SWSURFACE; - current->flags |= SDL_PREALLOC; current->flags |= SDL_ASYNCBLIT; + current->hwdata = (void *) cg_context; - /* - current->pixels now points to the window's pixels - We want it to point to the *view's* pixels - */ - { - int vOffset = [ qz_window frame ].size.height - - [ window_view frame ].size.height - [ window_view frame ].origin.y; - - int hOffset = [ window_view frame ].origin.x; - - current->pixels = (Uint8 *)current->pixels + (vOffset * current->pitch) + hOffset * (qdbpp/8); - } this->UpdateRects = QZ_UpdateRects; - this->LockHWSurface = QZ_LockWindow; - this->UnlockHWSurface = QZ_UnlockWindow; + this->LockHWSurface = QZ_LockHWSurface; + this->UnlockHWSurface = QZ_UnlockHWSurface; } /* Save flags to ensure correct teardown */ @@ -877,8 +877,8 @@ } /* Setup windowed video */ else { - /* Force bpp to the device's bpp */ - bpp = device_bpp; + /* Force bpp to 32 */ + bpp = 32; current = QZ_SetVideoWindowed (this, current, width, height, &bpp, flags); if (current == NULL) return NULL; @@ -1062,6 +1062,9 @@ /* On error, skip VBL delay */ ERROR: + /* TODO: use CGContextDrawImage here too! Create two CGContextRefs the same way we + create two buffers, replace current_buffer with current_context and set it + appropriately in QZ_FlipDoubleBuffer. */ while ( h-- ) { SDL_memcpy (dst, src, len); @@ -1105,254 +1108,7 @@ #pragma unused(this,num_rects,rects) } -/* - The obscured code is based on work by Matt Slot fprefect@ambrosiasw.com, - who supplied sample code for Carbon. -*/ -/*#define TEST_OBSCURED 1*/ - -#if TEST_OBSCURED -#include "CGS.h" -#endif - -static int QZ_IsWindowObscured (NSWindow *window) { - - -#if TEST_OBSCURED - - /* - In order to determine if a direct copy to the screen is possible, - we must figure out if there are any windows covering ours (including shadows). - This can be done by querying the window server about the on screen - windows for their screen rectangle and window level. - The procedure used below is puts accuracy before speed; however, it aims to call - the window server the fewest number of times possible to keep things reasonable. - In my testing on a 300mhz G3, this routine typically takes < 2 ms. -DW - - Notes: - -Calls into the Window Server involve IPC which is slow. - -Getting a rectangle seems slower than getting the window level - -The window list we get back is in sorted order, top to bottom - -On average, I suspect, most windows above ours are dock icon windows (hence optimization) - -Some windows above ours are always there, and cannot move or obscure us (menu bar) - - Bugs: - -no way (yet) to deactivate direct drawing when a window is dragged, - or suddenly obscured, so drawing continues and can produce garbage - We need some kind of locking mechanism on window movement to prevent this - - -deactivated normal windows use activated normal - window shadows (slight inaccuraccy) - */ - - /* Cache the connection to the window server */ - static CGSConnectionID cgsConnection = (CGSConnectionID) -1; - - /* Cache the dock icon windows */ - static CGSWindowID dockIcons[kMaxWindows]; - static int numCachedDockIcons = 0; - - CGSWindowID windows[kMaxWindows]; - CGSWindowCount i, count; - CGSWindowLevel winLevel; - CGSRect winRect; - - CGSRect contentRect; - int windowNumber; - int firstDockIcon; - int dockIconCacheMiss; - int windowContentOffset; - - int obscured = SDL_TRUE; - - if ( [ window isVisible ] ) { - - /* - walk the window list looking for windows over top of - (or casting a shadow on) ours - */ - - /* - Get a connection to the window server - Should probably be moved out into SetVideoMode() or InitVideo() - */ - if (cgsConnection == (CGSConnectionID) -1) { - cgsConnection = (CGSConnectionID) 0; - cgsConnection = _CGSDefaultConnection (); - } - - if (cgsConnection) { - - if ( ! [ window styleMask ] & NSBorderlessWindowMask ) - windowContentOffset = 22; - else - windowContentOffset = 0; - - windowNumber = [ window windowNumber ]; - - /* The window list is sorted according to order on the screen */ - count = 0; - CGSGetOnScreenWindowList (cgsConnection, 0, kMaxWindows, windows, &count); - CGSGetScreenRectForWindow (cgsConnection, windowNumber, &contentRect); - - /* adjust rect for window title bar (if present) */ - contentRect.origin.y += windowContentOffset; - contentRect.size.height -= windowContentOffset; - - firstDockIcon = -1; - dockIconCacheMiss = SDL_FALSE; - - /* - The first window is always an empty window with level kCGSWindowLevelTop - so start at index 1 - */ - for (i = 1; i < count; i++) { - - /* If we reach our window in the list, it cannot be obscured */ - if (windows[i] == windowNumber) { - - obscured = SDL_FALSE; - break; - } - else { - - float shadowSide; - float shadowTop; - float shadowBottom; - - CGSGetWindowLevel (cgsConnection, windows[i], &winLevel); - - if (winLevel == kCGSWindowLevelDockIcon) { - - int j; - - if (firstDockIcon < 0) { - - firstDockIcon = i; - - if (numCachedDockIcons > 0) { - - for (j = 0; j < numCachedDockIcons; j++) { - - if (windows[i] == dockIcons[j]) - i++; - else - break; - } - - if (j != 0) { - - i--; - - if (j < numCachedDockIcons) { - - dockIconCacheMiss = SDL_TRUE; - } - } - - } - } - - continue; - } - else if (winLevel == kCGSWindowLevelMenuIgnore - /* winLevel == kCGSWindowLevelTop */) { - - continue; /* cannot obscure window */ - } - else if (winLevel == kCGSWindowLevelDockMenu || - winLevel == kCGSWindowLevelMenu) { - - shadowSide = 18; - shadowTop = 4; - shadowBottom = 22; - } - else if (winLevel == kCGSWindowLevelUtility) { - - shadowSide = 8; - shadowTop = 4; - shadowBottom = 12; - } - else if (winLevel == kCGSWindowLevelNormal) { - - /* - These numbers are for foreground windows, - they are too big (but will work) for background windows - */ - shadowSide = 20; - shadowTop = 10; - shadowBottom = 24; - } - else if (winLevel == kCGSWindowLevelDock) { - - /* Create dock icon cache */ - if (numCachedDockIcons != (i-firstDockIcon) || - dockIconCacheMiss) { - - numCachedDockIcons = i - firstDockIcon; - SDL_memcpy (dockIcons, &(windows[firstDockIcon]), - numCachedDockIcons * sizeof(*windows)); - } - - /* no shadow */ - shadowSide = 0; - shadowTop = 0; - shadowBottom = 0; - } - else { - - /* - kCGSWindowLevelDockLabel, - kCGSWindowLevelDock, - kOther??? - */ - - /* no shadow */ - shadowSide = 0; - shadowTop = 0; - shadowBottom = 0; - } - - CGSGetScreenRectForWindow (cgsConnection, windows[i], &winRect); - - winRect.origin.x -= shadowSide; - winRect.origin.y -= shadowTop; - winRect.size.width += shadowSide; - winRect.size.height += shadowBottom; - - if (NSIntersectsRect (contentRect, winRect)) { - - obscured = SDL_TRUE; - break; - } - - } /* window was not our window */ - - } /* iterate over windows */ - - } /* get cgsConnection */ - - } /* window is visible */ - - return obscured; -#else - return SDL_TRUE; -#endif -} - - -/* Locking functions for the software window buffer */ -static int QZ_LockWindow (_THIS, SDL_Surface *surface) { - - return LockPortBits ( [ window_view qdPort ] ); -} - -static void QZ_UnlockWindow (_THIS, SDL_Surface *surface) { - - UnlockPortBits ( [ window_view qdPort ] ); -} - /* Resize icon, BMP format */ static const unsigned char QZ_ResizeIcon[] = { 0x42,0x4d,0x31,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, @@ -1393,41 +1149,34 @@ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0b }; -static void QZ_DrawResizeIcon (_THIS, RgnHandle dirtyRegion) { +static void QZ_DrawResizeIcon (_THIS) { /* Check if we should draw the resize icon */ if (SDL_VideoSurface->flags & SDL_RESIZABLE) { - Rect icon; - SetRect (&icon, SDL_VideoSurface->w - 13, SDL_VideoSurface->h - 13, - SDL_VideoSurface->w, SDL_VideoSurface->h); - - if (RectInRgn (&icon, dirtyRegion)) { + SDL_Rect icon_rect; - SDL_Rect icon_rect; + /* Create the icon image */ + if (resize_icon == NULL) { + + SDL_RWops *rw; + SDL_Surface *tmp; - /* Create the icon image */ - if (resize_icon == NULL) { + rw = SDL_RWFromConstMem (QZ_ResizeIcon, sizeof(QZ_ResizeIcon)); + tmp = SDL_LoadBMP_RW (rw, SDL_TRUE); + + resize_icon = SDL_ConvertSurface (tmp, SDL_VideoSurface->format, SDL_SRCCOLORKEY); + SDL_SetColorKey (resize_icon, SDL_SRCCOLORKEY, 0xFFFFFF); - SDL_RWops *rw; - SDL_Surface *tmp; - - rw = SDL_RWFromConstMem (QZ_ResizeIcon, sizeof(QZ_ResizeIcon)); - tmp = SDL_LoadBMP_RW (rw, SDL_TRUE); - - resize_icon = SDL_ConvertSurface (tmp, SDL_VideoSurface->format, SDL_SRCCOLORKEY); - SDL_SetColorKey (resize_icon, SDL_SRCCOLORKEY, 0xFFFFFF); - - SDL_FreeSurface (tmp); - } + SDL_FreeSurface (tmp); + } - icon_rect.x = SDL_VideoSurface->w - 13; - icon_rect.y = SDL_VideoSurface->h - 13; - icon_rect.w = 13; - icon_rect.h = 13; + icon_rect.x = SDL_VideoSurface->w - 13; + icon_rect.y = SDL_VideoSurface->h - 13; + icon_rect.w = 13; + icon_rect.h = 13; - SDL_BlitSurface (resize_icon, NULL, SDL_VideoSurface, &icon_rect); - } + SDL_BlitSurface (resize_icon, NULL, SDL_VideoSurface, &icon_rect); } } @@ -1441,75 +1190,19 @@ /* Do nothing if miniaturized */ } - else if ( ! QZ_IsWindowObscured (qz_window) ) { - - /* Use direct copy to flush contents to the display */ - CGrafPtr savePort; - CGrafPtr dstPort, srcPort; - const BitMap *dstBits, *srcBits; - Rect dstRect, srcRect; - Point offset; - int i; - - GetPort (&savePort); - - dstPort = CreateNewPortForCGDisplayID ((UInt32)display_id); - srcPort = [ window_view qdPort ]; - - offset.h = 0; - offset.v = 0; - SetPort (srcPort); - LocalToGlobal (&offset); - - SetPort (dstPort); - - LockPortBits (dstPort); - LockPortBits (srcPort); - - dstBits = GetPortBitMapForCopyBits (dstPort); - srcBits = GetPortBitMapForCopyBits (srcPort); - - for (i = 0; i < numRects; i++) { - - SetRect (&srcRect, rects[i].x, rects[i].y, - rects[i].x + rects[i].w, - rects[i].y + rects[i].h); - - SetRect (&dstRect, - rects[i].x + offset.h, - rects[i].y + offset.v, - rects[i].x + rects[i].w + offset.h, - rects[i].y + rects[i].h + offset.v); - - CopyBits (srcBits, dstBits, - &srcRect, &dstRect, srcCopy, NULL); - - } - - SetPort (savePort); - } else { - /* Use QDFlushPortBuffer() to flush content to display */ - int i; - RgnHandle dirty = NewRgn (); - RgnHandle temp = NewRgn (); - - SetEmptyRgn (dirty); - - /* Build the region of dirty rectangles */ - for (i = 0; i < numRects; i++) { - - MacSetRectRgn (temp, rects[i].x, rects[i].y, - rects[i].x + rects[i].w, rects[i].y + rects[i].h); - MacUnionRgn (dirty, temp, dirty); - } - - QZ_DrawResizeIcon (this, dirty); + CGContextRef cgc = (CGContextRef) + [[NSGraphicsContext graphicsContextWithWindow: qz_window] + graphicsPort]; + QZ_DrawResizeIcon (this); + CGContextFlush (cg_context); + CGImageRef image = CGBitmapContextCreateImage (cg_context); + CGRect rectangle = CGRectMake (0,0,[window_view frame].size.width,[window_view frame].size.height); - /* Flush the dirty region */ - QDFlushPortBuffer ( [ window_view qdPort ], dirty ); - DisposeRgn (dirty); - DisposeRgn (temp); + CGContextDrawImage (cgc, rectangle, image); + CGImageRelease(image); + CGContextFlush (cgc); + CGContextRelease (cgc); } } Index: src/video/quartz/SDL_QuartzWindow.m =================================================================== --- src/video/quartz/SDL_QuartzWindow.m (revision 4707) +++ src/video/quartz/SDL_QuartzWindow.m (working copy) @@ -125,31 +125,6 @@ newViewFrame = [ window_view frame ]; SDL_PrivateResize (newViewFrame.size.width, newViewFrame.size.height); - - /* If not OpenGL, we have to update the pixels and pitch */ - if ( ! ( SDL_VideoSurface->flags & SDL_OPENGL ) ) { - - CGrafPtr thePort = [ window_view qdPort ]; - LockPortBits ( thePort ); - - SDL_VideoSurface->pixels = GetPixBaseAddr ( GetPortPixMap ( thePort ) ); - SDL_VideoSurface->pitch = GetPixRowBytes ( GetPortPixMap ( thePort ) ); - - /* - SDL_VideoSurface->pixels now points to the window's pixels - We want it to point to the *view's* pixels - */ - { - int vOffset = [ qz_window frame ].size.height - - newViewFrame.size.height - newViewFrame.origin.y; - - int hOffset = newViewFrame.origin.x; - - SDL_VideoSurface->pixels = (Uint8 *)SDL_VideoSurface->pixels + (vOffset * SDL_VideoSurface->pitch) + hOffset * (device_bpp/8); - } - - UnlockPortBits ( thePort ); - } } } @@ -183,7 +158,7 @@ SDL_PrivateAppActive (1, SDL_APPACTIVE); } -- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag +- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag { /* Make our window subclass receive these application notifications */ [ [ NSNotificationCenter defaultCenter ] addObserver:self Index: configure.in =================================================================== --- configure.in (revision 4710) +++ configure.in (working copy) @@ -2665,7 +2665,8 @@ fi if test x$enable_video_carbon = xyes -o x$enable_video_cocoa = xyes; then # The Cocoa backend still needs Carbon, and the YUV code QuickTime - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuickTime -Wl,-framework,ApplicationServices" + dnl EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuickTime -Wl,-framework,ApplicationServices" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ApplicationServices" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon" fi # If either the audio or CD driver is used, add the AudioUnit framework