Changeset 769 for trunk/src/gui/image
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/image/qicon.cpp
r763 r769 105 105 static QBasicAtomicInt serialNumCounter = Q_BASIC_ATOMIC_INITIALIZER(1); 106 106 107 static void qt_cleanup_icon_cache(); 108 typedef QCache<QString, QIcon> IconCache; 109 Q_GLOBAL_STATIC_WITH_INITIALIZER(IconCache, qtIconCache, qAddPostRoutine(qt_cleanup_icon_cache)) 110 111 static void qt_cleanup_icon_cache() 112 { 113 qtIconCache()->clear(); 114 } 115 107 116 QIconPrivate::QIconPrivate() 108 117 : engine(0), ref(1), … … 964 973 QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) 965 974 { 966 static QCache <QString, QIcon> iconCache;967 968 975 QIcon icon; 969 976 970 if ( iconCache.contains(name)) {971 icon = * iconCache.object(name);977 if (qtIconCache()->contains(name)) { 978 icon = *qtIconCache()->object(name); 972 979 } else { 973 980 QIcon *cachedIcon = new QIcon(new QIconLoaderEngine(name)); 974 iconCache.insert(name, cachedIcon);981 qtIconCache()->insert(name, cachedIcon); 975 982 icon = *cachedIcon; 976 983 } 977 984 978 if (icon.availableSizes().isEmpty()) 985 // Note the qapp check is to allow lazy loading of static icons 986 // Supporting fallbacks will not work for this case. 987 if (qApp && icon.availableSizes().isEmpty()) 979 988 return fallback; 980 989 -
trunk/src/gui/image/qiconloader.cpp
r651 r769 86 86 87 87 QIconLoader::QIconLoader() : 88 m_themeKey(1), m_supportsSvg(false) 89 { 90 m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName(); 91 if (m_systemTheme.isEmpty()) 92 m_systemTheme = fallbackTheme(); 93 88 m_themeKey(1), m_supportsSvg(false), m_initialized(false) 89 { 90 } 91 92 // We lazily initialize the loader to make static icons 93 // work. Though we do not officially support this. 94 void QIconLoader::ensureInitialized() 95 { 96 if (!m_initialized) { 97 m_initialized = true; 98 99 Q_ASSERT(qApp); 100 101 m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName(); 102 if (m_systemTheme.isEmpty()) 103 m_systemTheme = fallbackTheme(); 94 104 #ifndef QT_NO_LIBRARY 95 QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid,96 QLatin1String("/iconengines"),97 Qt::CaseInsensitive);98 if (iconFactoryLoader.keys().contains(QLatin1String("svg")))99 m_supportsSvg = true;105 QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid, 106 QLatin1String("/iconengines"), 107 Qt::CaseInsensitive); 108 if (iconFactoryLoader.keys().contains(QLatin1String("svg"))) 109 m_supportsSvg = true; 100 110 #endif //QT_NO_LIBRARY 111 } 101 112 } 102 113 … … 340 351 void QIconLoaderEngine::ensureLoaded() 341 352 { 353 354 iconLoaderInstance()->ensureInitialized(); 355 342 356 if (!(iconLoaderInstance()->themeKey() == m_key)) { 343 357 -
trunk/src/gui/image/qiconloader_p.h
r651 r769 170 170 void updateSystemTheme(); 171 171 void invalidateKey() { m_themeKey++; } 172 void ensureInitialized(); 172 173 173 174 private: … … 177 178 uint m_themeKey; 178 179 bool m_supportsSvg; 180 bool m_initialized; 179 181 180 182 mutable QString m_userTheme; -
trunk/src/gui/image/qimage.cpp
r651 r769 119 119 } 120 120 121 extern int qt_defaultDpiX();122 extern int qt_defaultDpiY();121 Q_GUI_EXPORT extern int qt_defaultDpiX(); 122 Q_GUI_EXPORT extern int qt_defaultDpiY(); 123 123 124 124 QBasicAtomicInt qimage_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1); … … 5668 5668 detach(); 5669 5669 5670 *this = convertToFormat(QImage::Format_ARGB32_Premultiplied); 5670 QImage converted = convertToFormat(QImage::Format_ARGB32_Premultiplied); 5671 if (!converted.isNull()) 5672 *this = converted; 5673 else 5674 return; 5671 5675 5672 5676 // Slight optimization since alphachannels are returned as 8-bit grays. -
trunk/src/gui/image/qimagepixmapcleanuphooks.cpp
r651 r769 97 97 { 98 98 QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); 99 // the global destructor for the pixmap and image hooks might have 100 // been called already if the app is "leaking" global 101 // pixmaps/images 102 if (!h) 103 return; 99 104 for (int i = 0; i < h->pixmapModificationHooks.count(); ++i) 100 105 h->pixmapModificationHooks[i](pmd); … … 107 112 { 108 113 QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); 114 // the global destructor for the pixmap and image hooks might have 115 // been called already if the app is "leaking" global 116 // pixmaps/images 117 if (!h) 118 return; 109 119 for (int i = 0; i < h->pixmapDestructionHooks.count(); ++i) 110 120 h->pixmapDestructionHooks[i](pmd); … … 123 133 } 124 134 125 void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap)126 {127 enableCleanupHooks(const_cast<QPixmap &>(pixmap).data_ptr().data());128 }129 135 130 136 void QImagePixmapCleanupHooks::enableCleanupHooks(QPixmapData *pixmapData) 131 137 { 132 138 pixmapData->is_cached = true; 139 } 140 141 void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap) 142 { 143 enableCleanupHooks(const_cast<QPixmap &>(pixmap).data_ptr().data()); 133 144 } 134 145 … … 138 149 } 139 150 151 bool QImagePixmapCleanupHooks::isImageCached(const QImage &image) 152 { 153 return const_cast<QImage &>(image).data_ptr()->is_cached; 154 } 155 156 bool QImagePixmapCleanupHooks::isPixmapCached(const QPixmap &pixmap) 157 { 158 return const_cast<QPixmap&>(pixmap).data_ptr().data()->is_cached; 159 } 160 161 162 140 163 QT_END_NAMESPACE -
trunk/src/gui/image/qimagepixmapcleanuphooks_p.h
r651 r769 73 73 static void enableCleanupHooks(QPixmapData *pixmapData); 74 74 75 static bool isImageCached(const QImage &image); 76 static bool isPixmapCached(const QPixmap &pixmap); 77 75 78 // Gets called when a pixmap data is about to be modified: 76 79 void addPixmapDataModificationHook(_qt_pixmap_cleanup_hook_pmd); -
trunk/src/gui/image/qimagereader.cpp
r651 r769 264 264 } 265 265 266 if (!handler && !testFormat.isEmpty() && autoDetectImageFormat &&!ignoresFormatAndExtension) {266 if (!handler && !testFormat.isEmpty() && !ignoresFormatAndExtension) { 267 267 // check if any plugin supports the format (they are not allowed to 268 268 // read from the device yet). 269 269 const qint64 pos = device ? device->pos() : 0; 270 for (int i = 0; i < keys.size(); ++i) { 271 if (i != suffixPluginIndex) { 272 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i))); 273 if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { 270 271 if (autoDetectImageFormat) { 272 for (int i = 0; i < keys.size(); ++i) { 273 if (i != suffixPluginIndex) { 274 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i))); 275 if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { 274 276 #ifdef QIMAGEREADER_DEBUG 275 qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this format"; 276 #endif 277 handler = plugin->create(device, testFormat); 278 break; 277 qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this format"; 278 #endif 279 handler = plugin->create(device, testFormat); 280 break; 281 } 279 282 } 283 } 284 } else { 285 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(QLatin1String(testFormat))); 286 if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { 287 #ifdef QIMAGEREADER_DEBUG 288 qDebug() << "QImageReader::createReadHandler: the" << testFormat << "plugin can read this format"; 289 #endif 290 handler = plugin->create(device, testFormat); 280 291 } 281 292 } … … 283 294 device->seek(pos); 284 295 } 296 285 297 #endif // QT_NO_LIBRARY 286 298 -
trunk/src/gui/image/qimagewriter.cpp
r651 r769 198 198 QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(keys.at(i))); 199 199 if (plugin && (plugin->capabilities(device, testFormat) & QImageIOPlugin::CanWrite)) { 200 delete handler; 200 201 handler = plugin->create(device, testFormat); 201 202 break; -
trunk/src/gui/image/qnativeimage.cpp
r651 r769 202 202 ok = (xshminfo.shmaddr != (char*)-1); 203 203 if (ok) 204 image = QImage((uchar *)xshmimg->data, width, height, systemFormat());204 image = QImage((uchar *)xshmimg->data, width, height, format); 205 205 } 206 206 xshminfo.readOnly = false; -
trunk/src/gui/image/qpaintengine_pic.cpp
r651 r769 478 478 } 479 479 480 extern int qt_defaultDpi();480 Q_GUI_EXPORT extern int qt_defaultDpi(); 481 481 482 482 void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti) -
trunk/src/gui/image/qpicture.cpp
r651 r769 109 109 static const quint16 mfhdr_maj = 11; // major version # 110 110 static const quint16 mfhdr_min = 0; // minor version # 111 extern int qt_defaultDpiX();112 extern int qt_defaultDpiY();111 Q_GUI_EXPORT extern int qt_defaultDpiX(); 112 Q_GUI_EXPORT extern int qt_defaultDpiY(); 113 113 114 114 /*! -
trunk/src/gui/image/qpixmap.cpp
r651 r769 832 832 return true; 833 833 834 bool ok; 835 836 if (data) { 837 ok = data->fromFile(fileName, format, flags); 838 } else { 839 QScopedPointer<QPixmapData> tmp(QPixmapData::create(0, 0, QPixmapData::PixmapType)); 840 ok = tmp->fromFile(fileName, format, flags); 841 if (ok) 842 data = tmp.take(); 843 } 844 845 if (ok) 834 QScopedPointer<QPixmapData> tmp(QPixmapData::create(0, 0, data ? data->type : QPixmapData::PixmapType)); 835 if (tmp->fromFile(fileName, format, flags)) { 836 data = tmp.take(); 846 837 QPixmapCache::insert(key, *this); 847 848 return ok; 838 return true; 839 } 840 841 return false; 849 842 } 850 843 … … 1671 1664 1672 1665 The hasAlphaChannel() returns true if the pixmap has a format that 1673 respects the alpha channel, otherwise returns false, while the 1674 hasAlpha() function returns true if the pixmap has an alpha 1675 channel \e or a mask (otherwise false). The mask() function returns 1676 the mask as a QBitmap object, which can be set using setMask(). 1666 respects the alpha channel, otherwise returns false. The hasAlpha(), 1667 setMask() and mask() functions are legacy and should not be used. 1668 They are potentially very slow. 1677 1669 1678 1670 The createHeuristicMask() function creates and returns a 1-bpp … … 1760 1752 Returns true if this pixmap has an alpha channel, \e or has a 1761 1753 mask, otherwise returns false. 1754 1755 \warning This is potentially an expensive operation. 1762 1756 1763 1757 \sa hasAlphaChannel(), mask() … … 2028 2022 too. The mouse cursor is generally not grabbed. 2029 2023 2030 Note on X11 that if the given \a window doesn't have the same depth2024 Note on X11 that if the given \a window doesn't have the same depth 2031 2025 as the root window, and another window partially or entirely 2032 2026 obscures the one you grab, you will \e not get pixels from the … … 2034 2028 pixmap will be undefined and uninitialized. 2035 2029 2030 On Windows Vista and above grabbing a layered window, which is 2031 created by setting the Qt::WA_TranslucentBackground attribute, will 2032 not work. Instead grabbing the desktop widget should work. 2033 2036 2034 \warning In general, grabbing an area outside the screen is not 2037 2035 safe. This depends on the underlying window system. -
trunk/src/gui/image/qpixmap_raster.cpp
r651 r769 358 358 } 359 359 360 extern int qt_defaultDpiX();361 extern int qt_defaultDpiY();360 Q_GUI_EXPORT extern int qt_defaultDpiX(); 361 Q_GUI_EXPORT extern int qt_defaultDpiY(); 362 362 363 363 int QRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const -
trunk/src/gui/image/qpixmap_s60.cpp
r651 r769 338 338 return QPixmap(); 339 339 340 QScopedPointer<Q S60PixmapData> data(new QS60PixmapData(QPixmapData::PixmapType));340 QScopedPointer<QPixmapData> data(QPixmapData::create(0,0, QPixmapData::PixmapType)); 341 341 data->fromNativeType(reinterpret_cast<void*>(bitmap), QPixmapData::FbsBitmap); 342 342 QPixmap pixmap(data.take()); … … 736 736 return QPixmap(); 737 737 738 QScopedPointer<Q S60PixmapData> data(new QS60PixmapData(QPixmapData::PixmapType));738 QScopedPointer<QPixmapData> data(QPixmapData::create(0,0, QPixmapData::PixmapType)); 739 739 data->fromNativeType(reinterpret_cast<void*>(sgImage), QPixmapData::SgImage); 740 740 QPixmap pixmap(data.take()); -
trunk/src/gui/image/qpixmap_x11.cpp
r651 r769 384 384 // Will implicitly also check format and return quickly for opaque types... 385 385 checked = true; 386 has = const_cast<QImage *>(image)->data_ptr()->checkForAlphaPixels();386 has = image->isNull() ? false : const_cast<QImage *>(image)->data_ptr()->checkForAlphaPixels(); 387 387 return has; 388 388 } -
trunk/src/gui/image/qpixmapfilter.cpp
r651 r769 423 423 return; 424 424 425 if (src.isNull()) 426 return; 427 425 428 QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? 426 429 static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; … … 775 778 Q_GUI_EXPORT QImage qt_halfScaled(const QImage &source) 776 779 { 780 if (source.width() < 2 || source.height() < 2) 781 return QImage(); 782 777 783 QImage srcImage = source; 778 784 … … 867 873 868 874 qreal scale = 1; 869 if (radius >= 4 ) {875 if (radius >= 4 && blurImage.width() >= 2 && blurImage.height() >= 2) { 870 876 blurImage = qt_halfScaled(blurImage); 871 877 scale = 2; … … 893 899 } 894 900 895 bool qt_scaleForTransform(const QTransform &transform, qreal *scale);901 Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale); 896 902 897 903 /*! … … 902 908 Q_D(const QPixmapBlurFilter); 903 909 if (!painter->isActive()) 910 return; 911 912 if (src.isNull()) 904 913 return; 905 914 … … 1084 1093 { 1085 1094 Q_D(const QPixmapColorizeFilter); 1095 1096 if (src.isNull()) 1097 return; 1098 1086 1099 QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ? 1087 1100 static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0; … … 1314 1327 { 1315 1328 Q_D(const QPixmapDropShadowFilter); 1329 1330 if (px.isNull()) 1331 return; 1332 1316 1333 QPixmapFilter *filter = p->paintEngine() && p->paintEngine()->isExtended() ? 1317 1334 static_cast<QPaintEngineEx *>(p->paintEngine())->pixmapFilter(type(), this) : 0;
Note:
See TracChangeset
for help on using the changeset viewer.