diff options
author | Thomas McGuire <thomas.mcguire.qnx@kdab.com> | 2013-04-25 16:06:08 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-07 15:02:15 +0200 |
commit | 0d9526b5c9740d3d77d9c4d8403a6f9e7370643f (patch) | |
tree | befde05e75607014919cadf2243ef36fa39346c1 /src/imports/multimedia/qdeclarativevideooutput.cpp | |
parent | 2eac932747682e4fcc374843e764a377a84e8a3c (diff) |
VideoOutput: Take the surface's viewport into account
Task-Number: QTBUG-30410
Change-Id: I480ce0bcd7ec136e54b5bfc5fec0e901141b72d8
Reviewed-by: Josh Faust <jfaust@suitabletech.com>
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
Diffstat (limited to 'src/imports/multimedia/qdeclarativevideooutput.cpp')
-rw-r--r-- | src/imports/multimedia/qdeclarativevideooutput.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/imports/multimedia/qdeclarativevideooutput.cpp b/src/imports/multimedia/qdeclarativevideooutput.cpp index 1b4b9cd5b..653d45b6d 100644 --- a/src/imports/multimedia/qdeclarativevideooutput.cpp +++ b/src/imports/multimedia/qdeclarativevideooutput.cpp @@ -436,13 +436,18 @@ QRectF QDeclarativeVideoOutput::contentRect() const This property holds the area of the source video content that is considered for rendering. The - values are in source pixel coordinates. + values are in source pixel coordinates, adjusted for + the source's pixel aspect ratio. Note that typically the top left corner of this rectangle will be \c {0,0} while the width and height will be the - width and height of the input content. + width and height of the input content. Only when the video + source has a viewport set, these values will differ. The orientation setting does not affect this rectangle. + + \sa QVideoSurfaceFormat::pixelAspectRatio() + \sa QVideoSurfaceFormat::viewport() */ QRectF QDeclarativeVideoOutput::sourceRect() const { @@ -451,7 +456,19 @@ QRectF QDeclarativeVideoOutput::sourceRect() const if (!qIsDefaultAspect(m_orientation)) { size.transpose(); } - return QRectF(QPointF(), size); // XXX ignores viewport + + // No backend? Just assume no viewport. + if (!m_nativeSize.isValid() || !m_backend) { + return QRectF(QPointF(), size); + } + + // Take the viewport into account for the top left position. + // m_nativeSize is already adjusted to the viewport, as it originats + // from QVideoSurfaceFormat::sizeHint(), which includes pixel aspect + // ratio and viewport. + const QRectF viewport = m_backend->adjustedViewport(); + Q_ASSERT(viewport.size() == size); + return QRectF(viewport.topLeft(), size); } /*! |