src/video/directfb/SDL_DirectFB_video.h
author Couriersud
Tue, 13 Jan 2009 21:17:38 +0000
changeset 3037 490f3e4fe753
parent 3023 d72a0dd80e8b
child 3038 c73a5f8a03d2
permissions -rw-r--r--
Added DFB_VERSION_ATLEAST macro
First attempt at replacing MakeSubSurface for pre 1.2.0 ==> Scaling not yet working
slouken@167
     1
/*
slouken@167
     2
    SDL - Simple DirectMedia Layer
slouken@2859
     3
    Copyright (C) 1997-2009 Sam Lantinga
slouken@167
     4
slouken@167
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@167
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@167
     9
slouken@167
    10
    This library is distributed in the hope that it will be useful,
slouken@167
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@167
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@167
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@167
    18
slouken@167
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@167
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@167
    23
slouken@167
    24
#ifndef _SDL_DirectFB_video_h
slouken@167
    25
#define _SDL_DirectFB_video_h
slouken@167
    26
slouken@2737
    27
#include "../SDL_sysvideo.h"
slouken@2737
    28
slouken@167
    29
#include <directfb.h>
slouken@2226
    30
#include <directfb_version.h>
slouken@2226
    31
slouken@2737
    32
#include "SDL_mouse.h"
slouken@2737
    33
slouken@2737
    34
#define DEBUG 0
slouken@2226
    35
#define LOG_CHANNEL 	stdout
slouken@2226
    36
couriersud@3037
    37
#define DFB_VERSIONNUM(X, Y, Z)						\
couriersud@3037
    38
	((X)*1000 + (Y)*100 + (Z))
couriersud@3037
    39
couriersud@3037
    40
#define DFB_COMPILEDVERSION \
couriersud@3037
    41
	DFB_VERSIONNUM(DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION, DIRECTFB_MICRO_VERSION)
slouken@2226
    42
couriersud@3037
    43
#define DFB_VERSION_ATLEAST(X, Y, Z) \
couriersud@3037
    44
	(DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z))
couriersud@3037
    45
couriersud@3037
    46
#if (DFB_VERSION_ATLEAST(1,0,0))
couriersud@3037
    47
	#define SDL_DIRECTFB_OPENGL 1
couriersud@3037
    48
	#include <directfbgl.h>
couriersud@3037
    49
#else
couriersud@3037
    50
	#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
slouken@2226
    51
#endif
slouken@2226
    52
slouken@2226
    53
#if SDL_DIRECTFB_OPENGL
slouken@2226
    54
#include "SDL_loadso.h"
slouken@2226
    55
#endif
slouken@167
    56
slouken@2737
    57
#include "SDL_DirectFB_events.h"
slouken@2737
    58
/*
slouken@2737
    59
 * #include "SDL_DirectFB_gamma.h"
slouken@2737
    60
 * #include "SDL_DirectFB_keyboard.h"
slouken@2737
    61
 */
slouken@2737
    62
#include "SDL_DirectFB_modes.h"
slouken@2737
    63
#include "SDL_DirectFB_mouse.h"
slouken@2737
    64
#include "SDL_DirectFB_opengl.h"
slouken@2737
    65
#include "SDL_DirectFB_window.h"
couriersud@3023
    66
#include "SDL_DirectFB_WM.h"
slouken@167
    67
slouken@2998
    68
#define DFBENV_USE_YUV_UNDERLAY 	"SDL_DIRECTFB_YUV_UNDERLAY"     /* Default: off */
slouken@2998
    69
#define DFBENV_USE_YUV_DIRECT   	"SDL_DIRECTFB_YUV_DIRECT"       /* Default: off */
slouken@2998
    70
#define DFBENV_USE_X11_CHECK		"SDL_DIRECTFB_X11_CHECK"        /* Default: on  */
slouken@2998
    71
#define DFBENV_USE_LINUX_INPUT		"SDL_DIRECTFB_LINUX_INPUT"      /* Default: on  */
couriersud@3023
    72
#define DFBENV_USE_WM				"SDL_DIRECTFB_WM"		      	/* Default: off  */
slouken@2226
    73
slouken@2226
    74
#define SDL_DFB_RELEASE(x) do { if ( x ) { x->Release(x); x = NULL; } } while (0)
slouken@2226
    75
#define SDL_DFB_FREE(x) do { if ( x ) { SDL_free(x); x = NULL; } } while (0)
slouken@2226
    76
#define SDL_DFB_UNLOCK(x) do { if ( x ) { x->Unlock(x); } } while (0)
slouken@2226
    77
slouken@2226
    78
#if DEBUG
slouken@2226
    79
#define SDL_DFB_DEBUG(x...) do { fprintf(LOG_CHANNEL, "%s:", __FUNCTION__); fprintf(LOG_CHANNEL, x); } while (0)
slouken@2226
    80
#define SDL_DFB_DEBUGC(x...) do { fprintf(LOG_CHANNEL, x); } while (0)
slouken@2226
    81
#else
slouken@2226
    82
#define SDL_DFB_DEBUG(x...) do { } while (0)
slouken@2226
    83
#define SDL_DFB_DEBUGC(x...) do { } while (0)
slouken@2226
    84
#endif
slouken@2226
    85
slouken@2226
    86
#define SDL_DFB_CONTEXT "SDL_DirectFB"
slouken@2226
    87
slouken@2226
    88
#define SDL_DFB_ERR(x...) 							\
slouken@2226
    89
	do {											\
slouken@2226
    90
		fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t",			\
slouken@2226
    91
			SDL_DFB_CONTEXT, __FILE__, __LINE__ );	\
slouken@2226
    92
		fprintf(LOG_CHANNEL, x );						\
slouken@2226
    93
	} while (0)
slouken@2226
    94
slouken@2226
    95
#define SDL_DFB_CHECK(x...) \
slouken@2226
    96
     do {                                                                \
slouken@2226
    97
          ret = x;                                                    \
slouken@2226
    98
          if (ret != DFB_OK) {                                        \
slouken@2226
    99
               fprintf(LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); 	      \
couriersud@3023
   100
               fprintf(LOG_CHANNEL, "\t%s\n", #x ); \
couriersud@3023
   101
               fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); \
slouken@2226
   102
               SDL_SetError( #x, DirectFBErrorString (ret) );         \
slouken@2226
   103
          }                                                           \
slouken@2226
   104
     } while (0)
slouken@2226
   105
slouken@2226
   106
#define SDL_DFB_CHECKERR(x...) \
slouken@2226
   107
     do {                                                                \
slouken@2226
   108
          ret = x;                                                    \
slouken@2226
   109
          if (ret != DFB_OK) {                                        \
slouken@2226
   110
               fprintf(LOG_CHANNEL, "%s <%d>:\n", __FILE__, __LINE__ ); \
slouken@2226
   111
               fprintf(LOG_CHANNEL, "\t%s\n", #x ); \
slouken@2226
   112
               fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); \
slouken@2226
   113
               SDL_SetError( #x, DirectFBErrorString (ret) );         \
slouken@2226
   114
               goto error; 					      \
slouken@2226
   115
          }                                                           \
slouken@2226
   116
     } while (0)
slouken@2226
   117
slouken@2226
   118
#define SDL_DFB_CALLOC(r, n, s) \
slouken@2226
   119
     do {                                                                \
slouken@2226
   120
          r = SDL_calloc (n, s);                                      \
slouken@2226
   121
          if (!(r)) {                                                 \
slouken@2226
   122
               fprintf( LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
slouken@2226
   123
               SDL_OutOfMemory();                                     \
slouken@2226
   124
               goto error; 					      \
slouken@2226
   125
          }                                                           \
slouken@2226
   126
     } while (0)
slouken@167
   127
slouken@167
   128
/* Private display data */
slouken@167
   129
couriersud@3023
   130
#define SDL_DFB_DEVICEDATA(dev)  DFB_DeviceData *devdata = (dev ? (DFB_DeviceData *) ((dev)->driverdata) : NULL)
slouken@2226
   131
slouken@2226
   132
#define DFB_MAX_SCREENS 10
slouken@2226
   133
slouken@2226
   134
typedef struct _DFB_DeviceData DFB_DeviceData;
slouken@2226
   135
struct _DFB_DeviceData
slouken@167
   136
{
slouken@1895
   137
    int initialized;
slouken@167
   138
slouken@1895
   139
    IDirectFB *dfb;
slouken@2860
   140
    int num_mice;
slouken@2860
   141
    int mouse_id[0x100];
slouken@2860
   142
    int num_keyboard;
slouken@2860
   143
    struct
slouken@2860
   144
    {
slouken@2860
   145
        int is_generic;
slouken@2860
   146
        int id;
slouken@2860
   147
    } keyboard[10];
slouken@2226
   148
    DFB_WindowData *firstwin;
icculus@728
   149
slouken@2737
   150
    int use_yuv_underlays;
slouken@2998
   151
    int use_linux_input;
couriersud@3023
   152
    int has_own_wm;
slouken@2226
   153
slouken@2721
   154
    /* OpenGL */
slouken@2226
   155
    void (*glFinish) (void);
slouken@2226
   156
    void (*glFlush) (void);
slouken@167
   157
slouken@2737
   158
    /* global events */
slouken@2737
   159
    IDirectFBEventBuffer *events;
slouken@2226
   160
};
slouken@478
   161
slouken@167
   162
#endif /* _SDL_DirectFB_video_h */