summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-04-12 14:05:25 +0200
committerLars Knoll <lars.knoll@qt.io>2021-04-16 10:50:06 +0000
commita9a332e265528d12ad05c5b3be23118ab712cc3d (patch)
treeb10e19d8b8ca07f9d5ca77ce66b039b3994843a8
parent301c0f6fd94e0459fd06cac70f25bbbaea1cc92e (diff)
Clean up QVideoSink and it's platform implementation
* Normalize ranges of brightness and friends to [-1, 1] and use floating point numbers. * Remove getters for values from the platform API, rather store them in the frontend. This simplifies the work that needs to be done on the backend side. Change-Id: I8d63dacaa6b2873b33e17fcd7831e41173109a7e Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Doris Verria <doris.verria@qt.io>
-rw-r--r--examples/multimediawidgets/player/player.cpp8
-rw-r--r--src/multimedia/platform/darwin/avfvideosink.mm40
-rw-r--r--src/multimedia/platform/darwin/avfvideosink_p.h31
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstreamervideooverlay.cpp170
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstreamervideooverlay_p.h15
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstreamervideosink.cpp48
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstreamervideosink_p.h20
-rw-r--r--src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp46
-rw-r--r--src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol_p.h25
-rw-r--r--src/multimedia/platform/qplatformvideosink.cpp64
-rw-r--r--src/multimedia/platform/qplatformvideosink_p.h19
-rw-r--r--src/multimedia/platform/windows/evr/evrvideowindowcontrol.cpp83
-rw-r--r--src/multimedia/platform/windows/evr/evrvideowindowcontrol_p.h31
-rw-r--r--src/multimedia/video/qvideosink.cpp72
-rw-r--r--src/multimedia/video/qvideosink.h18
-rw-r--r--src/multimediawidgets/qvideowidget.cpp40
-rw-r--r--src/multimediawidgets/qvideowidget.h32
-rw-r--r--tests/auto/integration/qdeclarativevideooutput_window/tst_qdeclarativevideooutput_window.cpp34
18 files changed, 211 insertions, 585 deletions
diff --git a/examples/multimediawidgets/player/player.cpp b/examples/multimediawidgets/player/player.cpp
index fbdac1263..f0c48cd18 100644
--- a/examples/multimediawidgets/player/player.cpp
+++ b/examples/multimediawidgets/player/player.cpp
@@ -537,25 +537,25 @@ void Player::showColorDialog()
QSlider *brightnessSlider = new QSlider(Qt::Horizontal);
brightnessSlider->setRange(-100, 100);
brightnessSlider->setValue(m_videoWidget->brightness());
- connect(brightnessSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setBrightness);
+ connect(brightnessSlider, &QSlider::sliderMoved, [this](int b) { m_videoWidget->setBrightness(b/100.); });
connect(m_videoWidget, &QVideoWidget::brightnessChanged, brightnessSlider, &QSlider::setValue);
QSlider *contrastSlider = new QSlider(Qt::Horizontal);
contrastSlider->setRange(-100, 100);
contrastSlider->setValue(m_videoWidget->contrast());
- connect(contrastSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setContrast);
+ connect(contrastSlider, &QSlider::sliderMoved, [this](int c) { m_videoWidget->setContrast(c/100.); });
connect(m_videoWidget, &QVideoWidget::contrastChanged, contrastSlider, &QSlider::setValue);
QSlider *hueSlider = new QSlider(Qt::Horizontal);
hueSlider->setRange(-100, 100);
hueSlider->setValue(m_videoWidget->hue());
- connect(hueSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setHue);
+ connect(hueSlider, &QSlider::sliderMoved, [this](int h) { m_videoWidget->setHue(h/100.); });
connect(m_videoWidget, &QVideoWidget::hueChanged, hueSlider, &QSlider::setValue);
QSlider *saturationSlider = new QSlider(Qt::Horizontal);
saturationSlider->setRange(-100, 100);
saturationSlider->setValue(m_videoWidget->saturation());
- connect(saturationSlider, &QSlider::sliderMoved, m_videoWidget, &QVideoWidget::setSaturation);
+ connect(saturationSlider, &QSlider::sliderMoved, [this](int s) { m_videoWidget->setSaturation(s/100.); });
connect(m_videoWidget, &QVideoWidget::saturationChanged, saturationSlider, &QSlider::setValue);
QFormLayout *layout = new QFormLayout;
diff --git a/src/multimedia/platform/darwin/avfvideosink.mm b/src/multimedia/platform/darwin/avfvideosink.mm
index b0d727038..f28ff98c4 100644
--- a/src/multimedia/platform/darwin/avfvideosink.mm
+++ b/src/multimedia/platform/darwin/avfvideosink.mm
@@ -100,8 +100,8 @@ QRect AVFVideoSink::displayRect() const
void AVFVideoSink::setDisplayRect(const QRect &rect)
{
- if (m_displayRect == rect)
- return;
+ Q_ASSERT(m_displayRect != rect);
+
m_displayRect = rect;
if (m_interface)
m_interface->updateLayerBounds();
@@ -114,8 +114,8 @@ bool AVFVideoSink::isFullScreen() const
void AVFVideoSink::setFullScreen(bool fullScreen)
{
- if (fullScreen == m_fullscreen)
- return;
+ Q_ASSERT(fullScreen != m_fullscreen);
+
m_fullscreen = fullScreen;
if (m_interface)
m_interface->reconfigure();
@@ -142,49 +142,29 @@ Qt::AspectRatioMode AVFVideoSink::aspectRatioMode() const
void AVFVideoSink::setAspectRatioMode(Qt::AspectRatioMode mode)
{
- if (m_aspectRatioMode == mode)
- return;
+ Q_ASSERT(m_aspectRatioMode != mode);
+
m_aspectRatioMode = mode;
if (m_interface)
m_interface->updateAspectRatio();
}
-int AVFVideoSink::brightness() const
-{
- return m_brightness;
-}
-
-void AVFVideoSink::setBrightness(int brightness)
+void AVFVideoSink::setBrightness(float brightness)
{
m_brightness = brightness;
}
-int AVFVideoSink::contrast() const
-{
- return m_contrast;
-}
-
-void AVFVideoSink::setContrast(int contrast)
+void AVFVideoSink::setContrast(float contrast)
{
m_contrast = contrast;
}
-int AVFVideoSink::hue() const
-{
- return m_hue;
-}
-
-void AVFVideoSink::setHue(int hue)
+void AVFVideoSink::setHue(float hue)
{
m_hue = hue;
}
-int AVFVideoSink::saturation() const
-{
- return m_saturation;
-}
-
-void AVFVideoSink::setSaturation(int saturation)
+void AVFVideoSink::setSaturation(float saturation)
{
m_saturation = saturation;
}
diff --git a/src/multimedia/platform/darwin/avfvideosink_p.h b/src/multimedia/platform/darwin/avfvideosink_p.h
index a5b5ade35..c8228d3b6 100644
--- a/src/multimedia/platform/darwin/avfvideosink_p.h
+++ b/src/multimedia/platform/darwin/avfvideosink_p.h
@@ -81,34 +81,27 @@ public:
QVideoSink::GraphicsType graphicsType() const override { return m_graphicsType; }
bool setGraphicsType(QVideoSink::GraphicsType type) override;
- WId winId() const override;
+ WId winId() const;
void setWinId(WId id) override;
void setRhi(QRhi *rhi) override;
- QRect displayRect() const override;
+ QRect displayRect() const;
void setDisplayRect(const QRect &rect) override;
- bool isFullScreen() const override;
+ bool isFullScreen() const;
void setFullScreen(bool fullScreen) override;
QSize nativeSize() const override;
void setNativeSize(QSize size);
- Qt::AspectRatioMode aspectRatioMode() const override;
+ Qt::AspectRatioMode aspectRatioMode() const;
void setAspectRatioMode(Qt::AspectRatioMode mode) override;
- int brightness() const override;
- void setBrightness(int brightness) override;
-
- int contrast() const override;
- void setContrast(int contrast) override;
-
- int hue() const override;
- void setHue(int hue) override;
-
- int saturation() const override;
- void setSaturation(int saturation) override;
+ void setBrightness(float brightness) override;
+ void setContrast(float contrast) override;
+ void setHue(float hue) override;
+ void setSaturation(float saturation) override;
void setLayer(CALayer *playerLayer);
@@ -125,10 +118,10 @@ private:
QSize m_nativeSize;
QRect m_displayRect;
bool m_fullscreen = false;
- int m_brightness = 0;
- int m_contrast = 0;
- int m_hue = 0;
- int m_saturation = 0;
+ float m_brightness = 0;
+ float m_contrast = 0;
+ float m_hue = 0;
+ float m_saturation = 0;
Qt::AspectRatioMode m_aspectRatioMode = Qt::KeepAspectRatio;
};
diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay.cpp b/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay.cpp
index 5db0497e9..7c017a108 100644
--- a/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay.cpp
+++ b/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay.cpp
@@ -74,15 +74,10 @@ public:
virtual bool hasShowPrerollFrame() const = 0;
virtual void reset() = 0;
- virtual int brightness() const = 0;
- virtual bool setBrightness(int brightness) = 0;
- virtual int contrast() const = 0;
- virtual bool setContrast(int contrast) = 0;
- virtual int hue() const = 0;
- virtual bool setHue(int hue) = 0;
- virtual int saturation() const = 0;
- virtual bool setSaturation(int saturation) = 0;
- virtual Qt::AspectRatioMode aspectRatioMode() const = 0;
+ virtual bool setBrightness(float brightness) = 0;
+ virtual bool setContrast(float contrast) = 0;
+ virtual bool setHue(float hue) = 0;
+ virtual bool setSaturation(float saturation) = 0;
virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0;
};
@@ -115,90 +110,42 @@ public:
setSaturation(m_saturation);
}
- int brightness() const override
- {
- int brightness = 0;
- if (m_hasBrightness)
- brightness = m_videoSink.getInt("brightness");
-
- return brightness / 10;
- }
-
- bool setBrightness(int brightness) override
+ bool setBrightness(float brightness) override
{
m_brightness = brightness;
if (m_hasBrightness)
- m_videoSink.set("brightness", brightness * 10);
+ m_videoSink.set("brightness", brightness * 1000);
return m_hasBrightness;
}
- int contrast() const override
- {
- int contrast = 0;
- if (m_hasContrast)
- contrast = m_videoSink.getInt("contrast");
-
- return contrast / 10;
- }
-
- bool setContrast(int contrast) override
+ bool setContrast(float contrast) override
{
m_contrast = contrast;
if (m_hasContrast)
- m_videoSink.set("contrast", contrast * 10);
+ m_videoSink.set("contrast", contrast * 1000);
return m_hasContrast;
}
- int hue() const override
- {
- int hue = 0;
- if (m_hasHue)
- hue = m_videoSink.getInt("hue");
-
- return hue / 10;
- }
-
- bool setHue(int hue) override
+ bool setHue(float hue) override
{
m_hue = hue;
if (m_hasHue)
- m_videoSink.set("hue", hue * 10);
+ m_videoSink.set("hue", hue * 1000);
return m_hasHue;
}
- int saturation() const override
- {
- int saturation = 0;
- if (m_hasSaturation)
- saturation = m_videoSink.getInt("saturation");
-
- return saturation / 10;
- }
-
- bool setSaturation(int saturation) override
+ bool setSaturation(float saturation) override
{
m_saturation = saturation;
if (m_hasSaturation)
- m_videoSink.set("saturation", saturation * 10);
+ m_videoSink.set("saturation", saturation * 1000);
return m_hasSaturation;
}
- Qt::AspectRatioMode aspectRatioMode() const override
- {
- Qt::AspectRatioMode mode = Qt::KeepAspectRatio;
- if (m_hasForceAspectRatio) {
- gboolean forceAR = m_videoSink.getBool("force-aspect-ratio");
- if (!forceAR)
- mode = Qt::IgnoreAspectRatio;
- }
-
- return mode;
- }
-
void setAspectRatioMode(Qt::AspectRatioMode mode) override
{
m_aspectRatioMode = mode;
@@ -216,10 +163,10 @@ protected:
bool m_hasSaturation = false;
bool m_hasShowPrerollFrame = false;
Qt::AspectRatioMode m_aspectRatioMode = Qt::KeepAspectRatio;
- int m_brightness = 0;
- int m_contrast = 0;
- int m_hue = 0;
- int m_saturation = 0;
+ float m_brightness = 0;
+ float m_contrast = 0;
+ float m_hue = 0;
+ float m_saturation = 0;
};
class QVaapiSinkProperties : public QXVImageSinkProperties
@@ -233,80 +180,44 @@ public:
m_saturation = 1;
}
- int brightness() const override
- {
- gfloat brightness = 0;
- if (m_hasBrightness)
- brightness = m_videoSink.getFloat("brightness");
-
- return brightness * 100; // [-1,1] -> [-100,100]
- }
-
- bool setBrightness(int brightness) override
+ bool setBrightness(float brightness) override
{
m_brightness = brightness;
if (m_hasBrightness) {
- gfloat v = brightness / 100.0; // [-100,100] -> [-1,1]
+ gfloat v = brightness;
m_videoSink.set("brightness", v);
}
return m_hasBrightness;
}
- int contrast() const override
- {
- gfloat contrast = 1;
- if (m_hasContrast)
- contrast = m_videoSink.getFloat("contrast");
-
- return (contrast - 1) * 100; // [0,2] -> [-100,100]
- }
-
- bool setContrast(int contrast) override
+ bool setContrast(float contrast) override
{
m_contrast = contrast;
if (m_hasContrast) {
- gfloat v = (contrast / 100.0) + 1; // [-100,100] -> [0,2]
+ gfloat v = contrast + 1; // [-1, 1] -> [0,2]
m_videoSink.set("contrast", v);
}
return m_hasContrast;
}
- int hue() const override
- {
- gfloat hue = 0;
- if (m_hasHue)
- hue = m_videoSink.getFloat("hue");
-
- return hue / 180 * 100; // [-180,180] -> [-100,100]
- }
-
- bool setHue(int hue) override
+ bool setHue(float hue) override
{
m_hue = hue;
if (m_hasHue) {
- gfloat v = hue / 100.0 * 180; // [-100,100] -> [-180,180]
+ gfloat v = hue * 180; // [-1,1] -> [-180,180]
m_videoSink.set("hue", v);
}
return m_hasHue;
}
- int saturation() const override
- {
- gfloat saturation = 1;
- if (m_hasSaturation)
- saturation = m_videoSink.getFloat("saturation");
-
- return (saturation - 1) * 100; // [0,2] -> [-100,100]
- }
-
- bool setSaturation(int saturation) override
+ bool setSaturation(float saturation) override
{
m_saturation = saturation;
if (m_hasSaturation) {
- gfloat v = (saturation / 100.0) + 1; // [-100,100] -> [0,2]
+ gfloat v = saturation + 1; // [-100,100] -> [0,2]
m_videoSink.set("saturation", v);
}
@@ -519,52 +430,27 @@ void QGstreamerVideoOverlay::showPrerollFrameChanged(GObject *, GParamSpec *, QG
overlay->updateIsActive();
}
-Qt::AspectRatioMode QGstreamerVideoOverlay::aspectRatioMode() const
-{
- return m_sinkProperties->aspectRatioMode();
-}
-
void QGstreamerVideoOverlay::setAspectRatioMode(Qt::AspectRatioMode mode)
{
m_sinkProperties->setAspectRatioMode(mode);
}
-int QGstreamerVideoOverlay::brightness() const
-{
- return m_sinkProperties->brightness();
-}
-
-void QGstreamerVideoOverlay::setBrightness(int brightness)
+void QGstreamerVideoOverlay::setBrightness(float brightness)
{
m_sinkProperties->setBrightness(brightness);
}
-int QGstreamerVideoOverlay::contrast() const
-{
- return m_sinkProperties->contrast();
-}
-
-void QGstreamerVideoOverlay::setContrast(int contrast)
+void QGstreamerVideoOverlay::setContrast(float contrast)
{
m_sinkProperties->setContrast(contrast);
}
-int QGstreamerVideoOverlay::hue() const
-{
- return m_sinkProperties->hue();
-}
-
-void QGstreamerVideoOverlay::setHue(int hue)
+void QGstreamerVideoOverlay::setHue(float hue)
{
m_sinkProperties->setHue(hue);
}
-int QGstreamerVideoOverlay::saturation() const
-{
- return m_sinkProperties->saturation();
-}
-
-void QGstreamerVideoOverlay::setSaturation(int saturation)
+void QGstreamerVideoOverlay::setSaturation(float saturation)
{
m_sinkProperties->setSaturation(saturation);
}
diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay_p.h b/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay_p.h
index 48571d926..c1ce528c8 100644
--- a/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay_p.h
+++ b/src/multimedia/platform/gstreamer/common/qgstreamervideooverlay_p.h
@@ -82,17 +82,10 @@ public:
Qt::AspectRatioMode aspectRatioMode() const;
void setAspectRatioMode(Qt::AspectRatioMode mode);
- int brightness() const;
- void setBrightness(int brightness);
-
- int contrast() const;
- void setContrast(int contrast);
-
- int hue() const;
- void setHue(int hue);
-
- int saturation() const;
- void setSaturation(int saturation);
+ void setBrightness(float brightness);
+ void setContrast(float contrast);
+ void setHue(float hue);
+ void setSaturation(float saturation);
bool processSyncMessage(const QGstreamerMessage &message) override;
bool processBusMessage(const QGstreamerMessage &message) override;
diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideosink.cpp b/src/multimedia/platform/gstreamer/common/qgstreamervideosink.cpp
index d3d1647da..c56363f72 100644
--- a/src/multimedia/platform/gstreamer/common/qgstreamervideosink.cpp
+++ b/src/multimedia/platform/gstreamer/common/qgstreamervideosink.cpp
@@ -86,11 +86,6 @@ QGstElement QGstreamerVideoSink::gstSink()
return m_videoRenderer->gstVideoSink();
}
-WId QGstreamerVideoSink::winId() const
-{
- return m_windowId;
-}
-
void QGstreamerVideoSink::setWinId(WId id)
{
if (m_windowId == id)
@@ -120,71 +115,36 @@ bool QGstreamerVideoSink::processBusMessage(const QGstreamerMessage &message)
return m_videoOverlay->processBusMessage(message);
}
-QRect QGstreamerVideoSink::displayRect() const
-{
- return m_displayRect;
-}
-
void QGstreamerVideoSink::setDisplayRect(const QRect &rect)
{
m_videoOverlay->setRenderRectangle(m_displayRect = rect);
}
-Qt::AspectRatioMode QGstreamerVideoSink::aspectRatioMode() const
-{
- return m_videoOverlay->aspectRatioMode();
-}
-
void QGstreamerVideoSink::setAspectRatioMode(Qt::AspectRatioMode mode)
{
m_videoOverlay->setAspectRatioMode(mode);
}
-int QGstreamerVideoSink::brightness() const
-{
- return m_videoOverlay->brightness();
-}
-
-void QGstreamerVideoSink::setBrightness(int brightness)
+void QGstreamerVideoSink::setBrightness(float brightness)
{
m_videoOverlay->setBrightness(brightness);
}
-int QGstreamerVideoSink::contrast() const
-{
- return m_videoOverlay->contrast();
-}
-
-void QGstreamerVideoSink::setContrast(int contrast)
+void QGstreamerVideoSink::setContrast(float contrast)
{
m_videoOverlay->setContrast(contrast);
}
-int QGstreamerVideoSink::hue() const
-{
- return m_videoOverlay->hue();
-}
-
-void QGstreamerVideoSink::setHue(int hue)
+void QGstreamerVideoSink::setHue(float hue)
{
m_videoOverlay->setHue(hue);
}
-int QGstreamerVideoSink::saturation() const
-{
- return m_videoOverlay->saturation();
-}
-
-void QGstreamerVideoSink::setSaturation(int saturation)
+void QGstreamerVideoSink::setSaturation(float saturation)
{
m_videoOverlay->setSaturation(saturation);
}
-bool QGstreamerVideoSink::isFullScreen() const
-{
- return m_fullScreen;
-}
-
void QGstreamerVideoSink::setFullScreen(bool fullScreen)
{
if (fullScreen == m_fullScreen)
diff --git a/src/multimedia/platform/gstreamer/common/qgstreamervideosink_p.h b/src/multimedia/platform/gstreamer/common/qgstreamervideosink_p.h
index d75dc25b0..9293a6c6b 100644
--- a/src/multimedia/platform/gstreamer/common/qgstreamervideosink_p.h
+++ b/src/multimedia/platform/gstreamer/common/qgstreamervideosink_p.h
@@ -75,34 +75,22 @@ public:
QVideoSink::GraphicsType graphicsType() const override;
bool setGraphicsType(QVideoSink::GraphicsType type) override;
- WId winId() const override;
void setWinId(WId id) override;
- QRhi *rhi() const { return m_rhi; }
void setRhi(QRhi *rhi) override;
- QRect displayRect() const override;
void setDisplayRect(const QRect &rect) override;
- bool isFullScreen() const override;
void setFullScreen(bool fullScreen) override;
QSize nativeSize() const override;
- Qt::AspectRatioMode aspectRatioMode() const override;
void setAspectRatioMode(Qt::AspectRatioMode mode) override;
- int brightness() const override;
- void setBrightness(int brightness) override;
-
- int contrast() const override;
- void setContrast(int contrast) override;
-
- int hue() const override;
- void setHue(int hue) override;
-
- int saturation() const override;
- void setSaturation(int saturation) override;
+ void setBrightness(float brightness) override;
+ void setContrast(float contrast) override;
+ void setHue(float hue) override;
+ void setSaturation(float saturation) override;
QGstElement gstSink();
diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp b/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp
index fe0f6f874..902835a2f 100644
--- a/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp
+++ b/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol.cpp
@@ -78,11 +78,6 @@ void MmRendererVideoWindowControl::setWinId(WId id)
m_winId = id;
}
-QRect MmRendererVideoWindowControl::displayRect() const
-{
- return m_displayRect ;
-}
-
void MmRendererVideoWindowControl::setDisplayRect(const QRect &rect)
{
if (m_displayRect != rect) {
@@ -91,11 +86,6 @@ void MmRendererVideoWindowControl::setDisplayRect(const QRect &rect)
}
}
-bool MmRendererVideoWindowControl::isFullScreen() const
-{
- return m_fullscreen;
-}
-
void MmRendererVideoWindowControl::setFullScreen(bool fullScreen)
{
if (m_fullscreen != fullScreen) {
@@ -125,12 +115,7 @@ void MmRendererVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
m_aspectRatioMode = mode;
}
-int MmRendererVideoWindowControl::brightness() const
-{
- return m_brightness;
-}
-
-void MmRendererVideoWindowControl::setBrightness(int brightness)
+void MmRendererVideoWindowControl::setBrightness(float brightness)
{
if (m_brightness != brightness) {
m_brightness = brightness;
@@ -139,12 +124,7 @@ void MmRendererVideoWindowControl::setBrightness(int brightness)
}
}
-int MmRendererVideoWindowControl::contrast() const
-{
- return m_contrast;
-}
-
-void MmRendererVideoWindowControl::setContrast(int contrast)
+void MmRendererVideoWindowControl::setContrast(float contrast)
{
if (m_contrast != contrast) {
m_contrast = contrast;
@@ -153,12 +133,7 @@ void MmRendererVideoWindowControl::setContrast(int contrast)
}
}
-int MmRendererVideoWindowControl::hue() const
-{
- return m_hue;
-}
-
-void MmRendererVideoWindowControl::setHue(int hue)
+void MmRendererVideoWindowControl::setHue(float hue)
{
if (m_hue != hue) {
m_hue = hue;
@@ -167,12 +142,7 @@ void MmRendererVideoWindowControl::setHue(int hue)
}
}
-int MmRendererVideoWindowControl::saturation() const
-{
- return m_saturation;
-}
-
-void MmRendererVideoWindowControl::setSaturation(int saturation)
+void MmRendererVideoWindowControl::setSaturation(float saturation)
{
if (m_saturation != saturation) {
m_saturation = saturation;
@@ -307,7 +277,7 @@ void MmRendererVideoWindowControl::updateVideoPosition()
void MmRendererVideoWindowControl::updateBrightness()
{
if (m_window != 0) {
- const int backendValue = m_brightness * 2.55f;
+ const int backendValue = m_brightness * 255f;
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BRIGHTNESS, &backendValue) != 0)
perror("Setting brightness failed");
}
@@ -316,7 +286,7 @@ void MmRendererVideoWindowControl::updateBrightness()
void MmRendererVideoWindowControl::updateContrast()
{
if (m_window != 0) {
- const int backendValue = m_contrast * 1.27f;
+ const int backendValue = m_contrast * 127f;
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_CONTRAST, &backendValue) != 0)
perror("Setting contrast failed");
}
@@ -325,7 +295,7 @@ void MmRendererVideoWindowControl::updateContrast()
void MmRendererVideoWindowControl::updateHue()
{
if (m_window != 0) {
- const int backendValue = m_hue * 1.27f;
+ const int backendValue = m_hue * 127f;
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_HUE, &backendValue) != 0)
perror("Setting hue failed");
}
@@ -334,7 +304,7 @@ void MmRendererVideoWindowControl::updateHue()
void MmRendererVideoWindowControl::updateSaturation()
{
if (m_window != 0) {
- const int backendValue = m_saturation * 1.27f;
+ const int backendValue = m_saturation * 127f;
if (screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SATURATION, &backendValue) != 0)
perror("Setting saturation failed");
}
diff --git a/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol_p.h b/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol_p.h
index 518eb8099..315a75077 100644
--- a/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol_p.h
+++ b/src/multimedia/platform/qnx/mediaplayer/mmrenderervideowindowcontrol_p.h
@@ -68,10 +68,8 @@ public:
WId winId() const override;
void setWinId(WId id) override;
- QRect displayRect() const override;
void setDisplayRect(const QRect &rect) override;
- bool isFullScreen() const override;
void setFullScreen(bool fullScreen) override;
void repaint() override;
@@ -81,17 +79,10 @@ public:
Qt::AspectRatioMode aspectRatioMode() const override;
void setAspectRatioMode(Qt::AspectRatioMode mode) override;
- int brightness() const override;
- void setBrightness(int brightness) override;
-
- int contrast() const override;
- void setContrast(int contrast) override;
-
- int hue() const override;
- void setHue(int hue) override;
-
- int saturation() const override;
- void setSaturation(int saturation) override;
+ void setBrightness(float brightness) override;
+ void setContrast(float contrast) override;
+ void setHue(float hue) override;
+ void setSaturation(float saturation) override;
//
// Called by media control
@@ -118,10 +109,10 @@ private:
Qt::AspectRatioMode m_aspectRatioMode;
QString m_windowName;
screen_window_t m_window;
- int m_hue;
- int m_brightness;
- int m_contrast;
- int m_saturation;
+ float m_hue;
+ float m_brightness;
+ float m_contrast;
+ float m_saturation;
};
QT_END_NAMESPACE
diff --git a/src/multimedia/platform/qplatformvideosink.cpp b/src/multimedia/platform/qplatformvideosink.cpp
index f1ec3dcbc..2912b32e4 100644
--- a/src/multimedia/platform/qplatformvideosink.cpp
+++ b/src/multimedia/platform/qplatformvideosink.cpp
@@ -143,15 +143,7 @@ QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent)
*/
/*!
- \fn QPlatformVideoSink::brightness() const
-
- Returns the brightness adjustment applied to a video overlay.
-
- Valid brightness values range between -100 and 100, the default is 0.
-*/
-
-/*!
- \fn QPlatformVideoSink::setBrightness(int brightness)
+ \fn QPlatformVideoSink::setBrightness(float brightness)
Sets a \a brightness adjustment for a video overlay.
@@ -159,21 +151,7 @@ QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent)
*/
/*!
- \fn QPlatformVideoSink::brightnessChanged(int brightness)
-
- Signals that a video overlay's \a brightness adjustment has changed.
-*/
-
-/*!
- \fn QPlatformVideoSink::contrast() const
-
- Returns the contrast adjustment applied to a video overlay.
-
- Valid contrast values range between -100 and 100, the default is 0.
-*/
-
-/*!
- \fn QPlatformVideoSink::setContrast(int contrast)
+ \fn QPlatformVideoSink::setContrast(float contrast)
Sets the \a contrast adjustment for a video overlay.
@@ -181,21 +159,7 @@ QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent)
*/
/*!
- \fn QPlatformVideoSink::contrastChanged(int contrast)
-
- Signals that a video overlay's \a contrast adjustment has changed.
-*/
-
-/*!
- \fn QPlatformVideoSink::hue() const
-
- Returns the hue adjustment applied to a video overlay.
-
- Value hue values range between -100 and 100, the default is 0.
-*/
-
-/*!
- \fn QPlatformVideoSink::setHue(int hue)
+ \fn QPlatformVideoSink::setHue(float hue)
Sets a \a hue adjustment for a video overlay.
@@ -203,32 +167,12 @@ QPlatformVideoSink::QPlatformVideoSink(QVideoSink *parent)
*/
/*!
- \fn QPlatformVideoSink::hueChanged(int hue)
-
- Signals that a video overlay's \a hue adjustment has changed.
-*/
-
-/*!
- \fn QPlatformVideoSink::saturation() const
-
- Returns the saturation adjustment applied to a video overlay.
-
- Value saturation values range between -100 and 100, the default is 0.
-*/
-
-/*!
- \fn QPlatformVideoSink::setSaturation(int saturation)
+ \fn QPlatformVideoSink::setSaturation(float saturation)
Sets a \a saturation adjustment for a video overlay.
Valid saturation values range between -100 and 100, the default is 0.
*/
-/*!
- \fn QPlatformVideoSink::saturationChanged(int saturation)
-
- Signals that a video overlay's \a saturation adjustment has changed.
-*/
-
QT_END_NAMESPACE
#include "moc_qplatformvideosink_p.cpp"
diff --git a/src/multimedia/platform/qplatformvideosink_p.h b/src/multimedia/platform/qplatformvideosink_p.h
index 61f0a678d..2e43e0f71 100644
--- a/src/multimedia/platform/qplatformvideosink_p.h
+++ b/src/multimedia/platform/qplatformvideosink_p.h
@@ -61,33 +61,22 @@ public:
virtual QVideoSink::GraphicsType graphicsType() const { return QVideoSink::NativeWindow; }
virtual bool setGraphicsType(QVideoSink::GraphicsType /*type*/) { return false; }
- virtual WId winId() const = 0;
virtual void setWinId(WId id) = 0;
virtual void setRhi(QRhi */*rhi*/) {}
- virtual QRect displayRect() const = 0;
virtual void setDisplayRect(const QRect &rect) = 0;
- virtual bool isFullScreen() const = 0;
virtual void setFullScreen(bool fullScreen) = 0;
virtual QSize nativeSize() const = 0;
- virtual Qt::AspectRatioMode aspectRatioMode() const = 0;
virtual void setAspectRatioMode(Qt::AspectRatioMode mode) = 0;
- virtual int brightness() const = 0;
- virtual void setBrightness(int brightness) = 0;
-
- virtual int contrast() const = 0;
- virtual void setContrast(int contrast) = 0;
-
- virtual int hue() const = 0;
- virtual void setHue(int hue) = 0;
-
- virtual int saturation() const = 0;
- virtual void setSaturation(int saturation) = 0;
+ virtual void setBrightness(float brightness) = 0;
+ virtual void setContrast(float contrast) = 0;
+ virtual void setHue(float hue) = 0;
+ virtual void setSaturation(float saturation) = 0;
QVideoSink *videoSink() { return sink; }
diff --git a/src/multimedia/platform/windows/evr/evrvideowindowcontrol.cpp b/src/multimedia/platform/windows/evr/evrvideowindowcontrol.cpp
index 00f29793a..4b8e6dc0f 100644
--- a/src/multimedia/platform/windows/evr/evrvideowindowcontrol.cpp
+++ b/src/multimedia/platform/windows/evr/evrvideowindowcontrol.cpp
@@ -98,11 +98,6 @@ void EvrVideoWindowControl::clear()
m_processor = NULL;
}
-WId EvrVideoWindowControl::winId() const
-{
- return m_windowId;
-}
-
void EvrVideoWindowControl::setWinId(WId id)
{
m_windowId = id;
@@ -111,11 +106,6 @@ void EvrVideoWindowControl::setWinId(WId id)
m_displayControl->SetVideoWindow(HWND(m_windowId));
}
-QRect EvrVideoWindowControl::displayRect() const
-{
- return m_displayRect;
-}
-
void EvrVideoWindowControl::setDisplayRect(const QRect &rect)
{
m_displayRect = rect;
@@ -152,46 +142,12 @@ void EvrVideoWindowControl::setDisplayRect(const QRect &rect)
}
}
-bool EvrVideoWindowControl::isFullScreen() const
-{
- return m_fullScreen;
-}
-
void EvrVideoWindowControl::setFullScreen(bool fullScreen)
{
if (m_fullScreen == fullScreen)
return;
}
-void EvrVideoWindowControl::repaint()
-{
- QSize size = nativeSize();
- if (size.width() > 0 && size.height() > 0
- && m_displayControl
- && SUCCEEDED(m_displayControl->RepaintVideo())) {
- return;
- }
-
- PAINTSTRUCT paint;
- if (HDC dc = ::BeginPaint(HWND(m_windowId), &paint)) {
- HPEN pen = ::CreatePen(PS_SOLID, 1, m_windowColor);
- HBRUSH brush = ::CreateSolidBrush(m_windowColor);
- ::SelectObject(dc, pen);
- ::SelectObject(dc, brush);
-
- ::Rectangle(
- dc,
- m_displayRect.left(),
- m_displayRect.top(),
- m_displayRect.right() + 1,
- m_displayRect.bottom() + 1);
-
- ::DeleteObject(pen);
- ::DeleteObject(brush);
- ::EndPaint(HWND(m_windowId), &paint);
- }
-}
-
QSize EvrVideoWindowControl::nativeSize() const
{
QSize size;
@@ -203,11 +159,6 @@ QSize EvrVideoWindowControl::nativeSize() const
return size;
}
-Qt::AspectRatioMode EvrVideoWindowControl::aspectRatioMode() const
-{
- return m_aspectRatioMode;
-}
-
void EvrVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
{
m_aspectRatioMode = mode;
@@ -233,12 +184,7 @@ void EvrVideoWindowControl::setAspectRatioMode(Qt::AspectRatioMode mode)
}
}
-int EvrVideoWindowControl::brightness() const
-{
- return m_brightness;
-}
-
-void EvrVideoWindowControl::setBrightness(int brightness)
+void EvrVideoWindowControl::setBrightness(float brightness)
{
if (m_brightness == brightness)
return;
@@ -250,12 +196,7 @@ void EvrVideoWindowControl::setBrightness(int brightness)
applyImageControls();
}
-int EvrVideoWindowControl::contrast() const
-{
- return m_contrast;
-}
-
-void EvrVideoWindowControl::setContrast(int contrast)
+void EvrVideoWindowControl::setContrast(float contrast)
{
if (m_contrast == contrast)
return;
@@ -267,12 +208,7 @@ void EvrVideoWindowControl::setContrast(int contrast)
applyImageControls();
}
-int EvrVideoWindowControl::hue() const
-{
- return m_hue;
-}
-
-void EvrVideoWindowControl::setHue(int hue)
+void EvrVideoWindowControl::setHue(float hue)
{
if (m_hue == hue)
return;
@@ -284,12 +220,7 @@ void EvrVideoWindowControl::setHue(int hue)
applyImageControls();
}
-int EvrVideoWindowControl::saturation() const
-{
- return m_saturation;
-}
-
-void EvrVideoWindowControl::setSaturation(int saturation)
+void EvrVideoWindowControl::setSaturation(float saturation)
{
if (m_saturation == saturation)
return;
@@ -324,7 +255,7 @@ void EvrVideoWindowControl::applyImageControls()
}
}
-DXVA2_Fixed32 EvrVideoWindowControl::scaleProcAmpValue(DWORD prop, int value) const
+DXVA2_Fixed32 EvrVideoWindowControl::scaleProcAmpValue(DWORD prop, float value) const
{
float scaledValue = 0.0;
@@ -332,9 +263,9 @@ DXVA2_Fixed32 EvrVideoWindowControl::scaleProcAmpValue(DWORD prop, int value) co
if (SUCCEEDED(m_processor->GetProcAmpRange(prop, &range))) {
scaledValue = DXVA2FixedToFloat(range.DefaultValue);
if (value > 0)
- scaledValue += float(value) * (DXVA2FixedToFloat(range.MaxValue) - DXVA2FixedToFloat(range.DefaultValue)) / 100;
+ scaledValue += float(value) * (DXVA2FixedToFloat(range.MaxValue) - DXVA2FixedToFloat(range.DefaultValue));
else if (value < 0)
- scaledValue -= float(value) * (DXVA2FixedToFloat(range.MinValue) - DXVA2FixedToFloat(range.DefaultValue)) / 100;
+ scaledValue -= float(value) * (DXVA2FixedToFloat(range.MinValue) - DXVA2FixedToFloat(range.DefaultValue));
}
return DXVA2FloatToFixed(scaledValue);
diff --git a/src/multimedia/platform/windows/evr/evrvideowindowcontrol_p.h b/src/multimedia/platform/windows/evr/evrvideowindowcontrol_p.h
index 0d829398f..b9fbc271c 100644
--- a/src/multimedia/platform/windows/evr/evrvideowindowcontrol_p.h
+++ b/src/multimedia/platform/windows/evr/evrvideowindowcontrol_p.h
@@ -66,49 +66,36 @@ public:
bool setEvr(IUnknown *evr);
- WId winId() const override;
void setWinId(WId id) override;
- QRect displayRect() const override;
void setDisplayRect(const QRect &rect) override;
- bool isFullScreen() const override;
void setFullScreen(bool fullScreen) override;
- void repaint() override;
-
QSize nativeSize() const override;
- Qt::AspectRatioMode aspectRatioMode() const override;
void setAspectRatioMode(Qt::AspectRatioMode mode) override;
- int brightness() const override;
- void setBrightness(int brightness) override;
-
- int contrast() const override;
- void setContrast(int contrast) override;
-
- int hue() const override;
- void setHue(int hue) override;
-
- int saturation() const override;
- void setSaturation(int saturation) override;
+ void setBrightness(float brightness) override;
+ void setContrast(float contrast) override;
+ void setHue(float hue) override;
+ void setSaturation(float saturation) override;
void applyImageControls();
private:
void clear();
- DXVA2_Fixed32 scaleProcAmpValue(DWORD prop, int value) const;
+ DXVA2_Fixed32 scaleProcAmpValue(DWORD prop, float value) const;
WId m_windowId;
COLORREF m_windowColor;
DWORD m_dirtyValues;
Qt::AspectRatioMode m_aspectRatioMode;
QRect m_displayRect;
- int m_brightness;
- int m_contrast;
- int m_hue;
- int m_saturation;
+ float m_brightness;
+ float m_contrast;
+ float m_hue;
+ float m_saturation;
bool m_fullScreen;
IMFVideoDisplayControl *m_displayControl;
diff --git a/src/multimedia/video/qvideosink.cpp b/src/multimedia/video/qvideosink.cpp
index 93308112e..7cd786651 100644
--- a/src/multimedia/video/qvideosink.cpp
+++ b/src/multimedia/video/qvideosink.cpp
@@ -65,17 +65,15 @@ public:
QVideoSink *q_ptr = nullptr;
QPlatformVideoSink *videoSink = nullptr;
QVideoSink::GraphicsType type = QVideoSink::Memory;
- QVideoFrameFormat surfaceFormat;
- QSize nativeResolution;
- bool active = false;
+ bool fullScreen = false;
WId window = 0;
QRhi *rhi = nullptr;
Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio;
QRectF targetRect;
- int brightness = 0;
- int contrast = 0;
- int saturation = 0;
- int hue = 0;
+ float brightness = 0;
+ float contrast = 0;
+ float saturation = 0;
+ float hue = 0;
Qt::BGMode backgroundMode = Qt::OpaqueMode;
};
@@ -133,18 +131,12 @@ void QVideoSink::setGraphicsType(QVideoSink::GraphicsType type)
d->videoSink->setGraphicsType(type);
}
-bool QVideoSink::isGraphicsTypeSupported(QVideoSink::GraphicsType type)
-{
- // ####
- return type == NativeWindow;
-}
-
/*!
Returns the native window id that the sink is currently rendering to.
*/
WId QVideoSink::nativeWindowId() const
{
- return d->videoSink->winId();
+ return d->window;
}
/*!
@@ -157,6 +149,9 @@ WId QVideoSink::nativeWindowId() const
*/
void QVideoSink::setNativeWindowId(WId id)
{
+ if (d->window == id)
+ return;
+ d->window = id;
d->videoSink->setWinId(id);
}
@@ -189,6 +184,9 @@ void QVideoSink::setRhi(QRhi *rhi)
*/
void QVideoSink::setFullScreen(bool fullscreen)
{
+ if (d->fullScreen == fullscreen)
+ return;
+ d->fullScreen = fullscreen;
d->videoSink->setFullScreen(fullscreen);
}
@@ -197,16 +195,18 @@ void QVideoSink::setFullScreen(bool fullscreen)
*/
bool QVideoSink::isFullscreen() const
{
- return d->videoSink->isFullScreen();
+ return d->fullScreen;
}
Qt::AspectRatioMode QVideoSink::aspectRatioMode() const
{
- return d->videoSink->aspectRatioMode();
+ return d->aspectRatioMode;
}
void QVideoSink::setAspectRatioMode(Qt::AspectRatioMode mode)
{
+ if (d->aspectRatioMode == mode)
+ return;
d->videoSink->setAspectRatioMode(mode);
}
@@ -217,47 +217,61 @@ QRectF QVideoSink::targetRect() const
void QVideoSink::setTargetRect(const QRectF &rect)
{
- d->videoSink->setDisplayRect(rect.toRect());
+ if (d->targetRect == rect)
+ return;
d->targetRect = rect;
+ d->videoSink->setDisplayRect(rect.toRect());
}
-int QVideoSink::brightness() const
+float QVideoSink::brightness() const
{
- return d->videoSink->brightness();
+ return d->brightness;
}
-void QVideoSink::setBrightness(int brightness)
+void QVideoSink::setBrightness(float brightness)
{
+ if (d->brightness == brightness)
+ return;
+ d->brightness = brightness;
d->videoSink->setBrightness(brightness);
}
-int QVideoSink::contrast() const
+float QVideoSink::contrast() const
{
- return d->videoSink->contrast();
+ return d->contrast;
}
-void QVideoSink::setContrast(int contrast)
+void QVideoSink::setContrast(float contrast)
{
+ if (d->contrast == contrast)
+ return;
+ d->contrast = contrast;
d->videoSink->setContrast(contrast);
}
-int QVideoSink::hue() const
+float QVideoSink::hue() const
{
- return d->videoSink->hue();
+ return d->hue;
}
-void QVideoSink::setHue(int hue)
+void QVideoSink::setHue(float hue)
{
+ if (d->hue == hue)
+ return;
+ d->hue = hue;
d->videoSink->setHue(hue);
}
-int QVideoSink::saturation() const
+float QVideoSink::saturation() const
{
- return d->videoSink->saturation();
+ return d->saturation;
}
-void QVideoSink::setSaturation(int saturation)
+void QVideoSink::setSaturation(float saturation)
{
+ if (d->saturation == saturation)
+ return;
+ d->saturation = saturation;
d->videoSink->setSaturation(saturation);
}
diff --git a/src/multimedia/video/qvideosink.h b/src/multimedia/video/qvideosink.h
index e88a288c5..34b2f7bf9 100644
--- a/src/multimedia/video/qvideosink.h
+++ b/src/multimedia/video/qvideosink.h
@@ -71,8 +71,6 @@ public:
GraphicsType graphicsType() const;
void setGraphicsType(GraphicsType type);
- static bool isGraphicsTypeSupported(GraphicsType type);
-
// setter sets graphics type to NativeWindow
WId nativeWindowId() const;
void setNativeWindowId(WId id);
@@ -89,17 +87,17 @@ public:
QRectF targetRect() const;
void setTargetRect(const QRectF &rect);
- int brightness() const;
- void setBrightness(int brightness);
+ float brightness() const;
+ void setBrightness(float brightness);
- int contrast() const;
- void setContrast(int contrast);
+ float contrast() const;
+ void setContrast(float contrast);
- int hue() const;
- void setHue(int hue);
+ float hue() const;
+ void setHue(float hue);
- int saturation() const;
- void setSaturation(int saturation);
+ float saturation() const;
+ void setSaturation(float saturation);
Qt::BGMode backgroundMode() const;
void setBackgroundMode(Qt::BGMode mode);
diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp
index cd15b6275..898226674 100644
--- a/src/multimediawidgets/qvideowidget.cpp
+++ b/src/multimediawidgets/qvideowidget.cpp
@@ -191,19 +191,19 @@ void QVideoWidget::setFullScreen(bool fullScreen)
\property QVideoWidget::brightness
\brief an adjustment to the brightness of displayed video.
- Valid brightness values range between -100 and 100, the default is 0.
+ Valid brightness values range between -1. and 1., the default is 0.
*/
-int QVideoWidget::brightness() const
+float QVideoWidget::brightness() const
{
return d_func()->videoSink->brightness();
}
-void QVideoWidget::setBrightness(int brightness)
+void QVideoWidget::setBrightness(float brightness)
{
Q_D(QVideoWidget);
- int boundedBrightness = qBound(-100, brightness, 100);
+ float boundedBrightness = qBound(-1., brightness, 1.);
if (boundedBrightness == d->videoSink->brightness())
return;
@@ -213,7 +213,7 @@ void QVideoWidget::setBrightness(int brightness)
}
/*!
- \fn QVideoWidget::brightnessChanged(int brightness)
+ \fn QVideoWidget::brightnessChanged(float brightness)
Signals that a video widgets's \a brightness adjustment has changed.
@@ -224,20 +224,20 @@ void QVideoWidget::setBrightness(int brightness)
\property QVideoWidget::contrast
\brief an adjustment to the contrast of displayed video.
- Valid contrast values range between -100 and 100, the default is 0.
+ Valid contrast values range between -1. and 1., the default is 0.
*/
-int QVideoWidget::contrast() const
+float QVideoWidget::contrast() const
{
return d_func()->videoSink->contrast();
}
-void QVideoWidget::setContrast(int contrast)
+void QVideoWidget::setContrast(float contrast)
{
Q_D(QVideoWidget);
- int boundedContrast = qBound(-100, contrast, 100);
+ float boundedContrast = qBound(-1., contrast, 1.);
if (boundedContrast == d->videoSink->contrast())
return;
@@ -247,7 +247,7 @@ void QVideoWidget::setContrast(int contrast)
}
/*!
- \fn QVideoWidget::contrastChanged(int contrast)
+ \fn QVideoWidget::contrastChanged(float contrast)
Signals that a video widgets's \a contrast adjustment has changed.
@@ -258,19 +258,19 @@ void QVideoWidget::setContrast(int contrast)
\property QVideoWidget::hue
\brief an adjustment to the hue of displayed video.
- Valid hue values range between -100 and 100, the default is 0.
+ Valid hue values range between -1. and 1., the default is 0.
*/
-int QVideoWidget::hue() const
+float QVideoWidget::hue() const
{
return d_func()->videoSink->hue();
}
-void QVideoWidget::setHue(int hue)
+void QVideoWidget::setHue(float hue)
{
Q_D(QVideoWidget);
- int boundedHue = qBound(-100, hue, 100);
+ float boundedHue = qBound(-1., hue, 1.);
if (boundedHue == d->videoSink->hue())
return;
@@ -280,7 +280,7 @@ void QVideoWidget::setHue(int hue)
}
/*!
- \fn QVideoWidget::hueChanged(int hue)
+ \fn QVideoWidget::hueChanged(float hue)
Signals that a video widgets's \a hue has changed.
@@ -291,19 +291,19 @@ void QVideoWidget::setHue(int hue)
\property QVideoWidget::saturation
\brief an adjustment to the saturation of displayed video.
- Valid saturation values range between -100 and 100, the default is 0.
+ Valid saturation values range between -1. and 1., the default is 0.
*/
-int QVideoWidget::saturation() const
+float QVideoWidget::saturation() const
{
return d_func()->videoSink->saturation();
}
-void QVideoWidget::setSaturation(int saturation)
+void QVideoWidget::setSaturation(float saturation)
{
Q_D(QVideoWidget);
- int boundedSaturation = qBound(-100, saturation, 100);
+ float boundedSaturation = qBound(-1., saturation, 1.);
if (boundedSaturation == d->videoSink->saturation())
return;
@@ -313,7 +313,7 @@ void QVideoWidget::setSaturation(int saturation)
}
/*!
- \fn QVideoWidget::saturationChanged(int saturation)
+ \fn QVideoWidget::saturationChanged(float saturation)
Signals that a video widgets's \a saturation has changed.
diff --git a/src/multimediawidgets/qvideowidget.h b/src/multimediawidgets/qvideowidget.h
index 88c1af15d..b3e8ff890 100644
--- a/src/multimediawidgets/qvideowidget.h
+++ b/src/multimediawidgets/qvideowidget.h
@@ -54,10 +54,10 @@ class Q_MULTIMEDIAWIDGETS_EXPORT QVideoWidget : public QWidget
Q_OBJECT
Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode NOTIFY aspectRatioModeChanged)
- Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
- Q_PROPERTY(int contrast READ contrast WRITE setContrast NOTIFY contrastChanged)
- Q_PROPERTY(int hue READ hue WRITE setHue NOTIFY hueChanged)
- Q_PROPERTY(int saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
+ Q_PROPERTY(float brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
+ Q_PROPERTY(float contrast READ contrast WRITE setContrast NOTIFY contrastChanged)
+ Q_PROPERTY(float hue READ hue WRITE setHue NOTIFY hueChanged)
+ Q_PROPERTY(float saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
public:
explicit QVideoWidget(QWidget *parent = nullptr);
@@ -71,10 +71,10 @@ public:
Qt::AspectRatioMode aspectRatioMode() const;
- int brightness() const;
- int contrast() const;
- int hue() const;
- int saturation() const;
+ float brightness() const;
+ float contrast() const;
+ float hue() const;
+ float saturation() const;
QSize sizeHint() const override;
#if defined(Q_OS_WIN)
@@ -84,17 +84,17 @@ public:
public Q_SLOTS:
void setFullScreen(bool fullScreen);
void setAspectRatioMode(Qt::AspectRatioMode mode);
- void setBrightness(int brightness);
- void setContrast(int contrast);
- void setHue(int hue);
- void setSaturation(int saturation);
+ void setBrightness(float brightness);
+ void setContrast(float contrast);
+ void setHue(float hue);
+ void setSaturation(float saturation);
Q_SIGNALS:
void fullScreenChanged(bool fullScreen);
- void brightnessChanged(int brightness);
- void contrastChanged(int contrast);
- void hueChanged(int hue);
- void saturationChanged(int saturation);
+ void brightnessChanged(float brightness);
+ void contrastChanged(float contrast);
+ void hueChanged(float hue);
+ void saturationChanged(float saturation);
void aspectRatioModeChanged(Qt::AspectRatioMode mode);
protected:
diff --git a/tests/auto/integration/qdeclarativevideooutput_window/tst_qdeclarativevideooutput_window.cpp b/tests/auto/integration/qdeclarativevideooutput_window/tst_qdeclarativevideooutput_window.cpp
index 657e43a8f..97ca5e524 100644
--- a/tests/auto/integration/qdeclarativevideooutput_window/tst_qdeclarativevideooutput_window.cpp
+++ b/tests/auto/integration/qdeclarativevideooutput_window/tst_qdeclarativevideooutput_window.cpp
@@ -60,39 +60,41 @@ public:
QtTestWindowControl(QVideoSink *parent = nullptr)
: QPlatformVideoSink(parent)
{}
- [[nodiscard]] WId winId() const override { return m_winId; }
void setWinId(WId id) override { m_winId = id; }
- [[nodiscard]] QRect displayRect() const override { return m_displayRect; }
void setDisplayRect(const QRect &rect) override { m_displayRect = rect; }
- [[nodiscard]] bool isFullScreen() const override { return m_fullScreen; }
void setFullScreen(bool fullScreen) override { m_fullScreen = fullScreen; }
[[nodiscard]] QSize nativeSize() const override { return m_nativeSize; }
void setNativeSize(const QSize &size) { m_nativeSize = size; emit nativeSizeChanged(); }
- [[nodiscard]] Qt::AspectRatioMode aspectRatioMode() const override { return m_aspectRatioMode; }
void setAspectRatioMode(Qt::AspectRatioMode mode) override { m_aspectRatioMode = mode; }
- [[nodiscard]] int brightness() const override { return m_brightness; }
- void setBrightness(int brightness) override { m_brightness = brightness; }
+ void setBrightness(float brightness) override { m_brightness = brightness; }
+ void setContrast(float contrast) override { m_contrast = contrast; }
+ void setHue(float hue) override { m_hue = hue; }
+ void setSaturation(float saturation) override { m_saturation = saturation; }
- [[nodiscard]] int contrast() const override { return m_contrast; }
- void setContrast(int contrast) override { m_contrast = contrast; }
+ [[nodiscard]] WId winId() const { return m_winId; }
- [[nodiscard]] int hue() const override { return m_hue; }
- void setHue(int hue) override { m_hue = hue; }
+ [[nodiscard]] QRect displayRect() const { return m_displayRect; }
- [[nodiscard]] int saturation() const override { return m_saturation; }
- void setSaturation(int saturation) override { m_saturation = saturation; }
+ [[nodiscard]] bool isFullScreen() const { return m_fullScreen; }
+
+ [[nodiscard]] Qt::AspectRatioMode aspectRatioMode() const { return m_aspectRatioMode; }
+
+ [[nodiscard]] float brightness() const { return m_brightness; }
+ [[nodiscard]] float contrast() const { return m_contrast; }
+ [[nodiscard]] float hue() const { return m_hue; }
+ [[nodiscard]] float saturation() const { return m_saturation; }
private:
WId m_winId = 0;
- int m_brightness = 0;
- int m_contrast = 0;
- int m_hue = 0;
- int m_saturation = 0;
+ float m_brightness = 0;
+ float m_contrast = 0;
+ float m_hue = 0;
+ float m_saturation = 0;
Qt::AspectRatioMode m_aspectRatioMode = Qt::KeepAspectRatio;
QRect m_displayRect;
QSize m_nativeSize;