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 MMSPERF_H_
00034 #define MMSPERF_H_
00035
00036 #include "mmstools/mmsthread.h"
00037 #include "mmsgui/fb/mmsfbsurface.h"
00038
00039 #if MMSFB_BLIT_CNT > MMSFB_DRAW_CNT
00040 #define MMSFBPERF_MAXFLAGS MMSFB_BLIT_CNT
00041 #else
00042 #define MMSFBPERF_MAXFLAGS MMSFB_DRAW_CNT
00043 #endif
00044
00045 typedef struct {
00046 unsigned int calls;
00047 unsigned int mpixels;
00048 unsigned int rpixels;
00049 unsigned int usecs;
00050 unsigned int mpps;
00051 } MMSFBPERF_MEASURING_VALS;
00052
00053 typedef MMSFBPERF_MEASURING_VALS MMSFBPERF_MEASURING_LIST[2][MMSFB_PF_CNT][MMSFB_PF_CNT][MMSFBPERF_MAXFLAGS];
00054
00055
00056 #define MMSFBPERF_MAXVKEYS 1024
00057
00058 typedef struct {
00059 unsigned int calls;
00060 unsigned int usecs;
00061 } MMSFBPERF_MEASURING_VALS_VKEY;
00062
00063 typedef MMSFBPERF_MEASURING_VALS_VKEY MMSFBPERF_MEASURING_LIST_VKEY[MMSFBPERF_MAXVKEYS];
00064
00065
00066 class MMSPerf {
00067 private:
00068
00069
00070 static bool initialized;
00071
00072
00073 static MMSMutex lockme;
00074
00075
00076 static struct timeval start_time;
00077
00078
00079 static MMSFBPERF_MEASURING_LIST fillrect;
00080
00081
00082 static MMSFBPERF_MEASURING_LIST drawline;
00083
00084
00085 static MMSFBPERF_MEASURING_LIST drawstring;
00086
00087
00088 static MMSFBPERF_MEASURING_LIST blit;
00089
00090
00091 static MMSFBPERF_MEASURING_LIST stretchblit;
00092
00093
00094 static MMSFBPERF_MEASURING_LIST xshmputimage;
00095
00096
00097 static MMSFBPERF_MEASURING_LIST xvshmputimage;
00098
00099
00100 static MMSFBPERF_MEASURING_LIST vsync;
00101
00102
00103 static MMSFBPERF_MEASURING_LIST swapdisplay;
00104
00105
00106
00107 static MMSFBPERF_MEASURING_LIST_VKEY vkey;
00108
00109
00110 void lock();
00111 void unlock();
00112
00113
00114 void reset();
00115
00116 unsigned int getDuration();
00117
00118 void addMeasuringVals(MMSFBPERF_MEASURING_VALS *summary, MMSFBPERF_MEASURING_VALS *add_sum);
00119
00120 void addMeasuringVals(MMSFBPERF_MEASURING_VALS_VKEY *summary, MMSFBPERF_MEASURING_VALS_VKEY *add_sum);
00121
00122 int getPerfVals(MMSFBPERF_MEASURING_LIST *mlist, const char *prefix, char *retbuf, int retbuf_size,
00123 MMSFBPERF_MEASURING_VALS *summary);
00124
00125 int getPerfVals(MMSFBPERF_MEASURING_LIST_VKEY *mlist, char *retbuf, int retbuf_size,
00126 MMSFBPERF_MEASURING_VALS_VKEY *summary);
00127
00128 void stopMeasuring(struct timeval *perf_stime, MMSFBPERF_MEASURING_VALS *mvals,
00129 int sw = 0, int sh = 0, int dw = 0, int dh = 0);
00130
00131 void stopMeasuring(struct timeval *perf_stime, MMSFBPERF_MEASURING_VALS_VKEY *mvals);
00132
00133 public:
00134 MMSPerf();
00135 ~MMSPerf();
00136
00137 void startMeasuring(struct timeval *perf_stime);
00138
00139 void stopMeasuringFillRectangle(struct timeval *perf_stime,
00140 MMSFBSurface *surface, int w, int h);
00141
00142 void stopMeasuringDrawLine(struct timeval *perf_stime,
00143 MMSFBSurface *surface, int pixels);
00144
00145 void stopMeasuringDrawString(struct timeval *perf_stime,
00146 MMSFBSurface *surface, int w, int h);
00147
00148 void stopMeasuringBlit(struct timeval *perf_stime,
00149 MMSFBSurface *surface,
00150 MMSFBSurfacePixelFormat src_pixelformat,
00151 int sw, int sh);
00152
00153 void stopMeasuringStretchBlit(struct timeval *perf_stime,
00154 MMSFBSurface *surface,
00155 MMSFBSurfacePixelFormat src_pixelformat,
00156 int sw, int sh, int dw, int dh);
00157
00158 void stopMeasuringXShmPutImage(struct timeval *perf_stime,
00159 MMSFBSurface *surface,
00160 int sw, int sh);
00161
00162 void stopMeasuringXvShmPutImage(struct timeval *perf_stime,
00163 MMSFBSurface *surface,
00164 int sw, int sh, int dw, int dh);
00165
00166 void stopMeasuringVSync(struct timeval *perf_stime,
00167 MMSFBSurface *surface);
00168
00169 void stopMeasuringSwapDisplay(struct timeval *perf_stime,
00170 MMSFBSurface *surface);
00171
00172 friend class MMSPerfInterface;
00173 };
00174
00175 #endif