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

Commit

Permalink
Added DFB_VERSION_ATLEAST macro
Browse files Browse the repository at this point in the history
First attempt at replacing MakeSubSurface for pre 1.2.0 ==> Scaling not yet working
  • Loading branch information
Couriersud committed Jan 13, 2009
1 parent ecf335a commit 2be3a21
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/video/directfb/SDL_DirectFB_events.c
Expand Up @@ -48,7 +48,7 @@ static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button);
static void
DirectFB_SetContext(_THIS, SDL_WindowID id)
{
#if (DIRECTFB_MAJOR_VERSION >= 1)
#if (DFB_VERSION_ATLEAST(1,0,0))
/* FIXME: does not work on 1.0/1.2 with radeon driver
* the approach did work with the matrox driver
* This has simply no effect.
Expand Down
4 changes: 2 additions & 2 deletions src/video/directfb/SDL_DirectFB_modes.c
Expand Up @@ -335,7 +335,7 @@ DirectFB_InitModes(_THIS)
display.current_mode = mode;
display.driverdata = dispdata;

#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
#if (DFB_VERSION_ATLEAST(1,2,0))
dlc.flags =
DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT |
DLCONF_OPTIONS;
Expand Down Expand Up @@ -438,7 +438,7 @@ DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
SDL_DFB_DEBUG("Trace\n");
config.flags &= ~fail;
SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config));
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
#if (DFB_VERSION_ATLEAST(1,2,0))
/* Need to call this twice ! */
SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config));
#endif
Expand Down
12 changes: 6 additions & 6 deletions src/video/directfb/SDL_DirectFB_render.c
Expand Up @@ -140,7 +140,7 @@ typedef struct
IDirectFBPalette *palette;
SDL_VideoDisplay *display;
SDL_DirtyRectList dirty;
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
#if (DFB_VERSION_ATLEAST(1,2,0))
DFBSurfaceRenderOptions render_options;
#endif
} DirectFB_TextureData;
Expand Down Expand Up @@ -387,7 +387,7 @@ SDLToDFBPixelFormat(Uint32 format)
case SDL_PIXELFORMAT_INDEX4MSB:
return DSPF_UNKNOWN;
case SDL_PIXELFORMAT_RGB444:
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
#if (DFB_VERSION_ATLEAST(1,2,0))
return DSPF_RGB444;
#else
return DSPF_UNKNOWN;
Expand Down Expand Up @@ -543,7 +543,7 @@ DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
}

}
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
#if (DFB_VERSION_ATLEAST(1,2,0))
data->render_options = DSRO_NONE;
#endif

Expand Down Expand Up @@ -673,7 +673,7 @@ DirectFB_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
static int
DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
#if (DFB_VERSION_ATLEAST(1,2,0))

DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;

Expand Down Expand Up @@ -847,7 +847,7 @@ DirectFB_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)

PrepareDraw(renderer);
/* Use antialiasing when available */
#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
#if (DFB_VERSION_ATLEAST(1,2,0))
SDL_DFB_CHECKERR(data->surface->SetRenderOptions(data->surface,
DSRO_ANTIALIAS));
#endif
Expand Down Expand Up @@ -961,7 +961,7 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
data->blitFlags
| flags));

#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
#if (DFB_VERSION_ATLEAST(1,2,0))
SDL_DFB_CHECKERR(data->surface->SetRenderOptions(data->surface,
texturedata->
render_options));
Expand Down
19 changes: 13 additions & 6 deletions src/video/directfb/SDL_DirectFB_video.h
Expand Up @@ -34,13 +34,20 @@
#define DEBUG 0
#define LOG_CHANNEL stdout

#if (DIRECTFB_MAJOR_VERSION < 1)
#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
#endif
#define DFB_VERSIONNUM(X, Y, Z) \
((X)*1000 + (Y)*100 + (Z))

#define DFB_COMPILEDVERSION \
DFB_VERSIONNUM(DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION, DIRECTFB_MICRO_VERSION)

#if (DIRECTFB_MAJOR_VERSION >= 1) && (DIRECTFB_MINOR_VERSION >= 0) && (DIRECTFB_MICRO_VERSION >= 0 )
#define SDL_DIRECTFB_OPENGL 1
#include <directfbgl.h>
#define DFB_VERSION_ATLEAST(X, Y, Z) \
(DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z))

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

#if SDL_DIRECTFB_OPENGL
Expand Down
20 changes: 17 additions & 3 deletions src/video/directfb/SDL_DirectFB_window.c
Expand Up @@ -420,14 +420,28 @@ DirectFB_AdjustWindowSurface(SDL_Window * window)
}

if (adjust) {
SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
#if DFB_VERSION_ATLEAST(1,2,0)
SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
windata->size.w,
windata->size.h));
SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface,
SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface,
windata->
window_surface,
&windata->client));
DirectFB_WM_RedrawLayout(window);
#else
/* recreate subsurface */
windata->surface->ReleaseSource(windata->surface);
windata->window_surface->ReleaseSource(windata->window_surface);
SDL_DFB_RELEASE(windata->surface);
windata->surface = NULL;
SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
windata->size.w,
windata->size.h));
SDL_DFB_CHECKERR(windata->window_surface->
GetSubSurface(windata->window_surface, &windata->client,
&windata->surface));
#endif
DirectFB_WM_RedrawLayout(window);
}
error:
return;
Expand Down

0 comments on commit 2be3a21

Please sign in to comment.