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

mmsfbwindowmanagerthread.cpp

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 #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     //int   pointer_opacity = 0;
00048     //int   hidecnt = 1;
00049 
00050     while (1) {
00051 
00052         if (!this->flipQueue.empty()) {
00053             FLIP_STRUCT tmpFlipStruct;
00054             tmpFlipStruct = this->flipQueue.front();
00055             // drop all refresh cmds
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         // fade out the pointer
00070         mmsfbwindowmanager->fadePointer();
00071 
00072 
00073         if (!*(this->high_freq_surface)) {
00074             /* have no region */
00075             msleep(200);
00076             continue;
00077         }
00078 
00079         /* get the flip time */
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             /* already running */
00086             msleep(200);
00087             continue;
00088         }
00089 
00090         /* have a surface but it was not flipped fast enough */
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             /* copy saved surface because window works direct with layer */
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 

Generated by doxygen