diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-04-24 09:58:44 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-04-28 14:42:22 (GMT) |
commit | 6143217a8594c40d693e4ffceb914bc927f43b05 (patch) | |
tree | db8f11c76e0921330f86da264886adf1d16e2d65 | |
parent | c4e2008731cd7c9df922921c52294f84205fccb9 (diff) | |
download | Qt-6143217a8594c40d693e4ffceb914bc927f43b05.zip Qt-6143217a8594c40d693e4ffceb914bc927f43b05.tar.gz Qt-6143217a8594c40d693e4ffceb914bc927f43b05.tar.bz2 |
More work on translucent windows.
One step closer to semi-transparent windows, but not there yet. This
gets the transparent contents into the window, but the previous
contents are not cleared so it keeps drawing the backing store on top
of itself each time a Draw() is done. SetBackgroundColor() indicates
to WSERV that our window is semi-transparent. We also make sure not to
use 'EDrawModeWriteAlpha' when the widget is non-opaque since this
actually changes the alpha channel on the frame buffer (not the
window) so the gives undesired results. It's a faster draw mode though
so we should use it where we can.
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_s60.cpp | 6 | ||||
-rw-r--r-- | src/gui/painting/qwindowsurface_s60.cpp | 17 |
3 files changed, 14 insertions, 12 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index e1155ad..06e47a7 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -541,7 +541,8 @@ void QSymbianControl::Draw(const TRect& r) const QS60WindowSurface *s60Surface = static_cast<QS60WindowSurface *>(qwidget->windowSurface()); CFbsBitmap *bitmap = s60Surface->symbianBitmap(); CWindowGc &gc = SystemGc(); - gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + if (qwidget->d_func()->isOpaque) + gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); gc.BitBlt(r.iTl, bitmap, r); } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(r)), QPoint()); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 20325c2..f78b5be 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -206,7 +206,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO if (q->testAttribute(Qt::WA_TranslucentBackground)) { RWindow *rwindow = static_cast<RWindow*>(topExtra->rwindow); TDisplayMode gotDM = (TDisplayMode)rwindow->SetRequiredDisplayMode(EColor16MA); - int erro = rwindow->SetTransparencyAlphaChannel(); + if (rwindow->SetTransparencyAlphaChannel() == KErrNone) + rwindow->SetBackgroundColor(~0); } } @@ -451,7 +452,8 @@ void QWidgetPrivate::s60UpdateIsOpaque() QTLWExtra *topExtra = topData(); RWindow *rwindow = static_cast<RWindow*>(topExtra->rwindow); TDisplayMode gotDM = (TDisplayMode)rwindow->SetRequiredDisplayMode(EColor16MA); - int erro = rwindow->SetTransparencyAlphaChannel(); + if (rwindow->SetTransparencyAlphaChannel() == KErrNone) + rwindow->SetBackgroundColor(~0); } else { QTLWExtra *topExtra = topData(); RWindow *rwindow = static_cast<RWindow*>(topExtra->rwindow); diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index d0c3e1c..50278ce 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -35,12 +35,17 @@ QS60WindowSurface::QS60WindowSurface(QWidget* widget) d_ptr->bytes = 0; d_ptr->bitmap = 0; - TSize size(0, 0); TDisplayMode mode = S60->screenDevice()->DisplayMode(); + bool isOpaque = qt_widget_private(widget)->isOpaque; + if (mode == EColor16MA && isOpaque) + mode = EColor16MU; // Faster since 16MU -> 16MA is typically accelerated + else if (mode == EColor16MU && !isOpaque) + mode = EColor16MA; // Try for transparency anyway - // We create empty CFbsBitmap here -> it will be resized in setGeometry + + // We create empty CFbsBitmap here -> it will be resized in setGeometry d_ptr->bitmap = new (ELeave) CFbsBitmap; - User::LeaveIfError( d_ptr->bitmap->Create( size, mode ) ); + User::LeaveIfError( d_ptr->bitmap->Create(TSize(0, 0), mode ) ); updatePaintDeviceOnBitmap(); @@ -143,12 +148,6 @@ void QS60WindowSurface::lockBitmapHeap() // Get some values for QImage creation TDisplayMode mode = bitmap->DisplayMode(); - QWidget *win = QS60WindowSurfacePrivate::lockedSurface->window(); - RWindowBase *rwin = win->winId()->DrawableWindow(); - TDisplayMode rwMode = rwin->DisplayMode(); - - mode = rwMode; - if (mode == EColor16MA && qt_widget_private(QS60WindowSurfacePrivate::lockedSurface->window())->isOpaque) mode = EColor16MU; |