diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-10-01 15:00:55 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-02 10:43:55 +0200 |
commit | 5ad1e2578bb3eaa7da6aefa1f96d79947216d509 (patch) | |
tree | 6d4289e3058703662767b2a21908689d0513fdc7 /src/plugins/platforms/windows/qwindowscursor.h | |
parent | 8388b40108eb3f78531dac2af07eef0e89a44c03 (diff) |
Windows/Linux: Cache cursors by mask/pixmap keys and shape.
Task-number: QTBUG-33383
Change-Id: I65a5a0870f50f42c26a4d297331224b3597a36e0
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscursor.h')
-rw-r--r-- | src/plugins/platforms/windows/qwindowscursor.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index 1e818bc9b8..b366d9a06a 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -52,6 +52,27 @@ QT_BEGIN_NAMESPACE class QWindowsWindowCursorData; +struct QWindowsCursorCacheKey +{ + explicit QWindowsCursorCacheKey(const QCursor &c); + explicit QWindowsCursorCacheKey(Qt::CursorShape s) : shape(s), bitmapCacheKey(0), maskCacheKey(0) {} + QWindowsCursorCacheKey() : shape(Qt::CustomCursor), bitmapCacheKey(0), maskCacheKey(0) {} + + Qt::CursorShape shape; + qint64 bitmapCacheKey; + qint64 maskCacheKey; +}; + +inline bool operator==(const QWindowsCursorCacheKey &k1, const QWindowsCursorCacheKey &k2) +{ + return k1.shape == k2.shape && k1.bitmapCacheKey == k2.bitmapCacheKey && k1.maskCacheKey == k2.maskCacheKey; +} + +inline uint qHash(const QWindowsCursorCacheKey &k, uint seed) Q_DECL_NOTHROW +{ + return (uint(k.shape) + uint(k.bitmapCacheKey) + uint(k.maskCacheKey)) ^ seed; +} + class QWindowsWindowCursor { public: @@ -86,11 +107,9 @@ public: QWindowsWindowCursor pixmapWindowCursor(const QCursor &c); private: - typedef QHash<Qt::CursorShape, QWindowsWindowCursor> StandardCursorCache; - typedef QHash<qint64, QWindowsWindowCursor> PixmapCursorCache; + typedef QHash<QWindowsCursorCacheKey, QWindowsWindowCursor> CursorCache; - StandardCursorCache m_standardCursorCache; - PixmapCursorCache m_pixmapCursorCache; + CursorCache m_cursorCache; }; QT_END_NAMESPACE |