From c23d4d6644bff2195fbb6aa84d3425dc2d31491a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 18 Jun 2009 12:10:12 +0200 Subject: Prevented unnecessary depth clip updates in OpenGL paint engine. Keep track of whether the depth clip has actually changed between states, so that when QPainter::restore() is called we don't call the potentially expensive updateDepthClip() function when not needed. Task-number: 254658 Reviewed-by: Trond --- src/opengl/qpaintengine_opengl.cpp | 10 +++++++++- src/opengl/qpaintengine_opengl_p.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 044090b..b594f5b 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -2222,6 +2222,8 @@ void QOpenGLPaintEnginePrivate::updateDepthClip() { Q_Q(QOpenGLPaintEngine); + ++q->state()->depthClipId; + glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -5504,6 +5506,9 @@ void QOpenGLPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) void QOpenGLPaintEngine::setState(QPainterState *s) { Q_D(QOpenGLPaintEngine); + QOpenGLPaintEngineState *new_state = static_cast(s); + QOpenGLPaintEngineState *old_state = state(); + QPaintEngineEx::setState(s); // are we in a save() ? @@ -5513,7 +5518,8 @@ void QOpenGLPaintEngine::setState(QPainterState *s) } if (isActive()) { - d->updateDepthClip(); + if (old_state->depthClipId != new_state->depthClipId) + d->updateDepthClip(); penChanged(); brushChanged(); opacityChanged(); @@ -5547,11 +5553,13 @@ QOpenGLPaintEngineState::QOpenGLPaintEngineState(QOpenGLPaintEngineState &other) clipRegion = other.clipRegion; hasClipping = other.hasClipping; fastClip = other.fastClip; + depthClipId = other.depthClipId; } QOpenGLPaintEngineState::QOpenGLPaintEngineState() { hasClipping = false; + depthClipId = 0; } QOpenGLPaintEngineState::~QOpenGLPaintEngineState() diff --git a/src/opengl/qpaintengine_opengl_p.h b/src/opengl/qpaintengine_opengl_p.h index 891cbd6..439782b 100644 --- a/src/opengl/qpaintengine_opengl_p.h +++ b/src/opengl/qpaintengine_opengl_p.h @@ -69,6 +69,7 @@ public: QRegion clipRegion; bool hasClipping; QRect fastClip; + uint depthClipId; }; class QOpenGLPaintEngine : public QPaintEngineEx -- cgit v0.12