src/video/directfb/SDL_DirectFB_video.c
changeset 5199 164f20ba08eb
parent 4636 b196d2758026
child 5243 3a8a452b49f0
equal deleted inserted replaced
5198:7c3422025c35 5199:164f20ba08eb
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    18 
    19     Sam Lantinga
    19     Sam Lantinga
    20     slouken@libsdl.org
    20     slouken@libsdl.org
    21 
    21 
    22     SDL1.3 implementation by couriersud@arcor.de
    22     SDL1.3 DirectFB driver by couriersud@arcor.de
    23 	
    23 	
    24 */
    24 */
       
    25 
       
    26 #include "SDL_DirectFB_video.h"
       
    27 
       
    28 #include "SDL_DirectFB_events.h"
       
    29 /*
       
    30  * #include "SDL_DirectFB_gamma.h"
       
    31  * #include "SDL_DirectFB_keyboard.h"
       
    32  */
       
    33 #include "SDL_DirectFB_modes.h"
       
    34 #include "SDL_DirectFB_mouse.h"
       
    35 #include "SDL_DirectFB_opengl.h"
       
    36 #include "SDL_DirectFB_window.h"
       
    37 #include "SDL_DirectFB_WM.h"
    25 
    38 
    26 
    39 
    27 #include "SDL_config.h"
    40 #include "SDL_config.h"
    28 
    41 
    29 /* DirectFB video driver implementation.
    42 /* DirectFB video driver implementation.
    44 #include "../../events/SDL_events_c.h"
    57 #include "../../events/SDL_events_c.h"
    45 #include "SDL_DirectFB_video.h"
    58 #include "SDL_DirectFB_video.h"
    46 #include "SDL_DirectFB_events.h"
    59 #include "SDL_DirectFB_events.h"
    47 #include "SDL_DirectFB_render.h"
    60 #include "SDL_DirectFB_render.h"
    48 #include "SDL_DirectFB_mouse.h"
    61 #include "SDL_DirectFB_mouse.h"
       
    62 #include "SDL_DirectFB_shape.h"
       
    63 
    49 
    64 
    50 #include "SDL_DirectFB_dyn.h"
    65 #include "SDL_DirectFB_dyn.h"
    51 
    66 
    52 /* Initialization/Query functions */
    67 /* Initialization/Query functions */
    53 static int DirectFB_VideoInit(_THIS);
    68 static int DirectFB_VideoInit(_THIS);
    59 VideoBootStrap DirectFB_bootstrap = {
    74 VideoBootStrap DirectFB_bootstrap = {
    60     "directfb", "DirectFB",
    75     "directfb", "DirectFB",
    61     DirectFB_Available, DirectFB_CreateDevice
    76     DirectFB_Available, DirectFB_CreateDevice
    62 };
    77 };
    63 
    78 
       
    79 static const DirectFBSurfaceDrawingFlagsNames(drawing_flags);
       
    80 static const DirectFBSurfaceBlittingFlagsNames(blitting_flags);
       
    81 static const DirectFBAccelerationMaskNames(acceleration_mask);
       
    82 
    64 /* DirectFB driver bootstrap functions */
    83 /* DirectFB driver bootstrap functions */
    65 
    84 
    66 static int
    85 static int
    67 DirectFB_Available(void)
    86 DirectFB_Available(void)
    68 {
    87 {
    87 
   106 
    88     if (!SDL_DirectFB_LoadLibrary())
   107     if (!SDL_DirectFB_LoadLibrary())
    89         return NULL;
   108         return NULL;
    90 
   109 
    91     /* Initialize all variables that we clean on shutdown */
   110     /* Initialize all variables that we clean on shutdown */
    92     SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice));
   111     SDL_DFB_ALLOC_CLEAR(device, sizeof(SDL_VideoDevice));
    93 
   112 
    94     /* Set the function pointers */
   113     /* Set the function pointers */
    95 
   114 
    96     /* Set the function pointers */
   115     /* Set the function pointers */
    97     device->VideoInit = DirectFB_VideoInit;
   116     device->VideoInit = DirectFB_VideoInit;
   126     device->GL_SwapWindow = DirectFB_GL_SwapWindow;
   145     device->GL_SwapWindow = DirectFB_GL_SwapWindow;
   127     device->GL_DeleteContext = DirectFB_GL_DeleteContext;
   146     device->GL_DeleteContext = DirectFB_GL_DeleteContext;
   128 
   147 
   129 #endif
   148 #endif
   130 
   149 
       
   150 	/* Shaped window support */
       
   151 	device->shape_driver.CreateShaper = DirectFB_CreateShaper;
       
   152 	device->shape_driver.SetWindowShape = DirectFB_SetWindowShape;
       
   153 	device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape;
       
   154 	
   131     device->free = DirectFB_DeleteDevice;
   155     device->free = DirectFB_DeleteDevice;
   132 	fprintf(LOG_CHANNEL, "Device setup %p!!\n", device->ShowWindow);
   156     
   133     return device;
   157     return device;
   134   error:
   158   error:
   135     if (device)
   159     if (device)
   136         free(device);
   160         free(device);
   137     return (0);
   161     return (0);
   138 }
   162 }
   139 
   163 
   140 static const DirectFBSurfaceDrawingFlagsNames(drawing_flags);
       
   141 static const DirectFBSurfaceBlittingFlagsNames(blitting_flags);
       
   142 static const DirectFBAccelerationMaskNames(acceleration_mask);
       
   143 
       
   144 static void
   164 static void
   145 DirectFB_DeviceInformation(IDirectFB * dfb)
   165 DirectFB_DeviceInformation(IDirectFB * dfb)
   146 {
   166 {
   147     DFBGraphicsDeviceDescription desc;
   167     DFBGraphicsDeviceDescription desc;
   148     int n;
   168     int n;
   149 
   169 
   150     dfb->GetDeviceDescription(dfb, &desc);
   170     dfb->GetDeviceDescription(dfb, &desc);
   151 
   171 
   152     fprintf(LOG_CHANNEL, "DirectFB Device Information\n");
   172     SDL_DFB_LOG( "DirectFB Device Information\n");
   153     fprintf(LOG_CHANNEL, "===========================\n");
   173     SDL_DFB_LOG( "===========================\n");
   154     fprintf(LOG_CHANNEL, "Name:           %s\n", desc.name);
   174     SDL_DFB_LOG( "Name:           %s\n", desc.name);
   155     fprintf(LOG_CHANNEL, "Vendor:         %s\n", desc.vendor);
   175     SDL_DFB_LOG( "Vendor:         %s\n", desc.vendor);
   156     fprintf(LOG_CHANNEL, "Driver Name:    %s\n", desc.driver.name);
   176     SDL_DFB_LOG( "Driver Name:    %s\n", desc.driver.name);
   157     fprintf(LOG_CHANNEL, "Driver Vendor:  %s\n", desc.driver.vendor);
   177     SDL_DFB_LOG( "Driver Vendor:  %s\n", desc.driver.vendor);
   158     fprintf(LOG_CHANNEL, "Driver Version: %d.%d\n", desc.driver.major,
   178     SDL_DFB_LOG( "Driver Version: %d.%d\n", desc.driver.major,
   159             desc.driver.minor);
   179             desc.driver.minor);
   160 
   180 
   161     fprintf(LOG_CHANNEL, "\nVideo memoory:  %d\n", desc.video_memory);
   181     SDL_DFB_LOG( "\nVideo memoory:  %d\n", desc.video_memory);
   162 
   182 
   163     fprintf(LOG_CHANNEL, "\nBlitting flags:\n");
   183     SDL_DFB_LOG( "\nBlitting flags:\n");
   164     for (n = 0; blitting_flags[n].flag; n++) {
   184     for (n = 0; blitting_flags[n].flag; n++) {
   165         if (desc.blitting_flags & blitting_flags[n].flag)
   185         if (desc.blitting_flags & blitting_flags[n].flag)
   166             fprintf(LOG_CHANNEL, "    %s\n", blitting_flags[n].name);
   186             SDL_DFB_LOG( "    %s\n", blitting_flags[n].name);
   167     }
   187     }
   168 
   188 
   169     fprintf(LOG_CHANNEL, "\nDrawing flags:\n");
   189     SDL_DFB_LOG( "\nDrawing flags:\n");
   170     for (n = 0; drawing_flags[n].flag; n++) {
   190     for (n = 0; drawing_flags[n].flag; n++) {
   171         if (desc.drawing_flags & drawing_flags[n].flag)
   191         if (desc.drawing_flags & drawing_flags[n].flag)
   172             fprintf(LOG_CHANNEL, "    %s\n", drawing_flags[n].name);
   192             SDL_DFB_LOG( "    %s\n", drawing_flags[n].name);
   173     }
   193     }
   174 
   194 
   175 
   195 
   176     fprintf(LOG_CHANNEL, "\nAcceleration flags:\n");
   196     SDL_DFB_LOG( "\nAcceleration flags:\n");
   177     for (n = 0; acceleration_mask[n].mask; n++) {
   197     for (n = 0; acceleration_mask[n].mask; n++) {
   178         if (desc.acceleration_mask & acceleration_mask[n].mask)
   198         if (desc.acceleration_mask & acceleration_mask[n].mask)
   179             fprintf(LOG_CHANNEL, "    %s\n", acceleration_mask[n].name);
   199             SDL_DFB_LOG( "    %s\n", acceleration_mask[n].name);
   180     }
   200     }
   181 
   201 
   182 
   202 
       
   203 }
       
   204 
       
   205 static int readBoolEnv(const char *env_name, int def_val)
       
   206 {
       
   207     char *stemp;
       
   208 
       
   209     stemp = SDL_getenv(env_name);
       
   210     if (stemp)
       
   211         return atoi(stemp);
       
   212     else
       
   213         return def_val;
   183 }
   214 }
   184 
   215 
   185 static int
   216 static int
   186 DirectFB_VideoInit(_THIS)
   217 DirectFB_VideoInit(_THIS)
   187 {
   218 {
   188     IDirectFB *dfb = NULL;
   219     IDirectFB *dfb = NULL;
   189     DFB_DeviceData *devdata = NULL;
   220     DFB_DeviceData *devdata = NULL;
   190     char *stemp;
       
   191     DFBResult ret;
   221     DFBResult ret;
   192 
   222 
   193     SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata));
   223     SDL_DFB_ALLOC_CLEAR(devdata, sizeof(*devdata));
   194 
   224 
   195     SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL));
   225     SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL));
   196 
   226 
   197     /* avoid switching to the framebuffer when we
   227     /* avoid switching to the framebuffer when we
   198      * are running X11 */
   228      * are running X11 */
   199     stemp = SDL_getenv(DFBENV_USE_X11_CHECK);
   229     ret = readBoolEnv(DFBENV_USE_X11_CHECK , 1);
   200     if (stemp)
       
   201         ret = atoi(stemp);
       
   202     else
       
   203         ret = 1;
       
   204 
       
   205     if (ret) {
   230     if (ret) {
   206         if (SDL_getenv("DISPLAY"))
   231         if (SDL_getenv("DISPLAY"))
   207             DirectFBSetOption("system", "x11");
   232             DirectFBSetOption("system", "x11");
   208         else
   233         else
   209             DirectFBSetOption("disable-module", "x11input");
   234             DirectFBSetOption("disable-module", "x11input");
   210     }
   235     }
   211 
   236 
   212 	/* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */
   237 	/* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */
   213 	devdata->use_linux_input = 0;       /* default: on */
   238 	devdata->use_linux_input = readBoolEnv(DFBENV_USE_LINUX_INPUT, 0);       /* default: on */
   214     stemp = SDL_getenv(DFBENV_USE_LINUX_INPUT);
       
   215     if (stemp)
       
   216         devdata->use_linux_input = atoi(stemp);
       
   217 
   239 
   218     if (!devdata->use_linux_input)
   240     if (!devdata->use_linux_input)
       
   241     {
       
   242 		SDL_DFB_LOG("Disabling linxu input\n");    
   219         DirectFBSetOption("disable-module", "linux_input");
   243         DirectFBSetOption("disable-module", "linux_input");
   220 
   244     }
       
   245     
   221     SDL_DFB_CHECKERR(DirectFBCreate(&dfb));
   246     SDL_DFB_CHECKERR(DirectFBCreate(&dfb));
   222 
   247 
   223     DirectFB_DeviceInformation(dfb);
   248     DirectFB_DeviceInformation(dfb);
   224     devdata->use_yuv_underlays = 0;     /* default: off */
   249     
   225     stemp = SDL_getenv(DFBENV_USE_YUV_UNDERLAY);
   250     devdata->use_yuv_underlays = readBoolEnv(DFBENV_USE_YUV_UNDERLAY, 0);     /* default: off */
   226     if (stemp)
   251     devdata->use_yuv_direct = readBoolEnv(DFBENV_USE_YUV_DIRECT, 0);      /* default is off! */
   227         devdata->use_yuv_underlays = atoi(stemp);
       
   228 
       
   229 
   252 
   230     /* Create global Eventbuffer for axis events */
   253     /* Create global Eventbuffer for axis events */
   231     if (devdata->use_linux_input) {
   254     if (devdata->use_linux_input) {
   232         SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_ALL,
   255         SDL_DFB_CHECKERR(dfb->CreateInputEventBuffer(dfb, DICAPS_ALL,
   233                                                      DFB_TRUE,
   256                                                      DFB_TRUE,
   237                                                      /*DICAPS_ALL */ ,
   260                                                      /*DICAPS_ALL */ ,
   238                                                      DFB_TRUE,
   261                                                      DFB_TRUE,
   239                                                      &devdata->events));
   262                                                      &devdata->events));
   240     }
   263     }
   241 
   264 
       
   265     /* simple window manager support */
       
   266     devdata->has_own_wm = readBoolEnv(DFBENV_USE_WM, 0);
       
   267 
   242     devdata->initialized = 1;
   268     devdata->initialized = 1;
   243 
       
   244     /* simple window manager support */
       
   245     stemp = SDL_getenv(DFBENV_USE_WM);
       
   246     if (stemp)
       
   247         devdata->has_own_wm = atoi(stemp);
       
   248     else
       
   249         devdata->has_own_wm = 0;
       
   250 
   269 
   251     devdata->dfb = dfb;
   270     devdata->dfb = dfb;
   252     devdata->firstwin = NULL;
   271     devdata->firstwin = NULL;
   253     devdata->grabbed_window = NULL;
   272     devdata->grabbed_window = NULL;
   254 
   273 
   258 
   277 
   259 #if SDL_DIRECTFB_OPENGL
   278 #if SDL_DIRECTFB_OPENGL
   260     DirectFB_GL_Initialize(_this);
   279     DirectFB_GL_Initialize(_this);
   261 #endif
   280 #endif
   262 
   281 
   263     DirectFB_AddRenderDriver(_this);
       
   264     DirectFB_InitMouse(_this);
   282     DirectFB_InitMouse(_this);
   265     DirectFB_InitKeyboard(_this);
   283     DirectFB_InitKeyboard(_this);
   266 
   284 
   267     return 0;
   285     return 0;
   268 
   286 
   280 
   298 
   281     DirectFB_QuitModes(_this);
   299     DirectFB_QuitModes(_this);
   282     DirectFB_QuitKeyboard(_this);
   300     DirectFB_QuitKeyboard(_this);
   283     DirectFB_QuitMouse(_this);
   301     DirectFB_QuitMouse(_this);
   284 
   302 
       
   303     devdata->events->Reset(devdata->events);
   285     SDL_DFB_RELEASE(devdata->events);
   304     SDL_DFB_RELEASE(devdata->events);
   286     SDL_DFB_RELEASE(devdata->dfb);
   305     SDL_DFB_RELEASE(devdata->dfb);
   287 
   306 
   288 #if SDL_DIRECTFB_OPENGL
   307 #if SDL_DIRECTFB_OPENGL
   289     DirectFB_GL_Shutdown(_this);
   308     DirectFB_GL_Shutdown(_this);
   290 #endif
   309 #endif
   291 
   310 
   292     devdata->initialized = 0;
   311     devdata->initialized = 0;
   293 }
   312 }
       
   313 
       
   314 /* DirectFB driver general support functions */
       
   315 
       
   316 static const struct {
       
   317     DFBSurfacePixelFormat dfb;
       
   318     Uint32 sdl;
       
   319 } pixelformat_tab[] = 
       
   320 {
       
   321     { DSPF_RGB32, SDL_PIXELFORMAT_RGB888 },             /* 24 bit RGB (4 byte, nothing@24, red 8@16, green 8@8, blue 8@0) */
       
   322     { DSPF_ARGB, SDL_PIXELFORMAT_ARGB8888 },            /* 32 bit ARGB (4 byte, alpha 8@24, red 8@16, green 8@8, blue 8@0) */
       
   323     { DSPF_RGB16, SDL_PIXELFORMAT_RGB565 },             /* 16 bit RGB (2 byte, red 5@11, green 6@5, blue 5@0) */
       
   324     { DSPF_RGB332, SDL_PIXELFORMAT_RGB332 },            /* 8 bit RGB (1 byte, red 3@5, green 3@2, blue 2@0) */
       
   325     { DSPF_ARGB4444, SDL_PIXELFORMAT_ARGB4444 },        /* 16 bit ARGB (2 byte, alpha 4@12, red 4@8, green 4@4, blue 4@0) */
       
   326     { DSPF_ARGB1555, SDL_PIXELFORMAT_ARGB1555 },        /* 16 bit ARGB (2 byte, alpha 1@15, red 5@10, green 5@5, blue 5@0) */
       
   327     { DSPF_RGB24, SDL_PIXELFORMAT_RGB24 },              /* 24 bit RGB (3 byte, red 8@16, green 8@8, blue 8@0) */
       
   328     { DSPF_RGB444, SDL_PIXELFORMAT_RGB444 },            /* 16 bit RGB (2 byte, nothing @12, red 4@8, green 4@4, blue 4@0) */
       
   329     { DSPF_YV12, SDL_PIXELFORMAT_YV12 },                /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size V/U planes) */
       
   330     { DSPF_I420,SDL_PIXELFORMAT_IYUV },                 /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size U/V planes) */
       
   331     { DSPF_YUY2, SDL_PIXELFORMAT_YUY2 },                /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */
       
   332     { DSPF_UYVY, SDL_PIXELFORMAT_UYVY },                /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */
       
   333     { DSPF_RGB555, SDL_PIXELFORMAT_RGB555 },            /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */
       
   334 #if (ENABLE_LUT8)
       
   335     { DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 },              /* 8 bit LUT (8 bit color and alpha lookup from palette) */
       
   336 #endif
       
   337 
       
   338 #if (DFB_VERSION_ATLEAST(1,2,0))
       
   339     { DSPF_BGR555, SDL_PIXELFORMAT_BGR555 },            /* 16 bit BGR (2 byte, nothing @15, blue 5@10, green 5@5, red 5@0) */
       
   340 #else
       
   341     { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR555 },
       
   342 #endif
       
   343 
       
   344     /* Pfff ... nonmatching formats follow */    
       
   345     
       
   346     { DSPF_ALUT44, SDL_PIXELFORMAT_UNKNOWN },           /* 8 bit ALUT (1 byte, alpha 4@4, color lookup 4@0) */
       
   347  	{ DSPF_A8, SDL_PIXELFORMAT_UNKNOWN },               /* 	8 bit alpha (1 byte, alpha 8@0), e.g. anti-aliased glyphs */
       
   348  	{ DSPF_AiRGB, SDL_PIXELFORMAT_UNKNOWN },            /* 	32 bit ARGB (4 byte, inv. alpha 8@24, red 8@16, green 8@8, blue 8@0) */
       
   349  	{ DSPF_A1, SDL_PIXELFORMAT_UNKNOWN },               /* 	1 bit alpha (1 byte/ 8 pixel, most significant bit used first) */
       
   350  	{ DSPF_NV12, SDL_PIXELFORMAT_UNKNOWN },             /* 	12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CbCr [15:0] plane) */
       
   351  	{ DSPF_NV16, SDL_PIXELFORMAT_UNKNOWN },             /* 	16 bit YUV (8 bit Y plane followed by one 16 bit half width CbCr [15:0] plane) */
       
   352  	{ DSPF_ARGB2554, SDL_PIXELFORMAT_UNKNOWN },         /* 	16 bit ARGB (2 byte, alpha 2@14, red 5@9, green 5@4, blue 4@0) */
       
   353  	{ DSPF_NV21, SDL_PIXELFORMAT_UNKNOWN },             /* 	12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CrCb [15:0] plane) */
       
   354  	{ DSPF_AYUV, SDL_PIXELFORMAT_UNKNOWN },             /* 	32 bit AYUV (4 byte, alpha 8@24, Y 8@16, Cb 8@8, Cr 8@0) */
       
   355  	{ DSPF_A4, SDL_PIXELFORMAT_UNKNOWN },               /* 	4 bit alpha (1 byte/ 2 pixel, more significant nibble used first) */
       
   356  	{ DSPF_ARGB1666, SDL_PIXELFORMAT_UNKNOWN },         /* 	1 bit alpha (3 byte/ alpha 1@18, red 6@16, green 6@6, blue 6@0) */
       
   357  	{ DSPF_ARGB6666, SDL_PIXELFORMAT_UNKNOWN },         /* 	6 bit alpha (3 byte/ alpha 6@18, red 6@16, green 6@6, blue 6@0) */
       
   358  	{ DSPF_RGB18, SDL_PIXELFORMAT_UNKNOWN },            /* 	6 bit RGB (3 byte/ red 6@16, green 6@6, blue 6@0) */
       
   359  	{ DSPF_LUT2, SDL_PIXELFORMAT_UNKNOWN },             /* 	2 bit LUT (1 byte/ 4 pixel, 2 bit color and alpha lookup from palette) */
       
   360 
       
   361 #if (DFB_VERSION_ATLEAST(1,3,0))
       
   362  	{ DSPF_RGBA4444, SDL_PIXELFORMAT_UNKNOWN },         /* 16 bit RGBA (2 byte, red 4@12, green 4@8, blue 4@4, alpha 4@0) */
       
   363 #endif
       
   364 
       
   365 #if (DFB_VERSION_ATLEAST(1,4,3))
       
   366  	{ DSPF_RGBA5551, SDL_PIXELFORMAT_UNKNOWN },         /* 	16 bit RGBA (2 byte, red 5@11, green 5@6, blue 5@1, alpha 1@0) */
       
   367  	{ 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) */
       
   368  	{ DSPF_ARGB8565, SDL_PIXELFORMAT_UNKNOWN },         /* 	24 bit ARGB (3 byte, alpha 8@16, red 5@11, green 6@5, blue 5@0) */
       
   369  	{ 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) */
       
   370  	{ DSPF_VYU, SDL_PIXELFORMAT_UNKNOWN },              /* 	24 bit VYU 4:4:4 (3 byte, Cr 8@16, Y 8@8, Cb 8@0)  */
       
   371 #endif
       
   372  	
       
   373     { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB },
       
   374     { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1MSB },
       
   375     { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4LSB }, 
       
   376     { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4MSB },
       
   377     { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR24 },
       
   378     { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR888 },
       
   379     { DSPF_UNKNOWN, SDL_PIXELFORMAT_RGBA8888 },
       
   380     { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR8888 },
       
   381     { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGRA8888 },
       
   382     { DSPF_UNKNOWN, SDL_PIXELFORMAT_ARGB2101010 },
       
   383     { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR4444 },
       
   384     { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR1555 },
       
   385     { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR565 },
       
   386     { DSPF_UNKNOWN, SDL_PIXELFORMAT_YVYU },                        /**< Packed mode: Y0+V0+Y1+U0 (1 pla	*/
       
   387 };
       
   388 
       
   389 Uint32
       
   390 DirectFB_DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat)
       
   391 {
       
   392     int i;
       
   393     
       
   394     for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
       
   395         if (pixelformat_tab[i].dfb == pixelformat)
       
   396         {
       
   397             return pixelformat_tab[i].sdl;
       
   398         }
       
   399     return SDL_PIXELFORMAT_UNKNOWN;
       
   400 }
       
   401 
       
   402 DFBSurfacePixelFormat
       
   403 DirectFB_SDLToDFBPixelFormat(Uint32 format)
       
   404 {
       
   405     int i;
       
   406     
       
   407     for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
       
   408         if (pixelformat_tab[i].sdl == format)
       
   409         {
       
   410             return pixelformat_tab[i].dfb;
       
   411         }
       
   412     return DSPF_UNKNOWN;
       
   413 }
       
   414 
       
   415 void DirectFB_SetSupportedPixelFormats(SDL_RendererInfo* ri)
       
   416 {
       
   417 	int i, j;
       
   418 
       
   419     for (i=0, j=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++)
       
   420     	if (pixelformat_tab[i].sdl != SDL_PIXELFORMAT_UNKNOWN)
       
   421     		ri->texture_formats[j++] = pixelformat_tab[i].sdl;
       
   422     ri->num_texture_formats = j;
       
   423 }