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

Commit

Permalink
indent
Browse files Browse the repository at this point in the history
  • 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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ struct private_yuvhwdata
Uint16 pitches[3]; Uint16 pitches[3];
Uint8 *planes[3]; Uint8 *planes[3];


SDL_SW_YUVTexture *sw; SDL_SW_YUVTexture *sw;


SDL_TextureID textureID; 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 = overlay->hwdata->textureID =
SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h); SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h);
if (overlay->hwdata->textureID) { if (overlay->hwdata->textureID) {
overlay->hwdata->sw = NULL; overlay->hwdata->sw = NULL;
} else { } else {
overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h); overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h);
if (!overlay->hwdata->sw) { if (!overlay->hwdata->sw) {
SDL_FreeYUVOverlay(overlay); SDL_FreeYUVOverlay(overlay);
return NULL; return NULL;
} }


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

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


int int
Expand Down
12 changes: 6 additions & 6 deletions src/haptic/win32/SDL_syshaptic.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv);
static void static void
DI_SetError(const char *str, HRESULT err) DI_SetError(const char *str, HRESULT err)
{ {
/* /*
SDL_SetError("Haptic: %s - %s: %s", str, SDL_SetError("Haptic: %s - %s: %s", str,
DXGetErrorString8A(err), DXGetErrorDescription8A(err)); DXGetErrorString8A(err), DXGetErrorDescription8A(err));
*/ */
SDL_SetError("Haptic error %s", str); 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, ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectInput, (LPVOID)&dinput); &IID_IDirectInput, (LPVOID) & dinput);
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("CoCreateInstance", ret); DI_SetError("CoCreateInstance", ret);
return -1; return -1;
Expand Down
3 changes: 2 additions & 1 deletion src/video/SDL_renderer_sw.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ static int
SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{ {
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { 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 { } else {
int bpp; int bpp;
Uint32 Rmask, Gmask, Bmask, Amask; Uint32 Rmask, Gmask, Bmask, Amask;
Expand Down
122 changes: 61 additions & 61 deletions src/video/SDL_surface.c
Original file line number Original file line Diff line number Diff line change
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 */ /* This is a fairly slow function to switch from colorkey to alpha */
void void
SDL_ConvertColorkeyToAlpha(SDL_Surface *surface) SDL_ConvertColorkeyToAlpha(SDL_Surface * surface)
{ {
int x, y; int x, y;


if (!surface) { if (!surface) {
return; return;
} }


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


SDL_LockSurface(surface); SDL_LockSurface(surface);


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


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


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


SDL_UnlockSurface(surface); SDL_UnlockSurface(surface);


SDL_SetColorKey(surface, 0, 0); SDL_SetColorKey(surface, 0, 0);
} }


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


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


/* Available video drivers */ /* Available video drivers */
static VideoBootStrap *bootstrap[] = { 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); dst = SDL_ConvertSurface(surface, dst_fmt, 0);
if (dst) { if (dst) {
SDL_ConvertColorkeyToAlpha(dst); SDL_ConvertColorkeyToAlpha(dst);
SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch); SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
SDL_FreeSurface(dst); SDL_FreeSurface(dst);
} }
Expand Down
14 changes: 6 additions & 8 deletions src/video/SDL_yuv_sw.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@


struct SDL_SW_YUVTexture struct SDL_SW_YUVTexture
{ {
Uint32 format; Uint32 format;
Uint32 target_format; Uint32 target_format;
int w, h; int w, h;
Uint8 *pixels; Uint8 *pixels;
int *colortab; int *colortab;
Uint32 *rgb_2_pix; 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->format = format;
swdata->target_format = SDL_PIXELFORMAT_UNKNOWN; swdata->target_format = SDL_PIXELFORMAT_UNKNOWN;
swdata->w = w; swdata->w = w;
swdata->h = h; swdata->h = h;
swdata->pixels = (Uint8 *) SDL_malloc(w * h * 2); swdata->pixels = (Uint8 *) SDL_malloc(w * h * 2);
swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int)); swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int));
swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32)); 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[1] = swdata->pitches[0] / 2;
swdata->pitches[2] = swdata->pitches[0] / 2; swdata->pitches[2] = swdata->pitches[0] / 2;
swdata->planes[0] = swdata->pixels; swdata->planes[0] = swdata->pixels;
swdata->planes[1] = swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * h;
swdata->planes[0] + swdata->pitches[0] * h; swdata->planes[2] = swdata->planes[1] + swdata->pitches[1] * h / 2;
swdata->planes[2] =
swdata->planes[1] + swdata->pitches[1] * h / 2;
break; break;
case SDL_PIXELFORMAT_YUY2: case SDL_PIXELFORMAT_YUY2:
case SDL_PIXELFORMAT_UYVY: case SDL_PIXELFORMAT_UYVY:
Expand Down
5 changes: 3 additions & 2 deletions src/video/win32/SDL_d3drender.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


/* Direct3D renderer implementation */ /* 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 D3DPOOL_SDL D3DPOOL_MANAGED
#define SDL_MEMORY_POOL_MANAGED #define SDL_MEMORY_POOL_MANAGED
#else #else
Expand Down Expand Up @@ -633,7 +633,8 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
d3drect.top = rect->y; d3drect.top = rect->y;
d3drect.bottom = rect->y + rect->h; 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)) { if (FAILED(result)) {
D3D_SetError("LockRect()", result); D3D_SetError("LockRect()", result);
return -1; return -1;
Expand Down
3 changes: 2 additions & 1 deletion src/video/win32/SDL_gdirender.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
texture->driverdata = data; texture->driverdata = data;


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

0 comments on commit 8e54202

Please sign in to comment.