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

Latest commit

 

History

History
426 lines (340 loc) · 15.2 KB

SDL_DirectFB_video.c

File metadata and controls

426 lines (340 loc) · 15.2 KB
 
Feb 1, 2006
Feb 1, 2006
2
SDL - Simple DirectMedia Layer
Feb 12, 2011
Feb 12, 2011
3
Copyright (C) 1997-2011 Sam Lantinga
Feb 1, 2006
Feb 1, 2006
5
6
7
8
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Feb 1, 2006
Feb 1, 2006
10
11
12
13
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
Feb 1, 2006
Feb 1, 2006
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Feb 1, 2006
Feb 1, 2006
19
20
Sam Lantinga
slouken@libsdl.org
Oct 3, 2003
Oct 3, 2003
21
Feb 6, 2011
Feb 6, 2011
22
SDL1.3 DirectFB driver by couriersud@arcor.de
Aug 11, 2007
Aug 11, 2007
23
Aug 11, 2007
Aug 11, 2007
25
Feb 6, 2011
Feb 6, 2011
26
27
28
29
30
31
32
33
34
35
36
37
#include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_events.h"
/*
* #include "SDL_DirectFB_keyboard.h"
*/
#include "SDL_DirectFB_modes.h"
#include "SDL_DirectFB_mouse.h"
#include "SDL_DirectFB_opengl.h"
#include "SDL_DirectFB_window.h"
#include "SDL_DirectFB_WM.h"
Aug 11, 2007
Aug 11, 2007
38
Feb 21, 2006
Feb 21, 2006
39
#include "SDL_config.h"
40
41
42
43
44
45
46
47
48
/* DirectFB video driver implementation.
*/
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <directfb.h>
Nov 1, 2005
Nov 1, 2005
49
#include <directfb_version.h>
Jan 11, 2009
Jan 11, 2009
50
#include <directfb_strings.h>
51
52
53
#include "SDL_video.h"
#include "SDL_mouse.h"
Feb 16, 2006
Feb 16, 2006
54
55
56
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
57
58
#include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_events.h"
Aug 31, 2008
Aug 31, 2008
59
60
#include "SDL_DirectFB_render.h"
#include "SDL_DirectFB_mouse.h"
Feb 6, 2011
Feb 6, 2011
61
62
#include "SDL_DirectFB_shape.h"
Aug 11, 2007
Aug 11, 2007
63
Jan 4, 2009
Jan 4, 2009
64
65
#include "SDL_DirectFB_dyn.h"
Aug 11, 2007
Aug 11, 2007
66
67
68
69
/* Initialization/Query functions */
static int DirectFB_VideoInit(_THIS);
static void DirectFB_VideoQuit(_THIS);
Aug 31, 2008
Aug 31, 2008
70
71
static int DirectFB_Available(void);
static SDL_VideoDevice *DirectFB_CreateDevice(int devindex);
Aug 11, 2007
Aug 11, 2007
72
Aug 31, 2008
Aug 31, 2008
73
74
75
76
VideoBootStrap DirectFB_bootstrap = {
"directfb", "DirectFB",
DirectFB_Available, DirectFB_CreateDevice
};
Feb 6, 2011
Feb 6, 2011
78
79
80
81
static const DirectFBSurfaceDrawingFlagsNames(drawing_flags);
static const DirectFBSurfaceBlittingFlagsNames(blitting_flags);
static const DirectFBAccelerationMaskNames(acceleration_mask);
82
83
/* DirectFB driver bootstrap functions */
Jul 10, 2006
Jul 10, 2006
84
85
static int
DirectFB_Available(void)
Jan 4, 2009
Jan 4, 2009
87
88
89
if (!SDL_DirectFB_LoadLibrary())
return 0;
SDL_DirectFB_UnLoadLibrary();
Jul 10, 2006
Jul 10, 2006
90
return 1;
Jul 10, 2006
Jul 10, 2006
93
94
static void
DirectFB_DeleteDevice(SDL_VideoDevice * device)
Jan 4, 2009
Jan 4, 2009
96
97
98
SDL_DirectFB_UnLoadLibrary();
SDL_DFB_FREE(device->driverdata);
SDL_DFB_FREE(device);
Jul 10, 2006
Jul 10, 2006
101
102
static SDL_VideoDevice *
DirectFB_CreateDevice(int devindex)
Jul 10, 2006
Jul 10, 2006
104
105
SDL_VideoDevice *device;
Jan 4, 2009
Jan 4, 2009
106
107
108
if (!SDL_DirectFB_LoadLibrary())
return NULL;
Jul 10, 2006
Jul 10, 2006
109
/* Initialize all variables that we clean on shutdown */
Feb 6, 2011
Feb 6, 2011
110
SDL_DFB_ALLOC_CLEAR(device, sizeof(SDL_VideoDevice));
Aug 11, 2007
Aug 11, 2007
111
112
/* Set the function pointers */
Jul 10, 2006
Jul 10, 2006
113
114
115
116
/* Set the function pointers */
device->VideoInit = DirectFB_VideoInit;
device->VideoQuit = DirectFB_VideoQuit;
Aug 11, 2007
Aug 11, 2007
117
118
119
120
121
122
device->GetDisplayModes = DirectFB_GetDisplayModes;
device->SetDisplayMode = DirectFB_SetDisplayMode;
device->PumpEvents = DirectFB_PumpEventsWindow;
device->CreateWindow = DirectFB_CreateWindow;
device->CreateWindowFrom = DirectFB_CreateWindowFrom;
device->SetWindowTitle = DirectFB_SetWindowTitle;
Jan 11, 2009
Jan 11, 2009
123
device->SetWindowIcon = DirectFB_SetWindowIcon;
Aug 11, 2007
Aug 11, 2007
124
125
126
127
128
129
130
131
132
133
134
135
device->SetWindowPosition = DirectFB_SetWindowPosition;
device->SetWindowSize = DirectFB_SetWindowSize;
device->ShowWindow = DirectFB_ShowWindow;
device->HideWindow = DirectFB_HideWindow;
device->RaiseWindow = DirectFB_RaiseWindow;
device->MaximizeWindow = DirectFB_MaximizeWindow;
device->MinimizeWindow = DirectFB_MinimizeWindow;
device->RestoreWindow = DirectFB_RestoreWindow;
device->SetWindowGrab = DirectFB_SetWindowGrab;
device->DestroyWindow = DirectFB_DestroyWindow;
device->GetWindowWMInfo = DirectFB_GetWindowWMInfo;
Mar 15, 2011
Mar 15, 2011
136
137
138
139
/* Not supported by DFB, for completeness */
device->SetWindowGammaRamp = DirectFB_SetWindowGammaRamp;
device->GetWindowGammaRamp = DirectFB_GetWindowGammaRamp;
Aug 11, 2007
Aug 11, 2007
140
141
142
143
144
145
146
147
148
149
150
151
#if SDL_DIRECTFB_OPENGL
device->GL_LoadLibrary = DirectFB_GL_LoadLibrary;
device->GL_GetProcAddress = DirectFB_GL_GetProcAddress;
device->GL_MakeCurrent = DirectFB_GL_MakeCurrent;
device->GL_CreateContext = DirectFB_GL_CreateContext;
device->GL_SetSwapInterval = DirectFB_GL_SetSwapInterval;
device->GL_GetSwapInterval = DirectFB_GL_GetSwapInterval;
device->GL_SwapWindow = DirectFB_GL_SwapWindow;
device->GL_DeleteContext = DirectFB_GL_DeleteContext;
#endif
Jul 10, 2006
Jul 10, 2006
152
Feb 6, 2011
Feb 6, 2011
153
154
155
156
157
/* Shaped window support */
device->shape_driver.CreateShaper = DirectFB_CreateShaper;
device->shape_driver.SetWindowShape = DirectFB_SetWindowShape;
device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape;
Jul 10, 2006
Jul 10, 2006
158
device->free = DirectFB_DeleteDevice;
Feb 6, 2011
Feb 6, 2011
159
Jul 10, 2006
Jul 10, 2006
160
return device;
Aug 11, 2007
Aug 11, 2007
161
162
163
164
error:
if (device)
free(device);
return (0);
Jan 11, 2009
Jan 11, 2009
167
168
169
170
171
172
173
174
static void
DirectFB_DeviceInformation(IDirectFB * dfb)
{
DFBGraphicsDeviceDescription desc;
int n;
dfb->GetDeviceDescription(dfb, &desc);
Mar 15, 2011
Mar 15, 2011
175
176
177
178
179
180
181
SDL_DFB_LOG( "DirectFB Device Information");
SDL_DFB_LOG( "===========================");
SDL_DFB_LOG( "Name: %s", desc.name);
SDL_DFB_LOG( "Vendor: %s", desc.vendor);
SDL_DFB_LOG( "Driver Name: %s", desc.driver.name);
SDL_DFB_LOG( "Driver Vendor: %s", desc.driver.vendor);
SDL_DFB_LOG( "Driver Version: %d.%d", desc.driver.major,
Jan 11, 2009
Jan 11, 2009
182
183
desc.driver.minor);
Mar 15, 2011
Mar 15, 2011
184
SDL_DFB_LOG( "Video memoory: %d", desc.video_memory);
Jan 11, 2009
Jan 11, 2009
185
Mar 15, 2011
Mar 15, 2011
186
SDL_DFB_LOG( "Blitting flags:");
Jan 11, 2009
Jan 11, 2009
187
188
for (n = 0; blitting_flags[n].flag; n++) {
if (desc.blitting_flags & blitting_flags[n].flag)
Mar 15, 2011
Mar 15, 2011
189
SDL_DFB_LOG( " %s", blitting_flags[n].name);
Jan 11, 2009
Jan 11, 2009
190
191
}
Mar 15, 2011
Mar 15, 2011
192
SDL_DFB_LOG( "Drawing flags:");
Jan 11, 2009
Jan 11, 2009
193
194
for (n = 0; drawing_flags[n].flag; n++) {
if (desc.drawing_flags & drawing_flags[n].flag)
Mar 15, 2011
Mar 15, 2011
195
SDL_DFB_LOG( " %s", drawing_flags[n].name);
Jan 11, 2009
Jan 11, 2009
196
197
}
Jul 24, 2010
Jul 24, 2010
198
Mar 15, 2011
Mar 15, 2011
199
SDL_DFB_LOG( "Acceleration flags:");
Jan 11, 2009
Jan 11, 2009
200
201
for (n = 0; acceleration_mask[n].mask; n++) {
if (desc.acceleration_mask & acceleration_mask[n].mask)
Mar 15, 2011
Mar 15, 2011
202
SDL_DFB_LOG( " %s", acceleration_mask[n].name);
Jan 11, 2009
Jan 11, 2009
203
204
205
206
207
}
}
Feb 6, 2011
Feb 6, 2011
208
209
210
211
212
213
214
215
216
217
218
static int readBoolEnv(const char *env_name, int def_val)
{
char *stemp;
stemp = SDL_getenv(env_name);
if (stemp)
return atoi(stemp);
else
return def_val;
}
Aug 11, 2007
Aug 11, 2007
219
220
static int
DirectFB_VideoInit(_THIS)
Jul 10, 2006
Jul 10, 2006
222
IDirectFB *dfb = NULL;
Jan 4, 2009
Jan 4, 2009
223
DFB_DeviceData *devdata = NULL;
Aug 11, 2007
Aug 11, 2007
224
DFBResult ret;
Feb 6, 2011
Feb 6, 2011
226
SDL_DFB_ALLOC_CLEAR(devdata, sizeof(*devdata));
Jan 4, 2009
Jan 4, 2009
227
Aug 11, 2007
Aug 11, 2007
228
SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL));
Jan 4, 2009
Jan 4, 2009
230
231
/* avoid switching to the framebuffer when we
* are running X11 */
Feb 6, 2011
Feb 6, 2011
232
ret = readBoolEnv(DFBENV_USE_X11_CHECK , 1);
Jan 4, 2009
Jan 4, 2009
233
if (ret) {
Jan 11, 2009
Jan 11, 2009
234
if (SDL_getenv("DISPLAY"))
Jan 4, 2009
Jan 4, 2009
235
236
237
238
239
DirectFBSetOption("system", "x11");
else
DirectFBSetOption("disable-module", "x11input");
}
Aug 16, 2010
Aug 16, 2010
240
/* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */
Feb 6, 2011
Feb 6, 2011
241
devdata->use_linux_input = readBoolEnv(DFBENV_USE_LINUX_INPUT, 0); /* default: on */
Jan 4, 2009
Jan 4, 2009
242
243
if (!devdata->use_linux_input)
Feb 6, 2011
Feb 6, 2011
244
245
{
SDL_DFB_LOG("Disabling linxu input\n");
Jan 4, 2009
Jan 4, 2009
246
DirectFBSetOption("disable-module", "linux_input");
Feb 6, 2011
Feb 6, 2011
247
248
}
Jan 4, 2009
Jan 4, 2009
249
SDL_DFB_CHECKERR(DirectFBCreate(&dfb));
Oct 3, 2003
Oct 3, 2003
250
Jan 11, 2009
Jan 11, 2009
251
DirectFB_DeviceInformation(dfb);
Feb 6, 2011
Feb 6, 2011
252
253
254
devdata->use_yuv_underlays = readBoolEnv(DFBENV_USE_YUV_UNDERLAY, 0); /* default: off */
devdata->use_yuv_direct = readBoolEnv(DFBENV_USE_YUV_DIRECT, 0); /* default is off! */
Jan 4, 2009
Jan 4, 2009
255
Aug 31, 2008
Aug 31, 2008
256
/* Create global Eventbuffer for axis events */
Jan 4, 2009
Jan 4, 2009
257
if (devdata->use_linux_input) {
Jan 11, 2009
Jan 11, 2009
258
259
260
SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_ALL,
DFB_TRUE,
&devdata->events));
Dec 8, 2008
Dec 8, 2008
261
} else {
Jan 11, 2009
Jan 11, 2009
262
263
264
265
SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_AXES
/*DICAPS_ALL */ ,
DFB_TRUE,
&devdata->events));
Dec 8, 2008
Dec 8, 2008
266
}
Oct 3, 2003
Oct 3, 2003
267
Jan 11, 2009
Jan 11, 2009
268
/* simple window manager support */
Feb 6, 2011
Feb 6, 2011
269
270
271
devdata->has_own_wm = readBoolEnv(DFBENV_USE_WM, 0);
devdata->initialized = 1;
Jan 11, 2009
Jan 11, 2009
272
Aug 11, 2007
Aug 11, 2007
273
274
devdata->dfb = dfb;
devdata->firstwin = NULL;
Aug 16, 2010
Aug 16, 2010
275
devdata->grabbed_window = NULL;
Aug 24, 2002
Aug 24, 2002
276
Aug 11, 2007
Aug 11, 2007
277
_this->driverdata = devdata;
Oct 3, 2003
Oct 3, 2003
278
Aug 31, 2008
Aug 31, 2008
279
DirectFB_InitModes(_this);
Oct 3, 2003
Oct 3, 2003
280
Aug 11, 2007
Aug 11, 2007
281
#if SDL_DIRECTFB_OPENGL
Aug 31, 2008
Aug 31, 2008
282
DirectFB_GL_Initialize(_this);
Aug 11, 2007
Aug 11, 2007
283
#endif
Aug 24, 2002
Aug 24, 2002
284
Aug 11, 2007
Aug 11, 2007
285
DirectFB_InitMouse(_this);
Aug 26, 2008
Aug 26, 2008
286
DirectFB_InitKeyboard(_this);
Aug 31, 2008
Aug 31, 2008
287
Aug 11, 2007
Aug 11, 2007
288
return 0;
Jul 10, 2006
Jul 10, 2006
289
Aug 11, 2007
Aug 11, 2007
291
error:
Jan 4, 2009
Jan 4, 2009
292
SDL_DFB_FREE(devdata);
Aug 11, 2007
Aug 11, 2007
293
294
SDL_DFB_RELEASE(dfb);
return -1;
Aug 11, 2007
Aug 11, 2007
297
298
static void
DirectFB_VideoQuit(_THIS)
Aug 11, 2007
Aug 11, 2007
300
301
DFB_DeviceData *devdata = (DFB_DeviceData *) _this->driverdata;
Aug 31, 2008
Aug 31, 2008
302
303
304
DirectFB_QuitModes(_this);
DirectFB_QuitKeyboard(_this);
DirectFB_QuitMouse(_this);
Feb 6, 2011
Feb 6, 2011
306
devdata->events->Reset(devdata->events);
Aug 31, 2008
Aug 31, 2008
307
SDL_DFB_RELEASE(devdata->events);
Aug 11, 2007
Aug 11, 2007
308
SDL_DFB_RELEASE(devdata->dfb);
Aug 11, 2007
Aug 11, 2007
310
#if SDL_DIRECTFB_OPENGL
Aug 31, 2008
Aug 31, 2008
311
DirectFB_GL_Shutdown(_this);
Aug 11, 2007
Aug 11, 2007
312
#endif
Aug 31, 2002
Aug 31, 2002
313
Aug 11, 2007
Aug 11, 2007
314
315
devdata->initialized = 0;
}
Feb 6, 2011
Feb 6, 2011
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
/* DirectFB driver general support functions */
static const struct {
DFBSurfacePixelFormat dfb;
Uint32 sdl;
} pixelformat_tab[] =
{
{ DSPF_RGB32, SDL_PIXELFORMAT_RGB888 }, /* 24 bit RGB (4 byte, nothing@24, red 8@16, green 8@8, blue 8@0) */
{ DSPF_ARGB, SDL_PIXELFORMAT_ARGB8888 }, /* 32 bit ARGB (4 byte, alpha 8@24, red 8@16, green 8@8, blue 8@0) */
{ DSPF_RGB16, SDL_PIXELFORMAT_RGB565 }, /* 16 bit RGB (2 byte, red 5@11, green 6@5, blue 5@0) */
{ DSPF_RGB332, SDL_PIXELFORMAT_RGB332 }, /* 8 bit RGB (1 byte, red 3@5, green 3@2, blue 2@0) */
{ DSPF_ARGB4444, SDL_PIXELFORMAT_ARGB4444 }, /* 16 bit ARGB (2 byte, alpha 4@12, red 4@8, green 4@4, blue 4@0) */
{ DSPF_ARGB1555, SDL_PIXELFORMAT_ARGB1555 }, /* 16 bit ARGB (2 byte, alpha 1@15, red 5@10, green 5@5, blue 5@0) */
{ DSPF_RGB24, SDL_PIXELFORMAT_RGB24 }, /* 24 bit RGB (3 byte, red 8@16, green 8@8, blue 8@0) */
{ DSPF_RGB444, SDL_PIXELFORMAT_RGB444 }, /* 16 bit RGB (2 byte, nothing @12, red 4@8, green 4@4, blue 4@0) */
{ DSPF_YV12, SDL_PIXELFORMAT_YV12 }, /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size V/U planes) */
{ DSPF_I420,SDL_PIXELFORMAT_IYUV }, /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size U/V planes) */
{ DSPF_YUY2, SDL_PIXELFORMAT_YUY2 }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */
{ DSPF_UYVY, SDL_PIXELFORMAT_UYVY }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */
{ DSPF_RGB555, SDL_PIXELFORMAT_RGB555 }, /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */
#if (ENABLE_LUT8)
{ DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 }, /* 8 bit LUT (8 bit color and alpha lookup from palette) */
#endif
#if (DFB_VERSION_ATLEAST(1,2,0))
{ DSPF_BGR555, SDL_PIXELFORMAT_BGR555 }, /* 16 bit BGR (2 byte, nothing @15, blue 5@10, green 5@5, red 5@0) */
#else
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR555 },
#endif
/* Pfff ... nonmatching formats follow */
{ DSPF_ALUT44, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit ALUT (1 byte, alpha 4@4, color lookup 4@0) */
{ DSPF_A8, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit alpha (1 byte, alpha 8@0), e.g. anti-aliased glyphs */
{ DSPF_AiRGB, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit ARGB (4 byte, inv. alpha 8@24, red 8@16, green 8@8, blue 8@0) */
{ DSPF_A1, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (1 byte/ 8 pixel, most significant bit used first) */
{ DSPF_NV12, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CbCr [15:0] plane) */
{ DSPF_NV16, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit YUV (8 bit Y plane followed by one 16 bit half width CbCr [15:0] plane) */
{ DSPF_ARGB2554, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit ARGB (2 byte, alpha 2@14, red 5@9, green 5@4, blue 4@0) */
{ DSPF_NV21, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CrCb [15:0] plane) */
{ DSPF_AYUV, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AYUV (4 byte, alpha 8@24, Y 8@16, Cb 8@8, Cr 8@0) */
{ DSPF_A4, SDL_PIXELFORMAT_UNKNOWN }, /* 4 bit alpha (1 byte/ 2 pixel, more significant nibble used first) */
{ DSPF_ARGB1666, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (3 byte/ alpha 1@18, red 6@16, green 6@6, blue 6@0) */
{ DSPF_ARGB6666, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit alpha (3 byte/ alpha 6@18, red 6@16, green 6@6, blue 6@0) */
{ DSPF_RGB18, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit RGB (3 byte/ red 6@16, green 6@6, blue 6@0) */
{ DSPF_LUT2, SDL_PIXELFORMAT_UNKNOWN }, /* 2 bit LUT (1 byte/ 4 pixel, 2 bit color and alpha lookup from palette) */
#if (DFB_VERSION_ATLEAST(1,3,0))
{ DSPF_RGBA4444, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 4@12, green 4@8, blue 4@4, alpha 4@0) */
#endif
#if (DFB_VERSION_ATLEAST(1,4,3))
{ DSPF_RGBA5551, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 5@11, green 5@6, blue 5@1, alpha 1@0) */
{ DSPF_YUV444P, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit full YUV planar (8 bit Y plane followed by an 8 bit Cb and an 8 bit Cr plane) */
{ DSPF_ARGB8565, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit ARGB (3 byte, alpha 8@16, red 5@11, green 6@5, blue 5@0) */
{ DSPF_AVYU, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AVYU 4:4:4 (4 byte, alpha 8@24, Cr 8@16, Y 8@8, Cb 8@0) */
{ DSPF_VYU, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit VYU 4:4:4 (3 byte, Cr 8@16, Y 8@8, Cb 8@0) */
#endif
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1MSB },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4LSB },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4MSB },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR24 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR888 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_RGBA8888 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR8888 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGRA8888 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ARGB2101010 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR4444 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR1555 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR565 },
{ DSPF_UNKNOWN, SDL_PIXELFORMAT_YVYU }, /**< Packed mode: Y0+V0+Y1+U0 (1 pla */
};
Uint32
DirectFB_DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat)
{
int i;
for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
if (pixelformat_tab[i].dfb == pixelformat)
{
return pixelformat_tab[i].sdl;
}
return SDL_PIXELFORMAT_UNKNOWN;
}
DFBSurfacePixelFormat
DirectFB_SDLToDFBPixelFormat(Uint32 format)
{
int i;
for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
if (pixelformat_tab[i].sdl == format)
{
return pixelformat_tab[i].dfb;
}
return DSPF_UNKNOWN;
}
void DirectFB_SetSupportedPixelFormats(SDL_RendererInfo* ri)
{
int i, j;
for (i=0, j=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
if (pixelformat_tab[i].sdl != SDL_PIXELFORMAT_UNKNOWN)
ri->texture_formats[j++] = pixelformat_tab[i].sdl;
ri->num_texture_formats = j;
}