Commit b5dc26cf authored by Ryan C. Gordon's avatar Ryan C. Gordon

1.2 Quartz video: Ripped out QuickDraw and QuickTime.

Now we use the software path for YUV, and CoreGraphics for 2D stuff.

There are several other 10.6 fixes in here, too...now we can build a 64-bit
SDL for Snow Leopard!

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%403838
parent ddb6f9bd
...@@ -2696,8 +2696,8 @@ case "$host" in ...@@ -2696,8 +2696,8 @@ case "$host" in
need_iokit_framework=yes need_iokit_framework=yes
fi fi
if test x$enable_video_carbon = xyes -o x$enable_video_cocoa = xyes; then 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 # The Cocoa backend still needs Carbon
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuickTime -Wl,-framework,ApplicationServices" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ApplicationServices"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
fi fi
# If either the audio or CD driver is used, add the AudioUnit framework # If either the audio or CD driver is used, add the AudioUnit framework
......
...@@ -41,13 +41,24 @@ ...@@ -41,13 +41,24 @@
#define NSOpenGLPFASamples ((NSOpenGLPixelFormatAttribute) 56) #define NSOpenGLPFASamples ((NSOpenGLPixelFormatAttribute) 56)
#endif #endif
#ifdef __powerpc__ /* we lost this in 10.6, which has no PPC support. */
@implementation NSOpenGLContext (CGLContextAccess) @implementation NSOpenGLContext (CGLContextAccess)
- (CGLContextObj) cglContext; - (CGLContextObj) cglContext;
{ {
return _contextAuxiliary; return _contextAuxiliary;
} }
@end @end
CGLContextObj QZ_GetCGLContextObj(NSOpenGLContext *nsctx)
{
return [nsctx cglContext];
}
#else
CGLContextObj QZ_GetCGLContextObj(NSOpenGLContext *nsctx)
{
return (CGLContextObj) [nsctx CGLContextObj];
}
#endif
/* OpenGL helper functions (used internally) */ /* OpenGL helper functions (used internally) */
...@@ -165,7 +176,7 @@ int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags) { ...@@ -165,7 +176,7 @@ int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags) {
{ {
long cache_max = 64; long cache_max = 64;
CGLContextObj ctx = [ gl_context cglContext ]; CGLContextObj ctx = QZ_GetCGLContextObj(gl_context);
CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max); CGLSetParameter (ctx, GLI_SUBMIT_FUNC_CACHE_MAX, &cache_max);
CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max); CGLSetParameter (ctx, GLI_ARRAY_FUNC_CACHE_MAX, &cache_max);
} }
......
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
#include <Cocoa/Cocoa.h> #include <Cocoa/Cocoa.h>
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include <QuickTime/QuickTime.h>
#include <OpenGL/OpenGL.h> /* For CGL functions and types */ #include <OpenGL/OpenGL.h> /* For CGL functions and types */
#include <IOKit/IOKitLib.h> /* For powersave handling */ #include <IOKit/IOKitLib.h> /* For powersave handling */
#include <pthread.h> #include <pthread.h>
...@@ -68,13 +67,21 @@ ...@@ -68,13 +67,21 @@
#include "../SDL_pixels_c.h" #include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h" #include "../../events/SDL_events_c.h"
#ifdef __powerpc__
/* /*
This is a workaround to directly access NSOpenGLContext's CGL context This is a workaround to directly access NSOpenGLContext's CGL context
We need this to check for errors NSOpenGLContext doesn't support We need this to check for errors NSOpenGLContext doesn't support
Please note this is only used on PowerPC (Intel Macs are guaranteed to
have a better API for this, since it showed up in Mac OS X 10.3).
*/ */
@interface NSOpenGLContext (CGLContextAccess) @interface NSOpenGLContext (CGLContextAccess)
- (CGLContextObj) cglContext; - (CGLContextObj) cglContext;
@end @end
#endif
/* use this to get the CGLContext; it handles Cocoa interface changes. */
CGLContextObj QZ_GetCGLContextObj(NSOpenGLContext *nsctx);
/* Main driver structure to store required state information */ /* Main driver structure to store required state information */
...@@ -93,7 +100,8 @@ typedef struct SDL_PrivateVideoData { ...@@ -93,7 +100,8 @@ typedef struct SDL_PrivateVideoData {
Uint32 warp_flag; /* boolean; notify to event loop that a warp just occured */ Uint32 warp_flag; /* boolean; notify to event loop that a warp just occured */
Uint32 warp_ticks; /* timestamp when the warp occured */ Uint32 warp_ticks; /* timestamp when the warp occured */
NSWindow *window; /* Cocoa window to implement the SDL window */ 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_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_GrabMode current_grab_mode; /* default value is SDL_GRAB_OFF */
SDL_Rect **client_mode_list; /* resolution list to pass back to client */ SDL_Rect **client_mode_list; /* resolution list to pass back to client */
...@@ -113,14 +121,6 @@ typedef struct SDL_PrivateVideoData { ...@@ -113,14 +121,6 @@ typedef struct SDL_PrivateVideoData {
Uint8 *current_buffer; /* the buffer being copied to the screen */ Uint8 *current_buffer; /* the buffer being copied to the screen */
BOOL quit_thread; /* used to quit the async blitting thread */ BOOL quit_thread; /* used to quit the async blitting thread */
SInt32 system_version; /* used to dis-/enable workarounds depending on the system version */ SInt32 system_version; /* used to dis-/enable workarounds depending on the system version */
ImageDescriptionHandle yuv_idh;
MatrixRecordPtr yuv_matrix;
DecompressorComponent yuv_codec;
ImageSequence yuv_seq;
PlanarPixmapInfoYUV420 *yuv_pixmap;
Sint16 yuv_width, yuv_height;
CGrafPtr yuv_port;
void *opengl_library; /* dynamically loaded OpenGL library. */ void *opengl_library; /* dynamically loaded OpenGL library. */
} SDL_PrivateVideoData; } SDL_PrivateVideoData;
...@@ -139,6 +139,7 @@ typedef struct SDL_PrivateVideoData { ...@@ -139,6 +139,7 @@ typedef struct SDL_PrivateVideoData {
#define mode_flags (this->hidden->flags) #define mode_flags (this->hidden->flags)
#define qz_window (this->hidden->window) #define qz_window (this->hidden->window)
#define window_view (this->hidden->view) #define window_view (this->hidden->view)
#define cg_context (this->hidden->cg_context)
#define video_set (this->hidden->video_set) #define video_set (this->hidden->video_set)
#define warp_ticks (this->hidden->warp_ticks) #define warp_ticks (this->hidden->warp_ticks)
#define warp_flag (this->hidden->warp_flag) #define warp_flag (this->hidden->warp_flag)
...@@ -156,6 +157,7 @@ typedef struct SDL_PrivateVideoData { ...@@ -156,6 +157,7 @@ typedef struct SDL_PrivateVideoData {
#define cursor_should_be_visible (this->hidden->cursor_should_be_visible) #define cursor_should_be_visible (this->hidden->cursor_should_be_visible)
#define cursor_visible (this->hidden->cursor_visible) #define cursor_visible (this->hidden->cursor_visible)
#define sw_buffers (this->hidden->sw_buffers) #define sw_buffers (this->hidden->sw_buffers)
#define sw_contexts (this->hidden->sw_contexts)
#define thread (this->hidden->thread) #define thread (this->hidden->thread)
#define sem1 (this->hidden->sem1) #define sem1 (this->hidden->sem1)
#define sem2 (this->hidden->sem2) #define sem2 (this->hidden->sem2)
...@@ -215,11 +217,6 @@ int QZ_IconifyWindow (_THIS); ...@@ -215,11 +217,6 @@ int QZ_IconifyWindow (_THIS);
SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode); SDL_GrabMode QZ_GrabInput (_THIS, SDL_GrabMode grab_mode);
/*int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info);*/ /*int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info);*/
/* YUV functions */
SDL_Overlay* QZ_CreateYUVOverlay (_THIS, int width, int height,
Uint32 format, SDL_Surface *display);
/* Private functions (used internally) */ /* Private functions (used internally) */
void QZ_PrivateWarpCursor (_THIS, int x, int y); void QZ_PrivateWarpCursor (_THIS, int x, int y);
void QZ_ChangeGrabState (_THIS, int action); void QZ_ChangeGrabState (_THIS, int action);
......
This diff is collapsed.
...@@ -171,11 +171,7 @@ void QZ_PrivateSDLToCocoa (_THIS, NSPoint *p) { ...@@ -171,11 +171,7 @@ void QZ_PrivateSDLToCocoa (_THIS, NSPoint *p) {
else { else {
*p = [ window_view convertPoint:*p toView: nil ]; *p = [ window_view convertPoint:*p toView: nil ];
p->y = [window_view frame].size.height - p->y;
/* We need a workaround in OpenGL mode */
if ( SDL_VideoSurface->flags & SDL_OPENGL ) {
p->y = [window_view frame].size.height - p->y;
}
} }
} }
...@@ -189,11 +185,7 @@ void QZ_PrivateCocoaToSDL (_THIS, NSPoint *p) { ...@@ -189,11 +185,7 @@ void QZ_PrivateCocoaToSDL (_THIS, NSPoint *p) {
else { else {
*p = [ window_view convertPoint:*p fromView: nil ]; *p = [ window_view convertPoint:*p fromView: nil ];
p->y = [window_view frame].size.height - p->y;
/* 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;
}
} }
} }
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
*/ */
#include "SDL_config.h" #include "SDL_config.h"
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
typedef unsigned int NSUInteger;
#endif
/* Subclass of NSWindow to fix genie effect and support resize events */ /* Subclass of NSWindow to fix genie effect and support resize events */
@interface SDL_QuartzWindow : NSWindow @interface SDL_QuartzWindow : NSWindow
- (void)miniaturize:(id)sender; - (void)miniaturize:(id)sender;
...@@ -29,7 +33,7 @@ ...@@ -29,7 +33,7 @@
- (void)appDidHide:(NSNotification*)note; - (void)appDidHide:(NSNotification*)note;
- (void)appWillUnhide:(NSNotification*)note; - (void)appWillUnhide:(NSNotification*)note;
- (void)appDidUnhide:(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 @end
/* Delegate for our NSWindow to send SDLQuit() on close */ /* Delegate for our NSWindow to send SDLQuit() on close */
......
...@@ -125,31 +125,6 @@ static void QZ_SetPortAlphaOpaque () { ...@@ -125,31 +125,6 @@ static void QZ_SetPortAlphaOpaque () {
newViewFrame = [ window_view frame ]; newViewFrame = [ window_view frame ];
SDL_PrivateResize (newViewFrame.size.width, newViewFrame.size.height); 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 @@ static void QZ_SetPortAlphaOpaque () { ...@@ -183,7 +158,7 @@ static void QZ_SetPortAlphaOpaque () {
SDL_PrivateAppActive (1, SDL_APPACTIVE); 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 */ /* Make our window subclass receive these application notifications */
[ [ NSNotificationCenter defaultCenter ] addObserver:self [ [ NSNotificationCenter defaultCenter ] addObserver:self
......
This diff is collapsed.
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