diff options
author | Jake Petroules <jake.petroules@qt.io> | 2016-05-09 19:13:23 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2016-05-24 06:45:37 +0000 |
commit | 1f43c7433ae7be13fc51f70b85e3b69fce84bc82 (patch) | |
tree | f22981a8d4316b7538b0677a262706177ee049c4 | |
parent | 5d286546f0041dc1afe51c9a202e4d34fef69c38 (diff) | |
download | qtgraphicaleffects-1f43c7433ae7be13fc51f70b85e3b69fce84bc82.tar.gz |
Provide the ability to invert alpha in sourceMasks of OpacityMask.
This is very useful for using masks exported directly from design tools
like Photoshop which may utilize alpha in the inverse manner of Qt.
Change-Id: I5e6358714b176cd3fe3cb22db380f313663aa0f7
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
-rw-r--r-- | src/effects/OpacityMask.qml | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/effects/OpacityMask.qml b/src/effects/OpacityMask.qml index 6653ddf..c4c5f7a 100644 --- a/src/effects/OpacityMask.qml +++ b/src/effects/OpacityMask.qml @@ -114,6 +114,21 @@ Item { */ property bool cached: false + /*! + This property controls how the alpha values of the sourceMask will behave. + + If this property is \c false, the resulting opacity is the source alpha + multiplied with the mask alpha, \c{As * Am}. + + If this property is \c true, the resulting opacity is the source alpha + multiplied with the inverse of the mask alpha, \c{As * (1 - Am)}. + + The default is \c false. + + \since 5.7 + */ + property bool invert: false + SourceProxy { id: sourceProxy input: rootItem.source @@ -147,7 +162,9 @@ Item { uniform lowp sampler2D source; uniform lowp sampler2D maskSource; void main(void) { - gl_FragColor = texture2D(source, qt_TexCoord0.st) * (texture2D(maskSource, qt_TexCoord0.st).a) * qt_Opacity; + gl_FragColor = texture2D(source, qt_TexCoord0.st) * (" + + (invert ? "1.0 - " : "") + + "texture2D(maskSource, qt_TexCoord0.st).a) * qt_Opacity; } " } |