Added DFB_VERSION_ATLEAST macro
authorCouriersud <couriersud@arcor.de>
Tue, 13 Jan 2009 21:17:38 +0000
changeset 3037490f3e4fe753
parent 3036 76a1692fcec5
child 3038 c73a5f8a03d2
Added DFB_VERSION_ATLEAST macro
First attempt at replacing MakeSubSurface for pre 1.2.0 ==> Scaling not yet working
src/video/directfb/SDL_DirectFB_events.c
src/video/directfb/SDL_DirectFB_modes.c
src/video/directfb/SDL_DirectFB_render.c
src/video/directfb/SDL_DirectFB_video.h
src/video/directfb/SDL_DirectFB_window.c
     1.1 --- a/src/video/directfb/SDL_DirectFB_events.c	Tue Jan 13 19:31:06 2009 +0000
     1.2 +++ b/src/video/directfb/SDL_DirectFB_events.c	Tue Jan 13 21:17:38 2009 +0000
     1.3 @@ -48,7 +48,7 @@
     1.4  static void
     1.5  DirectFB_SetContext(_THIS, SDL_WindowID id)
     1.6  {
     1.7 -#if (DIRECTFB_MAJOR_VERSION >= 1)
     1.8 +#if (DFB_VERSION_ATLEAST(1,0,0))
     1.9      /* FIXME: does not work on 1.0/1.2 with radeon driver
    1.10       *        the approach did work with the matrox driver
    1.11       *        This has simply no effect.
     2.1 --- a/src/video/directfb/SDL_DirectFB_modes.c	Tue Jan 13 19:31:06 2009 +0000
     2.2 +++ b/src/video/directfb/SDL_DirectFB_modes.c	Tue Jan 13 21:17:38 2009 +0000
     2.3 @@ -335,7 +335,7 @@
     2.4          display.current_mode = mode;
     2.5          display.driverdata = dispdata;
     2.6  
     2.7 -#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
     2.8 +#if (DFB_VERSION_ATLEAST(1,2,0))
     2.9          dlc.flags =
    2.10              DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT |
    2.11              DLCONF_OPTIONS;
    2.12 @@ -438,7 +438,7 @@
    2.13      SDL_DFB_DEBUG("Trace\n");
    2.14      config.flags &= ~fail;
    2.15      SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config));
    2.16 -#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
    2.17 +#if (DFB_VERSION_ATLEAST(1,2,0))
    2.18      /* Need to call this twice ! */
    2.19      SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config));
    2.20  #endif
     3.1 --- a/src/video/directfb/SDL_DirectFB_render.c	Tue Jan 13 19:31:06 2009 +0000
     3.2 +++ b/src/video/directfb/SDL_DirectFB_render.c	Tue Jan 13 21:17:38 2009 +0000
     3.3 @@ -140,7 +140,7 @@
     3.4      IDirectFBPalette *palette;
     3.5      SDL_VideoDisplay *display;
     3.6      SDL_DirtyRectList dirty;
     3.7 -#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
     3.8 +#if (DFB_VERSION_ATLEAST(1,2,0))
     3.9      DFBSurfaceRenderOptions render_options;
    3.10  #endif
    3.11  } DirectFB_TextureData;
    3.12 @@ -387,7 +387,7 @@
    3.13      case SDL_PIXELFORMAT_INDEX4MSB:
    3.14          return DSPF_UNKNOWN;
    3.15      case SDL_PIXELFORMAT_RGB444:
    3.16 -#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
    3.17 +#if (DFB_VERSION_ATLEAST(1,2,0))
    3.18          return DSPF_RGB444;
    3.19  #else
    3.20          return DSPF_UNKNOWN;
    3.21 @@ -543,7 +543,7 @@
    3.22          }
    3.23  
    3.24      }
    3.25 -#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
    3.26 +#if (DFB_VERSION_ATLEAST(1,2,0))
    3.27      data->render_options = DSRO_NONE;
    3.28  #endif
    3.29  
    3.30 @@ -673,7 +673,7 @@
    3.31  static int
    3.32  DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
    3.33  {
    3.34 -#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
    3.35 +#if (DFB_VERSION_ATLEAST(1,2,0))
    3.36  
    3.37      DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
    3.38  
    3.39 @@ -847,7 +847,7 @@
    3.40  
    3.41      PrepareDraw(renderer);
    3.42      /* Use antialiasing when available */
    3.43 -#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
    3.44 +#if (DFB_VERSION_ATLEAST(1,2,0))
    3.45      SDL_DFB_CHECKERR(data->surface->SetRenderOptions(data->surface,
    3.46                                                       DSRO_ANTIALIAS));
    3.47  #endif
    3.48 @@ -961,7 +961,7 @@
    3.49                                                           data->blitFlags
    3.50                                                           | flags));
    3.51  
    3.52 -#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
    3.53 +#if (DFB_VERSION_ATLEAST(1,2,0))
    3.54          SDL_DFB_CHECKERR(data->surface->SetRenderOptions(data->surface,
    3.55                                                           texturedata->
    3.56                                                           render_options));
     4.1 --- a/src/video/directfb/SDL_DirectFB_video.h	Tue Jan 13 19:31:06 2009 +0000
     4.2 +++ b/src/video/directfb/SDL_DirectFB_video.h	Tue Jan 13 21:17:38 2009 +0000
     4.3 @@ -34,13 +34,20 @@
     4.4  #define DEBUG 0
     4.5  #define LOG_CHANNEL 	stdout
     4.6  
     4.7 -#if (DIRECTFB_MAJOR_VERSION < 1)
     4.8 -#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
     4.9 -#endif
    4.10 +#define DFB_VERSIONNUM(X, Y, Z)						\
    4.11 +	((X)*1000 + (Y)*100 + (Z))
    4.12 +
    4.13 +#define DFB_COMPILEDVERSION \
    4.14 +	DFB_VERSIONNUM(DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION, DIRECTFB_MICRO_VERSION)
    4.15  
    4.16 -#if (DIRECTFB_MAJOR_VERSION >= 1) && (DIRECTFB_MINOR_VERSION >= 0) && (DIRECTFB_MICRO_VERSION >= 0 )
    4.17 -#define SDL_DIRECTFB_OPENGL 1
    4.18 -#include <directfbgl.h>
    4.19 +#define DFB_VERSION_ATLEAST(X, Y, Z) \
    4.20 +	(DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z))
    4.21 +
    4.22 +#if (DFB_VERSION_ATLEAST(1,0,0))
    4.23 +	#define SDL_DIRECTFB_OPENGL 1
    4.24 +	#include <directfbgl.h>
    4.25 +#else
    4.26 +	#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
    4.27  #endif
    4.28  
    4.29  #if SDL_DIRECTFB_OPENGL
     5.1 --- a/src/video/directfb/SDL_DirectFB_window.c	Tue Jan 13 19:31:06 2009 +0000
     5.2 +++ b/src/video/directfb/SDL_DirectFB_window.c	Tue Jan 13 21:17:38 2009 +0000
     5.3 @@ -420,14 +420,28 @@
     5.4      }
     5.5  
     5.6      if (adjust) {
     5.7 -        SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
     5.8 +#if DFB_VERSION_ATLEAST(1,2,0)
     5.9 +       SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
    5.10                                                          windata->size.w,
    5.11                                                          windata->size.h));
    5.12 -        SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface,
    5.13 +       SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface,
    5.14                                                            windata->
    5.15                                                            window_surface,
    5.16                                                            &windata->client));
    5.17 -        DirectFB_WM_RedrawLayout(window);
    5.18 +#else
    5.19 +       /* recreate subsurface */
    5.20 +       windata->surface->ReleaseSource(windata->surface);
    5.21 +       windata->window_surface->ReleaseSource(windata->window_surface);
    5.22 +       SDL_DFB_RELEASE(windata->surface);
    5.23 +       windata->surface = NULL;
    5.24 +       SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window,
    5.25 +                                                       windata->size.w,
    5.26 +                                                       windata->size.h));
    5.27 +       SDL_DFB_CHECKERR(windata->window_surface->
    5.28 +                        GetSubSurface(windata->window_surface, &windata->client,
    5.29 +                                      &windata->surface));
    5.30 +#endif
    5.31 +       DirectFB_WM_RedrawLayout(window);
    5.32      }
    5.33    error:
    5.34      return;