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 #include "mmsgui/fb/mmsfbwindowmanagerthread.h"
00034 #include "mmsgui/fb/mmsfbwindowmanager.h"
00035
00036 MMSFBWindowManagerThread::MMSFBWindowManagerThread(MMSFBSurface **high_freq_surface,
00037 MMSFBSurface **high_freq_saved_surface,
00038 int *high_freq_lastflip,
00039 MMSMutex *lock) {
00040 this->high_freq_surface = high_freq_surface;
00041 this->high_freq_saved_surface = high_freq_saved_surface;
00042 this->high_freq_lastflip = high_freq_lastflip;
00043 this->lock = lock;
00044 }
00045
00046 void MMSFBWindowManagerThread::threadMain() {
00047
00048
00049
00050 while (1) {
00051
00052 if (!this->flipQueue.empty()) {
00053 FLIP_STRUCT tmpFlipStruct;
00054 tmpFlipStruct = this->flipQueue.front();
00055 this->flipQueue.pop();
00056
00057 lock->lock();
00058 mmsfbwindowmanager->flipSurface(tmpFlipStruct.surface, tmpFlipStruct.region,
00059 MMSFB_FLIP_NONE, tmpFlipStruct.refresh);
00060 lock->unlock();
00061
00062 msleep(100);
00063 continue;
00064 }
00065
00066
00067 mmsfbwindowmanager->fadePointer();
00068
00069
00070 if (!*(this->high_freq_surface)) {
00071
00072 msleep(200);
00073 continue;
00074 }
00075
00076
00077 struct timeval tv;
00078 gettimeofday(&tv, NULL);
00079 int newfliptime = (((int)tv.tv_sec)%1000000)*1000+((int)tv.tv_usec)/1000;
00080 int diff = newfliptime - *(this->high_freq_lastflip);
00081 if ((diff > 0)&&(diff < 1000)) {
00082
00083 msleep(200);
00084 continue;
00085 }
00086
00087
00088 lock->lock();
00089 if (!*(this->high_freq_surface)) {
00090 lock->unlock();
00091 continue;
00092 }
00093 if (*(this->high_freq_saved_surface)) {
00094 (*(this->high_freq_surface))->lock();
00095 (*(this->high_freq_saved_surface))->lock();
00096
00097 (*(this->high_freq_surface))->setBlittingFlags(MMSFB_BLIT_NOFX);
00098 (*(this->high_freq_surface))->blit(*(this->high_freq_saved_surface), NULL, 0, 0);
00099 (*(this->high_freq_saved_surface))->unlock();
00100 (*(this->high_freq_surface))->unlock();
00101 }
00102 DEBUGOUT("flipped not fast enough");
00103 mmsfbwindowmanager->flipSurface(*(this->high_freq_surface), NULL,
00104 MMSFB_FLIP_NONE, true);
00105 *(this->high_freq_surface) = NULL;
00106 *(this->high_freq_saved_surface) = NULL;
00107 *(this->high_freq_lastflip) = 0;
00108 lock->unlock();
00109 }
00110 }
00111