Commit a733eee1 authored by Sam Lantinga's avatar Sam Lantinga

indent

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403247
parent de690ebe
...@@ -1350,7 +1350,7 @@ struct private_yuvhwdata ...@@ -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;
}; };
...@@ -1435,19 +1435,20 @@ SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display) ...@@ -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;
} }
...@@ -1465,16 +1466,18 @@ SDL_LockYUVOverlay(SDL_Overlay * overlay) ...@@ -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) {
...@@ -1501,22 +1504,25 @@ SDL_UnlockYUVOverlay(SDL_Overlay * overlay) ...@@ -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
......
...@@ -105,11 +105,11 @@ static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv); ...@@ -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);
} }
...@@ -154,7 +154,7 @@ SDL_SYS_HapticInit(void) ...@@ -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;
......
...@@ -361,7 +361,8 @@ static int ...@@ -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;
......
...@@ -271,68 +271,68 @@ SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key) ...@@ -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
......
...@@ -47,7 +47,7 @@ ...@@ -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[] = {
...@@ -1588,7 +1588,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) ...@@ -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);
} }
......
...@@ -91,9 +91,9 @@ ...@@ -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;
...@@ -1075,8 +1075,8 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) ...@@ -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));
...@@ -1110,10 +1110,8 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) ...@@ -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:
......
...@@ -27,7 +27,7 @@ ...@@ -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
...@@ -633,7 +633,8 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, ...@@ -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;
......
...@@ -294,7 +294,8 @@ GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) ...@@ -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;
} }
......
...@@ -311,7 +311,7 @@ main(int argc, char *argv[]) ...@@ -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();
......
...@@ -291,7 +291,7 @@ main(int argc, char *argv[]) ...@@ -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);
......
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