summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-16 12:38:10 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-16 13:12:51 (GMT)
commite4e92b74980c4f601d080e1e072b556b7318c915 (patch)
tree51fd15333c62895ba7c0afa9f3730d7c8417164f /src
parent181631276e1bf9a103eeb1a8dc9f195d51e3c279 (diff)
downloadQt-e4e92b74980c4f601d080e1e072b556b7318c915.zip
Qt-e4e92b74980c4f601d080e1e072b556b7318c915.tar.gz
Qt-e4e92b74980c4f601d080e1e072b556b7318c915.tar.bz2
Rename QStaticText::setUseBackendOptimizations to setPerformanceHint()
Make the API more general and more readable by using a PerformanceHint enum instead of an on/off-trigger for the OpenGL-specific caching. Reviewed-by: Samuel
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qstatictext.cpp47
-rw-r--r--src/gui/text/qstatictext.h9
2 files changed, 34 insertions, 22 deletions
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index e3f1d26..a14b83f 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -117,6 +117,20 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \enum QStaticText::PerformanceHint
+
+ This enum the different performance hints that can be set on the QStaticText. These hints
+ can be used to indicate that the QStaticText should use additional caches, if possible,
+ to improve performance at the expense of memory. In particular, setting the performance hint
+ AggressiveCaching on the QStaticText will improve performance when using the OpenGL graphics
+ system or when drawing to a QGLWidget.
+
+ \value ModerateCaching Do basic caching for high performance at a low memory cost.
+ \value AggressiveCaching Use additional caching when available. This may improve performance
+ at a higher memory cost.
+*/
+
+/*!
Constructs an empty QStaticText
*/
QStaticText::QStaticText()
@@ -268,41 +282,34 @@ QString QStaticText::text() const
}
/*!
- Sets whether the QStaticText object should use optimizations specific to the paint engine
- backend if they are available. If \a on is set to true, backend optimizations will be turned
- on, otherwise they will be turned off. The default value is false.
-
- If backend optimizations are on, the paint engine used to draw the static text is allowed to
- store data in the object which will assist it in future calls to drawStaticText. In particular,
- when using the opengl graphics system, or when painting on a QGLWidget, turning this flag on will
- improve performance, but increase the memory footprint of the QStaticText object.
+ Sets the performance hint of the QStaticText. This hint can be used to customize how much
+ caching is done internally to improve performance.
- The default value is false.
+ The default is QStaticText::ModerateCaching.
\note This function will cause the layout of the text to be recalculated.
- \sa useBackendOptimizations()
+ \sa performanceHint()
*/
-void QStaticText::setUseBackendOptimizations(bool on)
+void QStaticText::setPerformanceHint(PerformanceHint performanceHint)
{
- if ((!on && !data->useBackendOptimizations)
- || (on && data->useBackendOptimizations))
+ if ((performanceHint == ModerateCaching && !data->useBackendOptimizations)
+ || (performanceHint == AggressiveCaching && data->useBackendOptimizations)) {
return;
-
+ }
detach();
- data->useBackendOptimizations = on;
+ data->useBackendOptimizations = (performanceHint == AggressiveCaching);
data->init();
}
/*!
- Returns whether the QStaticText object should use optimizations specific to the paint engine
- backend when possible. By default this setting is false.
+ Returns which performance hint is set for the QStaticText.
- \sa setUseBackendOptimizations()
+ \sa setPerformanceHint()
*/
-bool QStaticText::useBackendOptimizations() const
+QStaticText::PerformanceHint QStaticText::performanceHint() const
{
- return data->useBackendOptimizations;
+ return data->useBackendOptimizations ? AggressiveCaching : ModerateCaching;
}
/*!
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
index 8eeb068..652bb84 100644
--- a/src/gui/text/qstatictext.h
+++ b/src/gui/text/qstatictext.h
@@ -60,6 +60,11 @@ class QStaticTextPrivate;
class Q_GUI_EXPORT QStaticText
{
public:
+ enum PerformanceHint {
+ ModerateCaching,
+ AggressiveCaching
+ };
+
QStaticText();
QStaticText(const QString &text, const QSizeF &maximumSize = QSizeF());
QStaticText(const QStaticText &other);
@@ -78,8 +83,8 @@ public:
void prepare(const QTransform &matrix, const QFont &font);
- void setUseBackendOptimizations(bool on);
- bool useBackendOptimizations() const;
+ void setPerformanceHint(PerformanceHint performanceHint);
+ PerformanceHint performanceHint() const;
QStaticText &operator=(const QStaticText &);
bool operator==(const QStaticText &) const;