summaryrefslogtreecommitdiffstats
path: root/src/opengl/qglpaintdevice.cpp
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-09-07 08:58:31 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-09-08 16:36:15 (GMT)
commit4feed48fdd738ed99cba86a4214e238a3e7275ed (patch)
treea9b3b41bc838275d56914b7f0d22e739794ae3c4 /src/opengl/qglpaintdevice.cpp
parente8b5bfa8a86b2d7c79aabcc4566f740f0a9afe7c (diff)
downloadQt-4feed48fdd738ed99cba86a4214e238a3e7275ed.zip
Qt-4feed48fdd738ed99cba86a4214e238a3e7275ed.tar.gz
Qt-4feed48fdd738ed99cba86a4214e238a3e7275ed.tar.bz2
Move buffer clear out of the paint engine and into the QGLPaintDevices
Previously, the paint engine cleared the surface's buffers in begin. This logic really belongs in QGLPaintDevice::beginPaint as not all paint devices will want this behaviour (in fact most don't). This also makes QGLPaintDevice API much simpler as the virtual getters for the clear color, etc. can be removed. It's much cleaner this way. The only possible problem is with the GL1 engine, which also cleared the accumulation & depth buffers in begin. However, the engine will also clear the depth buffer later as part of it's clipping logic. It also doesn't use the accumulation buffer, so clearing it seems unnessisary.
Diffstat (limited to 'src/opengl/qglpaintdevice.cpp')
-rw-r--r--src/opengl/qglpaintdevice.cpp64
1 files changed, 40 insertions, 24 deletions
diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp
index 51f9627..4f000ba 100644
--- a/src/opengl/qglpaintdevice.cpp
+++ b/src/opengl/qglpaintdevice.cpp
@@ -86,20 +86,20 @@ void QGLPaintDevice::endPaint()
}
}
-QColor QGLPaintDevice::backgroundColor() const
-{
- return QApplication::palette().brush(QPalette::Background).color();
-}
+//QColor QGLPaintDevice::backgroundColor() const
+//{
+// return QApplication::palette().brush(QPalette::Background).color();
+//}
-bool QGLPaintDevice::autoFillBackground() const
-{
- return false;
-}
+//bool QGLPaintDevice::autoFillBackground() const
+//{
+// return false;
+//}
-bool QGLPaintDevice::hasTransparentBackground() const
-{
- return false;
-}
+//bool QGLPaintDevice::hasTransparentBackground() const
+//{
+// return false;
+//}
QGLFormat QGLPaintDevice::format() const
{
@@ -112,6 +112,7 @@ QSize QGLPaintDevice::size() const
}
+
QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice()
{
}
@@ -121,26 +122,41 @@ QPaintEngine* QGLWidgetGLPaintDevice::paintEngine() const
return glWidget->paintEngine();
}
-QColor QGLWidgetGLPaintDevice::backgroundColor() const
-{
- return glWidget->palette().brush(glWidget->backgroundRole()).color();
-}
+//QColor QGLWidgetGLPaintDevice::backgroundColor() const
+//{
+// return glWidget->palette().brush(glWidget->backgroundRole()).color();
+//}
-bool QGLWidgetGLPaintDevice::autoFillBackground() const
-{
- return glWidget->autoFillBackground();
-}
+//bool QGLWidgetGLPaintDevice::autoFillBackground() const
+//{
+// return glWidget->autoFillBackground();
+//}
-bool QGLWidgetGLPaintDevice::hasTransparentBackground() const
-{
- return glWidget->testAttribute(Qt::WA_TranslucentBackground);
-}
+//bool QGLWidgetGLPaintDevice::hasTransparentBackground() const
+//{
+// return glWidget->testAttribute(Qt::WA_TranslucentBackground);
+//}
void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w)
{
glWidget = w;
}
+void QGLWidgetGLPaintDevice::beginPaint()
+{
+ QGLPaintDevice::beginPaint();
+ if (!glWidget->d_func()->disable_clear_on_painter_begin && glWidget->autoFillBackground()) {
+ if (glWidget->testAttribute(Qt::WA_TranslucentBackground))
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ else {
+ const QColor &c = glWidget->palette().brush(glWidget->backgroundRole()).color();
+ float alpha = c.alphaF();
+ glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha);
+ }
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+}
+
void QGLWidgetGLPaintDevice::endPaint()
{
if (glWidget->autoBufferSwap())