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

Commit

Permalink
Updated the DirectFB support, from Couriersud
Browse files Browse the repository at this point in the history
attached is a working directfb driver diff which works with the current
changes. There are a number of changes around it as well, e.g.
configure.in.

The directfb renderdriver right now still depends on a some "includes"
from src/video/directfb. That's why it is not yet moved to the new
render folder.
  • Loading branch information
slouken committed Feb 6, 2011
1 parent 4779d6b commit 8938cbf
Show file tree
Hide file tree
Showing 24 changed files with 1,330 additions and 769 deletions.
4 changes: 2 additions & 2 deletions README.DirectFB
Expand Up @@ -71,9 +71,9 @@ works at least on all directfb supported platforms.
As of this writing 20100802 you need to pull Mesa from git and do the following:

------------------------
git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
cd mesa
git clone git://anongit.freedesktop.org/git/mesa/mesa
cd mesa
git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
------------------------

Edit configs/linux-directfb so that the Directories-section looks like
Expand Down
9 changes: 5 additions & 4 deletions configure.in
Expand Up @@ -1312,8 +1312,7 @@ AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n
video_directfb=no

DIRECTFB_REQUIRED_VERSION=1.0.0

AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
if test x$DIRECTFBCONFIG = xno; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test x$PKG_CONFIG != xno; then
Expand Down Expand Up @@ -1353,13 +1352,15 @@ AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[
, enable_directfb_shared=yes)

AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB)
SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"

AC_MSG_CHECKING(for directfb dynamic loading support)
directfb_shared=no
directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]

directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS"`]
# | sed 's/.*\/\(.*\)/\1/; q'`]
AC_MSG_WARN("directfb $directfb_lib")
if test x$have_loadso != xyes && \
test x$enable_directfb_shared = xyes; then
AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
Expand Down
1 change: 1 addition & 0 deletions include/SDL_config.h.in
Expand Up @@ -279,6 +279,7 @@
#undef SDL_VIDEO_RENDER_D3D
#undef SDL_VIDEO_RENDER_OGL
#undef SDL_VIDEO_RENDER_OGL_ES
#undef SDL_VIDEO_RENDER_DIRECTFB

/* Enable OpenGL support */
#undef SDL_VIDEO_OPENGL
Expand Down
2 changes: 1 addition & 1 deletion include/SDL_syswm.h
Expand Up @@ -77,7 +77,7 @@ struct SDL_SysWMinfo;
#endif /* defined(SDL_VIDEO_DRIVER_X11) */

#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
#include <directfb/directfb.h>
#include <directfb.h>
#endif

#if defined(SDL_VIDEO_DRIVER_COCOA)
Expand Down
3 changes: 3 additions & 0 deletions src/render/SDL_render.c
Expand Up @@ -52,6 +52,9 @@ static const SDL_RenderDriver *render_drivers[] = {
#endif
#if SDL_VIDEO_RENDER_OGL_ES
&GL_ES_RenderDriver,
#endif
#if SDL_VIDEO_RENDER_DIRECTFB
&DirectFB_RenderDriver,
#endif
&SW_RenderDriver
};
Expand Down
3 changes: 3 additions & 0 deletions src/render/SDL_sysrender.h
Expand Up @@ -127,6 +127,9 @@ extern SDL_RenderDriver GL_RenderDriver;
#if SDL_VIDEO_RENDER_OGL_ES
extern SDL_RenderDriver GL_ES_RenderDriver;
#endif
#if SDL_VIDEO_RENDER_DIRECTFB
extern SDL_RenderDriver DirectFB_RenderDriver;
#endif
extern SDL_RenderDriver SW_RenderDriver;

#endif /* _SDL_sysrender_h */
Expand Down
169 changes: 94 additions & 75 deletions src/video/directfb/SDL_DirectFB_WM.c
Expand Up @@ -18,14 +18,13 @@
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
//#include "SDL_syswm.h"
//#include "../SDL_sysvideo.h"
//#include "../../events/SDL_keyboard_c.h"
SDL1.3 DirectFB driver by couriersud@arcor.de
*/

#include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_window.h"

#include "../../events/SDL_windowevents_c.h"

Expand Down Expand Up @@ -127,6 +126,11 @@ DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window)
if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN))
return;

SDL_DFB_CHECK(s->SetSrcBlendFunction(s, DSBF_ONE));
SDL_DFB_CHECK(s->SetDstBlendFunction(s, DSBF_ZERO));
SDL_DFB_CHECK(s->SetDrawingFlags(s, DSDRAW_NOFX));
SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX));

LoadFont(_this, window);
//s->SetDrawingFlags(s, DSDRAW_BLEND);
s->SetColor(s, COLOR_EXPAND(t->frame_color));
Expand Down Expand Up @@ -181,8 +185,10 @@ DFBResult
DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch)
{
SDL_DFB_WINDOWDATA(window);
IDirectFBWindow *dfbwin = windata->dfbwin;

SDL_DFB_CHECK(windata->window->GetSize(windata->window, cw, ch));
SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, cw, ch));
dfbwin->GetSize(dfbwin, cw, ch);
*cw -= windata->theme.left_size + windata->theme.right_size;
*ch -=
windata->theme.top_size + windata->theme.caption_size +
Expand All @@ -197,6 +203,9 @@ DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h)

if (!windata->is_managed)
windata->theme = theme_none;
else if (flags & SDL_WINDOW_BORDERLESS)
//desc.caps |= DWCAPS_NODECORATION;)
windata->theme = theme_none;
else if (flags & SDL_WINDOW_FULLSCREEN) {
windata->theme = theme_none;
} else if (flags & SDL_WINDOW_MAXIMIZED) {
Expand All @@ -220,37 +229,6 @@ DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h)
windata->theme.caption_size + windata->theme.bottom_size;
}

void
DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window)
{
SDL_DFB_WINDOWDATA(window);
SDL_VideoDisplay *display = window->display;

SDL_DFB_CHECK(windata->window->GetPosition(windata->window,
&windata->restore.x, &windata->restore.y));
SDL_DFB_CHECK(windata->window->GetSize(windata->window, &windata->restore.w,
&windata->restore.h));

DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ;

SDL_DFB_CHECK(windata->window->MoveTo(windata->window, 0, 0));
SDL_DFB_CHECK(windata->window->Resize(windata->window,
display->current_mode.w, display->current_mode.h));
}

void
DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window)
{
SDL_DFB_WINDOWDATA(window);

DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED),
windata->restore.w, windata->restore.h);

SDL_DFB_CHECK(windata->window->Resize(windata->window, windata->restore.w,
windata->restore.h));
SDL_DFB_CHECK(windata->window->MoveTo(windata->window, windata->restore.x,
windata->restore.y));
}

enum
{
Expand Down Expand Up @@ -307,20 +285,20 @@ WMPos(DFB_WindowData * p, int x, int y)
return pos;
}

static int wm_grab;
static int wm_lastx;
static int wm_lasty;

int
DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
{
SDL_DFB_DEVICEDATA(_this);
SDL_DFB_WINDOWDATA(window);
DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL);
IDirectFBWindow *dfbwin = windata->dfbwin;
DFBWindowOptions wopts;

if (!windata->is_managed)
return 0;

SDL_DFB_CHECK(dfbwin->GetOptions(dfbwin, &wopts));

switch (evt->type) {
case DWET_BUTTONDOWN:
if (evt->buttons & DIBM_LEFT) {
Expand All @@ -329,59 +307,99 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
case WM_POS_NONE:
return 0;
case WM_POS_CLOSE:
wm_grab = WM_POS_NONE;
windata->wm_grab = WM_POS_NONE;
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0,
0);
return 1;
case WM_POS_MAX:
wm_grab = WM_POS_NONE;
if (window->flags & SDL_WINDOW_MAXIMIZED) {
SDL_RestoreWindow(window);
} else {
SDL_MaximizeWindow(window);
}
windata->wm_grab = WM_POS_NONE;
if (window->flags & SDL_WINDOW_MAXIMIZED) {
SDL_RestoreWindow(window);
} else {
SDL_MaximizeWindow(window);
}
return 1;
case WM_POS_CAPTION:
DirectFB_RaiseWindow(_this, window);
if (!(wopts & DWOP_KEEP_STACKING)) {
DirectFB_RaiseWindow(_this, window);
}
if (window->flags & SDL_WINDOW_MAXIMIZED)
return 1;
/* fall through */
default:
wm_grab = pos;
windata->wm_grab = pos;
if (gwindata != NULL)
SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window));
SDL_DFB_CHECK(windata->window->GrabPointer(windata->window));
wm_lastx = evt->cx;
wm_lasty = evt->cy;
SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin));
SDL_DFB_CHECK(dfbwin->GrabPointer(dfbwin));
windata->wm_lastx = evt->cx;
windata->wm_lasty = evt->cy;
}
}
return 1;
case DWET_BUTTONUP:
if (!windata->wm_grab)
return 0;
if (!(evt->buttons & DIBM_LEFT)) {
if (windata->wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
int dx = evt->cx - windata->wm_lastx;
int dy = evt->cy - windata->wm_lasty;

if (!(wopts & DWOP_KEEP_SIZE)) {
int cw, ch;
if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
dx = 0;
else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
dy = 0;
SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch));

/* necessary to trigger an event - ugly*/
SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL));
SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx + 1, ch + dy));
SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL));

SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy));
}
}
SDL_DFB_CHECK(dfbwin->UngrabPointer(dfbwin));
if (gwindata != NULL)
SDL_DFB_CHECK(gwindata->dfbwin->GrabPointer(gwindata->dfbwin));
windata->wm_grab = WM_POS_NONE;
return 1;
}
break;
case DWET_MOTION:
if (!wm_grab)
if (!windata->wm_grab)
return 0;
if (evt->buttons & DIBM_LEFT) {
int dx = evt->cx - wm_lastx;
int dy = evt->cy - wm_lasty;
int cw, ch;

if (wm_grab & WM_POS_CAPTION)
SDL_DFB_CHECK(windata->window->Move(windata->window, dx, dy));
if (wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
dx = 0;
else if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
dy = 0;
SDL_DFB_CHECK(windata->window->GetSize(windata->window, &cw, &ch));
SDL_DFB_CHECK(windata->window->Resize(windata->window, cw + dx, ch + dy));
int dx = evt->cx - windata->wm_lastx;
int dy = evt->cy - windata->wm_lasty;

if (windata->wm_grab & WM_POS_CAPTION) {
if (!(wopts & DWOP_KEEP_POSITION))
SDL_DFB_CHECK(dfbwin->Move(dfbwin, dx, dy));
}
wm_lastx = evt->cx;
wm_lasty = evt->cy;
return 1;
if (windata->wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) {
if (!(wopts & DWOP_KEEP_SIZE)) {
int cw, ch;

/* Make sure all events are disabled for this operation ! */
SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL));

if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM)
dx = 0;
else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT)
dy = 0;

SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch));
SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy));

SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL));
}
}
windata->wm_lastx = evt->cx;
windata->wm_lasty = evt->cy;
return 1;
}
SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window));
if (gwindata != NULL)
SDL_DFB_CHECK(gwindata->window->GrabPointer(gwindata->window));
wm_grab = WM_POS_NONE;
break;
case DWET_KEYDOWN:
break;
Expand All @@ -392,3 +410,4 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
}
return 0;
}

8 changes: 5 additions & 3 deletions src/video/directfb/SDL_DirectFB_WM.h
Expand Up @@ -18,12 +18,16 @@
Sam Lantinga
slouken@libsdl.org
SDL1.3 DirectFB driver by couriersud@arcor.de
*/
#include "SDL_config.h"

#ifndef _SDL_directfb_wm_h
#define _SDL_directfb_wm_h

#include "SDL_DirectFB_video.h"

typedef struct _DFB_Theme DFB_Theme;
struct _DFB_Theme
{
Expand All @@ -42,8 +46,6 @@ struct _DFB_Theme
};

extern void DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h);
extern void DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window);
extern void DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window);
extern void DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window);

extern int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window,
Expand Down
7 changes: 6 additions & 1 deletion src/video/directfb/SDL_DirectFB_dyn.c
Expand Up @@ -18,7 +18,11 @@
Sam Lantinga
slouken@libsdl.org
SDL1.3 DirectFB driver by couriersud@arcor.de
*/

#include "SDL_config.h"

#include "SDL_DirectFB_video.h"
Expand All @@ -41,6 +45,7 @@ static struct _SDL_DirectFB_Symbols
#define DFB_SYM(ret, name, args, al, func) ret name args { func SDL_DirectFB_Symbols.name al ; }
DFB_SYMS
#undef DFB_SYM

static void *handle = NULL;

int
Expand All @@ -55,7 +60,7 @@ SDL_DirectFB_LoadLibrary(void)
#define DFB_SYM(ret, name, args, al, func) if (!(SDL_DirectFB_Symbols.name = SDL_LoadFunction(handle, # name))) retval = 0;
DFB_SYMS
#undef DFB_SYM
if (!
if (!
(SDL_DirectFB_Symbols.directfb_major_version =
SDL_LoadFunction(handle, "directfb_major_version")))
retval = 0;
Expand Down

0 comments on commit 8938cbf

Please sign in to comment.