Fixed bug reported here:
http://www.devolution.com/pipermail/sdl/2005-October/070998.html
--ryan.
--- a/src/video/quartz/SDL_QuartzVideo.m Tue Nov 22 09:05:15 2005 +0000
+++ b/src/video/quartz/SDL_QuartzVideo.m Tue Nov 22 09:59:42 2005 +0000
@@ -656,7 +656,7 @@
}
static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
- int height, int bpp, Uint32 flags) {
+ int height, int *bpp, Uint32 flags) {
unsigned int style;
NSRect contentRect;
BOOL isCustom = NO;
@@ -774,7 +774,7 @@
/* For OpenGL, we bind the context to a subview */
if ( flags & SDL_OPENGL ) {
- if ( ! QZ_SetupOpenGL (this, bpp, flags) ) {
+ if ( ! QZ_SetupOpenGL (this, *bpp, flags) ) {
return NULL;
}
@@ -789,6 +789,7 @@
}
/* For 2D, we set the subview to an NSQuickDrawView */
else {
+ short qdbpp = 0;
/* Only recreate the view if it doesn't already exist */
if (window_view == nil) {
@@ -803,8 +804,12 @@
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;
+
current->flags |= SDL_SWSURFACE;
current->flags |= SDL_PREALLOC;
current->flags |= SDL_ASYNCBLIT;
@@ -819,7 +824,7 @@
int hOffset = [ window_view frame ].origin.x;
- current->pixels += (vOffset * current->pitch) + hOffset * (device_bpp/8);
+ current->pixels += (vOffset * current->pitch) + hOffset * (qdbpp/8);
}
this->UpdateRects = QZ_UpdateRects;
this->LockHWSurface = QZ_LockWindow;
@@ -848,7 +853,7 @@
else {
/* Force bpp to the device's bpp */
bpp = device_bpp;
- current = QZ_SetVideoWindowed (this, current, width, height, bpp, flags);
+ current = QZ_SetVideoWindowed (this, current, width, height, &bpp, flags);
if (current == NULL)
return NULL;
}