diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-09-29 07:42:02 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2009-10-07 03:04:59 (GMT) |
commit | e5948fdb892810b5b783ceb4205a1eacd2a89a79 (patch) | |
tree | 28d43cb64d0a7021fe4fd9b42d60bc79a00482eb | |
parent | 75f4584bd73b6361e36edaff8fb90a90add52a4a (diff) | |
download | Qt-e5948fdb892810b5b783ceb4205a1eacd2a89a79.zip Qt-e5948fdb892810b5b783ceb4205a1eacd2a89a79.tar.gz Qt-e5948fdb892810b5b783ceb4205a1eacd2a89a79.tar.bz2 |
Optimized restore() in GL 2 paint engine.
Keep track of what state actually changed so we don't have to set all
the uniforms as dirty etc.
Reviewed-by: Trond
(cherry picked from commit 092c773b95b1f126d36ab7c918fb098ddad6cae3)
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 50 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 15 |
2 files changed, 46 insertions, 19 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 859ffe1..5875124 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1224,6 +1224,7 @@ void QGL2PaintEngineEx::opacityChanged() { // qDebug("QGL2PaintEngineEx::opacityChanged()"); Q_D(QGL2PaintEngineEx); + state()->opacityChanged = true; Q_ASSERT(d->shaderManager); d->brushUniformsDirty = true; @@ -1234,11 +1235,14 @@ void QGL2PaintEngineEx::compositionModeChanged() { // qDebug("QGL2PaintEngineEx::compositionModeChanged()"); Q_D(QGL2PaintEngineEx); + state()->compositionModeChanged = true; d->compositionModeDirty = true; } void QGL2PaintEngineEx::renderHintsChanged() { + state()->renderHintsChanged = true; + #if !defined(QT_OPENGL_ES_2) if ((state()->renderHints & QPainter::Antialiasing) || (state()->renderHints & QPainter::HighQualityAntialiasing)) @@ -1257,6 +1261,7 @@ void QGL2PaintEngineEx::transformChanged() { Q_D(QGL2PaintEngineEx); d->matrixDirty = true; + state()->matrixChanged = true; } @@ -1713,6 +1718,7 @@ void QGL2PaintEngineEx::ensureActive() d->transferMode(BrushDrawingMode); glViewport(0, 0, d->width, d->height); d->needsSync = false; + d->shaderManager->setDirty(); setState(state()); } } @@ -1769,6 +1775,8 @@ void QGL2PaintEngineEx::clipEnabledChanged() { Q_D(QGL2PaintEngineEx); + state()->clipChanged = true; + if (painter()->hasClipping()) d->regenerateClip(); else @@ -1851,6 +1859,8 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) // qDebug("QGL2PaintEngineEx::clip()"); Q_D(QGL2PaintEngineEx); + state()->clipChanged = true; + ensureActive(); if (op == Qt::ReplaceClip) { @@ -1947,6 +1957,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged() { Q_Q(QGL2PaintEngineEx); + q->state()->clipChanged = true; + if (systemClip.isEmpty()) { use_system_clip = false; } else { @@ -2005,21 +2017,28 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state) return; } - renderHintsChanged(); + if (old_state == s || s->renderHintsChanged) + renderHintsChanged(); - d->matrixDirty = true; - d->compositionModeDirty = true; - d->simpleShaderMatrixUniformDirty = true; - d->shaderMatrixUniformDirty = true; - d->opacityUniformDirty = true; + if (old_state == s || s->matrixChanged) { + d->matrixDirty = true; + d->simpleShaderMatrixUniformDirty = true; + d->shaderMatrixUniformDirty = true; + } - d->shaderManager->setDirty(); + if (old_state == s || s->compositionModeChanged) + d->compositionModeDirty = true; - if (old_state && old_state != s && old_state->canRestoreClip) { - d->updateClipScissorTest(); - glDepthFunc(GL_LEQUAL); - } else { - d->regenerateClip(); + if (old_state == s || s->opacityChanged) + d->opacityUniformDirty = true; + + if (old_state == s || s->clipChanged) { + if (old_state && old_state != s && old_state->canRestoreClip) { + d->updateClipScissorTest(); + glDepthFunc(GL_LEQUAL); + } else { + d->regenerateClip(); + } } } @@ -2036,6 +2055,12 @@ QPainterState *QGL2PaintEngineEx::createState(QPainterState *orig) const else s = new QOpenGL2PaintEngineState(*static_cast<QOpenGL2PaintEngineState *>(orig)); + s->matrixChanged = false; + s->compositionModeChanged = false; + s->opacityChanged = false; + s->renderHintsChanged = false; + s->clipChanged = false; + d->last_created_state = s; return s; } @@ -2051,7 +2076,6 @@ QOpenGL2PaintEngineState::QOpenGL2PaintEngineState(QOpenGL2PaintEngineState &oth { needsClipBufferClear = other.needsClipBufferClear; clipTestEnabled = other.clipTestEnabled; - scissorTestEnabled = other.scissorTestEnabled; currentClip = other.currentClip; canRestoreClip = other.canRestoreClip; rectangleClip = other.rectangleClip; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 662911f..28c972e 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -82,13 +82,16 @@ public: QOpenGL2PaintEngineState(); ~QOpenGL2PaintEngineState(); - bool needsClipBufferClear; + uint needsClipBufferClear : 1; + uint clipTestEnabled : 1; + uint canRestoreClip : 1; + uint matrixChanged : 1; + uint compositionModeChanged : 1; + uint opacityChanged : 1; + uint renderHintsChanged : 1; + uint clipChanged : 1; + uint currentClip : 8; - bool clipTestEnabled; - bool scissorTestEnabled; - uint currentClip; - - bool canRestoreClip; QRect rectangleClip; }; |