From d19ad17aed345433ab34cf165ccd7c7ddf917c19 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 26 Mar 2010 12:48:13 +1000 Subject: Support the Expanding aspect ratio mode in the gstreamer window control. Reviewed-by: Dmytro Poplavskiy Task-number: QTBUG-9118 --- .../gstreamer/qgstreamervideooverlay.cpp | 19 +++++++++++++++++-- .../mediaservices/gstreamer/qx11videosurface.cpp | 10 ++++++++++ .../mediaservices/gstreamer/qx11videosurface.h | 3 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp index 427d514..f381f7f 100644 --- a/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp +++ b/src/plugins/mediaservices/gstreamer/qgstreamervideooverlay.cpp @@ -192,21 +192,36 @@ void QGstreamerVideoOverlay::surfaceFormatChanged() void QGstreamerVideoOverlay::setScaledDisplayRect() { + QRect formatViewport = m_surface->surfaceFormat().viewport(); + switch (m_aspectRatioMode) { case Qt::KeepAspectRatio: { - QSize size = m_surface->surfaceFormat().viewport().size(); - + QSize size = m_surface->surfaceFormat().sizeHint(); size.scale(m_displayRect.size(), Qt::KeepAspectRatio); QRect rect(QPoint(0, 0), size); rect.moveCenter(m_displayRect.center()); m_surface->setDisplayRect(rect); + m_surface->setViewport(formatViewport); } break; case Qt::IgnoreAspectRatio: m_surface->setDisplayRect(m_displayRect); + m_surface->setViewport(formatViewport); + break; + case Qt::KeepAspectRatioByExpanding: + { + QSize size = m_displayRect.size(); + size.scale(m_surface->surfaceFormat().sizeHint(), Qt::KeepAspectRatio); + + QRect viewport(QPoint(0, 0), size); + viewport.moveCenter(formatViewport.center()); + + m_surface->setDisplayRect(m_displayRect); + m_surface->setViewport(viewport); + } break; }; } diff --git a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp b/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp index cbd5a76..70b8527 100644 --- a/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp +++ b/src/plugins/mediaservices/gstreamer/qx11videosurface.cpp @@ -213,6 +213,16 @@ void QX11VideoSurface::setDisplayRect(const QRect &rect) m_displayRect = rect; } +QRect QX11VideoSurface::viewport() const +{ + return m_viewport; +} + +void QX11VideoSurface::setViewport(const QRect &rect) +{ + m_viewport = rect; +} + int QX11VideoSurface::brightness() const { return getAttribute("XV_BRIGHTNESS", m_brightnessRange.first, m_brightnessRange.second); diff --git a/src/plugins/mediaservices/gstreamer/qx11videosurface.h b/src/plugins/mediaservices/gstreamer/qx11videosurface.h index 1be963e..10f79a6 100644 --- a/src/plugins/mediaservices/gstreamer/qx11videosurface.h +++ b/src/plugins/mediaservices/gstreamer/qx11videosurface.h @@ -67,6 +67,9 @@ public: QRect displayRect() const; void setDisplayRect(const QRect &rect); + QRect viewport() const; + void setViewport(const QRect &rect); + int brightness() const; void setBrightness(int brightness); -- cgit v0.12