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.
This commit is contained in:
Sam Lantinga 2013-03-09 10:35:12 -08:00
parent c51712467d
commit 7ce1b4475f
7 changed files with 47 additions and 37 deletions

2
configure vendored
View file

@ -20263,7 +20263,7 @@ fi
else else
set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'` set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3` NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
set -- `directfb-config --version | sed 's/\./ /g'` set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3` HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
if test $HAVE_VERSION -ge $NEED_VERSION; then if test $HAVE_VERSION -ge $NEED_VERSION; then
DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags` DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`

View file

@ -1423,7 +1423,7 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n
else else
set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'` set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3` NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
set -- `directfb-config --version | sed 's/\./ /g'` set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3` HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
if test $HAVE_VERSION -ge $NEED_VERSION; then if test $HAVE_VERSION -ge $NEED_VERSION; then
DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags` DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`

View file

@ -96,17 +96,17 @@ static void DirectFB_DirtyTexture(SDL_Renderer * renderer,
const SDL_Rect * rects); const SDL_Rect * rects);
static int DirectFB_SetDrawBlendMode(SDL_Renderer * renderer); static int DirectFB_SetDrawBlendMode(SDL_Renderer * renderer);
static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer, static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
const SDL_Point * points, int count); const SDL_FPoint * points, int count);
static int DirectFB_RenderDrawLines(SDL_Renderer * renderer, static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
const SDL_Point * points, int count); const SDL_FPoint * points, int count);
static int DirectFB_RenderDrawRects(SDL_Renderer * renderer, static int DirectFB_RenderDrawRects(SDL_Renderer * renderer,
const SDL_Rect ** rects, int count); const SDL_Rect ** rects, int count);
static int DirectFB_RenderFillRects(SDL_Renderer * renderer, static int DirectFB_RenderFillRects(SDL_Renderer * renderer,
const SDL_Rect * rects, int count); const SDL_FRect * rects, int count);
static int DirectFB_RenderCopy(SDL_Renderer * renderer, static int DirectFB_RenderCopy(SDL_Renderer * renderer,
SDL_Texture * texture, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_Rect * srcrect,
const SDL_Rect * dstrect); const SDL_FRect * dstrect);
static void DirectFB_RenderPresent(SDL_Renderer * renderer); static void DirectFB_RenderPresent(SDL_Renderer * renderer);
static void DirectFB_DestroyTexture(SDL_Renderer * renderer, static void DirectFB_DestroyTexture(SDL_Renderer * renderer,
SDL_Texture * texture); SDL_Texture * texture);
@ -175,6 +175,14 @@ SDLtoDFBRect(const SDL_Rect * sr, DFBRectangle * dr)
dr->h = sr->h; dr->h = sr->h;
dr->w = sr->w; dr->w = sr->w;
} }
static __inline__ void
SDLtoDFBRect_Float(const SDL_FRect * sr, DFBRectangle * dr)
{
dr->x = sr->x;
dr->y = sr->y;
dr->h = sr->h;
dr->w = sr->w;
}
static int static int
@ -206,6 +214,8 @@ TextureHasAlpha(DirectFB_TextureData * data)
static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window) static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window)
{ {
SDL_SysWMinfo wm_info; SDL_SysWMinfo wm_info;
SDL_memset(&wm_info, 0, sizeof(SDL_SysWMinfo));
SDL_VERSION(&wm_info.version); SDL_VERSION(&wm_info.version);
SDL_GetWindowWMInfo(window, &wm_info); SDL_GetWindowWMInfo(window, &wm_info);
@ -215,6 +225,8 @@ static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window)
static inline IDirectFBWindow *get_dfb_window(SDL_Window *window) static inline IDirectFBWindow *get_dfb_window(SDL_Window *window)
{ {
SDL_SysWMinfo wm_info; SDL_SysWMinfo wm_info;
SDL_memset(&wm_info, 0, sizeof(SDL_SysWMinfo));
SDL_VERSION(&wm_info.version); SDL_VERSION(&wm_info.version);
SDL_GetWindowWMInfo(window, &wm_info); SDL_GetWindowWMInfo(window, &wm_info);
@ -917,7 +929,7 @@ PrepareDraw(SDL_Renderer * renderer)
} }
static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer, static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
const SDL_Point * points, int count) const SDL_FPoint * points, int count)
{ {
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *destsurf = get_dfb_surface(data->window); IDirectFBSurface *destsurf = get_dfb_surface(data->window);
@ -934,7 +946,7 @@ static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer,
} }
static int DirectFB_RenderDrawLines(SDL_Renderer * renderer, static int DirectFB_RenderDrawLines(SDL_Renderer * renderer,
const SDL_Point * points, int count) const SDL_FPoint * points, int count)
{ {
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *destsurf = get_dfb_surface(data->window); IDirectFBSurface *destsurf = get_dfb_surface(data->window);
@ -977,7 +989,7 @@ DirectFB_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int c
} }
static int static int
DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count) DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count)
{ {
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *destsurf = get_dfb_surface(data->window); IDirectFBSurface *destsurf = get_dfb_surface(data->window);
@ -998,16 +1010,20 @@ DirectFB_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int co
static int static int
DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_Rect * dstrect) const SDL_Rect * srcrect, const SDL_FRect * dstrect)
{ {
DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
IDirectFBSurface *destsurf = get_dfb_surface(data->window); IDirectFBSurface *destsurf = get_dfb_surface(data->window);
DirectFB_TextureData *texturedata = DirectFB_TextureData *texturedata =
(DirectFB_TextureData *) texture->driverdata; (DirectFB_TextureData *) texture->driverdata;
Uint8 alpha, r, g, b; Uint8 alpha, r, g, b;
DFBRectangle sr, dr;
DirectFB_ActivateRenderer(renderer); DirectFB_ActivateRenderer(renderer);
SDLtoDFBRect(srcrect, &sr);
SDLtoDFBRect_Float(dstrect, &dr);
if (texturedata->display) { if (texturedata->display) {
int px, py; int px, py;
SDL_Window *window = renderer->window; SDL_Window *window = renderer->window;
@ -1018,20 +1034,17 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_DFB_CHECKERR(dispdata-> SDL_DFB_CHECKERR(dispdata->
vidlayer->SetSourceRectangle(dispdata->vidlayer, vidlayer->SetSourceRectangle(dispdata->vidlayer,
srcrect->x, srcrect->y, sr.x, sr.y, sr.w, sr.h));
srcrect->w,
srcrect->h));
dfbwin->GetPosition(dfbwin, &px, &py); dfbwin->GetPosition(dfbwin, &px, &py);
px += windata->client.x; px += windata->client.x;
py += windata->client.y; py += windata->client.y;
SDL_DFB_CHECKERR(dispdata-> SDL_DFB_CHECKERR(dispdata->
vidlayer->SetScreenRectangle(dispdata->vidlayer, vidlayer->SetScreenRectangle(dispdata->vidlayer,
px + dstrect->x, px + dr.x,
py + dstrect->y, py + dr.y,
dstrect->w, dr.w,
dstrect->h)); dr.h));
} else { } else {
DFBRectangle sr, dr;
DFBSurfaceBlittingFlags flags = 0; DFBSurfaceBlittingFlags flags = 0;
#if 0 #if 0

View file

@ -102,8 +102,9 @@ DirectFB_CreateDevice(int devindex)
{ {
SDL_VideoDevice *device; SDL_VideoDevice *device;
if (!SDL_DirectFB_LoadLibrary()) if (!SDL_DirectFB_LoadLibrary()) {
return NULL; return NULL;
}
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
SDL_DFB_ALLOC_CLEAR(device, sizeof(SDL_VideoDevice)); SDL_DFB_ALLOC_CLEAR(device, sizeof(SDL_VideoDevice));

View file

@ -31,6 +31,8 @@
#include "SDL_scancode.h" #include "SDL_scancode.h"
#include "SDL_render.h" #include "SDL_render.h"
#include "SDL_log.h"
#define DFB_VERSIONNUM(X, Y, Z) \ #define DFB_VERSIONNUM(X, Y, Z) \
((X)*1000 + (Y)*100 + (Z)) ((X)*1000 + (Y)*100 + (Z))
@ -66,7 +68,6 @@
#endif #endif
#define DIRECTFB_DEBUG 1 #define DIRECTFB_DEBUG 1
#define LOG_CHANNEL stdout
#define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" /* Default: off */ #define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" /* Default: off */
#define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" /* Default: off */ #define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" /* Default: off */
@ -80,23 +81,12 @@
#define SDL_DFB_CONTEXT "SDL_DirectFB" #define SDL_DFB_CONTEXT "SDL_DirectFB"
#define SDL_DFB_ERR(x...) \ #define SDL_DFB_ERR(x...) SDL_LogError(SDL_LOG_CATEGORY_ERROR, x)
do { \
fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t", \
SDL_DFB_CONTEXT, __FILE__, __LINE__ ); \
fprintf(LOG_CHANNEL, x ); \
} while (0)
#if (DIRECTFB_DEBUG) #if (DIRECTFB_DEBUG)
#define SDL_DFB_LOG(x...) SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, x)
#define SDL_DFB_LOG(x...) \ #define SDL_DFB_DEBUG(x...) SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, x)
do { \
fprintf(LOG_CHANNEL, "%s: ", SDL_DFB_CONTEXT); \
fprintf(LOG_CHANNEL, x ); \
fprintf(LOG_CHANNEL, "\n"); \
} while (0)
#define SDL_DFB_DEBUG(x...) SDL_DFB_ERR( x )
static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) { static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) {
if (ret != DFB_OK) { if (ret != DFB_OK) {

View file

@ -47,6 +47,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
int bshaped = 0; int bshaped = 0;
SDL_DFB_ALLOC_CLEAR(window->driverdata, sizeof(DFB_WindowData)); SDL_DFB_ALLOC_CLEAR(window->driverdata, sizeof(DFB_WindowData));
SDL_memset(&desc, 0, sizeof(DFBWindowDescription));
windata = (DFB_WindowData *) window->driverdata; windata = (DFB_WindowData *) window->driverdata;
windata->is_managed = devdata->has_own_wm; windata->is_managed = devdata->has_own_wm;
@ -89,7 +90,12 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
desc.height = windata->size.h; desc.height = windata->size.h;
desc.pixelformat = dispdata->pixelformat; desc.pixelformat = dispdata->pixelformat;
desc.surface_caps = DSCAPS_PREMULTIPLIED; desc.surface_caps = DSCAPS_PREMULTIPLIED;
#if DIRECTFB_MAJOR_VERSION == 1 && DIRECTFB_MINOR_VERSION >= 4
if (window->flags & SDL_WINDOW_OPENGL) {
desc.surface_caps |= DSCAPS_GL;
}
#endif
/* Create the window. */ /* Create the window. */
SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc, SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc,
&windata->dfbwin)); &windata->dfbwin));
@ -378,7 +384,7 @@ DirectFB_RestoreWindow(_THIS, SDL_Window * window)
} }
void void
DirectFB_SetWindowGrab(_THIS, SDL_Window * window) DirectFB_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
{ {
SDL_DFB_DEVICEDATA(_this); SDL_DFB_DEVICEDATA(_this);
SDL_DFB_WINDOWDATA(window); SDL_DFB_WINDOWDATA(window);

View file

@ -69,7 +69,7 @@ extern void DirectFB_RaiseWindow(_THIS, SDL_Window * window);
extern void DirectFB_MaximizeWindow(_THIS, SDL_Window * window); extern void DirectFB_MaximizeWindow(_THIS, SDL_Window * window);
extern void DirectFB_MinimizeWindow(_THIS, SDL_Window * window); extern void DirectFB_MinimizeWindow(_THIS, SDL_Window * window);
extern void DirectFB_RestoreWindow(_THIS, SDL_Window * window); extern void DirectFB_RestoreWindow(_THIS, SDL_Window * window);
extern void DirectFB_SetWindowGrab(_THIS, SDL_Window * window); extern void DirectFB_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
extern void DirectFB_DestroyWindow(_THIS, SDL_Window * window); extern void DirectFB_DestroyWindow(_THIS, SDL_Window * window);
extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window, extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info); struct SDL_SysWMinfo *info);