summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-05-28 11:45:42 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-05-28 12:13:21 (GMT)
commit27d979b0ea39922e6e2ae3a3cc6a4d45c9c8f0e9 (patch)
treee7b34f1f6cb3d61fc276ce3043b00d39f27ed16f /src/opengl
parent6b75c19e42cd7ffd6d8c0716aa9b1251be28b3e7 (diff)
downloadQt-27d979b0ea39922e6e2ae3a3cc6a4d45c9c8f0e9.zip
Qt-27d979b0ea39922e6e2ae3a3cc6a4d45c9c8f0e9.tar.gz
Qt-27d979b0ea39922e6e2ae3a3cc6a4d45c9c8f0e9.tar.bz2
Fixed incorrect handling of composition modes in GL2 paint engine.
Even if the source pixels are opaque we have to enable blending for the non-trivial composition modes. Some of the composition modes are independent of source alpha and depend on destination alpha for example. Reviewed-by: Tom
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp31
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h2
2 files changed, 11 insertions, 22 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 338919e..75422a2 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -425,7 +425,7 @@ static inline void setCoords(GLfloat *coords, const QGLRect &rect)
coords[7] = rect.bottom;
}
-void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize)
+void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque)
{
transferMode(ImageDrawingMode);
@@ -434,7 +434,7 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s
// Setup for texture drawing
shaderManager->setSrcPixelType(QGLEngineShaderManager::ImageSrc);
shaderManager->setTextureCoordsEnabled(true);
- prepareForDraw(false); // ###
+ prepareForDraw(opaque);
shaderManager->currentProgram()->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT);
@@ -634,11 +634,12 @@ void QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque)
updateMatrix();
const bool stateHasOpacity = q->state()->opacity < 0.99f;
- if ( (!srcPixelsAreOpaque || stateHasOpacity) &&
- q->state()->compositionMode() != QPainter::CompositionMode_Source)
- glEnable(GL_BLEND);
- else
+ if (q->state()->compositionMode() == QPainter::CompositionMode_Source
+ || (q->state()->compositionMode() == QPainter::CompositionMode_SourceOver
+ && srcPixelsAreOpaque && !stateHasOpacity))
glDisable(GL_BLEND);
+ else
+ glEnable(GL_BLEND);
bool useGlobalOpacityUniform = stateHasOpacity;
if (stateHasOpacity && (mode != ImageDrawingMode)) {
@@ -822,12 +823,7 @@ void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, c
ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, true);
//FIXME: we should use hasAlpha() instead, but that's SLOW at the moment
- if ((state()->opacity < 0.99f) || pixmap.hasAlphaChannel())
- glEnable(GL_BLEND);
- else
- glDisable(GL_BLEND);
-
- d->drawTexture(dest, src, pixmap.size());
+ d->drawTexture(dest, src, pixmap.size(), !pixmap.hasAlphaChannel());
}
void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const QRectF& src,
@@ -841,12 +837,7 @@ void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const
glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT);
ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, true);
- if ((state()->opacity < 0.99f) || image.hasAlphaChannel())
- glEnable(GL_BLEND);
- else
- glDisable(GL_BLEND);
-
- d->drawTexture(dest, src, image.size());
+ d->drawTexture(dest, src, image.size(), !image.hasAlphaChannel());
}
void QGL2PaintEngineEx::drawTextItem(const QPointF &p, const QTextItem &textItem)
@@ -1022,10 +1013,8 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
source->bind(false);
- glDisable(GL_BLEND);
-
QRect rect(0, 0, source->width(), source->height());
- d->drawTexture(QRectF(rect), QRectF(rect), rect.size());
+ d->drawTexture(QRectF(rect), QRectF(rect), rect.size(), true);
}
updateClipRegion(QRegion(), Qt::NoClip);
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index ef62390..dececa3 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -159,7 +159,7 @@ public:
// fill, drawOutline, drawTexture & drawCachedGlyphs are the rendering entry points:
void fill(const QVectorPath &path);
void drawOutline(const QVectorPath& path);
- void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize);
+ void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque);
void drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti);
void drawVertexArrays(QGL2PEXVertexArray& vertexArray, GLenum primitive);