diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-03-17 16:06:01 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-04-06 08:07:46 +0000 |
commit | 606cb4706ac770e84d5abe3936d1faa596d1815e (patch) | |
tree | 62e089ad0f9c54767473d457c68f4dc589530bd8 /src/multimedia | |
parent | 76aa4e1dd1921441fd34a3907a90e633a2f74911 (diff) |
Convert QGraphicsVideoItem to use QVideoSink
Change-Id: Id9af7457f590ed6387c36473e73c244ef44f8f8a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r-- | src/multimedia/video/qvideosink.cpp | 13 | ||||
-rw-r--r-- | src/multimedia/video/qvideosink.h | 3 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/multimedia/video/qvideosink.cpp b/src/multimedia/video/qvideosink.cpp index e00a39abb..931a4e5ab 100644 --- a/src/multimedia/video/qvideosink.cpp +++ b/src/multimedia/video/qvideosink.cpp @@ -75,6 +75,7 @@ public: int contrast = 0; int saturation = 0; int hue = 0; + Qt::BGMode backgroundMode = Qt::OpaqueMode; QMatrix4x4 transform; float opacity = 1.; }; @@ -206,6 +207,16 @@ void QVideoSink::setOpacity(float opacity) d->opacity = opacity; } +Qt::BGMode QVideoSink::backgroundMode() const +{ + return d->backgroundMode; +} + +void QVideoSink::setBackgroundMode(Qt::BGMode mode) +{ + d->backgroundMode = mode; +} + void QVideoSink::render(const QVideoFrame &frame) { Q_UNUSED(frame); @@ -237,7 +248,7 @@ void QVideoSink::paint(QPainter *painter, const QVideoFrame &f) targetRect = QRect(0, 0, size.width(), size.height()); targetRect.moveCenter(d->targetRect.center()); // we might not be drawing every pixel, fill the leftover black - if (d->targetRect != targetRect) { + if (d->backgroundMode == Qt::OpaqueMode && d->targetRect != targetRect) { if (targetRect.top() > d->targetRect.top()) { QRectF top(d->targetRect.left(), d->targetRect.top(), d->targetRect.width(), targetRect.top() - d->targetRect.top()); painter->fillRect(top, Qt::black); diff --git a/src/multimedia/video/qvideosink.h b/src/multimedia/video/qvideosink.h index 025057171..62f21fba7 100644 --- a/src/multimedia/video/qvideosink.h +++ b/src/multimedia/video/qvideosink.h @@ -109,6 +109,9 @@ public: float opacity() const; void setOpacity(float opacity); + Qt::BGMode backgroundMode() const; + void setBackgroundMode(Qt::BGMode mode); + // Thread safe void render(const QVideoFrame &frame); |