From 8a6da961602d9e372a9ccf88332889b4dffda825 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Thu, 17 Sep 2009 12:47:07 +0100 Subject: Added function for writing transparent pixels directly to the backing store See VideoOutput::transparentFill. This should be called from the paintEvent, having removed the TranslucentWindowBackground hack from the mediaplayer demo. As yet this has not been tested. --- src/3rdparty/phonon/mmf/defs.h | 4 +++ src/3rdparty/phonon/mmf/videooutput.cpp | 47 +++++++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/videooutput.h | 3 +++ 3 files changed, 54 insertions(+) diff --git a/src/3rdparty/phonon/mmf/defs.h b/src/3rdparty/phonon/mmf/defs.h index afb25dc..d5301d2 100644 --- a/src/3rdparty/phonon/mmf/defs.h +++ b/src/3rdparty/phonon/mmf/defs.h @@ -38,6 +38,10 @@ along with this library. If not, see . // problems caused by the window-owning control change. //#define PHONON_MMF_HARD_CODE_VIDEO_RECT_TO_EMPTY +// Defining this macro causes VideoOutput::paintEvent to write transparent +// alpha values directly into the backing store, rather than using QPainter +//#define PHONON_MMF_DIRECT_WRITE_ALPHA + QT_BEGIN_NAMESPACE namespace Phonon diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 2130d58..27e4f54 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -29,6 +29,13 @@ along with this library. If not, see . #include #include +// Required for implementation of transparentFill +#include +#include +#include +#include + + QT_BEGIN_NAMESPACE using namespace Phonon; @@ -120,6 +127,9 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) dump(); +#ifdef PHONON_MMF_DIRECT_WRITE_ALPHA + transparentFill(event->region().rects()); +#else // Note: composition mode code was a failed attempt to get transparent // alpha values to be propagated to the (EColor16MU) window surface. @@ -131,6 +141,43 @@ void MMF::VideoOutput::paintEvent(QPaintEvent* event) painter.drawRects(event->region().rects()); painter.end(); //painter.setCompositionMode(compositionMode); +#endif +} + +void MMF::VideoOutput::transparentFill(const QVector& rects) +{ + TRACE_CONTEXT(VideoOutput::transparentFill, EVideoInternal); + TRACE_ENTRY_0(); + + QImage *image = window()->windowSurface()->buffer(window()); + QRgb *data = reinterpret_cast(image->bits()); + const int row_stride = image->bytesPerLine() / 4; + + for (QVector::const_iterator it = rects.begin(); it != rects.end(); ++it) { + + const QRect& rect = *it; + + TRACE("%d %d size %d x %d", rect.x(), rect.y(), rect.width(), rect.height()); + + const int x_start = rect.x(); + const int width = rect.width(); + + const int y_start = rect.y(); + const int height = rect.height(); + + QRgb *row = data + row_stride * y_start; + for (int y = 0; y < height; ++y) { + + // Note: not using the optimised qt_memfill function implemented in + // gui/painting/qdrawhelper.cpp - can we somehow link against this? + + //qt_memfill(row + x_start, 0U, width); + memset(row + x_start, 0, width*4); + row += row_stride; + } + } + + TRACE_EXIT_0(); } void MMF::VideoOutput::resizeEvent(QResizeEvent* event) diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 566d065..298b4fe 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -20,6 +20,8 @@ along with this library. If not, see . #define PHONON_MMF_VIDEOOUTPUT_H #include +#include +#include #include "defs.h" QT_BEGIN_NAMESPACE @@ -52,6 +54,7 @@ protected: private: void dump() const; + void transparentFill(const QVector& rects); private: QSize m_frameSize; -- cgit v0.12