diff options
author | Gunnar Sletta <gunnar@trolltech.com> | 2009-12-01 08:18:47 (GMT) |
---|---|---|
committer | Gunnar Sletta <gunnar@trolltech.com> | 2009-12-01 11:40:36 (GMT) |
commit | dbfdfdb1bc37dd18dd1b723b5d5b0b65c37f3f41 (patch) | |
tree | ff1ca3a0e5e9555111cb60a05009b60cd27f07bf /src/gui/painting/qvectorpath_p.h | |
parent | b5b9faa7cdc877f8ab32a8d5ae480b5857761409 (diff) | |
download | Qt-dbfdfdb1bc37dd18dd1b723b5d5b0b65c37f3f41.zip Qt-dbfdfdb1bc37dd18dd1b723b5d5b0b65c37f3f41.tar.gz Qt-dbfdfdb1bc37dd18dd1b723b5d5b0b65c37f3f41.tar.bz2 |
Added caching of vectorpaths to the GL paint engine.
The first time a path is drawn we call makeCachable on the path, which
means that if it is drawn again, we start caching it. This is a bit of
a trick to avoid caching paths that are drawn once and discared while
at the same time cache paths that are reused automatically.
The GL engine owns the vertex information and is responsible for cleaning
it up. If the vectorpath is destroyed first, it will call the cleanup function.
if the engine dies first, we still require some hooks to clean up the cache
in the path. More to come. When VBO's are used, these will be a leaked if the
path is destroyed after the engine.
Reviewed-by: Samuel
Diffstat (limited to 'src/gui/painting/qvectorpath_p.h')
-rw-r--r-- | src/gui/painting/qvectorpath_p.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h index ec27970..5eaddf4 100644 --- a/src/gui/painting/qvectorpath_p.h +++ b/src/gui/painting/qvectorpath_p.h @@ -68,7 +68,7 @@ QT_MODULE(Gui) class QPaintEngineEx; -typedef void (*qvectorpath_cache_cleanup)(void *data); +typedef void (*qvectorpath_cache_cleanup)(QPaintEngineEx *engine, void *data); struct QRealRect { qreal x1, y1, x2, y2; @@ -118,6 +118,8 @@ public: { } + ~QVectorPath(); + QRectF controlPointRect() const; inline Hint shape() const { return (Hint) (m_hints & ShapeMask); } @@ -128,6 +130,7 @@ public: inline bool hasImplicitClose() const { return m_hints & ImplicitClose; } inline bool hasWindingFill() const { return m_hints & WindingFill; } + inline void makeCacheable() const { m_hints |= ShouldUseCacheHint; m_cache = 0; } inline uint hints() const { return m_hints; } inline const QPainterPath::ElementType *elements() const { return m_elements; } @@ -146,9 +149,9 @@ public: CacheEntry *next; }; - CacheEntry *addCacheData(QPaintEngineEx *engine, void *data, qvectorpath_cache_cleanup cleanup); + CacheEntry *addCacheData(QPaintEngineEx *engine, void *data, qvectorpath_cache_cleanup cleanup) const; inline CacheEntry *lookupCacheData(QPaintEngineEx *engine) const { - Q_ASSERT(m_hints & IsCachedHint); + Q_ASSERT(m_hints & ShouldUseCacheHint); CacheEntry *e = m_cache; while (e) { if (e->engine == engine) @@ -162,14 +165,14 @@ public: private: Q_DISABLE_COPY(QVectorPath) - CacheEntry *m_cache; - const QPainterPath::ElementType *m_elements; const qreal *m_points; const int m_count; mutable uint m_hints; mutable QRealRect m_cp_rect; + + mutable CacheEntry *m_cache; }; Q_GUI_EXPORT const QVectorPath &qtVectorPathForPath(const QPainterPath &path); |