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
00056 while (!this->flipQueue.empty()) {
00057 this->flipQueue.pop();
00058 }
00059
00060 lock->lock();
00061 mmsfbwindowmanager->flipSurface(tmpFlipStruct.surface, tmpFlipStruct.region,
00062 MMSFB_FLIP_NONE, tmpFlipStruct.refresh);
00063 lock->unlock();
00064
00065 msleep(100);
00066 continue;
00067 }
00068
00069
00070 mmsfbwindowmanager->fadePointer();
00071
00072
00073 if (!*(this->high_freq_surface)) {
00074
00075 msleep(200);
00076 continue;
00077 }
00078
00079
00080 struct timeval tv;
00081 gettimeofday(&tv, NULL);
00082 int newfliptime = (((int)tv.tv_sec)%1000000)*1000+((int)tv.tv_usec)/1000;
00083 int diff = newfliptime - *(this->high_freq_lastflip);
00084 if ((diff > 0)&&(diff < 1000)) {
00085
00086 msleep(200);
00087 continue;
00088 }
00089
00090
00091 lock->lock();
00092 if (!*(this->high_freq_surface)) {
00093 lock->unlock();
00094 continue;
00095 }
00096 if (*(this->high_freq_saved_surface)) {
00097 (*(this->high_freq_surface))->lock();
00098 (*(this->high_freq_saved_surface))->lock();
00099
00100 (*(this->high_freq_surface))->setBlittingFlags(MMSFB_BLIT_NOFX);
00101 (*(this->high_freq_surface))->blit(*(this->high_freq_saved_surface), NULL, 0, 0);
00102 (*(this->high_freq_saved_surface))->unlock();
00103 (*(this->high_freq_surface))->unlock();
00104 }
00105 DEBUGOUT("flipped not fast enough");
00106 mmsfbwindowmanager->flipSurface(*(this->high_freq_surface), NULL,
00107 MMSFB_FLIP_NONE, true);
00108 *(this->high_freq_surface) = NULL;
00109 *(this->high_freq_saved_surface) = NULL;
00110 *(this->high_freq_lastflip) = 0;
00111 lock->unlock();
00112 }
00113 }
00114