Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
indent
  • Loading branch information
slouken committed Jan 14, 2009
1 parent 41e8e41 commit 9e11f775631ae714d78a416bca583c4e7f0c6fb9
@@ -228,9 +228,9 @@ extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
int height,
int bpp, Uint32 flags);
extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags);
extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width,
int height,
extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat *
format, Uint32 flags);
extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
int bpp, Uint32 flags);
extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
@@ -370,7 +370,7 @@ SDL_RunAudio(void *devicep)
silence = 0;
}

#if 0 /* !!! FIXME: I took len_div out of the structure. Use rate_incr instead? */
#if 0 /* !!! FIXME: I took len_div out of the structure. Use rate_incr instead? */
/* If the result of the conversion alters the length, i.e. resampling is being used, use the streamer */
if (device->convert.len_mult != 1 || device->convert.len_div != 1) {
/* The streamer's maximum length should be twice whichever is larger: spec.size or len_cvt */
@@ -894,7 +894,7 @@ SDL_FindFrequencyMultiple(const int src_rate, const int dst_rate)

/* zero means "not a supported multiple" ... we only do 2x and 4x. */
if ((hi % lo) != 0)
return 0; /* not a multiple. */
return 0; /* not a multiple. */

div = hi / lo;
retval = ((div == 2) || (div == 4)) ? div : 0;
@@ -915,7 +915,8 @@ SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
if (filter == NULL) {
int i;
const int upsample = (src_rate < dst_rate) ? 1 : 0;
const int multiple = SDL_FindFrequencyMultiple(src_rate, dst_rate);
const int multiple =
SDL_FindFrequencyMultiple(src_rate, dst_rate);

for (i = 0; sdl_audio_rate_filters[i].filter != NULL; i++) {
const SDL_AudioRateFilters *filt = &sdl_audio_rate_filters[i];
@@ -980,7 +981,6 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
if ((src_rate == 0) || (dst_rate == 0)) {
return -1;
}

#ifdef DEBUG_CONVERT
printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
@@ -1054,7 +1054,8 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
}

/* Do rate conversion, if necessary. Updates (cvt). */
if (SDL_BuildAudioResampleCVT(cvt, dst_channels, src_rate, dst_rate) == -1) {
if (SDL_BuildAudioResampleCVT(cvt, dst_channels, src_rate, dst_rate) ==
-1) {
return -1; /* shouldn't happen, but just in case... */
}

@@ -50,7 +50,8 @@ CalculateGammaRamp(float gamma, Uint16 * ramp)
int value;
gamma = 1.0f / gamma;
for (i = 0; i < 256; ++i) {
value = (int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5);
value =
(int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5);
if (value > 65535) {
value = 65535;
}
@@ -73,7 +74,7 @@ CalculateGammaFromRamp(float *gamma, Uint16 * ramp)
if ((ramp[i] != 0) && (ramp[i] != 65535)) {
double B = (double) i / 256.0;
double A = ramp[i] / 65535.0;
sum += (float) (SDL_log(A) / SDL_log(B));
sum += (float) (SDL_log(A) / SDL_log(B));
count++;
}
}
@@ -199,19 +199,17 @@ DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window)
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);

windata->window->GetPosition(windata->window,
&windata->restore.x,
&windata->restore.y);
&windata->restore.x, &windata->restore.y);
windata->window->GetSize(windata->window, &windata->restore.w,
&windata->restore.h);
&windata->restore.h);

/* Do this already here */
window->flags |= SDL_WINDOW_MAXIMIZED;
DirectFB_WM_AdjustWindowLayout(window);

windata->window->MoveTo(windata->window, 0, 0);
windata->window->Resize(windata->window,
display->current_mode.w,
display->current_mode.h);
display->current_mode.w, display->current_mode.h);
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
}

@@ -291,7 +289,7 @@ static int wm_lastx;
static int wm_lasty;

int
DirectFB_WM_ProcessEvent(_THIS, SDL_Window *window, DFBWindowEvent * evt)
DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
{
SDL_DFB_WINDOWDATA(window);

@@ -306,13 +304,14 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window *window, DFBWindowEvent * evt)
case WM_POS_NONE:
return 0;
case WM_POS_CLOSE:
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_CLOSE, 0, 0);
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_CLOSE, 0,
0);
return 1;
case WM_POS_MAX:
if (window->flags & SDL_WINDOW_MAXIMIZED) {
DirectFB_WM_RestoreWindow(_this, window);
} else {
DirectFB_WM_MaximizeWindow(_this, window);
DirectFB_WM_MaximizeWindow(_this, window);
}
return 1;
default:
@@ -46,9 +46,11 @@ extern void DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window);
extern void DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window);
extern void DirectFB_WM_RedrawLayout(SDL_Window * window);

extern int DirectFB_WM_ProcessEvent(_THIS, SDL_Window *window, DFBWindowEvent * evt);
extern int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window,
DFBWindowEvent * evt);

extern DFBResult DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch);
extern DFBResult DirectFB_WM_GetClientSize(_THIS, SDL_Window * window,
int *cw, int *ch);


#endif /* _SDL_directfb_wm_h */
@@ -177,7 +177,7 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
break;
case DWET_MOTION:
if (ClientXY(p, &evt->x, &evt->y)) {
SDL_Window *window = SDL_GetWindowFromID(p->sdl_id);
SDL_Window *window = SDL_GetWindowFromID(p->sdl_id);
if (!devdata->use_linux_input) {
if (!(flags & SDL_WINDOW_INPUT_GRABBED))
SDL_SendMouseMotion(devdata->mouse_id[0], 0,
@@ -193,7 +193,8 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
}
}
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS))
SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_ENTER, 0, 0);
SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_ENTER, 0,
0);
}
break;
case DWET_KEYDOWN:
@@ -182,9 +182,9 @@ static void
SetBlendMode(DirectFB_RenderData * data, int blendMode,
DirectFB_TextureData * source)
{
SDL_DFB_WINDOWSURFACE(data->window);
//FIXME: check for format change
SDL_DFB_WINDOWSURFACE(data->window);

//FIXME: check for format change
if (1 || data->lastBlendMode != blendMode) {
switch (blendMode) {
case SDL_BLENDMODE_NONE:
@@ -198,15 +198,13 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode,
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
destsurf->SetDstBlendFunction(destsurf,
DSBF_INVSRCALPHA);
destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA);
break;
case SDL_BLENDMODE_BLEND:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
data->drawFlags = DSDRAW_BLEND;
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
destsurf->SetDstBlendFunction(destsurf,
DSBF_INVSRCALPHA);
destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA);
break;
case SDL_BLENDMODE_ADD:
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
@@ -215,8 +213,7 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode,
// It will be cheaper to copy the surface to
// a temporay surface and premultiply
if (source && TextureHasAlpha(source))
destsurf->SetSrcBlendFunction(destsurf,
DSBF_SRCALPHA);
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
else
destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE);
destsurf->SetDstBlendFunction(destsurf, DSBF_ONE);
@@ -324,7 +321,8 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
} else
data->flipflags |= DSFLIP_ONSYNC;

SDL_DFB_CHECKERR(windata->surface->GetCapabilities(windata->surface, &scaps));
SDL_DFB_CHECKERR(windata->surface->
GetCapabilities(windata->surface, &scaps));
if (scaps & DSCAPS_DOUBLE)
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
else if (scaps & DSCAPS_TRIPLE)
@@ -799,7 +797,7 @@ PrepareDraw(SDL_Renderer * renderer)
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
SDL_DFB_WINDOWSURFACE(data->window);

DFBResult ret;
Uint8 r, g, b, a;

@@ -809,8 +807,7 @@ PrepareDraw(SDL_Renderer * renderer)
a = renderer->a;

SetBlendMode(data, renderer->blendMode, NULL);
SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf,
data->drawFlags));
SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf, data->drawFlags));

switch (renderer->blendMode) {
case SDL_BLENDMODE_NONE:
@@ -856,8 +853,7 @@ DirectFB_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
PrepareDraw(renderer);
/* Use antialiasing when available */
#if (DFB_VERSION_ATLEAST(1,2,0))
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
DSRO_ANTIALIAS));
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, DSRO_ANTIALIAS));
#endif
SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, x1, y1, x2, y2));
return 0;
@@ -874,7 +870,7 @@ DirectFB_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)

PrepareDraw(renderer);
SDL_DFB_CHECKERR(destsurf->FillRectangle(destsurf, rect->x, rect->y,
rect->w, rect->h));
rect->w, rect->h));

return 0;
error:
@@ -938,48 +934,49 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
SDLtoDFBRect(srcrect, &sr);
SDLtoDFBRect(dstrect, &dr);

SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF));
if (texture->modMode &
(SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA)) {
SDL_DFB_CHECKERR(destsurf->
SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF));
if (texture->
modMode & (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA))
{
if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
alpha = texture->a;
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
0xFF, alpha));
0xFF, alpha));
}
if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {

SDL_DFB_CHECKERR(destsurf->SetColor(destsurf,
texture->r,
texture->g,
texture->b, alpha));
texture->r,
texture->g,
texture->b, alpha));
flags |= DSBLIT_COLORIZE;
}
if (alpha < 0xFF)
flags |= DSBLIT_SRC_PREMULTCOLOR;
} else
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
0xFF, 0xFF));
0xFF, 0xFF));

SetBlendMode(data, texture->blendMode, texturedata);

SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf,
data->blitFlags
| flags));
data->blitFlags | flags));

#if (DFB_VERSION_ATLEAST(1,2,0))
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
texturedata->
render_options));
texturedata->
render_options));
#endif

if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
SDL_DFB_CHECKERR(destsurf->Blit(destsurf,
texturedata->surface,
&sr, dr.x, dr.y));
texturedata->surface,
&sr, dr.x, dr.y));
} else {
SDL_DFB_CHECKERR(destsurf->StretchBlit(destsurf,
texturedata->surface,
&sr, &dr));
texturedata->surface,
&sr, &dr));
}
}
return 0;
@@ -1035,7 +1032,7 @@ static void
DirectFB_DestroyRenderer(SDL_Renderer * renderer)
{
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;

if (data) {
SDL_free(data);
}
@@ -254,9 +254,9 @@ DirectFB_VideoInit(_THIS)
/* simple window manager support */
stemp = SDL_getenv(DFBENV_USE_WM);
if (stemp)
devdata->has_own_wm = atoi(stemp);
devdata->has_own_wm = atoi(stemp);
else
devdata->has_own_wm = 0;
devdata->has_own_wm = 0;

devdata->dfb = dfb;
devdata->firstwin = NULL;
@@ -44,10 +44,10 @@
(DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z))

#if (DFB_VERSION_ATLEAST(1,0,0))
#define SDL_DIRECTFB_OPENGL 1
#include <directfbgl.h>
#define SDL_DIRECTFB_OPENGL 1
#include <directfbgl.h>
#else
#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
#endif

#if SDL_DIRECTFB_OPENGL
@@ -69,7 +69,7 @@
#define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" /* Default: off */
#define DFBENV_USE_X11_CHECK "SDL_DIRECTFB_X11_CHECK" /* Default: on */
#define DFBENV_USE_LINUX_INPUT "SDL_DIRECTFB_LINUX_INPUT" /* Default: on */
#define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */
#define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */

#define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { x->Release(x); x = NULL; } } while (0)
#define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0)

0 comments on commit 9e11f77

Please sign in to comment.