Commit 97c81738 authored by Sam Lantinga's avatar Sam Lantinga

Date: Thu, 16 Jan 2003 13:48:31 +0200

From: "Mike Gorchak"
Subject: All QNX patches

whole patches concerning QNX. Almost all code has been rewritten by Julian
and me. Added initial support for hw overlays in QNX and many many others
fixes.

P.S. This patches has been reviewed by Dave Rempel from QSSL and included in
SDL 1.2.5 distribution, which coming on 3rd party CD for newest 6.2.1
version of QNX, which will be available soon.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40572
parent b38a873c
......@@ -188,14 +188,8 @@ QNX: -= NOT YET SUPPORTED =-
The only hardware surface is the primary view surface.
Mouse events don't seem to be working right.
Fullscreen doesn't display correctly.
The software surfaces could use some speed up.
The mouse cursor doesn't look right.
AmigaOS: -= NOT YET SUPPORTED =-
The OpenGL support isn't implemented yet.
......
This diff is collapsed.
This diff is collapsed.
......@@ -27,7 +27,7 @@ static char rcsid =
#include "SDL_ph_video.h"
#define EVENT_SIZE sizeof( PhEvent_t ) + 1000
#define EVENT_SIZE sizeof(PhEvent_t) + 1000
/* Functions to be exported */
extern void ph_InitOSKeymap(_THIS);
......
......@@ -29,16 +29,60 @@ static char rcsid =
#include <Ph.h>
#include <photon/Pg.h>
#include "SDL.h"
#include "SDL_error.h"
#include "SDL_endian.h"
#include "SDL_video.h"
#include "SDL_pixels_c.h"
#include "SDL_ph_image_c.h"
/* remove this line, if photon headers updates */
int PgWaitHWIdle(void);
/* Mask values for SDL_ReallocFormat() */
struct ColourMasks
{
Uint32 red;
Uint32 green;
Uint32 blue;
Uint32 alpha;
Uint32 bpp;
};
static const struct ColourMasks *ph_GetColourMasks( int format )
{
/* The alpha mask doesn't appear to be needed */
static const struct ColourMasks phColorMasks[5] = {
/* 8 bit */ {0, 0, 0, 0, 8},
/* 15 bit ARGB */ {0x7C00, 0x03E0, 0x001F, 0x8000, 16},
/* 16 bit RGB */ {0xF800, 0x07E0, 0x001F, 0x0000, 16},
/* 24 bit RGB */ {0xFF0000, 0x00FF00, 0x0000FF, 0x000000, 24},
/* 32 bit ARGB */ {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, 32},
};
switch( format )
{
case Pg_IMAGE_PALETTE_BYTE:
return &phColorMasks[0];
break;
case Pg_IMAGE_DIRECT_1555:
case Pg_IMAGE_DIRECT_555:
return &phColorMasks[1];
break;
case Pg_IMAGE_DIRECT_565:
return &phColorMasks[2];
break;
case Pg_IMAGE_DIRECT_888:
return &phColorMasks[3];
break;
case Pg_IMAGE_DIRECT_8888:
return &phColorMasks[4];
break;
}
return NULL;
}
int ph_SetupImage(_THIS, SDL_Surface *screen)
{
PgColor_t* palette=NULL;
const struct ColourMasks* mask;
int type=0;
int bpp;
......@@ -68,7 +112,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
}
break;
default:{
fprintf(stderr,"ph_SetupImage(): unsupported bbp = %d\n", bpp);
fprintf(stderr,"ph_SetupImage(): unsupported bpp=%d !\n", bpp);
return -1;
}
break;
......@@ -84,7 +128,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
/* using shared memory for speed (set last param to 1) */
if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, palette, _Pg_MAX_PALETTE, 1)) == NULL)
{
fprintf(stderr,"ph_SetupImage(): PhCreateImage failed for bpp=8.\n");
fprintf(stderr,"ph_SetupImage(): PhCreateImage failed for bpp=8 !\n");
return -1;
}
}
......@@ -93,14 +137,20 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
/* using shared memory for speed (set last param to 1) */
if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL)
{
fprintf(stderr,"ph_SetupImage: PhCreateImage failed.\n");
fprintf(stderr,"ph_SetupImage: PhCreateImage failed !\n");
return -1;
}
}
screen->pixels = SDL_Image->image;
screen->pitch = SDL_Image->bpl; /* Recalculated pitch, created by PhCreateImage */
mask = ph_GetColourMasks(type);
if (mask != NULL)
{
SDL_ReallocFormat(screen, mask->bpp, mask->red, mask->green, mask->blue, 0);
}
this->UpdateRects = ph_NormalUpdate;
return 0;
......@@ -108,8 +158,12 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
int ph_SetupOCImage(_THIS, SDL_Surface *screen)
{
const struct ColourMasks *mask;
int type = 0;
int bpp;
screen->flags &= ~SDL_DOUBLEBUF;
OCImage.flags = screen->flags;
bpp=screen->format->BitsPerPixel;
......@@ -137,22 +191,14 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen)
}
break;
default:{
fprintf(stderr,"ph_SetupOCImage(): unsupported bpp = %d\n", bpp);
fprintf(stderr,"ph_SetupOCImage(): unsupported bpp=%d !\n", bpp);
return -1;
}
break;
}
OCImage.FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA)));
OCImage.FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof(FRAMEDATA)));
memset(OCImage.FrameData0, 0x00, (size_t)(sizeof(FRAMEDATA)));
memset(OCImage.FrameData1, 0x00, (size_t)(sizeof(FRAMEDATA)));
if(OCImage.direct_context == NULL)
{
OCImage.direct_context = PdCreateDirectContext();
}
/* Currently only offscreen contexts with the same bit depth as the
* display can be created. */
OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN);
if (OCImage.offscreen_context == NULL)
......@@ -161,13 +207,22 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen)
return -1;
}
screen->pitch = OCImage.offscreen_context->pitch; /* Recalculated pitch */
if (OCImage.flags & SDL_DOUBLEBUF)
/* If the bit depth of the context is different than was requested,
* these values need to be updated accordingly. SDL will
* allocate a shadow surface if it needs to. */
mask = ph_GetColourMasks(OCImage.offscreen_context->format);
if (mask != NULL)
{
fprintf(stderr, "ph_SetupOCImage(): Hardware flag for doublebuf offscreen context\n");
SDL_ReallocFormat(screen, mask->bpp, mask->red, mask->green, mask->blue, 0);
if (mask->bpp > 8)
{
screen->flags &= ~SDL_HWPALETTE;
}
}
screen->pitch = OCImage.offscreen_context->pitch; /* Recalculated pitch */
OCImage.dc_ptr.ptr8 = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context);
if (OCImage.dc_ptr.ptr8 == NULL)
......@@ -176,15 +231,13 @@ int ph_SetupOCImage(_THIS, SDL_Surface *screen)
return -1;
}
OCImage.FrameData0 = OCImage.dc_ptr.ptr8;
OCImage.CurrentFrameData = OCImage.FrameData0;
OCImage.CurrentFrameData->Y = OCImage.dc_ptr.ptr8;
OCImage.CurrentFrameData->U = NULL;
OCImage.CurrentFrameData->V = NULL;
OCImage.current = 0;
PhDCSetCurrent(OCImage.offscreen_context);
screen->pixels = OCImage.CurrentFrameData->Y;
screen->pixels = OCImage.CurrentFrameData;
this->UpdateRects = ph_OCUpdate;
......@@ -198,15 +251,67 @@ int ph_SetupOpenGLImage(_THIS, SDL_Surface* screen)
return 0;
}
int ph_SetupFullScreenImage(_THIS, SDL_Surface* screen)
{
const struct ColourMasks *mask;
screen->flags &= ~SDL_DOUBLEBUF;
OCImage.flags = screen->flags;
OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
if (OCImage.offscreen_context == NULL)
{
fprintf(stderr, "ph_SetupFullScreenImage(): PdCreateOffscreenContext failed !\n");
return -1;
}
/* If the bit depth of the context is different than was requested,
* these values need to be updated accordingly. SDL will
* allocate a shadow surface if it needs to. */
mask = ph_GetColourMasks(OCImage.offscreen_context->format);
if (mask != NULL)
{
SDL_ReallocFormat(screen, mask->bpp, mask->red, mask->green, mask->blue, 0);
if (mask->bpp > 8)
{
screen->flags &= ~SDL_HWPALETTE;
}
}
screen->pitch = OCImage.offscreen_context->pitch; /* Recalculated pitch */
OCImage.dc_ptr.ptr8 = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_context);
if (OCImage.dc_ptr.ptr8 == NULL)
{
fprintf(stderr, "ph_SetupOCImage(): PdGetOffscreenContextPtr failed !\n");
return -1;
}
/* wait for hw */
PgWaitHWIdle();
OCImage.FrameData0 = OCImage.dc_ptr.ptr8;
OCImage.CurrentFrameData = OCImage.FrameData0;
OCImage.current = 0;
PhDCSetCurrent(OCImage.offscreen_context);
screen->pixels = OCImage.CurrentFrameData;
this->UpdateRects = ph_OCUpdate;
return 0;
}
void ph_DestroyImage(_THIS, SDL_Surface *screen)
{
if (OCImage.offscreen_context != NULL)
{
PhDCRelease(OCImage.offscreen_context);
OCImage.offscreen_context = NULL;
free(OCImage.FrameData0);
OCImage.FrameData0 = NULL;
free(OCImage.FrameData1);
OCImage.FrameData1 = NULL;
}
......@@ -230,23 +335,24 @@ void ph_DestroyImage(_THIS, SDL_Surface *screen)
}
}
int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
int ph_SetupUpdateFunction(_THIS, SDL_Surface *screen, Uint32 flags)
{
ph_DestroyImage(this, screen);
if (flags & SDL_HWSURFACE)
if ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN)
{
return ph_SetupFullScreenImage(this, screen);
}
if ((flags & SDL_HWSURFACE)==SDL_HWSURFACE)
{
OCImage.flags = flags; /* needed for SDL_DOUBLEBUF check */
return ph_SetupOCImage(this, screen);
}
else if (flags & SDL_OPENGL)
if ((flags & SDL_OPENGL)==SDL_OPENGL)
{
return ph_SetupOpenGLImage(this, screen);
}
else
{
return ph_SetupImage(this, screen);
}
return ph_SetupImage(this, screen);
}
int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
{
......@@ -265,11 +371,6 @@ int ph_FlipHWSurface(_THIS, SDL_Surface *surface)
int ph_LockHWSurface(_THIS, SDL_Surface *surface)
{
if ((surface == SDL_VideoSurface) && blit_queued) {
PgFlush();
blit_queued = 0;
}
return(0);
}
......@@ -307,7 +408,7 @@ void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0)
{
fprintf(stderr,"ph_NormalUpdate(): PgDrawPhImageRectmx failed.\n");
fprintf(stderr,"ph_NormalUpdate(): PgDrawPhImageRectmx failed !\n");
}
}
......@@ -325,11 +426,6 @@ void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects)
PhArea_t src_rect;
PhArea_t dest_rect;
if(OCImage.direct_context == NULL)
{
return;
}
PgSetRegion(PtWidgetRid(window));
PgSetClipping(0, NULL);
PgWaitHWIdle();
......
......@@ -29,7 +29,7 @@ static char rcsid =
extern int ph_SetupImage(_THIS, SDL_Surface *screen);
extern void ph_DestroyImage(_THIS, SDL_Surface *screen);
extern int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags);
extern int ph_SetupUpdateFunction(_THIS, SDL_Surface *screen, Uint32 flags);
extern int ph_AllocHWSurface(_THIS, SDL_Surface *surface);
extern void ph_FreeHWSurface(_THIS, SDL_Surface *surface);
......
......@@ -31,35 +31,36 @@ static unsigned long key1, key2;
static PgVideoModeInfo_t mode_info;
static PgVideoModes_t mode_list;
/* The current list of available video modes */
/* The current list of available video modes */
SDL_Rect SDL_modelist[PH_MAX_VIDEOMODES];
SDL_Rect* SDL_modearray[PH_MAX_VIDEOMODES];
static int compare_modes_by_res(const void* mode1, const void* mode2)
{
if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
{
fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
*(unsigned short*)mode1);
return 0;
}
if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
{
fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
*(unsigned short*)mode1);
return 0;
}
key1 = mode_info.width * mode_info.height;
key1 = mode_info.width * mode_info.height;
if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
{
fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
*(unsigned short*)mode2);
return 0;
}
key2 = mode_info.width * mode_info.height;
if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
{
fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
*(unsigned short*)mode2);
return 0;
}
if (key1 > key2)
return 1;
else if (key1 == key2)
return 0;
else
return -1;
key2 = mode_info.width * mode_info.height;
if (key1 > key2)
return 1;
else if (key1 == key2)
return 0;
else
return -1;
}
SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
......@@ -117,89 +118,6 @@ void ph_FreeVideoModes(_THIS)
return;
}
#if 0
static void set_best_resolution(_THIS, int width, int height)
{
/* warning ! dead variable use_vidmode ! */
if ( use_vidmode ) {
PgDisplaySettings_t settings;
PgVideoModeInfo_t current_mode_info;
PgHWCaps_t my_hwcaps;
unsigned short current_bpp;
int i;
/*
if (PgGetVideoMode( &settings ) < 0)
{
fprintf(stderr,"error: PgGetVideoMode failed\n");
return;
}
if (PgGetVideoModeInfo( settings.mode, &current_mode_info ) < 0)
{
fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
return;
}
*/
//lu_zero
if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
{
fprintf(stderr,"set_best_resolution: GetGraphicsHWCaps failed!! \n");
//that HAVE to work
}
if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &current_mode_info) < 0)
{
fprintf(stderr,"set_best_resolution: PgGetVideoModeInfo failed\n");
}
current_bpp = current_mode_info.bits_per_pixel;
if (PgGetVideoModeList(&mode_list) >= 0)
{
qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
#ifdef PH_DEBUG
printf("Available modes:\n");
for ( i = 0; i < mode_list.num_modes; ++i )
{
PgGetVideoModeInfo(mode_list.modes[i], &mode_info);
printf("Mode %d: %dx%d\n", i, mode_info.width, mode_info.height);
}
#endif
for ( i = mode_list.num_modes-1; i >= 0 ; --i )
{
if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
{
fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
}
if ( (mode_info.width >= width) &&
(mode_info.height >= height) &&
(mode_info.bits_per_pixel == current_bpp) )
break;
}
if (i >= 0)
{
if ( (mode_info.width != current_mode_info.width) ||
(mode_info.height != current_mode_info.height) )
{
settings.mode = mode_list.modes[i];
if(PgSetVideoMode( &settings ) < 0)
{
fprintf(stderr,"error: PgSetVideoMode failed\n");
}
}
}
}
}
}
int ph_ResizeFullScreen(_THIS)
{
if (currently_fullscreen)
{
set_best_resolution(this, current_w, current_h);
}
return (1);
}
#endif /* 0 */
/* return the mode associated with width, height and bpp */
/* if there is no mode then zero is returned */
int get_mode(int width, int height, int bpp)
......@@ -270,7 +188,7 @@ int get_mode_any_format(int width, int height, int bpp)
/* get closest bpp */
closest = i++;
if (mode_info.bits_per_pixel == bpp)
return mode_list.modes[ closest ];
return mode_list.modes[closest];
min_delta = abs(mode_info.bits_per_pixel - bpp);
while(1)
......@@ -300,16 +218,12 @@ int get_mode_any_format(int width, int height, int bpp)
i++;
}
}
return mode_list.modes[ closest ];
return mode_list.modes[closest];
}
else
return 0;
}
void ph_WaitMapped(_THIS);
void ph_WaitUnmapped(_THIS);
void ph_QueueEnterFullScreen(_THIS);
int ph_ToggleFullScreen(_THIS, int on)
{
if (currently_fullscreen)
......@@ -338,17 +252,18 @@ int ph_EnterFullScreen(_THIS)
}
}
if (OCImage.direct_context == NULL)
if (OCImage.direct_context==NULL)
{
OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
}
if (!OCImage.direct_context)
{
fprintf(stderr, "ph_EnterFullScreen: Can't create direct context\n" );
fprintf(stderr, "ph_EnterFullScreen(): Can't create direct context !\n");
return 0;
}
PdDirectStart(OCImage.direct_context);
OCImage.oldDC=PdDirectStart(OCImage.direct_context);
currently_fullscreen = 1;
}
......@@ -372,7 +287,8 @@ int ph_LeaveFullScreen(_THIS)
{
PdDirectStop(OCImage.direct_context);
PdReleaseDirectContext(OCImage.direct_context);
PhDCSetCurrent(OCImage.oldDC);
currently_fullscreen=0;
/* Restore old video mode */
......@@ -384,7 +300,8 @@ int ph_LeaveFullScreen(_THIS)
if (PgSetVideoMode(&mymode_settings) < 0)
{
fprintf(stderr,"error: PgSetVideoMode failed\n");
fprintf(stderr, "Ph_LeaveFullScreen(): PgSetVideoMode failed !\n");
return 0;
}
}
......
......@@ -36,9 +36,6 @@ static char rcsid =
extern SDL_Rect **ph_ListModes(_THIS,SDL_PixelFormat *format, Uint32 flags);
extern void ph_FreeVideoModes(_THIS);
extern int ph_ResizeFullScreen(_THIS);
extern void ph_WaitMapped(_THIS);
extern void ph_WaitUnmapped(_THIS);
extern void ph_QueueEnterFullScreen(_THIS);
extern int ph_EnterFullScreen(_THIS);
extern int ph_LeaveFullScreen(_THIS);
extern int get_mode(int width, int height, int bpp);
......
......@@ -35,18 +35,18 @@ static char rcsid =
#include "SDL_cursor_c.h"
#include "SDL_ph_mouse_c.h"
struct WMcursor {
struct WMcursor
{
PhCursorDef_t *ph_cursor ;
};
void ph_FreeWMCursor(_THIS, WMcursor *cursor)
{
if (window != NULL)
{
SDL_Lock_EventThread();
if (PtSetResource( window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0 ) < 0)
if (PtSetResource( window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0) < 0)
{
/* TODO: output error msg */
}
......@@ -60,63 +60,60 @@ void ph_FreeWMCursor(_THIS, WMcursor *cursor)
WMcursor *ph_CreateWMCursor(_THIS,
Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
{
WMcursor* cursor;
int clen, i;
unsigned char bit, databit, maskbit;
/* Allocate and initialize the cursor memory */
if ((cursor = (WMcursor*)malloc(sizeof(WMcursor))) == NULL)
{
SDL_OutOfMemory();
return(NULL);
}
memset(cursor,0,sizeof(WMcursor));
cursor->ph_cursor = (PhCursorDef_t *) malloc(sizeof(PhCursorDef_t) + 32*4*2);
if(cursor->ph_cursor == NULL)
printf("cursor malloc failed\n");
memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2));
cursor->ph_cursor->hdr.type =Ph_RDATA_CURSOR;
cursor->ph_cursor->size1.x = (short)w;
cursor->ph_cursor->size1.y = (short)h;
cursor->ph_cursor->offset1.x = (short)hot_x;
cursor->ph_cursor->offset1.y = (short)hot_y;
cursor->ph_cursor->bytesperline1 = (char)w/8;
cursor->ph_cursor->color1 = Pg_WHITE;
cursor->ph_cursor->size2.x = (short)w;
cursor->ph_cursor->size2.y = (short)h;
cursor->ph_cursor->offset2.x = (short)hot_x;
cursor->ph_cursor->offset2.y = (short)hot_y;
cursor->ph_cursor->bytesperline2 = (char)w/8;
cursor->ph_cursor->color2 = Pg_BLACK;
clen = (w/8)*h;
/* Copy the mask and the data to different
bitmap planes */
for ( i=0; i<clen; ++i )
{
for ( bit = 0; bit < 8; bit++ )
{
databit = data[i] & (1 << bit);
maskbit = mask[i] & (1 << bit);
cursor->ph_cursor->images[i] |=
(databit == 0) ? maskbit : 0;
/* If the databit != 0, treat it as a black pixel and
* ignore the maskbit (can't do an inverted color) */
cursor->ph_cursor->images[i+clen] |= databit;
}
}
/* #bytes following the hdr struct */
cursor->ph_cursor->hdr.len =sizeof(PhCursorDef_t) + clen*2 - sizeof(PhRegionDataHdr_t);
return (cursor);
}
WMcursor* cursor;
int clen, i;
unsigned char bit, databit, maskbit;
/* Allocate and initialize the cursor memory */
if ((cursor = (WMcursor*)malloc(sizeof(WMcursor))) == NULL)
{
SDL_OutOfMemory();
return(NULL);
}
memset(cursor,0,sizeof(WMcursor));
cursor->ph_cursor = (PhCursorDef_t *) malloc(sizeof(PhCursorDef_t) + 32*4*2);
if (cursor->ph_cursor == NULL)
printf("cursor malloc failed\n");
memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2));
cursor->ph_cursor->hdr.type =Ph_RDATA_CURSOR;
cursor->ph_cursor->size1.x = (short)w;
cursor->ph_cursor->size1.y = (short)h;
cursor->ph_cursor->offset1.x = (short)hot_x;
cursor->ph_cursor->offset1.y = (short)hot_y;
cursor->ph_cursor->bytesperline1 = (char)w/8;
cursor->ph_cursor->color1 = Pg_WHITE;
cursor->ph_cursor->size2.x = (short)w;
cursor->ph_cursor->size2.y = (short)h;
cursor->ph_cursor->offset2.x = (short)hot_x;
cursor->ph_cursor->offset2.y = (short)hot_y;
cursor->ph_cursor->bytesperline2 = (char)w/8;
cursor->ph_cursor->color2 = Pg_BLACK;
clen = (w/8)*h;
/* Copy the mask and the data to different bitmap planes */
for (i=0; i<clen; ++i)
{
for (bit = 0; bit < 8; bit++)
{
databit = data[i] & (1 << bit);
maskbit = mask[i] & (1 << bit);
cursor->ph_cursor->images[i] |= (databit == 0) ? maskbit : 0;
/* If the databit != 0, treat it as a black pixel and
* ignore the maskbit (can't do an inverted color) */
cursor->ph_cursor->images[i+clen] |= databit;
}
}
/* #bytes following the hdr struct */
cursor->ph_cursor->hdr.len =sizeof(PhCursorDef_t) + clen*2 - sizeof(PhRegionDataHdr_t);
return (cursor);
}
PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor)
{
......@@ -125,47 +122,46 @@ PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor)
int ph_ShowWMCursor(_THIS, WMcursor *cursor)
{
PtArg_t args[3];
int nargs = 0;
short cursor_is_defined = 0;
/* Don't do anything if the display is gone */
if ( window == NULL ) {
return(0);
}
/* Set the photon cursor cursor, or blank if cursor is NULL */
if ( window ) {
if ( cursor != NULL ) {
PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0 );
/* Could set next to any PgColor_t value */
PtSetArg( &args[1], Pt_ARG_CURSOR_COLOR,Ph_CURSOR_DEFAULT_COLOR , 0 );
PtSetArg( &args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t)) );
nargs = 3;
cursor_is_defined = 1;
}
else /* Ph_CURSOR_NONE */
{
PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE,Ph_CURSOR_NONE, 0);
nargs = 1;
cursor_is_defined = 1;
}
if (cursor_is_defined)
{
SDL_Lock_EventThread();
if (PtSetResources( window, nargs, args ) < 0 )
{
return(0);
}
SDL_Unlock_EventThread();
}
else
return(0);
}
return(1);
PtArg_t args[3];
int nargs = 0;
/* Don't do anything if the display is gone */
if (window == NULL)
{
return (0);
}
/* looks like photon can't draw mouse cursor in direct mode */
if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
{
return (0);
}
/* Set the photon cursor cursor, or blank if cursor is NULL */
if (cursor!=NULL)
{
PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0);
/* Could set next to any PgColor_t value */
PtSetArg(&args[1], Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR , 0);
PtSetArg(&args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t)));
nargs = 3;
}
else /* Ph_CURSOR_NONE */
{
PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0);
nargs = 1;
}
SDL_Lock_EventThread();
if (PtSetResources(window, nargs, args) < 0 )
{
return (0);
}
SDL_Unlock_EventThread();
return (1);
}
void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
......
This diff is collapsed.
......@@ -44,18 +44,16 @@
#define SDLPH_PAL_SYSTEM 0x00000002L
typedef union vidptr{
uint8_t *volatile ptr8;
uint16_t *volatile ptr16;
uint32_t *volatile ptr32;
uint8_t* volatile ptr8;
uint16_t* volatile ptr16;
uint32_t* volatile ptr32;
} VidPtr_t;
typedef struct {
unsigned char *Y;
unsigned char *V;
unsigned char *U;
}FRAMEDATA;
#define EVENT_SIZE sizeof( PhEvent_t ) + 1000
unsigned char* Y;
unsigned char* V;
unsigned char* U;
} FRAMEDATA;
/* Private display data */
struct SDL_PrivateVideoData {
......@@ -65,15 +63,17 @@ struct SDL_PrivateVideoData {
#ifdef HAVE_OPENGL
PdOpenGLContext_t* OGLContext; /* OpenGL context */
#endif /* HAVE_OPENGL */
PgColor_t ph_palette[_Pg_MAX_PALETTE];
PgColor_t savedpal[_Pg_MAX_PALETTE];
PgColor_t syspalph[_Pg_MAX_PALETTE];
struct {
PdDirectContext_t *direct_context;
PdOffscreenContext_t *offscreen_context;
PdDirectContext_t* direct_context;
PdOffscreenContext_t* offscreen_context;
PhDrawContext_t* oldDC;
VidPtr_t dc_ptr;
FRAMEDATA *CurrentFrameData;
FRAMEDATA *FrameData0;
FRAMEDATA *FrameData1;
unsigned char* CurrentFrameData;
unsigned char* FrameData0;
unsigned char* FrameData1;
int current;
long flags;
} ocimage;
......@@ -82,40 +82,15 @@ struct SDL_PrivateVideoData {
int old_video_mode; /* Stored mode before fullscreen switch */
int old_refresh_rate; /* Stored refresh rate befor fullscreen switch */
/* The current width and height of the fullscreen mode */
int current_w;
int current_h;
/* Support for internal mouse warping */
struct {
int x;
int y;
} mouse_last;
struct {
int numerator;
int denominator;
int threshold;
} mouse_accel;
int mouse_relative;
WMcursor* BlankCursor;
int depth; /* current visual depth (not bpp) */
int desktopbpp; /* bpp of desktop at the moment of start */
int desktoppal; /* palette mode emulation or system */
int captionflag; /* caption setting flag */
int use_vidmode;
int currently_fullscreen;
/* Automatic mode switching support (entering/leaving fullscreen) */
Uint32 switch_waiting;
Uint32 switch_time;
/* Prevent too many XSync() calls */
int blit_queued;
PhEvent_t* event;
};
......@@ -129,23 +104,13 @@ struct SDL_PrivateVideoData {
#define graphics_card_caps (this->hidden->graphics_card_caps)
#define desktopbpp (this->hidden->desktopbpp)
#define desktoppal (this->hidden->desktoppal)
#define ph_palette (this->hidden->ph_palette)
#define savedpal (this->hidden->savedpal)
#define syspalph (this->hidden->syspalph)
/* Old variable names */
#define current_w (this->hidden->current_w)
#define current_h (this->hidden->current_h)
#define mouse_last (this->hidden->mouse_last)
#define mouse_accel (this->hidden->mouse_accel)
#define mouse_relative (this->hidden->mouse_relative)
#define saved_mode (this->hidden->saved_mode)
#define saved_view (this->hidden->saved_view)
#define use_vidmode (this->hidden->use_vidmode)
#define currently_fullscreen (this->hidden->currently_fullscreen)
#define switch_waiting (this->hidden->switch_waiting)
#define switch_time (this->hidden->switch_time)
#define blit_queued (this->hidden->blit_queued)
#define event (this->hidden->event)
#define SDL_BlankCursor (this->hidden->BlankCursor)
#define captionflag (this->hidden->captionflag)
#endif /* _SDL_x11video_h */
......@@ -56,15 +56,11 @@ void ph_SetCaption(_THIS, const char *title, const char *icon)
{
SDL_Lock_EventThread();
/* check for set caption call before window init */
/* sanity check for set caption call before window init */
if (window!=NULL)
{
PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
}
else
{
captionflag=1;
}
SDL_Unlock_EventThread();
}
......@@ -88,36 +84,35 @@ int ph_IconifyWindow(_THIS)
SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
{
short abs_x, abs_y;
if( mode == SDL_GRAB_OFF )
{
PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
}
else
{
PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISALTKEY);
PtGetAbsPosition(window, &abs_x, &abs_y);
PhMoveCursorAbs(PhInputGroup(NULL), abs_x + SDL_VideoSurface->w/2, abs_y + SDL_VideoSurface->h/2);
}
SDL_Unlock_EventThread();
return(mode);
}
SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
{
short abs_x, abs_y;
SDL_Lock_EventThread();
/* mode = ph_GrabInputNoLock(this, mode);*/
if( mode == SDL_GRAB_OFF )
{
PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE,
Ph_WM_STATE_ISALTKEY );
}
else
{
PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE,
Ph_WM_STATE_ISALTKEY );
PtGetAbsPosition( window, &abs_x, &abs_y );
PhMoveCursorAbs( PhInputGroup( NULL ),
abs_x + SDL_VideoSurface->w/2,
abs_y + SDL_VideoSurface->h/2 );
}
SDL_Unlock_EventThread();
return(mode);
SDL_Lock_EventThread();
mode = ph_GrabInputNoLock(this, mode);
SDL_Unlock_EventThread();
return(mode);
}
int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
{
if (info->version.major <= SDL_MAJOR_VERSION)
......
This diff is collapsed.
......@@ -31,11 +31,7 @@ static char rcsid =
#include "SDL_ph_video.h"
extern SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
extern int ph_LockYUVOverlay(_THIS, SDL_Overlay *overlay);
extern void ph_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay);
extern int ph_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect);
extern void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay);
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