From 4e3ba194fe2404de380fbe544f87773edd66f7b9 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 24 Apr 2009 14:22:37 +0200 Subject: Get transparency working by clearing the window surface. This is duplicated code from the raster paint engine's beginPaint() function. For translucent windows the previous contents must be cleared from the backing store before the new content is painted. This class should probably be re-written as a subclass of the raster version. The reason we cannot use that implementation directly is because we cannot use QNativeImage because it doesn't provide anywhere we can do locking. --- src/gui/painting/qwindowsurface_s60.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 50278ce..85190c2 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -15,6 +15,7 @@ #include #include "qwindowsurface_s60_p.h" #include "qt_s60_p.h" +#include "private/qdrawhelper_p.h" QT_BEGIN_NAMESPACE @@ -61,7 +62,7 @@ QS60WindowSurface::~QS60WindowSurface() delete d_ptr; } -void QS60WindowSurface::beginPaint(const QRegion &) +void QS60WindowSurface::beginPaint(const QRegion &rgn) { if(!d_ptr->bitmap) return; @@ -69,6 +70,26 @@ void QS60WindowSurface::beginPaint(const QRegion &) Q_ASSERT(!QS60WindowSurfacePrivate::lockedSurface); QS60WindowSurfacePrivate::lockedSurface = this; lockBitmapHeap(); + + if (!qt_widget_private(window())->isOpaque) { + QRgb *data = reinterpret_cast(d_ptr->device.bits()); + const int row_stride = d_ptr->device.bytesPerLine() / 4; + + const QVector rects = rgn.rects(); + for (QVector::const_iterator it = rects.begin(); it != rects.end(); ++it) { + const int x_start = it->x(); + const int width = it->width(); + + const int y_start = it->y(); + const int height = it->height(); + + QRgb *row = data + row_stride * y_start; + for (int y = 0; y < height; ++y) { + qt_memfill(row + x_start, 0U, width); + row += row_stride; + } + } + } } void QS60WindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &) -- cgit v0.12