diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2017-01-31 17:09:21 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-01-31 16:52:58 +0000 |
commit | 9ae12590ac965ca454b67c27f4411d71ad05ae86 (patch) | |
tree | bab852f45d8936604a91c9a514531613d9f4a8e6 /src/render/framegraph/qviewport.cpp | |
parent | 708720b8a1056aec2c62a3a2467a324d62a25ee1 (diff) |
Add gamma to QViewport's API
Change-Id: Ieced911cf1e51c0befc5ce91e8529a421b5c5a80
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/framegraph/qviewport.cpp')
-rw-r--r-- | src/render/framegraph/qviewport.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/render/framegraph/qviewport.cpp b/src/render/framegraph/qviewport.cpp index a78e260a5..8c1ebe67c 100644 --- a/src/render/framegraph/qviewport.cpp +++ b/src/render/framegraph/qviewport.cpp @@ -50,6 +50,7 @@ namespace Qt3DRender { QViewportPrivate::QViewportPrivate() : QFrameGraphNodePrivate() , m_normalizedRect(QRectF(0.0f, 0.0f, 1.0f, 1.0f)) + , m_gamma(2.2f) { } @@ -62,7 +63,8 @@ QViewportPrivate::QViewportPrivate() \inherits Qt3DRender::QFrameGraphNode Qt3DRender::QViewport of the scene specifies at which portion of the render surface Qt3D - is rendering to. Area outside the viewport is left untouched. + is rendering to. Area outside the viewport is left untouched. It also controls global parameters + to the rendering in that viewport like gamma. */ /*! @@ -74,7 +76,8 @@ QViewportPrivate::QViewportPrivate() \brief A viewport on the Qt3D Scene Viewport of the scene specifies at which portion of the render surface Qt3D is - rendering to. Area outside the viewport is left untouched. + rendering to. Area outside the viewport is left untouched. It also controls global parameters + to the rendering in that viewport like gamma. */ /*! @@ -86,6 +89,12 @@ QViewportPrivate::QViewportPrivate() */ /*! + \qmlproperty rect Viewport::gamma + + Specifies the gamma factor for the viewport. The default is 2.2 which should give proper result on most screens. + */ + +/*! Constructs QViewport with given \a parent. */ QViewport::QViewport(QNode *parent) @@ -111,6 +120,12 @@ QRectF QViewport::normalizedRect() const return d->m_normalizedRect; } +float QViewport::gamma() const +{ + Q_D(const QViewport); + return d->m_gamma; +} + /*! \property QViewport::normalizedRect @@ -127,12 +142,27 @@ void QViewport::setNormalizedRect(const QRectF &normalizedRect) } } +/*! + \property QViewport::gamma + + Specifies the gamma factor for the viewport. The default is 2.2 which should give proper result on most screens. + */ +void QViewport::setGamma(float gamma) +{ + Q_D(QViewport); + if (gamma != d->m_gamma) { + d->m_gamma = gamma; + emit gammaChanged(gamma); + } +} + Qt3DCore::QNodeCreatedChangeBasePtr QViewport::createNodeCreationChange() const { auto creationChange = QFrameGraphNodeCreatedChangePtr<QViewportData>::create(this); auto &data = creationChange->data; Q_D(const QViewport); data.normalizedRect = d->m_normalizedRect; + data.gamma = d->m_gamma; return creationChange; } |