Windows: Introduce pixmap cursor cache.

Cache custom cursors.

Task-number: QTBUG-28879

Change-Id: I8f2b5b9149966399a6173dbd19f6a8e85898924b
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
bb10
Friedemann Kleint 2013-01-21 11:55:11 +01:00 committed by The Qt Project
parent f5c6a5d06b
commit 63faa00066
2 changed files with 17 additions and 1 deletions

View File

@ -393,6 +393,19 @@ QWindowsWindowCursor QWindowsCursor::standardWindowCursor(Qt::CursorShape shape)
return it.value();
}
/*!
\brief Return cached pixmap cursor or create new one.
*/
QWindowsWindowCursor QWindowsCursor::pixmapWindowCursor(const QCursor &c)
{
const qint64 cacheKey = c.pixmap().cacheKey();
PixmapCursorCache::iterator it = m_pixmapCursorCache.find(cacheKey);
if (it == m_pixmapCursorCache.end())
it = m_pixmapCursorCache.insert(cacheKey, QWindowsWindowCursor(c));
return it.value();
}
/*!
\brief Set a cursor on a window.
@ -413,7 +426,7 @@ void QWindowsCursor::changeCursor(QCursor *cursorIn, QWindow *window)
}
const QWindowsWindowCursor wcursor =
cursorIn->shape() == Qt::BitmapCursor ?
QWindowsWindowCursor(*cursorIn) : standardWindowCursor(cursorIn->shape());
pixmapWindowCursor(*cursorIn) : standardWindowCursor(cursorIn->shape());
if (wcursor.handle()) {
QWindowsWindow::baseWindowOf(window)->setCursor(wcursor);
} else {

View File

@ -83,11 +83,14 @@ public:
static QPoint mousePosition();
QWindowsWindowCursor standardWindowCursor(Qt::CursorShape s = Qt::ArrowCursor);
QWindowsWindowCursor pixmapWindowCursor(const QCursor &c);
private:
typedef QHash<Qt::CursorShape, QWindowsWindowCursor> StandardCursorCache;
typedef QHash<qint64, QWindowsWindowCursor> PixmapCursorCache;
StandardCursorCache m_standardCursorCache;
PixmapCursorCache m_pixmapCursorCache;
};
QT_END_NAMESPACE