Skip to content

Commit

Permalink
Date: Sat, 23 Mar 2002 13:53:37 +0200
Browse files Browse the repository at this point in the history
From: "Mike Gorchak" <mike@malva.ua>
Subject: Big QNX patch again.

Added 8bit palette emulation code for window mode with bpp>=15.
Added store/restore original palette for 8bit modes.
Added more information about photon API call fails.
Rewroten change palette code, slow but works.
Fixed bug with set caption before window was inited.
Fixed bugs with some initial state of variables.
Fixed bug with storing old video mode settings.
Fixed bug with switching to fullscreen mode and back.
Fixed few double SEGFAULTS during parachute mode.
Removed compilation warning with no PgWaitHWIdle prototype.
Removed pack of dead unusable code.
Cleanups SDL_PrivateVideoData structure, some headers.
Some code formatting.
  • Loading branch information
slouken committed Mar 23, 2002
1 parent 6c4f07f commit d65ffef
Show file tree
Hide file tree
Showing 7 changed files with 325 additions and 510 deletions.
184 changes: 106 additions & 78 deletions src/video/photon/SDL_ph_image.c
Expand Up @@ -33,9 +33,13 @@ static char rcsid =
#include "SDL_endian.h"
#include "SDL_ph_image_c.h"

/* remove this line, if photon headers updates */
int PgWaitHWIdle(void);

int ph_SetupImage(_THIS, SDL_Surface *screen)
{
int type = 0;
int type=0;
PgColor_t* palette=NULL;

/* Determine image type */
switch(screen->format->BitsPerPixel)
Expand Down Expand Up @@ -69,11 +73,28 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
break;
}

/* using shared memory for speed (set last param to 1) */
if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL)
/* palette emulation code */
if ((screen->format->BitsPerPixel==8) && (desktoppal==SDLPH_PAL_EMULATE))
{
/* creating image palette */
palette=malloc(_Pg_MAX_PALETTE*sizeof(PgColor_t));
PgGetPalette(palette);

/* 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");
return -1;
}
}
else
{
fprintf(stderr,"error: PhCreateImage failed.\n");
return -1;
/* 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");
return -1;
}
}

screen->pixels = SDL_Image->image;
Expand All @@ -83,7 +104,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
return 0;
}

int ph_SetupOCImage(_THIS, SDL_Surface *screen) //Offscreen context
int ph_SetupOCImage(_THIS, SDL_Surface *screen)
{
int type = 0;

Expand Down Expand Up @@ -185,11 +206,18 @@ void ph_DestroyImage(_THIS, SDL_Surface *screen)

if (SDL_Image)
{
/* if palette allocated, free it */
if (SDL_Image->palette)
{
free(SDL_Image->palette);
}
PgShmemDestroy(SDL_Image->image);
free(SDL_Image);
SDL_Image = NULL;
}

/* Must be zeroed everytime */
SDL_Image = NULL;

if (screen)
{
screen->pixels = NULL;
Expand All @@ -200,14 +228,14 @@ int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
{
ph_DestroyImage(this, screen);

if( flags & SDL_HWSURFACE)
if (flags & SDL_HWSURFACE)
{
OCImage.flags = flags; /* needed for SDL_DOUBLEBUF check */
return ph_SetupOCImage(this, screen);
}
else if(flags & SDL_OPENGL)
else if (flags & SDL_OPENGL)
{
return ph_SetupOpenGLImage(this, screen);
return ph_SetupOpenGLImage(this, screen);
}
else
{
Expand All @@ -217,32 +245,32 @@ int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)

int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
{
return(-1);
return(-1);
}

void ph_FreeHWSurface(_THIS, SDL_Surface *surface)
{
return;
return;
}

int ph_FlipHWSurface(_THIS, SDL_Surface *surface)
{
return(0);
return(0);
}

int ph_LockHWSurface(_THIS, SDL_Surface *surface)
{
if ( (surface == SDL_VideoSurface) && blit_queued ) {
// XSync(GFX_Display, False);
PgFlush();
blit_queued = 0;
}
return(0);
if ((surface == SDL_VideoSurface) && blit_queued) {
PgFlush();
blit_queued = 0;
}

return(0);
}

void ph_UnlockHWSurface(_THIS, SDL_Surface *surface)
{
return;
return;
}

static PhPoint_t ph_pos;
Expand All @@ -258,80 +286,80 @@ void ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect* rects)

void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
{

for ( i=0; i<numrects; ++i )
{
if ( rects[i].w == 0 ) { /* Clipped? */
continue;
{
if (rects[i].w==0) /* Clipped? */
{
continue;
}

ph_pos.x = rects[i].x;
ph_pos.y = rects[i].y;
ph_rect.ul.x = rects[i].x;
ph_rect.ul.y = rects[i].y;
ph_rect.lr.x = rects[i].x + rects[i].w;
ph_rect.lr.y = rects[i].y + rects[i].h;
ph_pos.x = rects[i].x;
ph_pos.y = rects[i].y;
ph_rect.ul.x = rects[i].x;
ph_rect.ul.y = rects[i].y;
ph_rect.lr.x = rects[i].x + rects[i].w;
ph_rect.lr.y = rects[i].y + rects[i].h;

if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0)
{
fprintf(stderr,"ph_NormalUpdate: PgDrawPhImageRectmx failed.\n");
}
}

if (PgDrawPhImageRectmx( &ph_pos, SDL_Image, &ph_rect, 0 ) < 0)
{
fprintf(stderr,"error: PgDrawPhImageRectmx failed.\n");
}
}
if (PgFlush() < 0)
{
fprintf(stderr,"error: PgFlush failed.\n");
fprintf(stderr,"ph_NormalUpdate: PgFlush failed.\n");
}
}
void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects)
{
PhPoint_t zero = {0};
PhRect_t src_rect;
PhRect_t dest_rect;
PhPoint_t zero = {0};
PhRect_t src_rect;
PhRect_t dest_rect;

if(OCImage.direct_context == NULL)
{
return;
}

PgSetRegion(PtWidgetRid(window));
PgSetClipping(0,NULL);
PgWaitHWIdle();

if(OCImage.direct_context == NULL)
{
return;
}

for ( i=0; i<numrects; ++i )
{
if ( rects[i].w == 0 ) { /* Clipped? */
continue;
PgSetRegion(PtWidgetRid(window));
PgSetClipping(0,NULL);
PgWaitHWIdle();

for (i=0; i<numrects; ++i)
{
if (rects[i].w == 0) /* Clipped? */
{
continue;
}

src_rect.ul.x=rects[i].x;
src_rect.ul.y=rects[i].y;
dest_rect.ul.x=rects[i].x;
dest_rect.ul.y=rects[i].y;
dest_rect.lr.x=src_rect.lr.x= rects[i].x +rects[i].w;
dest_rect.lr.y=src_rect.lr.y= rects[i].y +rects[i].h;
zero.x = zero.y = 0;
PgSetTranslation (&zero, 0);
PgSetRegion(PtWidgetRid(window));
PgSetClipping(0,NULL);
PgContextBlitArea(OCImage.offscreen_context, (PhArea_t *)(&src_rect), NULL, (PhArea_t *)(&dest_rect));
}
src_rect.ul.x=rects[i].x;
src_rect.ul.y=rects[i].y;
dest_rect.ul.x=rects[i].x;
dest_rect.ul.y=rects[i].y;

dest_rect.lr.x=src_rect.lr.x= rects[i].x +rects[i].w;
dest_rect.lr.y=src_rect.lr.y= rects[i].y +rects[i].h;

zero.x = zero.y = 0;
PgSetTranslation (&zero, 0);
PgSetRegion(PtWidgetRid(window));
PgSetClipping(0,NULL);
PgContextBlitArea(OCImage.offscreen_context, (PhArea_t *)(&src_rect), NULL, (PhArea_t *)(&dest_rect));

}
if (PgFlush() < 0)
{
fprintf(stderr,"error: PgFlush failed.\n");
fprintf(stderr,"ph_OCUpdate: PgFlush failed.\n");
}

//later used to toggling double buffer
if(OCImage.current == 0)
{
OCImage.CurrentFrameData = OCImage.FrameData0;
}
else
{
OCImage.CurrentFrameData = OCImage.FrameData1;
}
/* later used to toggling double buffer */
if (OCImage.current == 0)
{
OCImage.CurrentFrameData = OCImage.FrameData0;
}
else
{
OCImage.CurrentFrameData = OCImage.FrameData1;
}
}

0 comments on commit d65ffef

Please sign in to comment.