summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-06-18 09:54:23 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-06-18 11:19:33 (GMT)
commitb11eb293ca873691e4a84afdf4e89ecf16ed03b1 (patch)
tree4a41bcb1eb532431cbdafda5f68d8040ce257257 /src/opengl
parentcc08a4d04894eace196631029731a3af37547b7f (diff)
downloadQt-b11eb293ca873691e4a84afdf4e89ecf16ed03b1.zip
Qt-b11eb293ca873691e4a84afdf4e89ecf16ed03b1.tar.gz
Qt-b11eb293ca873691e4a84afdf4e89ecf16ed03b1.tar.bz2
Added save state detection in OpenGL engine to avoid dirtying state.
When setState() is called right after createState() it means that none of the OpenGL state needs changing, so we can simply return. Task-number: 254658 Reviewed-by: Trond
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qpaintengine_opengl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index 84ad4d5..044090b 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -662,6 +662,7 @@ public:
, txop(QTransform::TxNone)
, inverseScale(1)
, moveToCount(0)
+ , last_created_state(0)
, shader_ctx(0)
, grad_palette(0)
, drawable_texture(0)
@@ -788,6 +789,8 @@ public:
void updateGLMatrix() const;
+ mutable QPainterState *last_created_state;
+
QGLContext *shader_ctx;
GLuint grad_palette;
@@ -5502,6 +5505,13 @@ void QOpenGLPaintEngine::setState(QPainterState *s)
{
Q_D(QOpenGLPaintEngine);
QPaintEngineEx::setState(s);
+
+ // are we in a save() ?
+ if (s == d->last_created_state) {
+ d->last_created_state = 0;
+ return;
+ }
+
if (isActive()) {
d->updateDepthClip();
penChanged();
@@ -5515,12 +5525,15 @@ void QOpenGLPaintEngine::setState(QPainterState *s)
QPainterState *QOpenGLPaintEngine::createState(QPainterState *orig) const
{
+ const Q_D(QOpenGLPaintEngine);
+
QOpenGLPaintEngineState *s;
if (!orig)
s = new QOpenGLPaintEngineState();
else
s = new QOpenGLPaintEngineState(*static_cast<QOpenGLPaintEngineState *>(orig));
+ d->last_created_state = s;
return s;
}