summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-09-14 09:19:41 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-09-14 09:20:31 (GMT)
commit75426b7cd200a502d3a0b821c49ef3f1ea3029d2 (patch)
treeda27844333365a96fcaf879a43c4e4beec8c4bf3 /src/opengl
parent24334c206e0611c2a8c5ef7265b96465c9459939 (diff)
downloadQt-75426b7cd200a502d3a0b821c49ef3f1ea3029d2.zip
Qt-75426b7cd200a502d3a0b821c49ef3f1ea3029d2.tar.gz
Qt-75426b7cd200a502d3a0b821c49ef3f1ea3029d2.tar.bz2
Some small optimizations to gl2 engine.
Use qpen_ and qbrush_ accessors for slightly better performance and avoid calling for the same value again and again. Secondly, the engine doesn't use its pen and brush states so there is no point in maintaining them, so don't reset old brush all the time. Reviewed-by: Samuel
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qglengineshadermanager.cpp4
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp37
2 files changed, 11 insertions, 30 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
index 2d1885c..2502069 100644
--- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
+++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp
@@ -216,6 +216,8 @@ void QGLEngineSharedShaders::shaderDestroyed(QObject *shader)
QGLShader *QGLEngineSharedShaders::compileNamedShader(ShaderName name, QGLShader::ShaderType type)
{
Q_ASSERT(name != CustomImageSrcFragmentShader);
+ Q_ASSERT(name < InvalidShaderName);
+
if (compiledShaders[name])
return compiledShaders[name];
@@ -514,7 +516,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg()
else switch (srcPixelType) {
default:
case Qt::NoBrush:
- qCritical("QGLEngineShaderManager::useCorrectShaderProg() - I'm scared, Qt::NoBrush style is set");
+ qFatal("QGLEngineShaderManager::useCorrectShaderProg() - Qt::NoBrush style is set");
break;
case QGLEngineShaderManager::ImageSrc:
srcPixelFragShaderName = QGLEngineSharedShaders::ImageSrcFragmentShader;
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index adde89c..ea5bec8 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1039,13 +1039,12 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush)
{
Q_D(QGL2PaintEngineEx);
- if (brush.style() == Qt::NoBrush)
+ if (qbrush_style(brush) == Qt::NoBrush)
return;
if (!d->inRenderText)
ensureActive();
d->setBrush(&brush);
d->fill(path);
- d->setBrush(&(state()->brush)); // reset back to the state's brush
}
void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
@@ -1059,42 +1058,26 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
ensureActive();
- if ( (pen.isCosmetic() && (pen.style() == Qt::SolidLine)) && (pen.widthF() < 2.5f) )
+ qreal penWidth = qpen_widthf(pen);
+ if ( (pen.isCosmetic() && (penStyle == Qt::SolidLine)) && (penWidth < 2.5f) )
{
// We only handle solid, cosmetic pens with a width of 1 pixel
const QBrush& brush = pen.brush();
d->setBrush(&brush);
- if (pen.widthF() < 0.01f)
+ if (penWidth < 0.01f)
glLineWidth(1.0);
else
- glLineWidth(pen.widthF());
+ glLineWidth(penWidth);
d->drawOutline(path);
- d->setBrush(&(state()->brush));
} else
return QPaintEngineEx::stroke(path, pen);
}
-void QGL2PaintEngineEx::penChanged()
-{
-// qDebug("QGL2PaintEngineEx::penChanged() not implemented!");
-}
-
-
-void QGL2PaintEngineEx::brushChanged()
-{
-// qDebug("QGL2PaintEngineEx::brushChanged()");
- Q_D(QGL2PaintEngineEx);
- d->setBrush(&(state()->brush));
-}
-
-void QGL2PaintEngineEx::brushOriginChanged()
-{
-// qDebug("QGL2PaintEngineEx::brushOriginChanged()");
- Q_D(QGL2PaintEngineEx);
- d->brushUniformsDirty = true;
-}
+void QGL2PaintEngineEx::penChanged() { }
+void QGL2PaintEngineEx::brushChanged() { }
+void QGL2PaintEngineEx::brushOriginChanged() { }
void QGL2PaintEngineEx::opacityChanged()
{
@@ -1302,8 +1285,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, const QTextIte
glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray.data());
glDrawArrays(GL_TRIANGLES, 0, 6 * glyphs.size());
-
- setBrush(&(q->state()->brush)); //###
}
bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
@@ -1717,8 +1698,6 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state)
d->matrixDirty = true;
d->compositionModeDirty = true;
- d->brushTextureDirty = true;
- d->brushUniformsDirty = true;
d->simpleShaderDepthUniformDirty = true;
d->depthUniformDirty = true;
d->simpleShaderMatrixUniformDirty = true;