QML ShaderEffectSource Element
- hideSource : bool
- live : bool
- sourceItem : Item
- sourceRect : QRectF
- textureSize : QSize
- wrapMode : enumeration
ShaderEffectSource is available in the Qt.labs.shaders 1.0 module. Elements in the Qt.labs module are not guaranteed to remain compatible in future versions.
This element provides preliminary support for OpenGL shaders in QML, and may be heavily changed or removed in later versions.
ShaderEffectSource object encapsulates the source content so that it can be utilized in ShaderEffectItem. Source content can be a live QML object tree, or a snapshot of QML object tree.
hideSource : bool
This property holds the flag to define whether the original source item is hidden when the effect item is drawn.
The default value is false.
live : bool
This property holds the optimization flag to define whether the source item content is changing or static.
If value true is assigned to this property, source item content is re-rendered into a texture for every frame. Setting the value to false improves the performance as it skips rendering the source item (and its chidleren) and instead immediately passes the previously rendered and cached texture to the shaders.
The default value is true.
sourceItem : Item
This property holds the Item which is used as the source for the shader effect. If the item has children, those are included as well.
Note: When source item content is passed to the ShaderEffectItem(s), it is always clipped to the boundingrect of the sourceItem regardless of its clipping property.
sourceRect : QRectF
This property can be used to specify margins for the source content.
If other value than Qt.rect(0,0,0,0) is assigned to this property, it is interpreted as specifying a relative source rectangle for the source content.
For example, setting Qt.rect(-10.0, -10.0, 120.0, 120.0) for a source that has width and height of 100 pixels would produce 10 pixels margins to each side of the source.
Margins are useful when the original content is wanted to be spread outside the original source area, like when creating a dropshadow with the shader or in other similar effects.
The default value is Qt.rect(0,0,0,0).
textureSize : QSize
wrapMode : enumeration
This property defines the wrap parameter for the source after it has been mapped as a texture.
- ShaderEffectSource.ClampToEdge - Causes texturecoordinates to be clamped to the range [ 1/2*N , 1 - 1/2*N ], where N is the texture width.
- ShaderEffectSource.RepeatHorizontally - Causes the integer part of the horizontal texturecoordinate to be ignored; the GL uses only the fractional part, thereby creating a horizontal repeating pattern.
- ShaderEffectSource.RepeatVertically - Causes the integer part of the vertical texturecoordinate to be ignored; the GL uses only the fractional part, thereby creating a vertical repeating pattern.
- ShaderEffectSource.Repeat - Causes the integer part of both the horizontal and vertical texturecoordinates to be ignored; the GL uses only the fractional part, thereby creating a repeating pattern.
The default value is ClampToEdge.
Repaints the source item content into the texture.
This method is useful when ShaderEffectSource::live has been set to false and the changes in the source item content is desired to be made visible for the shaders.