Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
indent
  • Loading branch information
slouken committed Nov 25, 2008
1 parent 6f3204f commit 8e54202
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 123 deletions.
86 changes: 46 additions & 40 deletions src/SDL_compat.c
Expand Up @@ -1350,7 +1350,7 @@ struct private_yuvhwdata
Uint16 pitches[3];
Uint8 *planes[3];

SDL_SW_YUVTexture *sw;
SDL_SW_YUVTexture *sw;

SDL_TextureID textureID;
};
Expand Down Expand Up @@ -1435,19 +1435,20 @@ SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display)
overlay->hwdata->textureID =
SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h);
if (overlay->hwdata->textureID) {
overlay->hwdata->sw = NULL;
} else {
overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h);
if (!overlay->hwdata->sw) {
SDL_FreeYUVOverlay(overlay);
return NULL;
}

/* Create a supported RGB format texture for display */
overlay->hwdata->textureID =
SDL_CreateTexture(SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, w, h);
}
if (!overlay->hwdata->textureID) {
overlay->hwdata->sw = NULL;
} else {
overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h);
if (!overlay->hwdata->sw) {
SDL_FreeYUVOverlay(overlay);
return NULL;
}

/* Create a supported RGB format texture for display */
overlay->hwdata->textureID =
SDL_CreateTexture(SDL_PIXELFORMAT_RGB888,
SDL_TEXTUREACCESS_STREAMING, w, h);
}
if (!overlay->hwdata->textureID) {
SDL_FreeYUVOverlay(overlay);
return NULL;
}
Expand All @@ -1465,16 +1466,18 @@ SDL_LockYUVOverlay(SDL_Overlay * overlay)
SDL_SetError("Passed a NULL overlay");
return -1;
}
if (overlay->hwdata->sw) {
if (SDL_SW_QueryYUVTexturePixels(overlay->hwdata->sw, &pixels, &pitch) < 0) {
return -1;
}
} else {
if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch)
< 0) {
return -1;
}
}
if (overlay->hwdata->sw) {
if (SDL_SW_QueryYUVTexturePixels(overlay->hwdata->sw, &pixels, &pitch)
< 0) {
return -1;
}
} else {
if (SDL_LockTexture
(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch)
< 0) {
return -1;
}
}
overlay->pixels[0] = (Uint8 *) pixels;
overlay->pitches[0] = pitch;
switch (overlay->format) {
Expand All @@ -1501,22 +1504,25 @@ SDL_UnlockYUVOverlay(SDL_Overlay * overlay)
if (!overlay) {
return;
}
if (overlay->hwdata->sw) {
void *pixels;
int pitch;
if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) == 0) {
SDL_Rect srcrect;

srcrect.x = 0;
srcrect.y = 0;
srcrect.w = overlay->w;
srcrect.h = overlay->h;
SDL_SW_CopyYUVToRGB(overlay->hwdata->sw, &srcrect, SDL_PIXELFORMAT_RGB888, overlay->w, overlay->h, pixels, pitch);
SDL_UnlockTexture(overlay->hwdata->textureID);
}
} else {
SDL_UnlockTexture(overlay->hwdata->textureID);
}
if (overlay->hwdata->sw) {
void *pixels;
int pitch;
if (SDL_LockTexture
(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) == 0) {
SDL_Rect srcrect;

srcrect.x = 0;
srcrect.y = 0;
srcrect.w = overlay->w;
srcrect.h = overlay->h;
SDL_SW_CopyYUVToRGB(overlay->hwdata->sw, &srcrect,
SDL_PIXELFORMAT_RGB888, overlay->w,
overlay->h, pixels, pitch);
SDL_UnlockTexture(overlay->hwdata->textureID);
}
} else {
SDL_UnlockTexture(overlay->hwdata->textureID);
}
}

int
Expand Down
12 changes: 6 additions & 6 deletions src/haptic/win32/SDL_syshaptic.c
Expand Up @@ -105,11 +105,11 @@ static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv);
static void
DI_SetError(const char *str, HRESULT err)
{
/*
SDL_SetError("Haptic: %s - %s: %s", str,
DXGetErrorString8A(err), DXGetErrorDescription8A(err));
*/
SDL_SetError("Haptic error %s", str);
/*
SDL_SetError("Haptic: %s - %s: %s", str,
DXGetErrorString8A(err), DXGetErrorDescription8A(err));
*/
SDL_SetError("Haptic error %s", str);
}


Expand Down Expand Up @@ -154,7 +154,7 @@ SDL_SYS_HapticInit(void)
}

ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectInput, (LPVOID)&dinput);
&IID_IDirectInput, (LPVOID) & dinput);
if (FAILED(ret)) {
DI_SetError("CoCreateInstance", ret);
return -1;
Expand Down
3 changes: 2 additions & 1 deletion src/video/SDL_renderer_sw.c
Expand Up @@ -361,7 +361,8 @@ static int
SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
texture->driverdata = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
texture->driverdata =
SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
} else {
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
Expand Down
122 changes: 61 additions & 61 deletions src/video/SDL_surface.c
Expand Up @@ -271,68 +271,68 @@ SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key)

/* This is a fairly slow function to switch from colorkey to alpha */
void
SDL_ConvertColorkeyToAlpha(SDL_Surface *surface)
SDL_ConvertColorkeyToAlpha(SDL_Surface * surface)
{
int x, y;

if (!surface) {
return;
}

if (!(surface->map->info.flags & SDL_COPY_COLORKEY) ||
!surface->format->Amask) {
return;
}

SDL_LockSurface(surface);

switch (surface->format->BytesPerPixel) {
case 2:
{
Uint16 *row, *spot;
Uint16 ckey = (Uint16)surface->map->info.colorkey;
Uint16 mask = (Uint16)(~surface->format->Amask);

row = (Uint16 *)surface->pixels;
for (y = surface->h; y--; ) {
spot = row;
for (x = surface->w; x--; ) {
if (*spot == ckey) {
*spot &= mask;
}
++spot;
}
row += surface->pitch / 2;
}
}
break;
case 3:
/* FIXME */
break;
case 4:
{
Uint32 *row, *spot;
Uint32 ckey = surface->map->info.colorkey;
Uint32 mask = ~surface->format->Amask;

row = (Uint32 *)surface->pixels;
for (y = surface->h; y--; ) {
spot = row;
for (x = surface->w; x--; ) {
if (*spot == ckey) {
*spot &= mask;
}
++spot;
}
row += surface->pitch / 4;
}
}
break;
}

SDL_UnlockSurface(surface);

SDL_SetColorKey(surface, 0, 0);
int x, y;

if (!surface) {
return;
}

if (!(surface->map->info.flags & SDL_COPY_COLORKEY) ||
!surface->format->Amask) {
return;
}

SDL_LockSurface(surface);

switch (surface->format->BytesPerPixel) {
case 2:
{
Uint16 *row, *spot;
Uint16 ckey = (Uint16) surface->map->info.colorkey;
Uint16 mask = (Uint16) (~surface->format->Amask);

row = (Uint16 *) surface->pixels;
for (y = surface->h; y--;) {
spot = row;
for (x = surface->w; x--;) {
if (*spot == ckey) {
*spot &= mask;
}
++spot;
}
row += surface->pitch / 2;
}
}
break;
case 3:
/* FIXME */
break;
case 4:
{
Uint32 *row, *spot;
Uint32 ckey = surface->map->info.colorkey;
Uint32 mask = ~surface->format->Amask;

row = (Uint32 *) surface->pixels;
for (y = surface->h; y--;) {
spot = row;
for (x = surface->w; x--;) {
if (*spot == ckey) {
*spot &= mask;
}
++spot;
}
row += surface->pitch / 4;
}
}
break;
}

SDL_UnlockSurface(surface);

SDL_SetColorKey(surface, 0, 0);
}

int
Expand Down
4 changes: 2 additions & 2 deletions src/video/SDL_video.c
Expand Up @@ -47,7 +47,7 @@
#endif /* SDL_VIDEO_OPENGL */

/* From SDL_surface.c */
extern void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface);
extern void SDL_ConvertColorkeyToAlpha(SDL_Surface * surface);

/* Available video drivers */
static VideoBootStrap *bootstrap[] = {
Expand Down Expand Up @@ -1588,7 +1588,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
}
dst = SDL_ConvertSurface(surface, dst_fmt, 0);
if (dst) {
SDL_ConvertColorkeyToAlpha(dst);
SDL_ConvertColorkeyToAlpha(dst);
SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
SDL_FreeSurface(dst);
}
Expand Down
14 changes: 6 additions & 8 deletions src/video/SDL_yuv_sw.c
Expand Up @@ -91,9 +91,9 @@

struct SDL_SW_YUVTexture
{
Uint32 format;
Uint32 format;
Uint32 target_format;
int w, h;
int w, h;
Uint8 *pixels;
int *colortab;
Uint32 *rgb_2_pix;
Expand Down Expand Up @@ -1075,8 +1075,8 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)

swdata->format = format;
swdata->target_format = SDL_PIXELFORMAT_UNKNOWN;
swdata->w = w;
swdata->h = h;
swdata->w = w;
swdata->h = h;
swdata->pixels = (Uint8 *) SDL_malloc(w * h * 2);
swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int));
swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32));
Expand Down Expand Up @@ -1110,10 +1110,8 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
swdata->pitches[1] = swdata->pitches[0] / 2;
swdata->pitches[2] = swdata->pitches[0] / 2;
swdata->planes[0] = swdata->pixels;
swdata->planes[1] =
swdata->planes[0] + swdata->pitches[0] * h;
swdata->planes[2] =
swdata->planes[1] + swdata->pitches[1] * h / 2;
swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * h;
swdata->planes[2] = swdata->planes[1] + swdata->pitches[1] * h / 2;
break;
case SDL_PIXELFORMAT_YUY2:
case SDL_PIXELFORMAT_UYVY:
Expand Down
5 changes: 3 additions & 2 deletions src/video/win32/SDL_d3drender.c
Expand Up @@ -27,7 +27,7 @@

/* Direct3D renderer implementation */

#if 1 /* This takes more memory but you won't lose your texture data */
#if 1 /* This takes more memory but you won't lose your texture data */
#define D3DPOOL_SDL D3DPOOL_MANAGED
#define SDL_MEMORY_POOL_MANAGED
#else
Expand Down Expand Up @@ -633,7 +633,8 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
d3drect.top = rect->y;
d3drect.bottom = rect->y + rect->h;

result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
result =
IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0);
if (FAILED(result)) {
D3D_SetError("LockRect()", result);
return -1;
Expand Down
3 changes: 2 additions & 1 deletion src/video/win32/SDL_gdirender.c
Expand Up @@ -294,7 +294,8 @@ GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
texture->driverdata = data;

if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
data->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
data->yuv =
SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
if (!data->yuv) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion test/testsprite.c
Expand Up @@ -311,7 +311,7 @@ main(int argc, char *argv[])
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
double fps = ((double) frames * 1000) / (now - then);
printf("%2.2f frames per second\n", fps);
}
SDL_Quit();
Expand Down
2 changes: 1 addition & 1 deletion test/testsprite2.c
Expand Up @@ -291,7 +291,7 @@ main(int argc, char *argv[])
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
double fps = ((double) frames * 1000) / (now - then);
printf("%2.2f frames per second\n", fps);
}
quit(0);
Expand Down

0 comments on commit 8e54202

Please sign in to comment.