00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef MMSFBBASE_H_
00034 #define MMSFBBASE_H_
00035
00036 #include <cstring>
00037 #include <string.h>
00038 #include "mmstools/base.h"
00039 #include "mmstools/mmstypes.h"
00040 #include "mmstools/mmsmutex.h"
00041 #include "mmstools/mmstafffile.h"
00042
00043 #ifdef __HAVE_XLIB__
00044 #include <X11/Xlib.h>
00045 #include <X11/Xutil.h>
00046 #include <X11/extensions/XShm.h>
00047 #endif
00048
00049 #ifdef __HAVE_XV__
00050 #include <X11/extensions/Xv.h>
00051 #include <X11/extensions/Xvlib.h>
00052 #include <X11/extensions/xf86vmode.h>
00053 #endif
00054
00055
00056 #ifdef __HAVE_DIRECTFB__
00057 extern "C" {
00058 #include <direct/debug.h>
00059 #include <direct/trace.h>
00060
00061 #include <directfb.h>
00062 #include <directfb_keynames.h>
00063 #include <directfb_strings.h>
00064 #include <directfb_util.h>
00065 }
00066 #endif
00067
00068 #ifdef MMSFB_TRACE_ENABLE
00069 #define MMSFB_TRACE() direct_trace_print_stack(NULL)
00070 #else
00071 #define MMSFB_TRACE() do {} while (0)
00072 #endif
00073
00074 #ifdef MMSFB_BREAK_ENABLE
00075 #define MMSFB_BREAK() D_BREAK("bad function")
00076 #else
00077 #define MMSFB_BREAK() do {} while (0)
00078 #endif
00079
00080
00081
00082
00083
00084 #define USE_MMSFB_WINMAN
00085
00086
00087 extern string MMSFB_LastErrorString;
00088
00089
00090 extern bool MMSFBBase_rotate180;
00091
00092
00093
00094
00095 typedef unsigned int MMSFBBlittingFlags;
00096
00097
00098 #define MMSFB_BLIT_CNT 0x40
00099
00100
00101 #define MMSFB_BLIT_NOFX 0x00000000
00102
00103 #define MMSFB_BLIT_BLEND_ALPHACHANNEL 0x00000001
00104
00105 #define MMSFB_BLIT_BLEND_COLORALPHA 0x00000002
00106
00107 #define MMSFB_BLIT_COLORIZE 0x00000004
00108
00109 #define MMSFB_BLIT_SRC_PREMULTIPLY 0x00000008
00110
00111 #define MMSFB_BLIT_SRC_PREMULTCOLOR 0x00000010
00112
00113 #define MMSFB_BLIT_ANTIALIASING 0x00000020
00114
00115
00116 typedef unsigned int MMSFBDrawingFlags;
00117
00118
00119 #define MMSFB_DRAW_CNT 0x04
00120
00121
00122 #define MMSFB_DRAW_NOFX 0x00000000
00123
00124 #define MMSFB_DRAW_BLEND 0x00000001
00125
00126 #define MMSFB_DRAW_SRC_PREMULTIPLY 0x00000002
00127
00128
00129
00130 typedef unsigned int MMSFBFlipFlags;
00131
00132
00133 #define MMSFB_FLIP_NONE 0x00000000
00134
00135 #define MMSFB_FLIP_WAIT 0x00000001
00136
00137 #define MMSFB_FLIP_ONSYNC 0x00000002
00138
00139 #define MMSFB_FLIP_WAITFORSYNC 0x00000004
00140
00141 #define MMSFB_FLIP_FLUSH 0x00000008
00142
00143
00144
00145 typedef unsigned int MMSFBLockFlags;
00146
00147
00148 #define MMSFB_LOCK_NONE 0x00000000
00149
00150 #define MMSFB_LOCK_READ 0x00000001
00151
00152 #define MMSFB_LOCK_WRITE 0x00000002
00153
00154
00155
00156 typedef enum {
00157
00158 MMSFB_MM_ANAGLYPH_RED_CYAN = 0,
00159
00160 MMSFB_MM_LINE_INTERLEAVED
00161 } MMSFBMergingMode;
00162
00163
00164
00165
00166
00167 #define MMSFB_BM_NONE ""
00168
00169 #define MMSFB_BM_FRONTONLY "FRONTONLY"
00170
00171 #define MMSFB_BM_BACKVIDEO "BACKVIDEO"
00172
00173 #define MMSFB_BM_BACKSYSTEM "BACKSYSTEM"
00174
00175 #define MMSFB_BM_TRIPLE "TRIPLE"
00176
00177 #define MMSFB_BM_WINDOWS "WINDOWS"
00178
00179
00180
00181 #define MMSFB_LO_NONE ""
00182
00183 #define MMSFB_LO_ALPHACHANNEL "ALPHACHANNEL"
00184
00185 #define MMSFB_LO_FLICKER_FILTERING "FLICKER_FILTERING"
00186
00187 #define MMSFB_LO_DEINTERLACING "DEINTERLACING"
00188
00189 #define MMSFB_LO_SRC_COLORKEY "SRC_COLORKEY"
00190
00191 #define MMSFB_LO_DST_COLORKEY "DST_COLORKEY"
00192
00193 #define MMSFB_LO_OPACITY "OPACITY"
00194
00195 #define MMSFB_LO_FIELD_PARITY "FIELD_PARITY"
00196
00197
00198
00199 string MMSFB_ErrorString(const int rc, const string msg);
00200 void MMSFB_SetError(const int rc, const string msg);
00201
00202 typedef struct {
00203 int bits;
00204 int red_length;
00205 int red_offset;
00206 int green_length;
00207 int green_offset;
00208 int blue_length;
00209 int blue_offset;
00210 int transp_length;
00211 int transp_offset;
00212 } MMSFBPixelDef;
00213
00214
00215 bool isAlphaPixelFormat(MMSFBSurfacePixelFormat pf);
00216 bool isIndexedPixelFormat(MMSFBSurfacePixelFormat pf);
00217 bool isRGBPixelFormat(MMSFBSurfacePixelFormat pf);
00218 void getBitsPerPixel(MMSFBSurfacePixelFormat pf, MMSFBPixelDef *pixeldef);
00219
00220 #ifdef __HAVE_DIRECTFB__
00221
00222
00223
00224 MMSFBSurfacePixelFormat getMMSFBPixelFormatFromDFBPixelFormat(DFBSurfacePixelFormat pf);
00225 DFBSurfacePixelFormat getDFBPixelFormatFromMMSFBPixelFormat(MMSFBSurfacePixelFormat pf);
00226
00227
00228 string getDFBLayerBufferModeString(DFBDisplayLayerBufferMode bm);
00229 DFBDisplayLayerBufferMode getDFBLayerBufferModeFromString(string bm);
00230
00231
00232 string getDFBLayerOptionsString(DFBDisplayLayerOptions opts);
00233 DFBDisplayLayerOptions getDFBLayerOptionsFromString(string opts);
00234
00235
00236 DFBSurfaceBlittingFlags getDFBSurfaceBlittingFlagsFromMMSFBBlittingFlags(MMSFBBlittingFlags flags);
00237 DFBSurfaceDrawingFlags getDFBSurfaceDrawingFlagsFromMMSFBDrawingFlags(MMSFBDrawingFlags flags);
00238 DFBSurfaceFlipFlags getDFBSurfaceFlipFlagsFromMMSFBFlipFlags(MMSFBFlipFlags flags);
00239 DFBSurfaceLockFlags getDFBSurfaceLockFlagsFromMMSFBLockFlags(MMSFBLockFlags flags);
00240 #endif
00241
00242 void calcAspectRatio(int sw, int sh, int dw, int dh, MMSFBRectangle &dest, bool aspect_ratio, bool even_aligned);
00243
00244
00245
00246
00247 #ifdef __ENABLE_ACTMON__
00248
00249 #define MMSFBPERF_START_MEASURING { \
00250 struct timeval perf_stime; \
00251 if (mmsperf) mmsperf->startMeasuring(&perf_stime);
00252
00253 #define MMSFBPERF_STOP_MEASURING_FILLRECT(surface, dw, dh) \
00254 if (mmsperf) mmsperf->stopMeasuringFillRectangle( \
00255 &perf_stime, surface, dw, dh); }
00256
00257 #define MMSFBPERF_STOP_MEASURING_DRAWLINE(surface, x1, y1, x2, y2) { \
00258 int w=x2-x1;if(w<0)w=-w;w++; \
00259 int h=y2-y1;if(h<0)h=-h;h++; \
00260 if (mmsperf) mmsperf->stopMeasuringDrawLine( \
00261 &perf_stime, surface, (w>=h)?w:h); }}
00262
00263 #define MMSFBPERF_STOP_MEASURING_DRAWSTRING(surface, clipreg, text, len, x, y) { \
00264 int w, h; \
00265 surface->config.font->getStringWidth(text, len, &w); \
00266 surface->config.font->getHeight(&h); \
00267 MMSFBRegion myreg = clipreg; \
00268 if (x+w-1 < myreg.x2) myreg.x2 = x+w-1; \
00269 if (y+h-1 < myreg.y2) myreg.y2 = y+h-1; \
00270 if (x > myreg.x1) myreg.x1 = x; \
00271 if (y > myreg.y1) myreg.y1 = y; \
00272 if ((myreg.x1 <= myreg.x2) && (myreg.y1 <= myreg.y2)) \
00273 if (mmsperf) mmsperf->stopMeasuringDrawString( \
00274 &perf_stime, surface, myreg.x2 - myreg.x1 + 1, myreg.y2 - myreg.y1 + 1); }}
00275
00276 #define MMSFBPERF_STOP_MEASURING_BLIT(surface, src_pixelformat, sw, sh) \
00277 if (mmsperf) mmsperf->stopMeasuringBlit( \
00278 &perf_stime, surface, src_pixelformat, sw, sh); }
00279
00280 #define MMSFBPERF_STOP_MEASURING_STRETCHBLIT(surface, source, sw, sh, dw, dh) \
00281 if (mmsperf) mmsperf->stopMeasuringStretchBlit( \
00282 &perf_stime, surface, src_pixelformat, sw, sh, dw, dh); }
00283
00284 #define MMSFBPERF_STOP_MEASURING_XSHMPUTIMAGE(surface, sw, sh) \
00285 if (mmsperf) mmsperf->stopMeasuringXShmPutImage( \
00286 &perf_stime, surface, sw, sh); }
00287
00288 #define MMSFBPERF_STOP_MEASURING_XVSHMPUTIMAGE(surface, sw, sh, dw, dh) \
00289 if (mmsperf) mmsperf->stopMeasuringXvShmPutImage( \
00290 &perf_stime, surface, sw, sh, dw, dh); }
00291
00292 #define MMSFBPERF_STOP_MEASURING_VSYNC(surface) \
00293 if (mmsperf) mmsperf->stopMeasuringVSync( \
00294 &perf_stime, surface); }
00295
00296 #define MMSFBPERF_STOP_MEASURING_SWAPDISPLAY(surface) \
00297 if (mmsperf) mmsperf->stopMeasuringSwapDisplay( \
00298 &perf_stime, surface); }
00299
00300 #else
00301
00302 #define MMSFBPERF_START_MEASURING
00303 #define MMSFBPERF_STOP_MEASURING_FILLRECT(surface, dw, dh)
00304 #define MMSFBPERF_STOP_MEASURING_DRAWLINE(surface, x1, y1, x2, y2)
00305 #define MMSFBPERF_STOP_MEASURING_DRAWSTRING(surface, clipreg, text, len, x, y)
00306 #define MMSFBPERF_STOP_MEASURING_BLIT(surface, src_pixelformat, sw, sh)
00307 #define MMSFBPERF_STOP_MEASURING_STRETCHBLIT(surface, source, sw, sh, dw, dh)
00308 #define MMSFBPERF_STOP_MEASURING_XSHMPUTIMAGE(surface, sw, sh)
00309 #define MMSFBPERF_STOP_MEASURING_XVSHMPUTIMAGE(surface, sw, sh, dw, dh)
00310 #define MMSFBPERF_STOP_MEASURING_VSYNC(surface)
00311 #define MMSFBPERF_STOP_MEASURING_SWAPDISPLAY(surface)
00312
00313 #endif
00314
00315
00316
00317 #endif