2 Simple DirectMedia Layer
3 Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
22 #include "../../SDL_internal.h"
24 #ifndef SDL_DirectFB_video_h_
25 #define SDL_DirectFB_video_h_
28 #include <directfb_version.h>
30 #include "../SDL_sysvideo.h"
31 #include "SDL_scancode.h"
32 #include "SDL_render.h"
35 #define DFB_VERSIONNUM(X, Y, Z) \
36 ((X)*1000 + (Y)*100 + (Z))
38 #define DFB_COMPILEDVERSION \
39 DFB_VERSIONNUM(DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION, DIRECTFB_MICRO_VERSION)
41 #define DFB_VERSION_ATLEAST(X, Y, Z) \
42 (DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z))
44 #if (DFB_VERSION_ATLEAST(1,0,0))
45 #ifdef SDL_VIDEO_OPENGL
46 #define SDL_DIRECTFB_OPENGL 1
49 #error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
52 /* Set below to 1 to compile with (old) multi mice/keyboard api. Code left in
53 * in case we see this again ...
56 #define USE_MULTI_API (0)
58 /* Support for LUT8/INDEX8 pixel format.
59 * This is broken in DirectFB 1.4.3. It works in 1.4.0 and 1.4.5
63 #if (DFB_COMPILEDVERSION == DFB_VERSIONNUM(1, 4, 3))
64 #define ENABLE_LUT8 (0)
66 #define ENABLE_LUT8 (1)
69 #define DIRECTFB_DEBUG 1
71 #define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" /* Default: off */
72 #define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" /* Default: off */
73 #define DFBENV_USE_X11_CHECK "SDL_DIRECTFB_X11_CHECK" /* Default: on */
74 #define DFBENV_USE_LINUX_INPUT "SDL_DIRECTFB_LINUX_INPUT" /* Default: on */
75 #define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */
77 #define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { SDL_DFB_CHECK(x->Release(x)); x = NULL; } } while (0)
78 #define SDL_DFB_FREE(x) do { SDL_free((x)); (x) = NULL; } while (0)
79 #define SDL_DFB_UNLOCK(x) do { if ( (x) != NULL ) { x->Unlock(x); } } while (0)
81 #define SDL_DFB_CONTEXT "SDL_DirectFB"
83 #define SDL_DFB_ERR(x...) SDL_LogError(SDL_LOG_CATEGORY_ERROR, x)
86 #define SDL_DFB_LOG(x...) SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, x)
88 #define SDL_DFB_DEBUG(x...) SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, x)
90 static SDL_INLINE DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) {
92 SDL_DFB_LOG("%s (%d):%s", src_file, src_line, DirectFBErrorString (ret) );
93 SDL_SetError("%s:%s", SDL_DFB_CONTEXT, DirectFBErrorString (ret) );
98 #define SDL_DFB_CHECK(x...) do { sdl_dfb_check( x, __FILE__, __LINE__); } while (0)
99 #define SDL_DFB_CHECKERR(x...) do { if ( sdl_dfb_check( x, __FILE__, __LINE__) != DFB_OK ) goto error; } while (0)
103 #define SDL_DFB_CHECK(x...) x
104 #define SDL_DFB_CHECKERR(x...) do { if (x != DFB_OK ) goto error; } while (0)
105 #define SDL_DFB_LOG(x...) do {} while (0)
106 #define SDL_DFB_DEBUG(x...) do {} while (0)
111 #define SDL_DFB_CALLOC(r, n, s) \
113 r = SDL_calloc (n, s); \
115 SDL_DFB_ERR("Out of memory"); \
121 #define SDL_DFB_ALLOC_CLEAR(r, s) SDL_DFB_CALLOC(r, 1, s)
123 /* Private display data */
125 #define SDL_DFB_DEVICEDATA(dev) DFB_DeviceData *devdata = (dev ? (DFB_DeviceData *) ((dev)->driverdata) : NULL)
127 #define DFB_MAX_SCREENS 10
129 typedef struct _DFB_KeyboardData DFB_KeyboardData;
130 struct _DFB_KeyboardData
132 const SDL_Scancode *map; /* keyboard scancode map */
133 int map_size; /* size of map */
134 int map_adjust; /* index adjust */
135 int is_generic; /* generic keyboard */
139 typedef struct _DFB_DeviceData DFB_DeviceData;
140 struct _DFB_DeviceData
148 DFB_KeyboardData keyboard[10];
149 SDL_Window *firstwin;
151 int use_yuv_underlays;
158 SDL_Window *grabbed_window;
161 IDirectFBEventBuffer *events;
164 Uint32 DirectFB_DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat);
165 DFBSurfacePixelFormat DirectFB_SDLToDFBPixelFormat(Uint32 format);
166 void DirectFB_SetSupportedPixelFormats(SDL_RendererInfo *ri);
169 #endif /* SDL_DirectFB_video_h_ */