diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-03-30 00:42:43 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2010-03-30 00:45:28 (GMT) |
commit | 3546fcbd83b2a255894e6ad9aa673f6feaba6fe7 (patch) | |
tree | 90b5799bf329f3c608d909f11168e9ddedccf025 /src | |
parent | e19d9a53afa0a50d0ca85a144add9d546aac5b39 (diff) | |
download | Qt-3546fcbd83b2a255894e6ad9aa673f6feaba6fe7.zip Qt-3546fcbd83b2a255894e6ad9aa673f6feaba6fe7.tar.gz Qt-3546fcbd83b2a255894e6ad9aa673f6feaba6fe7.tar.bz2 |
Don't fill the video widget borders or background by default.
Can be enabled by settings setAutoFillBackground or the
Qt::WA_OpaquePaintEvent to true.
Reviewed-by: Dmytro Poplavskiy
Diffstat (limited to 'src')
-rw-r--r-- | src/multimedia/base/qvideowidget.cpp | 33 | ||||
-rw-r--r-- | src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp | 1 |
2 files changed, 27 insertions, 7 deletions
diff --git a/src/multimedia/base/qvideowidget.cpp b/src/multimedia/base/qvideowidget.cpp index 3820af9..467d7c6 100644 --- a/src/multimedia/base/qvideowidget.cpp +++ b/src/multimedia/base/qvideowidget.cpp @@ -218,13 +218,23 @@ void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event) { QPainter painter(m_widget); + if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { + QRegion borderRegion = event->region(); + borderRegion = borderRegion.subtracted(m_boundingRect); + + QBrush brush = m_widget->palette().window(); + + QVector<QRect> rects = borderRegion.rects(); + for (QVector<QRect>::iterator it = rects.begin(), end = rects.end(); it != end; ++it) { + painter.fillRect(*it, brush); + } + } + if (m_surface->isActive() && m_boundingRect.intersects(event->rect())) { m_surface->paint(&painter, m_boundingRect, m_sourceRect); m_surface->setReady(true); } else { - painter.fillRect(event->rect(), m_widget->palette().background()); - #if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) if (m_updatePaintDevice && (painter.paintEngine()->type() == QPaintEngine::OpenGL || painter.paintEngine()->type() == QPaintEngine::OpenGL2)) { @@ -239,6 +249,7 @@ void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event) } #endif } + } void QRendererVideoWidgetBackend::formatChanged(const QVideoSurfaceFormat &format) @@ -364,6 +375,12 @@ void QWindowVideoWidgetBackend::resizeEvent(QResizeEvent *) void QWindowVideoWidgetBackend::paintEvent(QPaintEvent *event) { + if (m_widget->testAttribute(Qt::WA_OpaquePaintEvent)) { + QPainter painter(m_widget); + + painter.fillRect(event->rect(), m_widget->palette().window()); + } + m_windowControl->repaint(); event->accept(); @@ -545,10 +562,6 @@ QVideoWidget::QVideoWidget(QWidget *parent) , d_ptr(new QVideoWidgetPrivate) { d_ptr->q_ptr = this; - - QPalette palette = QWidget::palette(); - palette.setColor(QPalette::Background, Qt::black); - setPalette(palette); } /*! @@ -602,6 +615,7 @@ void QVideoWidget::setMediaObject(QMediaObject *object) QVideoWidgetControl *widgetControl = qobject_cast<QVideoWidgetControl *>( d->service->control(QVideoWidgetControl_iid)); + widgetControl = 0; if (widgetControl != 0) { d->widgetBackend = new QVideoWidgetControlBackend(widgetControl, this); } else { @@ -913,8 +927,13 @@ void QVideoWidget::paintEvent(QPaintEvent *event) { Q_D(QVideoWidget); - if (d->currentBackend) + if (d->currentBackend) { d->currentBackend->paintEvent(event); + } else if (testAttribute(Qt::WA_OpaquePaintEvent)) { + QPainter painter(this); + + painter.fillRect(event->rect(), palette().window()); + } } #include "moc_qvideowidget.cpp" diff --git a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp index e25dd99..1c6df2c 100644 --- a/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp +++ b/src/plugins/mediaservices/directshow/mediaplayer/vmr9videowindowcontrol.cpp @@ -61,6 +61,7 @@ Vmr9VideoWindowControl::Vmr9VideoWindowControl(QObject *parent) if (IVMRFilterConfig9 *config = com_cast<IVMRFilterConfig9>(m_filter, IID_IVMRFilterConfig9)) { config->SetRenderingMode(VMR9Mode_Windowless); config->SetNumberOfStreams(1); + config->SetRenderingPrefs(RenderPrefs9_DoNotRenderBorder); config->Release(); } } |