src/gui/image/qpixmap_s60.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    61 QT_BEGIN_NAMESPACE
    61 QT_BEGIN_NAMESPACE
    62 
    62 
    63 const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
    63 const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
    64                                      0x10, 0x20, 0x40, 0x80 };
    64                                      0x10, 0x20, 0x40, 0x80 };
    65 
    65 
       
    66 static bool cleanup_function_registered = false;
       
    67 static QS60PixmapData *firstPixmap = 0;
       
    68 
       
    69 void qt_symbian_register_pixmap(QS60PixmapData *pd)
       
    70 {
       
    71     if(!cleanup_function_registered) {
       
    72         qAddPostRoutine(qt_symbian_release_pixmaps);
       
    73         cleanup_function_registered = true;
       
    74     }
       
    75 
       
    76     pd->next = firstPixmap;
       
    77     pd->prev = 0;
       
    78     if (firstPixmap)
       
    79         firstPixmap->prev = pd;
       
    80     firstPixmap = pd;
       
    81 }
       
    82 
       
    83 void qt_symbian_unregister_pixmap(QS60PixmapData *pd)
       
    84 {
       
    85     if (pd->next)
       
    86         pd->next->prev = pd->prev;
       
    87     if (pd->prev)
       
    88         pd->prev->next = pd->next;
       
    89     else
       
    90         firstPixmap = pd->next;
       
    91 }
       
    92 
       
    93 void qt_symbian_release_pixmaps()
       
    94 {
       
    95     // Scan all QS60PixmapData objects in the system and destroy them.
       
    96     QS60PixmapData *pd = firstPixmap;
       
    97     while (pd != 0) {
       
    98         pd->release();
       
    99         pd = pd->next;
       
   100     }
       
   101 }
    66 
   102 
    67 /*
   103 /*
    68     \class QSymbianFbsClient
   104     \class QSymbianFbsClient
    69     \since 4.6
   105     \since 4.6
    70     \internal
   106     \internal
   354 QS60PixmapData::QS60PixmapData(PixelType type) : QRasterPixmapData(type),
   390 QS60PixmapData::QS60PixmapData(PixelType type) : QRasterPixmapData(type),
   355     symbianBitmapDataAccess(new QSymbianBitmapDataAccess),
   391     symbianBitmapDataAccess(new QSymbianBitmapDataAccess),
   356     cfbsBitmap(0),
   392     cfbsBitmap(0),
   357     pengine(0),
   393     pengine(0),
   358     bytes(0),
   394     bytes(0),
   359     formatLocked(false)
   395     formatLocked(false),
   360 {
   396     next(0),
   361 
   397     prev(0)
       
   398 {
       
   399     qt_symbian_register_pixmap(this);
   362 }
   400 }
   363 
   401 
   364 QS60PixmapData::~QS60PixmapData()
   402 QS60PixmapData::~QS60PixmapData()
   365 {
   403 {
   366     release();
   404     release();
   367     delete symbianBitmapDataAccess;
   405     delete symbianBitmapDataAccess;
       
   406     qt_symbian_unregister_pixmap(this);
   368 }
   407 }
   369 
   408 
   370 void QS60PixmapData::resize(int width, int height)
   409 void QS60PixmapData::resize(int width, int height)
   371 {
   410 {
   372     if (width <= 0 || height <= 0) {
   411     if (width <= 0 || height <= 0) {