summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-03-24 14:10:01 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-04-16 08:42:05 (GMT)
commitd4eb0a29e73eb1f6c7e2909e6ae0302605927e02 (patch)
tree5ef1d2dc8b588e1bd223ce42887cf77a5da0ea59
parentfbce782f1d566c318737bf7e5ab55d0a66fb2a2c (diff)
downloadQt-d4eb0a29e73eb1f6c7e2909e6ae0302605927e02.zip
Qt-d4eb0a29e73eb1f6c7e2909e6ae0302605927e02.tar.gz
Qt-d4eb0a29e73eb1f6c7e2909e6ae0302605927e02.tar.bz2
GL2: Avoid expensive updateDepthClip() every time setState() is called
Only call updateDepthClip() if the clip has actually changed.
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp30
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h1
2 files changed, 14 insertions, 17 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 89ed1f7..e166b54 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1200,11 +1200,6 @@ void QGL2PaintEngineEx::updateClipRegion(const QRegion &clipRegion, Qt::ClipOper
state()->hasClipping = op != Qt::NoClip || d->use_system_clip;
}
- if (state()->hasClipping && state()->clipRegion.rects().size() == 1)
- state()->fastClip = state()->clipRegion.rects().at(0);
- else
- state()->fastClip = QRect();
-
d->updateDepthClip();
}
@@ -1221,14 +1216,10 @@ void QGL2PaintEngineExPrivate::updateDepthClip()
if (!q->state()->hasClipping)
return;
- QRect fastClip;
- if (q->state()->clipEnabled) {
- fastClip = q->state()->fastClip;
- } else if (use_system_clip && q->systemClip().rects().count() == 1) {
- fastClip = q->systemClip().rects().at(0);
- }
+ const QVector<QRect> rects = q->state()->clipEnabled ? q->state()->clipRegion.rects() : q->systemClip().rects();
+ if (rects.size() == 1) {
+ QRect fastClip = rects.at(0);
- if (!fastClip.isEmpty()) {
glEnable(GL_SCISSOR_TEST);
const int left = fastClip.left();
@@ -1245,7 +1236,6 @@ void QGL2PaintEngineExPrivate::updateDepthClip()
glClear(GL_DEPTH_BUFFER_BIT);
glClearDepthf(0x1);
- const QVector<QRect> rects = q->state()->clipEnabled ? q->state()->clipRegion.rects() : q->systemClip().rects();
glEnable(GL_SCISSOR_TEST);
for (int i = 0; i < rects.size(); ++i) {
QRect rect = rects.at(i);
@@ -1268,14 +1258,23 @@ void QGL2PaintEngineExPrivate::updateDepthClip()
-void QGL2PaintEngineEx::setState(QPainterState *s)
+void QGL2PaintEngineEx::setState(QPainterState *new_state)
{
// qDebug("QGL2PaintEngineEx::setState()");
Q_D(QGL2PaintEngineEx);
+
+ QOpenGLPaintEngineState *s = static_cast<QOpenGLPaintEngineState *>(new_state);
+
+ QOpenGLPaintEngineState *old_state = state();
+ const bool needsDepthClipUpdate = !old_state
+ || s->clipEnabled != old_state->clipEnabled
+ || s->clipEnabled && s->clipRegion != old_state->clipRegion;
+
QPaintEngineEx::setState(s);
- d->updateDepthClip();
+ if (needsDepthClipUpdate)
+ d->updateDepthClip();
d->matrixDirty = true;
d->compositionModeDirty = true;
@@ -1303,7 +1302,6 @@ QOpenGLPaintEngineState::QOpenGLPaintEngineState(QOpenGLPaintEngineState &other)
{
clipRegion = other.clipRegion;
hasClipping = other.hasClipping;
- fastClip = other.fastClip;
}
QOpenGLPaintEngineState::QOpenGLPaintEngineState()
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 9f84a25..10e5337 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -67,7 +67,6 @@ public:
QRegion clipRegion;
bool hasClipping;
- QRect fastClip;
};