comparison src/video/directfb/SDL_DirectFB_video.h @ 2226:0e70b4b8cf84

Date: Sat, 11 Aug 2007 02:03:16 +0200 (CEST) From: couriersud arcor.de To: slouken@libsdl.org Subject: Directfb driver for SDL1.3 Hi, the attachment contains a patch for a SDL1.3 directfb driver. It supports: - Renderer "directfb": Hardware acceleration as supported by the underlying directfb driver. With a radeon X850, testsprite2 runs at 50% to 70% of OpenGL (X11, dri) performance. Also supports hardware accelerated yuv overlays. This must be enabled by sett ing: export SDL_DIRECTFB_YUV_DIRECT=1 - Renderer "opengl" Supports software opengl using mesa opengl (make linux-directfb). Some more information may be found in README.DirectFB There will certainly still be some bugs, and there is some debug code around. When I find some time, I will compile against directfb-0.9.25 as distributed with ubuntu 7.04. The diff also contains a fix for SDL_LockYUVOverlay fixing a bug in *pixels and pitches initialization. Kind regards, couriersud
author Sam Lantinga <slouken@libsdl.org>
date Sat, 11 Aug 2007 21:51:19 +0000
parents c121d94672cb
children e82a0e3e9b0e
comparison
equal deleted inserted replaced
2225:3bca1b7ca25b 2226:0e70b4b8cf84
23 23
24 #ifndef _SDL_DirectFB_video_h 24 #ifndef _SDL_DirectFB_video_h
25 #define _SDL_DirectFB_video_h 25 #define _SDL_DirectFB_video_h
26 26
27 #include <directfb.h> 27 #include <directfb.h>
28 #include <directfb_version.h>
29
30 #define LOG_CHANNEL stdout
31
32 #if (DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)
33 #error "SDL_DIRECTFB: Please compile against libdirectfb version >=0.9.24"
34 #endif
35
36 #if (DIRECTFB_MAJOR_VERSION >= 1) && (DIRECTFB_MINOR_VERSION >= 0) && (DIRECTFB_MICRO_VERSION >= 0 )
37 #define SDL_DIRECTFB_OPENGL 1
38 #include <directfbgl.h>
39 #endif
40
41 #if SDL_DIRECTFB_OPENGL
42 #include "SDL_loadso.h"
43 #endif
28 44
29 #include "SDL_mouse.h" 45 #include "SDL_mouse.h"
30 #include "../SDL_sysvideo.h" 46 #include "../SDL_sysvideo.h"
31 47
32 #define _THIS SDL_VideoDevice *this 48 #define DEBUG 1
49
50 #define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0)
51 #define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0)
52 #define SDL_DFB_UNLOCK(x) do { if ( x ) { x->Unlock(x); } } while (0)
53
54 #if DEBUG
55 #define SDL_DFB_DEBUG(x...) do { fprintf(LOG_CHANNEL, "%s:", __FUNCTION__); fprintf(LOG_CHANNEL, x); } while (0)
56 #define SDL_DFB_DEBUGC(x...) do { fprintf(LOG_CHANNEL, x); } while (0)
57 #else
58 #define SDL_DFB_DEBUG(x...) do { } while (0)
59 #define SDL_DFB_DEBUGC(x...) do { } while (0)
60 #endif
61
62 #define SDL_DFB_CONTEXT "SDL_DirectFB"
63
64 #define SDL_DFB_ERR(x...) \
65 do { \
66 fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t", \
67 SDL_DFB_CONTEXT, __FILE__, __LINE__ ); \
68 fprintf(LOG_CHANNEL, x ); \
69 } while (0)
70
71 #define SDL_DFB_CHECK(x...) \
72 do { \
73 ret = x; \
74 if (ret != DFB_OK) { \
75 fprintf(LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
76 SDL_SetError( #x, DirectFBErrorString (ret) ); \
77 } \
78 } while (0)
79
80 #define SDL_DFB_CHECKERR(x...) \
81 do { \
82 ret = x; \
83 if (ret != DFB_OK) { \
84 fprintf(LOG_CHANNEL, "%s <%d>:\n", __FILE__, __LINE__ ); \
85 fprintf(LOG_CHANNEL, "\t%s\n", #x ); \
86 fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); \
87 SDL_SetError( #x, DirectFBErrorString (ret) ); \
88 goto error; \
89 } \
90 } while (0)
91
92 #define SDL_DFB_CALLOC(r, n, s) \
93 do { \
94 r = SDL_calloc (n, s); \
95 if (!(r)) { \
96 fprintf( LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
97 SDL_OutOfMemory(); \
98 goto error; \
99 } \
100 } while (0)
33 101
34 /* Private display data */ 102 /* Private display data */
35 103
36 struct SDL_PrivateVideoData 104 #define SDL_DFB_DEVICEDATA(dev) DFB_DeviceData *devdata = (DFB_DeviceData *) ((dev)->driverdata)
105 #define SDL_DFB_WINDOWDATA(win) DFB_WindowData *windata = ((win) ? (DFB_WindowData *) ((win)->driverdata) : NULL)
106 #define SDL_DFB_DISPLAYDATA(dev, win) DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (dev)->displays[(win)->display].driverdata : NULL)
107
108 typedef struct _DFB_DisplayData DFB_DisplayData;
109
110 #define DFB_MAX_SCREENS 10
111 #define DFB_MAX_MODES 50
112
113 struct _DFB_DisplayData
114 {
115 IDirectFBDisplayLayer *layer;
116 DFBSurfacePixelFormat pixelformat;
117 DFBDisplayLayerID vidID;
118
119 int cw;
120 int ch;
121
122 int nummodes;
123 SDL_DisplayMode *modelist;
124
125 #if 0
126 WMcursor *last_cursor;
127 WMcursor *blank_cursor;
128 WMcursor *default_cursor;
129 #endif
130 };
131
132
133 typedef struct _DFB_WindowData DFB_WindowData;
134 struct _DFB_WindowData
135 {
136 IDirectFBSurface *surface;
137 IDirectFBPalette *palette;
138 IDirectFBWindow *window;
139 IDirectFBGL *gl_context;
140 IDirectFBEventBuffer *eventbuffer;
141 DFBWindowID windowID;
142 int id; // SDL window id
143 DFB_WindowData *next;
144 u8 opacity;
145 };
146
147 typedef struct _DFB_DeviceData DFB_DeviceData;
148 struct _DFB_DeviceData
37 { 149 {
38 int initialized; 150 int initialized;
39 151
40 IDirectFB *dfb; 152 IDirectFB *dfb;
41 IDirectFBDisplayLayer *layer; 153 int mouse;
42 IDirectFBEventBuffer *eventbuffer; 154 int keyboard;
155 DFB_WindowData *firstwin;
43 156
44 int nummodes; 157 int numscreens;
45 SDL_Rect **modelist; 158 DFBScreenID screenid[DFB_MAX_SCREENS];
159 DFBDisplayLayerID gralayer[DFB_MAX_SCREENS];
160 DFBDisplayLayerID vidlayer[DFB_MAX_SCREENS];
46 161
47 /* MGA CRTC2 support */ 162 // auxiliary integer for callbacks
48 int enable_mga_crtc2; 163 int aux;
49 int mga_crtc2_stretch; 164
50 float mga_crtc2_stretch_overscan; 165 // OpenGL
51 IDirectFBDisplayLayer *c2layer; 166 void (*glFinish) (void);
52 IDirectFBSurface *c2frame; 167 void (*glFlush) (void);
53 DFBRectangle c2ssize; /* Real screen size */
54 DFBRectangle c2dsize; /* Stretched screen size */
55 DFBRectangle c2framesize; /* CRTC2 screen size */
56 }; 168 };
57 169
58 #define HIDDEN (this->hidden) 170 struct SDL_GLDriverData
171 {
172 int gl_active; /* to stop switching drivers while we have a valid context */
59 173
60 void SetDirectFBerror(const char *function, DFBResult code); 174 #if SDL_DIRECTFB_OPENGL
175 IDirectFBGL *gl_context;
176 #endif /* SDL_DIRECTFB_OPENGL */
177 };
61 178
62 #endif /* _SDL_DirectFB_video_h */ 179 #endif /* _SDL_DirectFB_video_h */
63 /* vi: set ts=4 sw=4 expandtab: */