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
set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
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`
if test $HAVE_VERSION -ge $NEED_VERSION; then
DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`

View File

@ -1423,7 +1423,7 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n
else
set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
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`
if test $HAVE_VERSION -ge $NEED_VERSION; then
DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`

View File

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

View File

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

View File

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

View File

@ -47,6 +47,7 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
int bshaped = 0;
SDL_DFB_ALLOC_CLEAR(window->driverdata, sizeof(DFB_WindowData));
SDL_memset(&desc, 0, sizeof(DFBWindowDescription));
windata = (DFB_WindowData *) window->driverdata;
windata->is_managed = devdata->has_own_wm;
@ -89,7 +90,12 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
desc.height = windata->size.h;
desc.pixelformat = dispdata->pixelformat;
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. */
SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc,
&windata->dfbwin));
@ -378,7 +384,7 @@ DirectFB_RestoreWindow(_THIS, SDL_Window * window)
}
void
DirectFB_SetWindowGrab(_THIS, SDL_Window * window)
DirectFB_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
{
SDL_DFB_DEVICEDATA(_this);
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_MinimizeWindow(_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 SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window,
struct SDL_SysWMinfo *info);