Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsfbbase.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2013 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
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 // switch between window managers
00083 //#define USE_DFB_WINMAN
00084 #define USE_MMSFB_WINMAN
00085 
00086 // access to the last error text
00087 extern string MMSFB_LastErrorString;
00088 
00089 // screen should be rotated by 180°?
00090 extern bool MMSFBBase_rotate180;
00091 
00092 
00093 
00094 //! surface blitting flags
00095 typedef unsigned int MMSFBBlittingFlags;
00096 
00097 //! max combination of blitting flags
00098 #define MMSFB_BLIT_CNT                  0x40
00099 
00100 //! surface blitting flag: no effects
00101 #define MMSFB_BLIT_NOFX                 0x00000000
00102 //! surface blitting flag: use alphachannel from source
00103 #define MMSFB_BLIT_BLEND_ALPHACHANNEL   0x00000001
00104 //! surface blitting flag: use alphachannel from color
00105 #define MMSFB_BLIT_BLEND_COLORALPHA     0x00000002
00106 //! surface blitting flag: modulates source pixel with color
00107 #define MMSFB_BLIT_COLORIZE             0x00000004
00108 //! surface blitting flag: modulates the source color with the source alpha
00109 #define MMSFB_BLIT_SRC_PREMULTIPLY      0x00000008
00110 //! surface blitting flag: modulates the source color with the color alpha
00111 #define MMSFB_BLIT_SRC_PREMULTCOLOR     0x00000010
00112 //! surface blitting flag: antialiasing (stretchBlit(), not all pixelformats will be supported)
00113 #define MMSFB_BLIT_ANTIALIASING         0x00000020
00114 
00115 //! surface drawing flags
00116 typedef unsigned int MMSFBDrawingFlags;
00117 
00118 //! max combination of drawing flags
00119 #define MMSFB_DRAW_CNT                  0x04
00120 
00121 //! surface drawing flag: no effects
00122 #define MMSFB_DRAW_NOFX                 0x00000000
00123 //! surface drawing flag: alpha from surface color
00124 #define MMSFB_DRAW_BLEND                0x00000001
00125 //! surface drawing flag: multiplies the color with the alpha channel
00126 #define MMSFB_DRAW_SRC_PREMULTIPLY      0x00000002
00127 
00128 
00129 //! surface flip flags
00130 typedef unsigned int MMSFBFlipFlags;
00131 
00132 //! surface flip flag: none
00133 #define MMSFB_FLIP_NONE                 0x00000000
00134 //! surface flip flag: returns upon vertical sync
00135 #define MMSFB_FLIP_WAIT                 0x00000001
00136 //! surface flip flag: flip upon the next vertical sync
00137 #define MMSFB_FLIP_ONSYNC               0x00000002
00138 //! surface flip flag: WAIT and ONSYNC
00139 #define MMSFB_FLIP_WAITFORSYNC          0x00000004
00140 //! surface flip flag: send pan event to fbdev every time the display buffer has changed
00141 #define MMSFB_FLIP_FLUSH                0x00000008
00142 
00143 
00144 //! surface lock flags
00145 typedef unsigned int MMSFBLockFlags;
00146 
00147 //! surface lock flag: none
00148 #define MMSFB_LOCK_NONE             0x00000000
00149 //! surface lock flag: read access
00150 #define MMSFB_LOCK_READ             0x00000001
00151 //! surface lock flag: write access
00152 #define MMSFB_LOCK_WRITE                0x00000002
00153 
00154 
00155 //! surface merging mode
00156 typedef enum {
00157     //! surface merging mode: anaglyph red-cyan (red channel from first, green and blue channels from second source surface)
00158     MMSFB_MM_ANAGLYPH_RED_CYAN = 0,
00159     //! surface merging mode: line interleaved (even lines from first, odd lines from second source surface)
00160     MMSFB_MM_LINE_INTERLEAVED
00161 } MMSFBMergingMode;
00162 
00163 
00164 
00165 
00166 //! buffer mode: none
00167 #define MMSFB_BM_NONE       ""
00168 //! buffer mode: no backbuffer
00169 #define MMSFB_BM_FRONTONLY  "FRONTONLY"
00170 //! buffer mode: backbuffer in video memory
00171 #define MMSFB_BM_BACKVIDEO  "BACKVIDEO"
00172 //! buffer mode: backbuffer in system memory
00173 #define MMSFB_BM_BACKSYSTEM "BACKSYSTEM"
00174 //! buffer mode: triple buffering
00175 #define MMSFB_BM_TRIPLE     "TRIPLE"
00176 //! buffer mode: no layer buffers at all, using buffer of each window
00177 #define MMSFB_BM_WINDOWS    "WINDOWS"
00178 
00179 
00180 //! layer option: none
00181 #define MMSFB_LO_NONE               ""
00182 //! layer option: Make usage of alpha channel for blending on a pixel per pixel basis.
00183 #define MMSFB_LO_ALPHACHANNEL       "ALPHACHANNEL"
00184 //! layer option: Enable flicker filtering.
00185 #define MMSFB_LO_FLICKER_FILTERING  "FLICKER_FILTERING"
00186 //! layer option: Enable deinterlacing of an interlaced (video) source.
00187 #define MMSFB_LO_DEINTERLACING      "DEINTERLACING"
00188 //! layer option: Enable source color key.
00189 #define MMSFB_LO_SRC_COLORKEY       "SRC_COLORKEY"
00190 //! layer option: Enable dest. color key.
00191 #define MMSFB_LO_DST_COLORKEY       "DST_COLORKEY"
00192 //! layer option: Make usage of the global alpha factor set by SetOpacity.
00193 #define MMSFB_LO_OPACITY            "OPACITY"
00194 //! layer option: Set field parity.
00195 #define MMSFB_LO_FIELD_PARITY       "FIELD_PARITY"
00196 
00197 
00198 // error logging routines
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 // pixelformat helpers
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 // dfb specific routines
00222 
00223 // conversion routines for pixel formats
00224 MMSFBSurfacePixelFormat getMMSFBPixelFormatFromDFBPixelFormat(DFBSurfacePixelFormat pf);
00225 DFBSurfacePixelFormat getDFBPixelFormatFromMMSFBPixelFormat(MMSFBSurfacePixelFormat pf);
00226 
00227 // conversion routines for layer buffer modes
00228 string getDFBLayerBufferModeString(DFBDisplayLayerBufferMode bm);
00229 DFBDisplayLayerBufferMode getDFBLayerBufferModeFromString(string bm);
00230 
00231 // conversion routines for layer options
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 /*MMSFBBASE_H_*/

Generated by doxygen