From 1bc673c89155119d110861efbc7b6b7b06091b39 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 16 Nov 2009 14:41:57 +0100 Subject: qmediaplayer: pausing behavior for dialog inconvenient. qmediaplayer when popping up dialogs shouldn't: * play when it's paused * pause when playing only audio Task-number: QTBUG-5851 Reviewed-by: Gareth Stockwell --- demos/qmediaplayer/mediaplayer.cpp | 28 +++++++++++++++++----------- demos/qmediaplayer/mediaplayer.h | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index 267a225..aa716c5 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -471,7 +471,7 @@ void MediaPlayer::effectChanged() void MediaPlayer::showSettingsDialog() { - playPauseForDialog(); + const bool hasPausedForDialog = playPauseForDialog(); if (!settingsDialog) initSettingsDialog(); @@ -519,7 +519,8 @@ void MediaPlayer::showSettingsDialog() ui->audioEffectsCombo->setCurrentIndex(currentEffect); } - playPauseForDialog(); + if (hasPausedForDialog) + m_MediaObject.play(); } void MediaPlayer::initVideoWindow() @@ -656,24 +657,29 @@ void MediaPlayer::setFile(const QString &fileName) m_MediaObject.play(); } -void MediaPlayer::playPauseForDialog() +bool MediaPlayer::playPauseForDialog() { - // If we're running on a small screen, we want to pause the video - // when popping up dialogs. - if (m_hasSmallScreen && - (Phonon::PlayingState == m_MediaObject.state() || - Phonon::PausedState == m_MediaObject.state())) - playPause(); + // If we're running on a small screen, we want to pause the video when + // popping up dialogs. We neither want to tamper with the state if the + // user has paused. + if (m_hasSmallScreen && m_MediaObject.hasVideo()) { + if (Phonon::PlayingState == m_MediaObject.state()) { + m_MediaObject.pause(); + return true; + } + } + return false; } void MediaPlayer::openFile() { - playPauseForDialog(); + const bool hasPausedForDialog = playPauseForDialog(); QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); - playPauseForDialog(); + if (hasPausedForDialog) + m_MediaObject.play(); m_MediaObject.clearQueue(); if (fileNames.size() > 0) { diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h index a1c3d92..c181e37 100644 --- a/demos/qmediaplayer/mediaplayer.h +++ b/demos/qmediaplayer/mediaplayer.h @@ -111,7 +111,7 @@ private slots: void hasVideoChanged(bool); private: - void playPauseForDialog(); + bool playPauseForDialog(); QIcon playIcon; QIcon pauseIcon; -- cgit v0.12 From e0a7245eba7207eaf43b1855a58c76dd3cf7b41b Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 16 Nov 2009 16:58:05 +0100 Subject: Keep the same capitalization for Phonon.dll. Task-number: QTBUG-4735 --- src/s60installs/s60installs.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 2d9c489..37adfa9 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -90,7 +90,7 @@ symbian: { } contains(QT_CONFIG, phonon): { - qtlibraries.sources += Phonon.dll + qtlibraries.sources += phonon.dll } contains(QT_CONFIG, script): { -- cgit v0.12 From a599898061b8b76bbd313d7b3ea0a4e0e9a6e8ed Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 18 Nov 2009 16:39:47 +0000 Subject: Mediaplayer: do not exit full-screen when paused This modifies the patch which introduced "exit full screen when end of playback is reached": f9d36789 Reviewed-by: Frans Englich --- demos/qmediaplayer/mediaplayer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index aa716c5..1cca3dc 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -363,12 +363,12 @@ void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) } QMessageBox::warning(this, "Phonon Mediaplayer", m_MediaObject.errorString(), QMessageBox::Close); break; - case Phonon::PausedState: - case Phonon::StoppedState: - playButton->setIcon(playIcon); + case Phonon::StoppedState: m_videoWidget->setFullScreen(false); - + // Fall through + case Phonon::PausedState: + playButton->setIcon(playIcon); if (m_MediaObject.currentSource().type() != Phonon::MediaSource::Invalid){ playButton->setEnabled(true); rewindButton->setEnabled(true); -- cgit v0.12 From 20679e140afc2cea8ff16043d40a0da1145e4165 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 18 Nov 2009 16:50:53 +0000 Subject: Added 'fullscreen video' menu option to media player Task-number: QTBUG-5586 Reviewed-by: Frans Englich --- demos/qmediaplayer/mediaplayer.cpp | 175 +++++++++++++++++++------------------ demos/qmediaplayer/mediaplayer.h | 43 +++++++-- 2 files changed, 128 insertions(+), 90 deletions(-) diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index 1cca3dc..a396c70 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -47,109 +47,105 @@ #include "ui_settings.h" -class MediaVideoWidget : public Phonon::VideoWidget +MediaVideoWidget::MediaVideoWidget(MediaPlayer *player, QWidget *parent) : + Phonon::VideoWidget(parent), m_player(player), m_action(this) +{ + m_action.setCheckable(true); + m_action.setChecked(false); + m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return)); + m_action.setShortcutContext(Qt::WindowShortcut); + connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool))); + addAction(&m_action); + setAcceptDrops(true); +} + +void MediaVideoWidget::setFullScreen(bool enabled) { -public: - MediaVideoWidget(MediaPlayer *player, QWidget *parent = 0) : - Phonon::VideoWidget(parent), m_player(player), m_action(this) - { - m_action.setCheckable(true); - m_action.setChecked(false); - m_action.setShortcut(QKeySequence( Qt::AltModifier + Qt::Key_Return)); - m_action.setShortcutContext(Qt::WindowShortcut); - connect(&m_action, SIGNAL(toggled(bool)), SLOT(setFullScreen(bool))); - addAction(&m_action); - setAcceptDrops(true); - } + Phonon::VideoWidget::setFullScreen(enabled); + emit fullScreenChanged(enabled); +} -protected: - void mouseDoubleClickEvent(QMouseEvent *e) - { - Phonon::VideoWidget::mouseDoubleClickEvent(e); - setFullScreen(!isFullScreen()); - } +void MediaVideoWidget::mouseDoubleClickEvent(QMouseEvent *e) +{ + Phonon::VideoWidget::mouseDoubleClickEvent(e); + setFullScreen(!isFullScreen()); +} - void keyPressEvent(QKeyEvent *e) - { - if (e->key() == Qt::Key_Space && !e->modifiers()) { - m_player->playPause(); - e->accept(); - return; - } else if (e->key() == Qt::Key_Escape && !e->modifiers()) { - setFullScreen(false); - e->accept(); - return; - } - Phonon::VideoWidget::keyPressEvent(e); +void MediaVideoWidget::keyPressEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Space && !e->modifiers()) { + m_player->playPause(); + e->accept(); + return; + } else if (e->key() == Qt::Key_Escape && !e->modifiers()) { + setFullScreen(false); + e->accept(); + return; } + Phonon::VideoWidget::keyPressEvent(e); +} - bool event(QEvent *e) +bool MediaVideoWidget::event(QEvent *e) +{ + switch(e->type()) { - switch(e->type()) - { - case QEvent::Close: - //we just ignore the cose events on the video widget - //this prevents ALT+F4 from having an effect in fullscreen mode - e->ignore(); - return true; - case QEvent::MouseMove: + case QEvent::Close: + //we just ignore the cose events on the video widget + //this prevents ALT+F4 from having an effect in fullscreen mode + e->ignore(); + return true; + case QEvent::MouseMove: #ifndef QT_NO_CURSOR - unsetCursor(); + unsetCursor(); #endif - //fall through - case QEvent::WindowStateChange: - { - //we just update the state of the checkbox, in case it wasn't already - m_action.setChecked(windowState() & Qt::WindowFullScreen); - const Qt::WindowFlags flags = m_player->windowFlags(); - if (windowState() & Qt::WindowFullScreen) { - m_timer.start(1000, this); - } else { - m_timer.stop(); + //fall through + case QEvent::WindowStateChange: + { + //we just update the state of the checkbox, in case it wasn't already + m_action.setChecked(windowState() & Qt::WindowFullScreen); + const Qt::WindowFlags flags = m_player->windowFlags(); + if (windowState() & Qt::WindowFullScreen) { + m_timer.start(1000, this); + } else { + m_timer.stop(); #ifndef QT_NO_CURSOR - unsetCursor(); + unsetCursor(); #endif - } } - break; - default: - break; } - - return Phonon::VideoWidget::event(e); + break; + default: + break; } - void timerEvent(QTimerEvent *e) - { - if (e->timerId() == m_timer.timerId()) { - //let's store the cursor shape + return Phonon::VideoWidget::event(e); +} + +void MediaVideoWidget::timerEvent(QTimerEvent *e) +{ + if (e->timerId() == m_timer.timerId()) { + //let's store the cursor shape #ifndef QT_NO_CURSOR - setCursor(Qt::BlankCursor); + setCursor(Qt::BlankCursor); #endif - } - Phonon::VideoWidget::timerEvent(e); - } - - void dropEvent(QDropEvent *e) - { - m_player->handleDrop(e); } + Phonon::VideoWidget::timerEvent(e); +} - void dragEnterEvent(QDragEnterEvent *e) { - if (e->mimeData()->hasUrls()) - e->acceptProposedAction(); - } +void MediaVideoWidget::dropEvent(QDropEvent *e) +{ + m_player->handleDrop(e); +} -private: - MediaPlayer *m_player; - QBasicTimer m_timer; - QAction m_action; -}; +void MediaVideoWidget::dragEnterEvent(QDragEnterEvent *e) { + if (e->mimeData()->hasUrls()) + e->acceptProposedAction(); +} MediaPlayer::MediaPlayer(const QString &filePath, const bool hasSmallScreen) : - playButton(0), nextEffect(0), settingsDialog(0), ui(0), + playButton(0), nextEffect(0), settingsDialog(0), ui(0), m_AudioOutput(Phonon::VideoCategory), m_videoWidget(new MediaVideoWidget(this)), m_hasSmallScreen(hasSmallScreen) @@ -297,22 +293,30 @@ MediaPlayer::MediaPlayer(const QString &filePath, QAction *scaleActionCrop = scaleMenu->addAction(tr("Scale and crop")); scaleActionCrop->setCheckable(true); scaleGroup->addAction(scaleActionCrop); - - fileMenu->addSeparator(); + + m_fullScreenAction = fileMenu->addAction(tr("Full screen video")); + m_fullScreenAction->setCheckable(true); + m_fullScreenAction->setEnabled(false); // enabled by hasVideoChanged + bool b = connect(m_fullScreenAction, SIGNAL(toggled(bool)), m_videoWidget, SLOT(setFullScreen(bool))); + Q_ASSERT(b); + b = connect(m_videoWidget, SIGNAL(fullScreenChanged(bool)), m_fullScreenAction, SLOT(setChecked(bool))); + Q_ASSERT(b); + + fileMenu->addSeparator(); QAction *settingsAction = fileMenu->addAction(tr("&Settings...")); - + // Setup signal connections: connect(rewindButton, SIGNAL(clicked()), this, SLOT(rewind())); //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); openButton->setMenu(fileMenu); - + connect(playButton, SIGNAL(clicked()), this, SLOT(playPause())); connect(forwardButton, SIGNAL(clicked()), this, SLOT(forward())); //connect(openButton, SIGNAL(clicked()), this, SLOT(openFile())); connect(settingsAction, SIGNAL(triggered(bool)), this, SLOT(showSettingsDialog())); connect(openUrlAction, SIGNAL(triggered(bool)), this, SLOT(openUrl())); connect(openFileAction, SIGNAL(triggered(bool)), this, SLOT(openFile())); - + connect(m_videoWidget, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(showContextMenu(const QPoint &))); connect(&m_MediaObject, SIGNAL(metaDataChanged()), this, SLOT(updateInfo())); @@ -874,4 +878,5 @@ void MediaPlayer::hasVideoChanged(bool bHasVideo) { info->setVisible(!bHasVideo); m_videoWindow.setVisible(bHasVideo); + m_fullScreenAction->setEnabled(bHasVideo); } diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h index c181e37..00f9b54 100644 --- a/demos/qmediaplayer/mediaplayer.h +++ b/demos/qmediaplayer/mediaplayer.h @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include #include @@ -67,6 +69,36 @@ class QMenu; class Ui_settings; QT_END_NAMESPACE +class MediaPlayer; + +class MediaVideoWidget : public Phonon::VideoWidget +{ + Q_OBJECT + +public: + MediaVideoWidget(MediaPlayer *player, QWidget *parent = 0); + +public slots: + // Over-riding non-virtual Phonon::VideoWidget slot + void setFullScreen(bool); + +signals: + void fullScreenChanged(bool); + +protected: + void mouseDoubleClickEvent(QMouseEvent *e); + void keyPressEvent(QKeyEvent *e); + bool event(QEvent *e); + void timerEvent(QTimerEvent *e); + void dropEvent(QDropEvent *e); + void dragEnterEvent(QDragEnterEvent *e); + +private: + MediaPlayer *m_player; + QBasicTimer m_timer; + QAction m_action; +}; + class MediaPlayer : public QWidget { @@ -74,7 +106,7 @@ class MediaPlayer : public: MediaPlayer(const QString &, const bool hasSmallScreen); - + void dragEnterEvent(QDragEnterEvent *e); void dragMoveEvent(QDragMoveEvent *e); void dropEvent(QDropEvent *e); @@ -82,7 +114,7 @@ public: void setFile(const QString &text); void initVideoWindow(); void initSettingsDialog(); - + public slots: void openFile(); void rewind(); @@ -104,7 +136,7 @@ private slots: void stateChanged(Phonon::State newstate, Phonon::State oldstate); void effectChanged(); void showSettingsDialog(); - void showContextMenu(const QPoint &); + void showContextMenu(const QPoint& point); void bufferStatus(int percent); void openUrl(); void configureEffect(); @@ -130,11 +162,12 @@ private: Phonon::Effect *nextEffect; QDialog *settingsDialog; Ui_settings *ui; - + QAction *m_fullScreenAction; + QWidget m_videoWindow; Phonon::MediaObject m_MediaObject; Phonon::AudioOutput m_AudioOutput; - Phonon::VideoWidget *m_videoWidget; + MediaVideoWidget *m_videoWidget; Phonon::Path m_audioOutputPath; const bool m_hasSmallScreen; }; -- cgit v0.12 From 2473ab1cf217a989849190cbfa47fe312698adb9 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 18 Nov 2009 17:12:26 +0000 Subject: Added additional keyboard shortcuts to MediaPlayer These shortcuts are used for pausing video playback while in full-screen mode, and for exiting full-screen mode. They are for non-QWERTY mobile devices, which lack keys mapping to the previously existing shortcut keycodes. Reviewed-by: Frans Englich --- demos/qmediaplayer/mediaplayer.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index a396c70..4e0da3f 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -73,14 +73,23 @@ void MediaVideoWidget::mouseDoubleClickEvent(QMouseEvent *e) void MediaVideoWidget::keyPressEvent(QKeyEvent *e) { - if (e->key() == Qt::Key_Space && !e->modifiers()) { - m_player->playPause(); - e->accept(); - return; - } else if (e->key() == Qt::Key_Escape && !e->modifiers()) { - setFullScreen(false); - e->accept(); - return; + if(!e->modifiers()) { + // On non-QWERTY Symbian key-based devices, there is no space key. + // The zero key typically is marked with a space character. + if (e->key() == Qt::Key_Space || e->key() == Qt::Key_0) { + m_player->playPause(); + e->accept(); + return; + } + + // On Symbian devices, there is no key which maps to Qt::Key_Escape + // On devices which lack a backspace key (i.e. non-QWERTY devices), + // the 'C' key maps to Qt::Key_Backspace + else if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Backspace) { + setFullScreen(false); + e->accept(); + return; + } } Phonon::VideoWidget::keyPressEvent(e); } -- cgit v0.12 From c815ebbf5689118688a9a08b19c40d5fc789b17d Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Tue, 24 Nov 2009 14:53:52 +0100 Subject: Adjust qmediaplayer's settings dialog for small screens. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch done jointly by me and Jan-arve. Task-number: QTBUG-4725 Reviewed-by: Jan-Arve Sæther Reviewed-by: Frans Englich --- demos/qmediaplayer/settings.ui | 351 ++++++++++++++++++++++------------------- 1 file changed, 191 insertions(+), 160 deletions(-) diff --git a/demos/qmediaplayer/settings.ui b/demos/qmediaplayer/settings.ui index d2cedd4..03bd70e 100644 --- a/demos/qmediaplayer/settings.ui +++ b/demos/qmediaplayer/settings.ui @@ -1,283 +1,314 @@ - + + settings - - + + 0 0 - 360 - 362 + 175 + 397 - + Settings - + - - + + Video options: - + true - - - - + + + + + QComboBox::AdjustToContentsOnFirstShow + + + + Fit in view + + + + + Scale and crop + + + + + + + Contrast: - - - + + + + + 0 + 0 + + + -8 - + 8 - + Qt::Horizontal - + QSlider::TicksBelow - + 4 - - - + + + Brightness: - - - + + + -8 - + 8 - + Qt::Horizontal - + QSlider::TicksBelow - + 4 - - - + + + Saturation: - - - + + + -8 - + 8 - + Qt::Horizontal - + QSlider::TicksBelow - + 4 - - - + + + Hue: - - - + + + -8 - + 8 - + Qt::Horizontal - + QSlider::TicksBelow - + 4 - - - + + + Aspect ratio: - - - - - 180 - 0 - + + + + QComboBox::AdjustToContentsOnFirstShow - + Auto - + Stretch - + 4/3 - + 16/9 - - - + + + Scale Mode: - - - - - 180 - 0 - - - - - Fit in view - - - - - Scale and crop - - - - + scalemodeCombo + label_9 + contrastSlider + label_8 + brightnessSlider + label_7 + saturationSlider + label_2 + hueSlider + label_10 + aspectCombo + label_11 - - + + Audio options: - + true - + - + - - - + + + 0 0 - + - 90 + 10 0 - + Audio device: - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - + + + 0 0 + + + 10 + 0 + + + + QComboBox::AdjustToMinimumContentsLength + - + - - - + + + 0 0 - + - 90 + 10 0 - + Audio effect: - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - + + + 0 0 + + + 10 + 0 + + + + QComboBox::AdjustToMinimumContentsLength + - - + + false - + Setup @@ -285,123 +316,123 @@ - + - - - + + + 0 0 - + - 90 + 10 0 - + Cross fade: - + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + - - - + + + 0 0 - + -20 - + 20 - + 1 - + 2 - + 0 - + Qt::Horizontal - + QSlider::TicksBelow - + - - + + 9 - + -10 Sec - + Qt::Horizontal - + - 40 + 0 20 - - + + 9 - + 0 - + Qt::Horizontal - + - 40 + 0 20 - - + + 9 - - 10 Sec + + 10 Sec @@ -415,11 +446,11 @@ - - + + Qt::Horizontal - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -434,11 +465,11 @@ settings accept() - + 248 254 - + 157 274 @@ -450,11 +481,11 @@ settings reject() - + 316 260 - + 286 274 -- cgit v0.12 From f70ed1f2cc4cce16d6e844c961003fa7d545ed51 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 25 Nov 2009 14:44:49 +0000 Subject: Allow Symbian widget implementations to select native paint mode On the Symbian platform, the Qt raster paint engine targets an off-screen buffer owned by the Font & Bitmap server (FBSERV). When an area of the screen needs to be refreshed, the window server (WSERV) asks the control environment (CONE) to redraw the control(s) intersecting that screen region. Each Qt native widget has an associated Symbian control, whose Draw function blits the required region of the backing store via WSERV. Use cases involving Direct Screen Access (DSA) may require this behaviour to be modified, to either of the following: - Disable: the Draw function does nothing. In this case, the output of paint events, rendered to the backing store, is not blitted to the screen. This mode was introduced by change 8f445e13. - Zero fill: the Draw function fills all pixels within the redraw region with zeroes. This change allows the widget implementation to select either of these alternative modes by setting a flag in its QWExtra structure. Note that these alternative modes are only suitable for native widgets, because they act on a per-control rather than per-widget basis. Task-number: QTBUG-5467 Reviewed-by: Jason Barron --- src/gui/kernel/qapplication_s60.cpp | 23 ++++++++++++++++++++++- src/gui/kernel/qwidget_p.h | 33 +++++++++++++++++++++++++++------ src/gui/kernel/qwidget_s60.cpp | 2 +- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index fb2bc72..ae7b494 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -822,10 +822,31 @@ void QSymbianControl::Draw(const TRect& controlRect) const CFbsBitmap *bitmap = s60Surface->symbianBitmap(); CWindowGc &gc = SystemGc(); - if(!qwidget->d_func()->extraData()->disableBlit) { + switch(qwidget->d_func()->extraData()->nativePaintMode) { + case QWExtra::Disable: + // Do nothing + break; + + case QWExtra::Blit: if (qwidget->d_func()->isOpaque) gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); gc.BitBlt(controlRect.iTl, bitmap, backingStoreRect); + break; + + case QWExtra::ZeroFill: + if (Window().DisplayMode() == EColor16MA) { + gc.SetBrushStyle(CGraphicsContext::ESolidBrush); + gc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); + gc.SetBrushColor(TRgb::Color16MA(0)); + gc.Clear(controlRect); + } else { + gc.SetBrushColor(TRgb(0x000000)); + gc.Clear(controlRect); + }; + break; + + default: + Q_ASSERT(false); } } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(backingStoreRect)), QPoint()); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 66efcb5..025d703 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -230,12 +230,33 @@ struct QWExtra { #elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian uint activated : 1; // RWindowBase::Activated has been called - // If set, QSymbianControl::Draw does not blit this widget - // This is to allow, for use cases such as video, widgets which, from the Qt point - // of view, are just placeholders in the scene. For these widgets, any necessary - // drawing to the UI framebuffer is done by the relevant Symbian subsystem. For - // video rendering, this would be an MMF controller, or MDF post-processor. - uint disableBlit : 1; + /** + * Defines the behaviour of QSymbianControl::Draw. + */ + enum NativePaintMode { + /** + * Normal drawing mode: blits the required region of the backing store + * via WSERV. + */ + Blit, + + /** + * Disable drawing for this widget. + */ + Disable, + + /** + * Paint zeros into the WSERV framebuffer, using BitGDI APIs. For windows + * with an EColor16MU display mode, zero is written only into the R, G and B + * channels of the pixel. + */ + ZeroFill, + + Default = Blit + }; + + NativePaintMode nativePaintMode : 2; + #endif }; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 359df2a..d7d76df 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -881,7 +881,7 @@ void QWidgetPrivate::deleteTLSysExtra() void QWidgetPrivate::createSysExtra() { extra->activated = 0; - extra->disableBlit = 0; + extra->nativePaintMode = QWExtra::Default; } void QWidgetPrivate::deleteSysExtra() -- cgit v0.12 From bff3e6d8d810dbba29978d666949f4f3bb70503f Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 25 Nov 2009 14:45:33 +0000 Subject: Changed video widget native paint mode to zero-fill native window Certain S60 video stacks require the screen region in which video will be rendered to be painted with a zero brush (opaque black for EColor16MU displays; transparent black for EColor16MA / EColor16MAP). Task-number: QTBUG-5467 Reviewed-by: Jason Barron --- src/3rdparty/phonon/mmf/objectdump_symbian.cpp | 2 +- src/3rdparty/phonon/mmf/videooutput.cpp | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/phonon/mmf/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/objectdump_symbian.cpp index 2efebdb..edad537 100644 --- a/src/3rdparty/phonon/mmf/objectdump_symbian.cpp +++ b/src/3rdparty/phonon/mmf/objectdump_symbian.cpp @@ -46,7 +46,7 @@ QList QAnnotatorWidget::annotation(const QObject& object) stream << "widget (Symbian): "; stream << "activated " << extra->activated << ' '; - stream << "disableBlit " << extra->disableBlit << ' '; + stream << "nativePaintMode " << extra->nativePaintMode << ' '; stream.flush(); result.append(array); diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index ddf30de..f16f332 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -72,12 +72,7 @@ MMF::VideoOutput::VideoOutput setAttribute(Qt::WA_NoSystemBackground, true); setAutoFillBackground(false); - // Causes QSymbianControl::Draw not to BitBlt this widget's region of the - // backing store. Since the backing store is (by default) a 16MU bitmap, - // blitting it results in this widget's screen region in the final - // framebuffer having opaque alpha values. This in turn causes the video - // to be invisible when running on the target device. - qt_widget_private(this)->extraData()->disableBlit = true; + qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill; getVideoWindowRect(); registerForAncestorMoved(); -- cgit v0.12 From e9704a297f788bb79b2a89e9b16214443931af5d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 25 Nov 2009 14:47:32 +0000 Subject: Symbian control invokes slots before and after native draw ops Direct Screen Access (DSA) allows a client to request notification from the window server when drawing is performed by other threads, into a specified region of the screen. This allows DSA rendering - for example video - to be suspended when notifications are drawn, preventing the video content from overwriting the notification. If the drawing originates from the same thread as that which holds the DSA session, DSA must be suspended while drawing takes place. This change allows a widget to request notification when native drawing is about to be performed by QSymbianControl::Draw. Task-number: QTBUG-5467 Reviewed-by: Jason Barron --- src/gui/kernel/qapplication_s60.cpp | 19 +++++++++++++++++++ src/gui/kernel/qwidget_p.h | 9 +++++++++ src/gui/kernel/qwidget_s60.cpp | 1 + 3 files changed, 29 insertions(+) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index ae7b494..d1471eb 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -812,6 +812,12 @@ void QSymbianControl::Draw(const TRect& controlRect) const if (!engine) return; + const bool sendNativePaintEvents = qwidget->d_func()->extraData()->receiveNativePaintEvents; + if (sendNativePaintEvents) { + const QRect r = qt_TRect2QRect(controlRect); + QMetaObject::invokeMethod(qwidget, "beginNativePaintEvent", Qt::DirectConnection, Q_ARG(QRect, r)); + } + // Map source rectangle into coordinates of the backing store. const QPoint controlBase(controlRect.iTl.iX, controlRect.iTl.iY); const QPoint backingStoreBase = qwidget->mapTo(qwidget->window(), controlBase); @@ -851,6 +857,19 @@ void QSymbianControl::Draw(const TRect& controlRect) const } else { surface->flush(qwidget, QRegion(qt_TRect2QRect(backingStoreRect)), QPoint()); } + + if (sendNativePaintEvents) { + const QRect r = qt_TRect2QRect(controlRect); + // The draw ops aren't actually sent to WSERV until the graphics + // context is deactivated, which happens in the function calling + // this one. We therefore delay the delivery of endNativePaintEvent, + // to ensure that drawing has completed by the time the widget + // receives the event. Note that, if the widget needs to ensure + // that the draw ops have actually been executed into the output + // framebuffer, a call to RWsSession::Flush is required in the + // endNativePaintEvent implementation. + QMetaObject::invokeMethod(qwidget, "endNativePaintEvent", Qt::QueuedConnection, Q_ARG(QRect, r)); + } } void QSymbianControl::SizeChanged() diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 025d703..04cf4bb 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -257,6 +257,15 @@ struct QWExtra { NativePaintMode nativePaintMode : 2; + /** + * If this bit is set, each native widget receives the signals from the + * Symbian control immediately before and immediately after draw ops are + * sent to the window server for this control: + * void beginNativePaintEvent(const QRect &paintRect); + * void endNativePaintEvent(const QRect &paintRect); + */ + uint receiveNativePaintEvents : 1; + #endif }; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index d7d76df..37614c7 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -882,6 +882,7 @@ void QWidgetPrivate::createSysExtra() { extra->activated = 0; extra->nativePaintMode = QWExtra::Default; + extra->receiveNativePaintEvents = 0; } void QWidgetPrivate::deleteSysExtra() -- cgit v0.12 From e84f5486724bf11d2a20e405a30db618f8c48e33 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 25 Nov 2009 14:48:03 +0000 Subject: Suspend DSA while drawing is in progress In order to prevent flicker or - on some versions of the platform - video disappearing from the screen altogether, the video controller's DSA session must be suspended while the window control is redrawn. Task-number: QTBUG-5467 Reviewed-by: Jason Barron --- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 57 ++++++++++++++++++++++++++++- src/3rdparty/phonon/mmf/mmf_videoplayer.h | 7 ++++ src/3rdparty/phonon/mmf/videooutput.cpp | 16 ++++++++ src/3rdparty/phonon/mmf/videooutput.h | 6 +++ 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 2059fbe..0fd4d67 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -50,6 +50,8 @@ MMF::VideoPlayer::VideoPlayer() , m_window(0) , m_totalTime(0) , m_pendingChanges(false) + , m_dsaActive(false) + , m_dsaWasActive(false) { construct(); } @@ -61,6 +63,7 @@ MMF::VideoPlayer::VideoPlayer(const AbstractPlayer& player) , m_window(0) , m_totalTime(0) , m_pendingChanges(false) + , m_dsaActive(false) { construct(); } @@ -86,6 +89,9 @@ void MMF::VideoPlayer::construct() )) ); + // CVideoPlayerUtility::NewL starts DSA + m_dsaActive = true; + if (KErrNone != err) changeState(ErrorState); @@ -349,6 +355,18 @@ void MMF::VideoPlayer::initVideoOutput() Q_ASSERT(connected); connected = connect( + m_videoOutput, SIGNAL(beginVideoWindowNativePaint()), + this, SLOT(suspendDirectScreenAccess()) + ); + Q_ASSERT(connected); + + connected = connect( + m_videoOutput, SIGNAL(endVideoWindowNativePaint()), + this, SLOT(resumeDirectScreenAccess()) + ); + Q_ASSERT(connected); + + connected = connect( m_videoOutput, SIGNAL(aspectRatioChanged()), this, SLOT(aspectRatioChanged()) ); @@ -370,12 +388,48 @@ void MMF::VideoPlayer::videoWindowChanged() TRACE_ENTRY("state %d", state()); m_window = m_videoOutput->videoWindow(); - updateVideoRect(); TRACE_EXIT_0(); } +void MMF::VideoPlayer::suspendDirectScreenAccess() +{ + m_dsaWasActive = stopDirectScreenAccess(); +} + +void MMF::VideoPlayer::resumeDirectScreenAccess() +{ + if(m_dsaWasActive) { + startDirectScreenAccess(); + m_dsaWasActive = false; + } +} + +void MMF::VideoPlayer::startDirectScreenAccess() +{ + if(!m_dsaActive) { + TRAPD(err, m_player->StartDirectScreenAccessL()); + if(KErrNone == err) + m_dsaActive = true; + else + setError(NormalError); + } +} + +bool MMF::VideoPlayer::stopDirectScreenAccess() +{ + const bool dsaWasActive = m_dsaActive; + if(m_dsaActive) { + TRAPD(err, m_player->StopDirectScreenAccessL()); + if(KErrNone == err) + m_dsaActive = false; + else + setError(NormalError); + } + return dsaWasActive; +} + // Helper function for aspect ratio / scale mode handling QSize scaleToAspect(const QSize& srcRect, int aspectWidth, int aspectHeight) { @@ -553,6 +607,7 @@ void MMF::VideoPlayer::applyVideoWindowChange() TRACE("SetDisplayWindowL err %d", err); setError(NormalError); } else { + m_dsaActive = true; TRAP(err, m_player->SetScaleFactorL(m_scaleWidth, m_scaleHeight, antialias)); if(KErrNone != err) { TRACE("SetScaleFactorL (2) err %d", err); diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.h b/src/3rdparty/phonon/mmf/mmf_videoplayer.h index 599bb88..abb1da8 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.h +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.h @@ -72,6 +72,8 @@ public Q_SLOTS: void videoWindowChanged(); void aspectRatioChanged(); void scaleModeChanged(); + void suspendDirectScreenAccess(); + void resumeDirectScreenAccess(); private: void construct(); @@ -89,6 +91,9 @@ private: void applyPendingChanges(); void applyVideoWindowChange(); + void startDirectScreenAccess(); + bool stopDirectScreenAccess(); + // AbstractMediaPlayer virtual int numberOfMetaDataEntries() const; virtual QPair metaDataEntry(int index) const; @@ -111,6 +116,8 @@ private: qint64 m_totalTime; bool m_pendingChanges; + bool m_dsaActive; + bool m_dsaWasActive; }; diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index f16f332..119dcb1 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -34,6 +34,8 @@ along with this library. If not, see . #include +#include // for CCoeEnv + QT_BEGIN_NAMESPACE using namespace Phonon; @@ -73,6 +75,7 @@ MMF::VideoOutput::VideoOutput setAutoFillBackground(false); qt_widget_private(this)->extraData()->nativePaintMode = QWExtra::ZeroFill; + qt_widget_private(this)->extraData()->receiveNativePaintEvents = true; getVideoWindowRect(); registerForAncestorMoved(); @@ -283,5 +286,18 @@ void MMF::VideoOutput::dump() const #endif } +void MMF::VideoOutput::beginNativePaintEvent(const QRect& /*controlRect*/) +{ + emit beginVideoWindowNativePaint(); +} + +void MMF::VideoOutput::endNativePaintEvent(const QRect& /*controlRect*/) +{ + // Ensure that draw ops are executed into the WSERV output framebuffer + CCoeEnv::Static()->WsSession().Flush(); + + emit endVideoWindowNativePaint(); +} + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/videooutput.h b/src/3rdparty/phonon/mmf/videooutput.h index 6dfe69d..2788401 100644 --- a/src/3rdparty/phonon/mmf/videooutput.h +++ b/src/3rdparty/phonon/mmf/videooutput.h @@ -63,10 +63,16 @@ public: // Debugging output void dump() const; +public Q_SLOTS: + void beginNativePaintEvent(const QRect& /*controlRect*/); + void endNativePaintEvent(const QRect& /*controlRect*/); + Q_SIGNALS: void videoWindowChanged(); void aspectRatioChanged(); void scaleModeChanged(); + void beginVideoWindowNativePaint(); + void endVideoWindowNativePaint(); protected: // Override QWidget functions -- cgit v0.12 From 3ac80bf663a2a8d69b860c44b0285fe72750da58 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 25 Nov 2009 09:09:20 +0000 Subject: Tidied up logic of retrieving video window in Phonon MMF backend Task-number: QTBUG-5467 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index 0fd4d67..be58e91 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -321,8 +321,7 @@ void MMF::VideoPlayer::getVideoWindow() m_videoOutput->dump(); initVideoOutput(); - m_window = m_videoOutput->videoWindow(); - updateVideoRect(); + videoWindowChanged(); } else // Top-level window m_window = QApplication::activeWindow()->effectiveWinId()->DrawableWindow(); -- cgit v0.12 From 58d8c744dbcde532270b62484ea16d865589bc38 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 25 Nov 2009 09:10:19 +0000 Subject: Clip video rect to physical screen dimensions The CVideoPlayerUtility API requires both a native window handle and an absolute screen rectangle in order to define the location of the rendered video output. On certain devices, such as the Nokia E75, which runs S60 3.2, if the absolute rectangle extends outside the physical screen extent, no video is rendered. This change works around this defect in the platform by clipping the video rectangle to the physical screen extent. Task-number: QTBUG-5467 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/mmf_videoplayer.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp index be58e91..b6f53ae 100644 --- a/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/mmf_videoplayer.cpp @@ -446,7 +446,18 @@ QSize scaleToAspect(const QSize& srcRect, int aspectWidth, int aspectHeight) void MMF::VideoPlayer::updateVideoRect() { QRect videoRect; - const QRect windowRect = m_videoOutput->videoWindowRect(); + QRect windowRect = m_videoOutput->videoWindowRect(); + + // Clip to physical window size + // This is due to a defect in the layout when running on S60 3.2, which + // results in the rectangle of the video widget extending outside the + // screen in certain circumstances. These include the initial startup + // of the mediaplayer demo in portrait mode. When this rectangle is + // passed to the CVideoPlayerUtility, no video is rendered. + const TSize screenSize = m_screenDevice.SizeInPixels(); + const QRect screenRect(0, 0, screenSize.iWidth, screenSize.iHeight); + windowRect = windowRect.intersected(screenRect); + const QSize windowSize = windowRect.size(); // Calculate size of smallest rect which contains video frame size -- cgit v0.12