From b11eb293ca873691e4a84afdf4e89ecf16ed03b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 18 Jun 2009 11:54:23 +0200 Subject: 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 --- src/opengl/qpaintengine_opengl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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(orig)); + d->last_created_state = s; return s; } -- cgit v0.12