QCameraImageProcessingControl API fixes
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
Wed, 25 Jan 2012 06:24:55 +0000 (16:24 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 2 Feb 2012 01:37:33 +0000 (02:37 +0100)
Moved white balance preset from the separate methods to
QCameraImageProcessingControl::ProcessingParameter;

Separated absolute contrast/saturation/sharpening/denoising
settings with adjustments to backend decided values,
with QCameraImageProcessing using adjustments versions.

Changed type of parameters from int to qreal
with [0..1] range for absolute values and [-1..1] for adjustments.

Change-Id: I85c8781c046be6dd45bcf626c25908e1ce5f6bcb
Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
doc/src/snippets/multimedia-snippets/camera.cpp
src/multimedia/camera/qcameraimageprocessing.cpp
src/multimedia/camera/qcameraimageprocessing.h
src/multimedia/controls/qcameraimageprocessingcontrol.cpp
src/multimedia/controls/qcameraimageprocessingcontrol.h
tests/auto/unit/qcamera/tst_qcamera.cpp
tests/auto/unit/qmultimedia_common/mockcameraimageprocessingcontrol.h

index 1712a64..08a2e89 100644 (file)
@@ -170,9 +170,7 @@ void cameraimageprocessing()
     //! [Camera image whitebalance]
 
     //! [Camera image denoising]
-    if (imageProcessing->isDenoisingSupported()) {
-        imageProcessing->setDenoisingLevel(3);
-    }
+    imageProcessing->setDenoisingLevel(-0.3); //reduce the amount of denoising applied
     //! [Camera image denoising]
 }
 
index ab004c3..3d7812b 100644 (file)
@@ -101,6 +101,18 @@ QT_BEGIN_NAMESPACE
     \sa QCameraImageProcessingControl
 */
 
+class QCameraImageProcessingFakeControl : public QCameraImageProcessingControl {
+public:
+    QCameraImageProcessingFakeControl(QObject *parent) :
+        QCameraImageProcessingControl(parent)
+    {}
+
+    bool isParameterSupported(ProcessingParameter) const { return false; }
+    bool isParameterValueSupported(ProcessingParameter, const QVariant &) const { return false; }
+    QVariant parameter(ProcessingParameter) const { return QVariant(); }
+    void setParameter(ProcessingParameter, const QVariant &) {}
+};
+
 
 class QCameraImageProcessingPrivate : public QMediaObjectPrivate
 {
@@ -112,6 +124,7 @@ public:
 
     QCamera *camera;
     QCameraImageProcessingControl *imageControl;
+    bool available;
 };
 
 
@@ -122,6 +135,11 @@ void QCameraImageProcessingPrivate::initControls()
     QMediaService *service = camera->service();
     if (service)
         imageControl = qobject_cast<QCameraImageProcessingControl *>(service->requestControl(QCameraImageProcessingControl_iid));
+
+    available = (imageControl != 0);
+
+    if (!imageControl)
+        imageControl = new QCameraImageProcessingFakeControl(q_ptr);
 }
 
 /*!
@@ -152,7 +170,7 @@ QCameraImageProcessing::~QCameraImageProcessing()
 */
 bool QCameraImageProcessing::isAvailable() const
 {
-    return d_func()->imageControl != 0;
+    return d_func()->available;
 }
 
 
@@ -162,7 +180,8 @@ bool QCameraImageProcessing::isAvailable() const
 
 QCameraImageProcessing::WhiteBalanceMode QCameraImageProcessing::whiteBalanceMode() const
 {
-    return d_func()->imageControl ? d_func()->imageControl->whiteBalanceMode() : QCameraImageProcessing::WhiteBalanceAuto;
+    return d_func()->imageControl->parameter(QCameraImageProcessingControl::WhiteBalancePreset)
+            .value<QCameraImageProcessing::WhiteBalanceMode>();
 }
 
 /*!
@@ -171,8 +190,9 @@ QCameraImageProcessing::WhiteBalanceMode QCameraImageProcessing::whiteBalanceMod
 
 void QCameraImageProcessing::setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode)
 {
-    if (d_func()->imageControl)
-        d_func()->imageControl->setWhiteBalanceMode(mode);
+    d_func()->imageControl->setParameter(
+                QCameraImageProcessingControl::WhiteBalancePreset,
+                QVariant::fromValue<QCameraImageProcessing::WhiteBalanceMode>(mode));
 }
 
 /*!
@@ -181,7 +201,10 @@ void QCameraImageProcessing::setWhiteBalanceMode(QCameraImageProcessing::WhiteBa
 
 bool QCameraImageProcessing::isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const
 {
-    return d_func()->imageControl ? d_func()->imageControl->isWhiteBalanceModeSupported(mode) : false;
+    return d_func()->imageControl->isParameterValueSupported(
+                QCameraImageProcessingControl::WhiteBalancePreset,
+                QVariant::fromValue<QCameraImageProcessing::WhiteBalanceMode>(mode));
+
 }
 
 /*!
@@ -190,14 +213,9 @@ bool QCameraImageProcessing::isWhiteBalanceModeSupported(QCameraImageProcessing:
     return value is undefined.
 */
 
-int QCameraImageProcessing::manualWhiteBalance() const
+qreal QCameraImageProcessing::manualWhiteBalance() const
 {
-    QVariant value;
-
-    if (d_func()->imageControl)
-        value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::ColorTemperature);
-
-    return value.toInt();
+    return d_func()->imageControl->parameter(QCameraImageProcessingControl::ColorTemperature).toReal();
 }
 
 /*!
@@ -205,161 +223,96 @@ int QCameraImageProcessing::manualWhiteBalance() const
     when whiteBalanceMode() is set to \c WhiteBalanceManual.  The units are Kelvin.
 */
 
-void QCameraImageProcessing::setManualWhiteBalance(int colorTemperature)
+void QCameraImageProcessing::setManualWhiteBalance(qreal colorTemperature)
 {
-    if (d_func()->imageControl) {
-        d_func()->imageControl->setProcessingParameter(
-                    QCameraImageProcessingControl::ColorTemperature,
-                    QVariant(colorTemperature));
-    }
+    d_func()->imageControl->setParameter(
+                QCameraImageProcessingControl::ColorTemperature,
+                QVariant(colorTemperature));
 }
 
 /*!
     Returns the contrast adjustment setting.
 */
-int QCameraImageProcessing::contrast() const
+qreal QCameraImageProcessing::contrast() const
 {
-    QVariant value;
-
-    if (d_func()->imageControl)
-        value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Contrast);
-
-    return value.toInt();
+    return d_func()->imageControl->parameter(QCameraImageProcessingControl::ContrastAdjustment).toReal();
 }
 
 /*!
     Set the contrast adjustment to \a value.
 
-    Valid contrast adjustment values range between -100 and 100, with a default of 0.
+    Valid contrast adjustment values range between -1.0 and 1.0, with a default of 0.
 */
-void QCameraImageProcessing::setContrast(int value)
+void QCameraImageProcessing::setContrast(qreal value)
 {
-    if (d_func()->imageControl)
-        d_func()->imageControl->setProcessingParameter(QCameraImageProcessingControl::Contrast,
-                                                       QVariant(value));
+    d_func()->imageControl->setParameter(QCameraImageProcessingControl::ContrastAdjustment,
+                                         QVariant(value));
 }
 
 /*!
     Returns the saturation adjustment value.
 */
-int QCameraImageProcessing::saturation() const
+qreal QCameraImageProcessing::saturation() const
 {
-    QVariant value;
-
-    if (d_func()->imageControl)
-        value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Saturation);
-
-    return value.toInt();
+    return d_func()->imageControl->parameter(QCameraImageProcessingControl::SaturationAdjustment).toReal();
 }
 
 /*!
     Sets the saturation adjustment value to \a value.
 
-    Valid saturation values range between -100 and 100, with a default of 0.
+    Valid saturation values range between -1.0 and 1.0, with a default of 0.
 */
 
-void QCameraImageProcessing::setSaturation(int value)
-{
-    if (d_func()->imageControl)
-        d_func()->imageControl->setProcessingParameter(QCameraImageProcessingControl::Saturation,
-                                                       QVariant(value));
-}
-
-/*!
-    Identifies if sharpening is supported.
-
-    Returns true if sharpening is supported; and false if it is not.
-*/
-bool QCameraImageProcessing::isSharpeningSupported() const
+void QCameraImageProcessing::setSaturation(qreal value)
 {
-    if (d_func()->imageControl)
-        return d_func()->imageControl->isProcessingParameterSupported(QCameraImageProcessingControl::Sharpening);
-    else
-        return false;
+    d_func()->imageControl->setParameter(QCameraImageProcessingControl::SaturationAdjustment,
+                                         QVariant(value));
 }
 
 /*!
-    Returns the sharpening level.
-
-    This may be \c DefaultSharpening if no particular sharpening level has been applied.
-
+    Returns the sharpening adjustment level.
 */
-int QCameraImageProcessing::sharpeningLevel() const
+qreal QCameraImageProcessing::sharpeningLevel() const
 {
-    QVariant value;
-
-    if (d_func()->imageControl)
-        value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Sharpening);
-
-    if (value.isNull())
-        return DefaultSharpening;
-    else
-        return value.toInt();
+    return d_func()->imageControl->parameter(QCameraImageProcessingControl::SharpeningAdjustment).toReal();
 }
 
 /*!
-    Sets the sharpening \a level.
-
-    If \c DefaultSharpening is supplied, the camera will decide what sharpening
-    to perform.  Otherwise a level of 0 will disable sharpening, and a level of 100
-    corresponds to maximum sharpening applied.
+    Sets the sharpening adjustment \a level.
 
+    Valid sharpening values range between -1.0 and 1.0, with a default of 0.
 */
 
-void QCameraImageProcessing::setSharpeningLevel(int level)
+void QCameraImageProcessing::setSharpeningLevel(qreal level)
 {
-    Q_D(QCameraImageProcessing);
-    if (d->imageControl)
-        d->imageControl->setProcessingParameter(QCameraImageProcessingControl::Sharpening,
-                                                level == DefaultSharpening ? QVariant() : QVariant(level));
+    d_func()->imageControl->setParameter(QCameraImageProcessingControl::SharpeningAdjustment,
+                                         QVariant(level));
 }
 
 /*!
-    Returns true if denoising is supported.
+    Returns the denoising adjustment level.
 */
-bool QCameraImageProcessing::isDenoisingSupported() const
+qreal QCameraImageProcessing::denoisingLevel() const
 {
-    if (d_func()->imageControl)
-        return d_func()->imageControl->isProcessingParameterSupported(QCameraImageProcessingControl::Denoising);
-    else
-        return false;
+    return d_func()->imageControl->parameter(QCameraImageProcessingControl::DenoisingAdjustment).toReal();
 }
 
 /*!
-    Returns the denoising level.  This may be \c DefaultDenoising if no
-    particular value has been set.
+    Sets the denoising adjustment \a level.
 
-*/
-int QCameraImageProcessing::denoisingLevel() const
-{
-    QVariant value;
-
-    if (d_func()->imageControl)
-        value = d_func()->imageControl->processingParameter(QCameraImageProcessingControl::Denoising);
-
-    if (value.isNull())
-        return DefaultDenoising;
-    else
-        return value.toInt();
-}
-
-/*!
-    Sets the denoising \a level.
-
-    If \c DefaultDenoising is supplied, the camera will decide what denoising
-    to perform.  Otherwise a level of 0 will disable denoising, and a level of 100
-    corresponds to maximum denoising applied.
+    Valid sharpening values range between -1.0 and 1.0, with a default of 0.
 
+    If the parameter value is set to 0, the amount of denoising applied
+    is selected by camera and depends on camera capabilities and settings.
+    Changing value in -1.0..1.0 range adjusts the amount of denoising applied
+    within the supported range.
 */
-void QCameraImageProcessing::setDenoisingLevel(int level)
+void QCameraImageProcessing::setDenoisingLevel(qreal level)
 {
-    Q_D(QCameraImageProcessing);
-    if (d->imageControl)
-        d->imageControl->setProcessingParameter(QCameraImageProcessingControl::Denoising,
-                                                level == DefaultDenoising ? QVariant() : QVariant(level));
+    d_func()->imageControl->setParameter(QCameraImageProcessingControl::DenoisingAdjustment,
+                                         QVariant(level));
 }
 
-
 /*!
     \enum QCameraImageProcessing::WhiteBalanceMode
 
@@ -373,7 +326,7 @@ void QCameraImageProcessing::setDenoisingLevel(int level)
     \value WhiteBalanceFluorescent  Fluorescent white balance mode.
     \value WhiteBalanceFlash        Flash white balance mode.
     \value WhiteBalanceSunset       Sunset white balance mode.
-    \value WhiteBalanceVendor       Vendor defined white balance mode.
+    \value WhiteBalanceVendor       Base value for vendor defined white balance modes.
 */
 
 #include "moc_qcameraimageprocessing.cpp"
index 5f118d9..ea1e76c 100644 (file)
@@ -86,24 +86,21 @@ public:
     WhiteBalanceMode whiteBalanceMode() const;
     void setWhiteBalanceMode(WhiteBalanceMode mode);
     bool isWhiteBalanceModeSupported(WhiteBalanceMode mode) const;
-    int manualWhiteBalance() const;
-    void setManualWhiteBalance(int colorTemperature);
 
-    int contrast() const;
-    void setContrast(int value);
+    qreal manualWhiteBalance() const;
+    void setManualWhiteBalance(qreal colorTemperature);
 
-    int saturation() const;
-    void setSaturation(int value);
+    qreal contrast() const;
+    void setContrast(qreal value);
 
-    static const int DefaultSharpening = -1;
-    bool isSharpeningSupported() const;
-    int sharpeningLevel() const;
-    void setSharpeningLevel(int value);
+    qreal saturation() const;
+    void setSaturation(qreal value);
 
-    static const int DefaultDenoising = -1;
-    bool isDenoisingSupported() const;
-    int denoisingLevel() const;
-    void setDenoisingLevel(int value);
+    qreal sharpeningLevel() const;
+    void setSharpeningLevel(qreal value);
+
+    qreal denoisingLevel() const;
+    void setDenoisingLevel(qreal value);
 
 private:
     friend class QCamera;
index 1beb940..ba1eda4 100644 (file)
@@ -71,7 +71,19 @@ namespace
     The interface name of QCameraImageProcessingControl is \c com.nokia.Qt.QCameraImageProcessingControl/1.0 as
     defined in QCameraImageProcessingControl_iid.
 
+    Camera service may choose the parameters of image processing pipeline depending
+    on sensor properties camera settings and capture parameters.
 
+    This control allows to modify some parameters of image processing pipeline
+    to achieve desired results.
+
+    Parameters with the "Adjustment" suffix, like ContrastAdjustment, SaturationAdjustment etc
+    allows to adjust the parameter values, selected by camera engine,
+    while parameters like Contrast and Saturation overwrites them.
+
+    For example setting the SharpeningAdjustment parameter to -0.1
+    slightly reduces the amount of sharpening applied,
+    while settings the Sharpening parameter to 0 disables sharpening at all.
 
     \sa QMediaService::requestControl(), QCamera
 */
@@ -103,25 +115,8 @@ QCameraImageProcessingControl::~QCameraImageProcessingControl()
 {
 }
 
-
-/*!
-    \fn QCameraImageProcessingControl::whiteBalanceMode() const
-    Return the white balance mode being used.
-*/
-
-/*!
-    \fn QCameraImageProcessingControl::setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode)
-    Set the white balance mode to \a mode
-*/
-
-/*!
-    \fn QCameraImageProcessingControl::isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const
-    Returns true if the white balance \a mode is supported.
-    The backend should support at least QCameraImageProcessing::WhiteBalanceAuto mode.
-*/
-
 /*!
-    \fn bool QCameraImageProcessingControl::isProcessingParameterSupported(ProcessingParameter parameter) const
+    \fn bool QCameraImageProcessingControl::isParameterSupported(ProcessingParameter parameter) const
 
     Returns true if the camera supports adjusting image processing \a parameter.
 
@@ -132,29 +127,43 @@ QCameraImageProcessingControl::~QCameraImageProcessingControl()
 */
 
 /*!
-    \fn QCameraImageProcessingControl::processingParameter(ProcessingParameter parameter) const
+    \fn bool QCameraImageProcessingControl::isParameterValueSupported(ProcessingParameter parameter, const QVariant &value) const
+
+    Returns true if the camera supports settings the the image processing \a parameter \a value.
+
+    It's used only for parameters with a limited set of values, like WhiteBalancePreset.
+*/
+
+
+/*!
+    \fn QCameraImageProcessingControl::parameter(ProcessingParameter parameter) const
+
     Returns the image processing \a parameter value.
 */
 
 /*!
-    \fn QCameraImageProcessingControl::setProcessingParameter(ProcessingParameter parameter, QVariant value)
+    \fn QCameraImageProcessingControl::setParameter(ProcessingParameter parameter, const QVariant &value)
 
     Sets the image processing \a parameter \a value.
     Passing the null or invalid QVariant value allows
     backend to choose the suitable parameter value.
 
-    The valid values range depends on the parameter type,
-    for contrast, saturation and brightness value should be
-    between -100 and 100, the default is 0,
-
-    For sharpening and denoising the range is 0..100,
-    0 for sharpening or denoising disabled
-    and 100 for maximum sharpening/denoising applied.
+    The valid values range depends on the parameter type.
+    For WhiteBalancePreset the value should be one of QCameraImageProcessing::WhiteBalanceMode values;
+    for Contrast, Saturation, Brightness, Sharpening and Denoising the value should be
+    in [0..1.0] range with invalid QVariant value indicating the default parameter value;
+    for ContrastAdjustment, SaturationAdjustment, BrightnessAdjustment,
+    SharpeningAdjustment and DenoisingAdjustment the value should be
+    in [-1.0..1.0] range with default 0.
 */
 
 /*!
   \enum QCameraImageProcessingControl::ProcessingParameter
 
+  \value WhiteBalancePreset
+    The white balance preset.
+  \value ColorTemperature
+    Color temperature in K. This value is used when the manual white balance mode is selected.
   \value Contrast
     Image contrast.
   \value Saturation
@@ -165,8 +174,16 @@ QCameraImageProcessingControl::~QCameraImageProcessingControl()
     Amount of sharpening applied.
   \value Denoising
     Amount of denoising applied.
-  \value ColorTemperature
-    Color temperature in K. This value is used when the manual white balance mode is selected.
+  \value ContrastAdjustment
+    Image contrast adjustment.
+  \value SaturationAdjustment
+    Image saturation adjustment.
+  \value BrightnessAdjustment
+    Image brightness adjustment.
+  \value SharpeningAdjustment
+    Adjustment of sharpening applied.
+  \value DenoisingAdjustment
+    Adjustment of denoising applied.
   \value ExtendedParameter
     The base value for platform specific extended parameters.
  */
index 4da0051..41200b2 100644 (file)
@@ -64,22 +64,25 @@ public:
     ~QCameraImageProcessingControl();
 
     enum ProcessingParameter {
-        Contrast = 0,
-        Saturation = 1,
-        Brightness = 2,
-        Sharpening = 3,
-        Denoising = 4,
-        ColorTemperature = 5,
+        WhiteBalancePreset,
+        ColorTemperature,
+        Contrast,
+        Saturation,
+        Brightness,
+        Sharpening,
+        Denoising,
+        ContrastAdjustment,
+        SaturationAdjustment,
+        BrightnessAdjustment,
+        SharpeningAdjustment,
+        DenoisingAdjustment,
         ExtendedParameter = 1000
     };
 
-    virtual QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode() const = 0;
-    virtual void setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode) = 0;
-    virtual bool isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode) const = 0;
-
-    virtual bool isProcessingParameterSupported(ProcessingParameter) const = 0;
-    virtual QVariant processingParameter(ProcessingParameter parameter) const = 0;
-    virtual void setProcessingParameter(ProcessingParameter parameter, QVariant value) = 0;
+    virtual bool isParameterSupported(ProcessingParameter) const = 0;
+    virtual bool isParameterValueSupported(ProcessingParameter parameter, const QVariant &value) const = 0;
+    virtual QVariant parameter(ProcessingParameter parameter) const = 0;
+    virtual void setParameter(ProcessingParameter parameter, const QVariant &value) = 0;
 
 protected:
     QCameraImageProcessingControl(QObject* parent = 0);
index 7f09b07..83b00a3 100644 (file)
@@ -217,9 +217,9 @@ void tst_QCamera::testSimpleCameraWhiteBalance()
     QCOMPARE(camera.imageProcessing()->whiteBalanceMode(), QCameraImageProcessing::WhiteBalanceAuto);
     camera.imageProcessing()->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceCloudy);
     QCOMPARE(camera.imageProcessing()->whiteBalanceMode(), QCameraImageProcessing::WhiteBalanceAuto);
-    QCOMPARE(camera.imageProcessing()->manualWhiteBalance()0);
+    QCOMPARE(camera.imageProcessing()->manualWhiteBalance()+1.0, 1.0);
     camera.imageProcessing()->setManualWhiteBalance(5000);
-    QCOMPARE(camera.imageProcessing()->manualWhiteBalance()0);
+    QCOMPARE(camera.imageProcessing()->manualWhiteBalance()+1.0, 1.0);
 }
 
 void tst_QCamera::testSimpleCameraExposure()
@@ -529,7 +529,7 @@ void tst_QCamera::testCameraWhiteBalance()
     MockCameraService service;
     service.mockImageProcessingControl->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceFlash);
     service.mockImageProcessingControl->setSupportedWhiteBalanceModes(whiteBalanceModes);
-    service.mockImageProcessingControl->setProcessingParameter(
+    service.mockImageProcessingControl->setParameter(
                 QCameraImageProcessingControl::ColorTemperature,
                 QVariant(34));
 
@@ -549,10 +549,10 @@ void tst_QCamera::testCameraWhiteBalance()
 
     cameraImageProcessing->setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceManual);
     QCOMPARE(cameraImageProcessing->whiteBalanceMode(), QCameraImageProcessing::WhiteBalanceManual);
-    QCOMPARE(cameraImageProcessing->manualWhiteBalance(), 34);
+    QCOMPARE(cameraImageProcessing->manualWhiteBalance(), 34.0);
 
-    cameraImageProcessing->setManualWhiteBalance(432);
-    QCOMPARE(cameraImageProcessing->manualWhiteBalance(), 432);
+    cameraImageProcessing->setManualWhiteBalance(432.0);
+    QCOMPARE(cameraImageProcessing->manualWhiteBalance(), 432.0);
 }
 
 void tst_QCamera::testCameraExposure()
@@ -1550,11 +1550,11 @@ void tst_QCamera::testContrast()
     QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
     QVERIFY(cameraImageProcessing->contrast() ==0);
 
-    cameraImageProcessing->setContrast(123);
-    QVERIFY(cameraImageProcessing->contrast() ==123);
+    cameraImageProcessing->setContrast(0.123);
+    QCOMPARE(cameraImageProcessing->contrast(), 0.123);
 
     cameraImageProcessing->setContrast(4.56);
-    QVERIFY(cameraImageProcessing->contrast() ==4);
+    QCOMPARE(cameraImageProcessing->contrast(), 4.56);
 }
 
 void tst_QCamera::testDenoisingLevel()
@@ -1562,18 +1562,13 @@ void tst_QCamera::testDenoisingLevel()
     QCamera camera;
     QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
 
-    if (cameraImageProcessing->isDenoisingSupported())
-    {
-        QVERIFY(cameraImageProcessing->denoisingLevel() == -1);
+    QCOMPARE(cameraImageProcessing->denoisingLevel()+1 , 1.0);
 
-        cameraImageProcessing->setDenoisingLevel(0);
-        QVERIFY(cameraImageProcessing->denoisingLevel() == 0);
+    cameraImageProcessing->setDenoisingLevel(-0.3);
+    QCOMPARE(cameraImageProcessing->denoisingLevel() , -0.3);
 
-        cameraImageProcessing->setDenoisingLevel(12);
-        QVERIFY(cameraImageProcessing->denoisingLevel() == 12);
-    }
-    else
-        QVERIFY(cameraImageProcessing->denoisingLevel() == -1);
+    cameraImageProcessing->setDenoisingLevel(0.3);
+    QCOMPARE(cameraImageProcessing->denoisingLevel() , 0.3);
 }
 
 void tst_QCamera::testIsAvailable()
@@ -1587,19 +1582,13 @@ void tst_QCamera::testSaturation()
 {
     QCamera camera;
     QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
-    QVERIFY(cameraImageProcessing->saturation() == 0);
-
-    cameraImageProcessing->setSaturation(50);
-    QVERIFY(cameraImageProcessing->saturation() == 50);
+    QCOMPARE(cameraImageProcessing->saturation()+1.0, 1.0);
 
-    cameraImageProcessing->setSaturation(-50);
-    QVERIFY(cameraImageProcessing->saturation() == -50);
+    cameraImageProcessing->setSaturation(0.5);
+    QCOMPARE(cameraImageProcessing->saturation(), 0.5);
 
-    cameraImageProcessing->setSaturation(100);
-    QVERIFY(cameraImageProcessing->saturation() == 100);
-
-    cameraImageProcessing->setSaturation(-100);
-    QVERIFY(cameraImageProcessing->saturation() == -100);
+    cameraImageProcessing->setSaturation(-0.5);
+    QCOMPARE(cameraImageProcessing->saturation(), -0.5);
 }
 
 void tst_QCamera::testSharpeningLevel()
@@ -1607,14 +1596,14 @@ void tst_QCamera::testSharpeningLevel()
     QCamera camera;
 
     QCameraImageProcessing *cameraImageProcessing = camera.imageProcessing();
-    QVERIFY(cameraImageProcessing->isSharpeningSupported());
-    QVERIFY(cameraImageProcessing->sharpeningLevel() == -1);
 
-    cameraImageProcessing->setSharpeningLevel(123);
-    QVERIFY(cameraImageProcessing->sharpeningLevel() == 123);
+    QCOMPARE(cameraImageProcessing->sharpeningLevel()+1 , 1.0);
+
+    cameraImageProcessing->setSharpeningLevel(-0.3);
+    QCOMPARE(cameraImageProcessing->sharpeningLevel() , -0.3);
 
-    cameraImageProcessing->setSharpeningLevel(4.67);
-    QVERIFY(cameraImageProcessing->sharpeningLevel() == 4);
+    cameraImageProcessing->setSharpeningLevel(0.3);
+    QCOMPARE(cameraImageProcessing->sharpeningLevel() , 0.3);
 }
 
 void tst_QCamera::testEnumOfQCameraImageProcessing()
index 29a3a1b..eca2d34 100644 (file)
@@ -73,67 +73,75 @@ public:
         m_supportedWhiteBalance = modes;
     }
 
-    bool isProcessingParameterSupported(ProcessingParameter parameter) const
+    bool isParameterSupported(ProcessingParameter parameter) const
     {
-        //return parameter == Contrast ||  parameter == Sharpening || parameter == ColorTemperature;
         switch (parameter)
         {
-        case Contrast:
-        case Brightness:
-        case Sharpening:
-        case Saturation:
-        case Denoising:
+        case ContrastAdjustment:
+        case BrightnessAdjustment:
+        case SharpeningAdjustment:
+        case SaturationAdjustment:
+        case DenoisingAdjustment:
         case ColorTemperature:
-        case ExtendedParameter:
+        case WhiteBalancePreset:
             return true;
         default :
             return false;
         }
     }
-    QVariant processingParameter(ProcessingParameter parameter) const
+
+    bool isParameterValueSupported(ProcessingParameter parameter, const QVariant &value) const
+    {
+        if (parameter != WhiteBalancePreset)
+            return false;
+
+        return m_supportedWhiteBalance.contains(value.value<QCameraImageProcessing::WhiteBalanceMode>());
+    }
+
+    QVariant parameter(ProcessingParameter parameter) const
     {
         switch (parameter) {
-        case Contrast:
+        case ContrastAdjustment:
             return m_contrast;
-        case Saturation:
+        case SaturationAdjustment:
             return m_saturation;
-        case Brightness:
+        case BrightnessAdjustment:
             return m_brightness;
-        case Sharpening:
+        case SharpeningAdjustment:
             return m_sharpeningLevel;
-        case Denoising:
+        case DenoisingAdjustment:
             return m_denoising;
         case ColorTemperature:
             return m_manualWhiteBalance;
-        case ExtendedParameter:
-            return m_extendedParameter;
+        case WhiteBalancePreset:
+            return QVariant::fromValue<QCameraImageProcessing::WhiteBalanceMode>(m_whiteBalanceMode);
         default:
             return QVariant();
         }
     }
-    void setProcessingParameter(ProcessingParameter parameter, QVariant value)
+    void setParameter(ProcessingParameter parameter, const QVariant &value)
     {
         switch (parameter) {
-        case Contrast:
+        case ContrastAdjustment:
             m_contrast = value;
             break;
-        case Saturation:
+        case SaturationAdjustment:
             m_saturation = value;
             break;
-        case Brightness:
+        case BrightnessAdjustment:
             m_brightness = value;
             break;
-        case Sharpening:
+        case SharpeningAdjustment:
             m_sharpeningLevel = value;
             break;
-        case Denoising:
+        case DenoisingAdjustment:
             m_denoising = value;
             break;
         case ColorTemperature:
             m_manualWhiteBalance = value;
             break;
-        case ExtendedParameter:
-            m_extendedParameter = value;
+        case WhiteBalancePreset:
+            m_whiteBalanceMode = value.value<QCameraImageProcessing::WhiteBalanceMode>();
             break;
         default:
             break;
@@ -150,7 +158,6 @@ private:
     QVariant m_saturation;
     QVariant m_brightness;
     QVariant m_denoising;
-    QVariant m_extendedParameter;
 };
 
 #endif // MOCKCAMERAIMAGEPROCESSINGCONTROL_H