Fixed bug 1744 - DirectFB video and renderer API is not updated
authorSam Lantinga <slouken@libsdl.org>
Sat, 09 Mar 2013 10:35:12 -0800
changeset 6986bc887debed9b
parent 6985 a0f905ecdda3
child 6987 7084af936d82
Fixed bug 1744 - DirectFB video and renderer API is not updated

tomaszewski.p

Recent changes in SDL_sysrenderer.h and SDL_sysvideo.h had no impact on directfb backend.

Attached patch:
- updates interface,
- resolves uninitialized variable reading,
- changes logging tio use SDL_Log API,
- updates configure to use DIRECTFBCONFIG variable instead direct call to directfb-config.
configure
configure.in
src/video/directfb/SDL_DirectFB_render.c
src/video/directfb/SDL_DirectFB_video.c
src/video/directfb/SDL_DirectFB_video.h
src/video/directfb/SDL_DirectFB_window.c
src/video/directfb/SDL_DirectFB_window.h
     1.1 --- a/configure	Sat Mar 09 09:24:43 2013 -0800
     1.2 +++ b/configure	Sat Mar 09 10:35:12 2013 -0800
     1.3 @@ -20263,7 +20263,7 @@
     1.4          else
     1.5              set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
     1.6              NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
     1.7 -            set -- `directfb-config --version | sed 's/\./ /g'`
     1.8 +            set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
     1.9              HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
    1.10              if test $HAVE_VERSION -ge $NEED_VERSION; then
    1.11                  DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
     2.1 --- a/configure.in	Sat Mar 09 09:24:43 2013 -0800
     2.2 +++ b/configure.in	Sat Mar 09 10:35:12 2013 -0800
     2.3 @@ -1423,7 +1423,7 @@
     2.4          else
     2.5              set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
     2.6              NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
     2.7 -            set -- `directfb-config --version | sed 's/\./ /g'`
     2.8 +            set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
     2.9              HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
    2.10              if test $HAVE_VERSION -ge $NEED_VERSION; then
    2.11                  DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
     3.1 --- a/src/video/directfb/SDL_DirectFB_render.c	Sat Mar 09 09:24:43 2013 -0800
     3.2 +++ b/src/video/directfb/SDL_DirectFB_render.c	Sat Mar 09 10:35:12 2013 -0800
     3.3 @@ -96,17 +96,17 @@
     3.4                                    const SDL_Rect * rects);
     3.5  static int DirectFB_SetDrawBlendMode(SDL_Renderer * renderer);
     3.6  static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
     3.7 -                                const SDL_Point * points, int count);
     3.8 +                                const SDL_FPoint * points, int count);
     3.9  static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
    3.10 -                               const SDL_Point * points, int count);
    3.11 +                               const SDL_FPoint * points, int count);
    3.12  static int DirectFB_RenderDrawRects(SDL_Renderer * renderer,
    3.13  		const SDL_Rect ** rects, int count);
    3.14  static int DirectFB_RenderFillRects(SDL_Renderer * renderer,
    3.15 -		const SDL_Rect * rects, int count);
    3.16 +		const SDL_FRect * rects, int count);
    3.17  static int DirectFB_RenderCopy(SDL_Renderer * renderer,
    3.18                                 SDL_Texture * texture,
    3.19                                 const SDL_Rect * srcrect,
    3.20 -                               const SDL_Rect * dstrect);
    3.21 +                               const SDL_FRect * dstrect);
    3.22  static void DirectFB_RenderPresent(SDL_Renderer * renderer);
    3.23  static void DirectFB_DestroyTexture(SDL_Renderer * renderer,
    3.24                                      SDL_Texture * texture);
    3.25 @@ -175,6 +175,14 @@
    3.26      dr->h = sr->h;
    3.27      dr->w = sr->w;
    3.28  }
    3.29 +static __inline__ void
    3.30 +SDLtoDFBRect_Float(const SDL_FRect * sr, DFBRectangle * dr)
    3.31 +{
    3.32 +    dr->x = sr->x;
    3.33 +    dr->y = sr->y;
    3.34 +    dr->h = sr->h;
    3.35 +    dr->w = sr->w;
    3.36 +}
    3.37  
    3.38  
    3.39  static int
    3.40 @@ -206,6 +214,8 @@
    3.41  static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window)
    3.42  {
    3.43  	SDL_SysWMinfo wm_info;
    3.44 +    SDL_memset(&wm_info, 0, sizeof(SDL_SysWMinfo));
    3.45 +
    3.46  	SDL_VERSION(&wm_info.version);
    3.47  	SDL_GetWindowWMInfo(window, &wm_info);
    3.48  
    3.49 @@ -215,6 +225,8 @@
    3.50  static inline IDirectFBWindow *get_dfb_window(SDL_Window *window)
    3.51  {
    3.52  	SDL_SysWMinfo wm_info;
    3.53 +    SDL_memset(&wm_info, 0, sizeof(SDL_SysWMinfo));
    3.54 +
    3.55  	SDL_VERSION(&wm_info.version);
    3.56  	SDL_GetWindowWMInfo(window, &wm_info);
    3.57  
    3.58 @@ -917,7 +929,7 @@
    3.59  }
    3.60  
    3.61  static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
    3.62 -                                const SDL_Point * points, int count)
    3.63 +                                const SDL_FPoint * points, int count)
    3.64  {
    3.65      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    3.66  	IDirectFBSurface *destsurf = get_dfb_surface(data->window);
    3.67 @@ -934,7 +946,7 @@
    3.68  }
    3.69  
    3.70  static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
    3.71 -                               const SDL_Point * points, int count)
    3.72 +                               const SDL_FPoint * points, int count)
    3.73  {
    3.74      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    3.75  	IDirectFBSurface *destsurf = get_dfb_surface(data->window);
    3.76 @@ -977,7 +989,7 @@
    3.77  }
    3.78  
    3.79  static int
    3.80 -DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count)
    3.81 +DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count)
    3.82  {
    3.83      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    3.84  	IDirectFBSurface *destsurf = get_dfb_surface(data->window);
    3.85 @@ -998,16 +1010,20 @@
    3.86  
    3.87  static int
    3.88  DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    3.89 -                    const SDL_Rect * srcrect, const SDL_Rect * dstrect)
    3.90 +                    const SDL_Rect * srcrect, const SDL_FRect * dstrect)
    3.91  {
    3.92      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    3.93  	IDirectFBSurface *destsurf = get_dfb_surface(data->window);
    3.94      DirectFB_TextureData *texturedata =
    3.95          (DirectFB_TextureData *) texture->driverdata;
    3.96      Uint8 alpha, r, g, b;
    3.97 +    DFBRectangle sr, dr;
    3.98  
    3.99      DirectFB_ActivateRenderer(renderer);
   3.100  
   3.101 +    SDLtoDFBRect(srcrect, &sr);
   3.102 +    SDLtoDFBRect_Float(dstrect, &dr);
   3.103 +
   3.104      if (texturedata->display) {
   3.105          int px, py;
   3.106          SDL_Window *window = renderer->window;
   3.107 @@ -1018,20 +1034,17 @@
   3.108  
   3.109          SDL_DFB_CHECKERR(dispdata->
   3.110                           vidlayer->SetSourceRectangle(dispdata->vidlayer,
   3.111 -                                                      srcrect->x, srcrect->y,
   3.112 -                                                      srcrect->w,
   3.113 -                                                      srcrect->h));
   3.114 +                                                      sr.x, sr.y, sr.w, sr.h));
   3.115          dfbwin->GetPosition(dfbwin, &px, &py);
   3.116          px += windata->client.x;
   3.117          py += windata->client.y;
   3.118          SDL_DFB_CHECKERR(dispdata->
   3.119                           vidlayer->SetScreenRectangle(dispdata->vidlayer,
   3.120 -                                                      px + dstrect->x,
   3.121 -                                                      py + dstrect->y,
   3.122 -                                                      dstrect->w,
   3.123 -                                                      dstrect->h));
   3.124 +                                                      px + dr.x,
   3.125 +                                                      py + dr.y,
   3.126 +                                                      dr.w,
   3.127 +                                                      dr.h));
   3.128      } else {
   3.129 -        DFBRectangle sr, dr;
   3.130          DFBSurfaceBlittingFlags flags = 0;
   3.131  
   3.132  #if 0
     4.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Sat Mar 09 09:24:43 2013 -0800
     4.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Sat Mar 09 10:35:12 2013 -0800
     4.3 @@ -102,8 +102,9 @@
     4.4  {
     4.5      SDL_VideoDevice *device;
     4.6  
     4.7 -    if (!SDL_DirectFB_LoadLibrary())
     4.8 +    if (!SDL_DirectFB_LoadLibrary()) {
     4.9          return NULL;
    4.10 +    }
    4.11  
    4.12      /* Initialize all variables that we clean on shutdown */
    4.13      SDL_DFB_ALLOC_CLEAR(device, sizeof(SDL_VideoDevice));
     5.1 --- a/src/video/directfb/SDL_DirectFB_video.h	Sat Mar 09 09:24:43 2013 -0800
     5.2 +++ b/src/video/directfb/SDL_DirectFB_video.h	Sat Mar 09 10:35:12 2013 -0800
     5.3 @@ -31,6 +31,8 @@
     5.4  #include "SDL_scancode.h"
     5.5  #include "SDL_render.h"
     5.6  
     5.7 +#include "SDL_log.h"
     5.8 +
     5.9  #define DFB_VERSIONNUM(X, Y, Z)						\
    5.10  	((X)*1000 + (Y)*100 + (Z))
    5.11  
    5.12 @@ -66,7 +68,6 @@
    5.13  #endif
    5.14  
    5.15  #define DIRECTFB_DEBUG 1
    5.16 -#define LOG_CHANNEL 	stdout
    5.17  
    5.18  #define DFBENV_USE_YUV_UNDERLAY 	"SDL_DIRECTFB_YUV_UNDERLAY"     /* Default: off */
    5.19  #define DFBENV_USE_YUV_DIRECT   	"SDL_DIRECTFB_YUV_DIRECT"       /* Default: off */
    5.20 @@ -80,23 +81,12 @@
    5.21  
    5.22  #define SDL_DFB_CONTEXT "SDL_DirectFB"
    5.23  
    5.24 -#define SDL_DFB_ERR(x...) 							\
    5.25 -	do {											\
    5.26 -		fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t",	\
    5.27 -			SDL_DFB_CONTEXT, __FILE__, __LINE__ );	\
    5.28 -        fprintf(LOG_CHANNEL, x ); 					\
    5.29 -	} while (0)
    5.30 +#define SDL_DFB_ERR(x...) SDL_LogError(SDL_LOG_CATEGORY_ERROR, x)
    5.31  
    5.32  #if (DIRECTFB_DEBUG)
    5.33 +#define SDL_DFB_LOG(x...) SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, x)
    5.34  
    5.35 -#define SDL_DFB_LOG(x...) 							\
    5.36 -	do {											\
    5.37 -		fprintf(LOG_CHANNEL, "%s: ", SDL_DFB_CONTEXT);		\
    5.38 -        fprintf(LOG_CHANNEL, x ); 					\
    5.39 -		fprintf(LOG_CHANNEL, "\n");					\
    5.40 -	} while (0)
    5.41 -
    5.42 -#define SDL_DFB_DEBUG(x...) SDL_DFB_ERR( x )
    5.43 +#define SDL_DFB_DEBUG(x...) SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, x)
    5.44  
    5.45  static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) {
    5.46  	if (ret != DFB_OK) {
     6.1 --- a/src/video/directfb/SDL_DirectFB_window.c	Sat Mar 09 09:24:43 2013 -0800
     6.2 +++ b/src/video/directfb/SDL_DirectFB_window.c	Sat Mar 09 10:35:12 2013 -0800
     6.3 @@ -47,6 +47,7 @@
     6.4      int bshaped = 0;
     6.5  
     6.6      SDL_DFB_ALLOC_CLEAR(window->driverdata, sizeof(DFB_WindowData));
     6.7 +    SDL_memset(&desc, 0, sizeof(DFBWindowDescription));
     6.8      windata = (DFB_WindowData *) window->driverdata;
     6.9  
    6.10      windata->is_managed = devdata->has_own_wm;
    6.11 @@ -89,7 +90,12 @@
    6.12      desc.height = windata->size.h;
    6.13      desc.pixelformat = dispdata->pixelformat;
    6.14      desc.surface_caps = DSCAPS_PREMULTIPLIED;
    6.15 -    
    6.16 +#if DIRECTFB_MAJOR_VERSION == 1 && DIRECTFB_MINOR_VERSION >= 4
    6.17 +    if (window->flags & SDL_WINDOW_OPENGL) {
    6.18 +        desc.surface_caps |= DSCAPS_GL;
    6.19 +    }
    6.20 +#endif
    6.21 +
    6.22      /* Create the window. */
    6.23      SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc,
    6.24                                                     &windata->dfbwin));
    6.25 @@ -378,7 +384,7 @@
    6.26  }
    6.27  
    6.28  void
    6.29 -DirectFB_SetWindowGrab(_THIS, SDL_Window * window)
    6.30 +DirectFB_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
    6.31  {
    6.32      SDL_DFB_DEVICEDATA(_this);
    6.33      SDL_DFB_WINDOWDATA(window);
     7.1 --- a/src/video/directfb/SDL_DirectFB_window.h	Sat Mar 09 09:24:43 2013 -0800
     7.2 +++ b/src/video/directfb/SDL_DirectFB_window.h	Sat Mar 09 10:35:12 2013 -0800
     7.3 @@ -69,7 +69,7 @@
     7.4  extern void DirectFB_MaximizeWindow(_THIS, SDL_Window * window);
     7.5  extern void DirectFB_MinimizeWindow(_THIS, SDL_Window * window);
     7.6  extern void DirectFB_RestoreWindow(_THIS, SDL_Window * window);
     7.7 -extern void DirectFB_SetWindowGrab(_THIS, SDL_Window * window);
     7.8 +extern void DirectFB_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
     7.9  extern void DirectFB_DestroyWindow(_THIS, SDL_Window * window);
    7.10  extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
    7.11                                           struct SDL_SysWMinfo *info);