diff options
author | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-05-27 12:02:14 (GMT) |
---|---|---|
committer | Tom Cooksey <thomas.cooksey@nokia.com> | 2009-05-27 12:09:40 (GMT) |
commit | 962d216ce9f9f1e6bd73fe43e3d2a7c86f64b75f (patch) | |
tree | 9fccf497be456fff3cfde4d5b0d0ea07aae0d7af /src/opengl | |
parent | 71cb35e942b94e4dba2055acdebbf90c352da762 (diff) | |
download | Qt-962d216ce9f9f1e6bd73fe43e3d2a7c86f64b75f.zip Qt-962d216ce9f9f1e6bd73fe43e3d2a7c86f64b75f.tar.gz Qt-962d216ce9f9f1e6bd73fe43e3d2a7c86f64b75f.tar.bz2 |
Make QGLWidgets have the same background colour as QWidgets
QWidgets are filled with Qt::transparent when WA_TranslucentBackground
is set, reguardless of what their background colour has been set to.
This patch makes QGLWidgets behave the same way.
Reviewed-By: Samuel Rødal
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 23 | ||||
-rw-r--r-- | src/opengl/qgl.cpp | 5 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 1 | ||||
-rw-r--r-- | src/opengl/qpaintengine_opengl.cpp | 10 |
4 files changed, 22 insertions, 17 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 5c8b364..f7dbed3 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1083,16 +1083,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) // qDebug("You should see green now"); // sleep(5); - const QColor &c = d->drawable.backgroundColor(); - glClearColor(c.redF(), c.greenF(), c.blueF(), d->drawable.format().alpha() ? c.alphaF() : 1.0); - if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) { - GLbitfield clearBits = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; -#ifndef QT_OPENGL_ES - clearBits |= GL_ACCUM_BUFFER_BIT; -#endif - glClear(clearBits); - } - d->brushTextureDirty = true; d->brushUniformsDirty = true; d->matrixDirty = true; @@ -1105,11 +1095,14 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) glDisable(GL_SCISSOR_TEST); QGLPixmapData *source = d->drawable.copyOnBegin(); - if (d->drawable.autoFillBackground()) { - QColor color = d->drawable.backgroundColor(); - - float alpha = color.alphaF(); - glClearColor(color.redF() * alpha, color.greenF() * alpha, color.blueF() * alpha, alpha); + if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) { + if (d->drawable.hasTransparentBackground()) + glClearColor(0.0, 0.0, 0.0, 0.0); + else { + const QColor &c = d->drawable.backgroundColor(); + float alpha = c.alphaF(); + glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); + } glClear(GL_COLOR_BUFFER_BIT); } else if (source) { d->transferMode(ImageDrawingMode); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 9626a3d..ced3452 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4530,6 +4530,11 @@ QColor QGLDrawable::backgroundColor() const return QApplication::palette().brush(QPalette::Background).color(); } +bool QGLDrawable::hasTransparentBackground() const +{ + return widget && widget->testAttribute(Qt::WA_TranslucentBackground); +} + QGLContext *QGLDrawable::context() const { if (widget) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 9657416..b1a63b5 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -314,6 +314,7 @@ public: QColor backgroundColor() const; QGLContext *context() const; bool autoFillBackground() const; + bool hasTransparentBackground() const; #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) QGLPixmapData *copyOnBegin() const; diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index d5bf1dc..e3d8a1d 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -1330,9 +1330,15 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) d->offscreen.begin(); - const QColor &c = d->drawable.backgroundColor(); - glClearColor(c.redF(), c.greenF(), c.blueF(), d->drawable.format().alpha() ? c.alphaF() : 1.0); if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) { + + if (d->drawable.hasTransparentBackground()) + glClearColor(0.0, 0.0, 0.0, 0.0); + else { + const QColor &c = d->drawable.backgroundColor(); + glClearColor(c.redF(), c.greenF(), c.blueF(), 1.0); + } + GLbitfield clearBits = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; #ifndef QT_OPENGL_ES clearBits |= GL_ACCUM_BUFFER_BIT; |