Changeset 846 for trunk/src/gui/image/qpixmap_s60.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/image/qpixmap_s60.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 64 64 0x10, 0x20, 0x40, 0x80 }; 65 65 66 static bool cleanup_function_registered = false; 67 static QS60PixmapData *firstPixmap = 0; 68 69 // static 70 void 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 85 void 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 96 void 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 } 66 105 67 106 /* … … 158 197 public: 159 198 160 bool heapWasLocked;199 static int heapRefCount; 161 200 QSysInfo::SymbianVersion symbianVersion; 162 201 163 explicit QSymbianBitmapDataAccess() : heapWasLocked(false)202 explicit QSymbianBitmapDataAccess() 164 203 { 165 204 symbianVersion = QSysInfo::symbianVersion(); … … 170 209 inline void beginDataAccess(CFbsBitmap *bitmap) 171 210 { 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 { 175 215 bitmap->LockHeap(ETrue); 216 } 217 218 heapRefCount++; 176 219 } 177 220 178 221 inline void endDataAccess(CFbsBitmap *bitmap) 179 222 { 223 heapRefCount--; 224 180 225 if (symbianVersion == QSysInfo::SV_9_2) { 181 if ( !heapWasLocked)226 if (heapRefCount == 0) 182 227 qt_symbianFbsClient()->unlockHeap(); 183 228 } else { … … 186 231 } 187 232 }; 233 234 int QSymbianBitmapDataAccess::heapRefCount = 0; 188 235 189 236 … … 349 396 pengine(0), 350 397 bytes(0), 351 formatLocked(false) 352 { 353 398 formatLocked(false), 399 next(0), 400 prev(0) 401 { 402 qt_symbian_register_pixmap(this); 354 403 } 355 404 … … 358 407 release(); 359 408 delete symbianBitmapDataAccess; 409 qt_symbian_unregister_pixmap(this); 360 410 } 361 411 … … 782 832 bool needsCopy = false; 783 833 784 QSysInfo::SymbianVersion symbianVersion = QSysInfo::symbianVersion();785 834 if (!(S60->supportsPremultipliedAlpha)) { 786 835 // Convert argb32_premultiplied to argb32 since Symbian 9.2 does … … 920 969 921 970 TSize size = sourceBitmap->SizeInPixels(); 971 int bytesPerLine = sourceBitmap->ScanLineLength(size.iWidth, displayMode); 922 972 923 973 QSymbianBitmapDataAccess da; 924 974 da.beginDataAccess(sourceBitmap); 925 975 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); 927 977 img = img.copy(); 928 978 da.endDataAccess(sourceBitmap); … … 963 1013 } 964 1014 1015 void 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 965 1042 QPixmapData *QS60PixmapData::createCompatiblePixmapData() const 966 1043 {
Note:
See TracChangeset
for help on using the changeset viewer.