diff options
author | Gareth Stockwell <gareth.stockwell@sosco.com> | 2009-09-17 11:47:07 (GMT) |
---|---|---|
committer | Frans Englich <frans.englich@nokia.com> | 2009-09-23 12:39:22 (GMT) |
commit | 8a6da961602d9e372a9ccf88332889b4dffda825 (patch) | |
tree | 01410d19434b5f86d28707f05e62d94ee80f8265 /src/3rdparty/phonon/mmf | |
parent | 031260adc1093e95c1c4d95d1d322b5b47ac1891 (diff) | |
download | Qt-8a6da961602d9e372a9ccf88332889b4dffda825.zip Qt-8a6da961602d9e372a9ccf88332889b4dffda825.tar.gz Qt-8a6da961602d9e372a9ccf88332889b4dffda825.tar.bz2 |
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.
Diffstat (limited to 'src/3rdparty/phonon/mmf')
-rw-r--r-- | src/3rdparty/phonon/mmf/defs.h | 4 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/videooutput.cpp | 47 | ||||
-rw-r--r-- | src/3rdparty/phonon/mmf/videooutput.h | 3 |
3 files changed, 54 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. // 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 <http://www.gnu.org/licenses/>. #include <QMoveEvent> #include <QResizeEvent> +// Required for implementation of transparentFill +#include <QtGui/private/qwidget_p.h> +#include <QtGui/private/qdrawhelper_p.h> +#include <QtGui/private/qwindowsurface_p.h> +#include <QImage> + + 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<QRect>& rects) +{ + TRACE_CONTEXT(VideoOutput::transparentFill, EVideoInternal); + TRACE_ENTRY_0(); + + QImage *image = window()->windowSurface()->buffer(window()); + QRgb *data = reinterpret_cast<QRgb *>(image->bits()); + const int row_stride = image->bytesPerLine() / 4; + + for (QVector<QRect>::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 <http://www.gnu.org/licenses/>. #define PHONON_MMF_VIDEOOUTPUT_H #include <QtGui/QWidget> +#include <QVector> +#include <QRect> #include "defs.h" QT_BEGIN_NAMESPACE @@ -52,6 +54,7 @@ protected: private: void dump() const; + void transparentFill(const QVector<QRect>& rects); private: QSize m_frameSize; |