Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/image/qpixmap_s60.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6464                                     0x10, 0x20, 0x40, 0x80 };
    6565
     66static bool cleanup_function_registered = false;
     67static QS60PixmapData *firstPixmap = 0;
     68
     69// static
     70void QS60PixmapData::qt_symbian_register_pixmap(QS60PixmapData *pd)
     71{
     72    if (!cleanup_function_registered) {
     73        qAddPostRoutine(qt_symbian_release_pixmaps);
     74        cleanup_function_registered = true;
     75    }
     76
     77    pd->next = firstPixmap;
     78    pd->prev = 0;
     79    if (firstPixmap)
     80        firstPixmap->prev = pd;
     81    firstPixmap = pd;
     82}
     83
     84// static
     85void QS60PixmapData::qt_symbian_unregister_pixmap(QS60PixmapData *pd)
     86{
     87    if (pd->next)
     88        pd->next->prev = pd->prev;
     89    if (pd->prev)
     90        pd->prev->next = pd->next;
     91    else
     92        firstPixmap = pd->next;
     93}
     94
     95// static
     96void QS60PixmapData::qt_symbian_release_pixmaps()
     97{
     98    // Scan all QS60PixmapData objects in the system and destroy them.
     99    QS60PixmapData *pd = firstPixmap;
     100    while (pd != 0) {
     101        pd->release();
     102        pd = pd->next;
     103    }
     104}
    66105
    67106/*
     
    158197public:
    159198
    160     bool heapWasLocked;
     199    static int heapRefCount;
    161200    QSysInfo::SymbianVersion symbianVersion;
    162201
    163     explicit QSymbianBitmapDataAccess() : heapWasLocked(false)
     202    explicit QSymbianBitmapDataAccess()
    164203    {
    165204        symbianVersion = QSysInfo::symbianVersion();
     
    170209    inline void beginDataAccess(CFbsBitmap *bitmap)
    171210    {
    172         if (symbianVersion == QSysInfo::SV_9_2)
    173             heapWasLocked = qt_symbianFbsClient()->lockHeap();
    174         else
     211        if (symbianVersion == QSysInfo::SV_9_2) {
     212            if (heapRefCount == 0)
     213                qt_symbianFbsClient()->lockHeap();
     214        } else {
    175215            bitmap->LockHeap(ETrue);
     216        }
     217
     218        heapRefCount++;
    176219    }
    177220
    178221    inline void endDataAccess(CFbsBitmap *bitmap)
    179222    {
     223        heapRefCount--;
     224
    180225        if (symbianVersion == QSysInfo::SV_9_2) {
    181             if (!heapWasLocked)
     226            if (heapRefCount == 0)
    182227                qt_symbianFbsClient()->unlockHeap();
    183228        } else {
     
    186231    }
    187232};
     233
     234int QSymbianBitmapDataAccess::heapRefCount = 0;
    188235
    189236
     
    349396    pengine(0),
    350397    bytes(0),
    351     formatLocked(false)
    352 {
    353 
     398    formatLocked(false),
     399    next(0),
     400    prev(0)
     401{
     402    qt_symbian_register_pixmap(this);
    354403}
    355404
     
    358407    release();
    359408    delete symbianBitmapDataAccess;
     409    qt_symbian_unregister_pixmap(this);
    360410}
    361411
     
    782832        bool needsCopy = false;
    783833
    784         QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion();
    785834        if (!(S60->supportsPremultipliedAlpha)) {
    786835            // Convert argb32_premultiplied to argb32 since Symbian 9.2 does
     
    920969
    921970            TSize size = sourceBitmap->SizeInPixels();
     971            int bytesPerLine = sourceBitmap->ScanLineLength(size.iWidth, displayMode);
    922972
    923973            QSymbianBitmapDataAccess da;
    924974            da.beginDataAccess(sourceBitmap);
    925975            uchar *bytes = (uchar*)sourceBitmap->DataAddress();
    926             QImage img = QImage(bytes, size.iWidth, size.iHeight, format);
     976            QImage img = QImage(bytes, size.iWidth, size.iHeight, bytesPerLine, format);
    927977            img = img.copy();
    928978            da.endDataAccess(sourceBitmap);
     
    9631013}
    9641014
     1015void QS60PixmapData::convertToDisplayMode(int mode)
     1016{
     1017    const TDisplayMode displayMode = static_cast<TDisplayMode>(mode);
     1018    if (!cfbsBitmap || cfbsBitmap->DisplayMode() == displayMode)
     1019        return;
     1020    if (image.depth() != TDisplayModeUtils::NumDisplayModeBitsPerPixel(displayMode)) {
     1021        qWarning("Cannot convert display mode due to depth mismatch");
     1022        return;
     1023    }
     1024
     1025    const TSize size = cfbsBitmap->SizeInPixels();
     1026    QScopedPointer<CFbsBitmap> newBitmap(createSymbianCFbsBitmap(size, displayMode));
     1027
     1028    const uchar *sptr = const_cast<const QImage &>(image).bits();
     1029    symbianBitmapDataAccess->beginDataAccess(newBitmap.data());
     1030    uchar *dptr = (uchar*)newBitmap->DataAddress();
     1031    Mem::Copy(dptr, sptr, image.byteCount());
     1032    symbianBitmapDataAccess->endDataAccess(newBitmap.data());
     1033
     1034    QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
     1035    delete cfbsBitmap;
     1036    lock.relock();
     1037    cfbsBitmap = newBitmap.take();
     1038    setSerialNumber(cfbsBitmap->Handle());
     1039    UPDATE_BUFFER();
     1040}
     1041
    9651042QPixmapData *QS60PixmapData::createCompatiblePixmapData() const
    9661043{
Note: See TracChangeset for help on using the changeset viewer.