[SailfishDevel] Different behaviour of ShaderEffectSource in emulator vs. device

Luca Donaggio donaggio at gmail.com
Tue Feb 10 10:24:57 UTC 2015


Hi Andrey, thanks for your reply.

Still, can you try both tests on your Jolla?
The first shouldn't work, while the second does.

On Tue, Feb 10, 2015 at 10:32 AM, Andrey Kozhevnikov <coderusinbox at gmail.com
> wrote:

>  sorry, not using emulator at all.
>
> 10.02.2015 14:28, Luca Donaggio пишет:
>
> Anybody is willing to try my test code and confirm or deny my finding?
>
> On Fri, Feb 6, 2015 at 2:12 PM, Luca Donaggio <donaggio at gmail.com> wrote:
>
>> The following code works fine in Emulator, changing the gradient of the
>> Rectangle correctly updates the nested ShaderEffectSource and it is
>> reflected on the ShaderEffect which uses it as its texture:
>>
>> Page {
>>     id: page
>>
>>     SilicaFlickable {
>>         anchors.fill: parent
>>
>>         contentHeight: column.height
>>
>>         Column {
>>             id: column
>>
>>             anchors { top: parent.top; left: parent.left; right:
>> parent.right; leftMargin: Theme.paddingLarge; rightMargin:
>> Theme.paddingLarge; }
>>             spacing: Theme.paddingLarge
>>
>>             PageHeader {
>>                 title: qsTr("ShaderEffect Test")
>>             }
>>
>>             Row {
>>                 anchors.horizontalCenter: parent.horizontalCenter
>>                 spacing: Theme.paddingLarge
>>
>>                 Column {
>>                     spacing: Theme.paddingSmall
>>
>>                     Rectangle {
>>                         id: gradientSource
>>
>>                         property list<Gradient> gradients: [
>>                             Gradient {
>>                                 GradientStop { position: 0.0; color:
>> "black"; }
>>                                 GradientStop { position: 1.0; color:
>> "blue"; }
>>                             },
>>
>>                             Gradient {
>>                                 GradientStop { position: 0.0; color:
>> "black"; }
>>                                 GradientStop { position: 1.0; color:
>> "red"; }
>>                             }
>>                         ]
>>
>>                         width: 100
>>                         height: 100
>>
>>                         gradient: gradients[0]
>>
>>                         ShaderEffectSource {
>>                             id: gradientTexture
>>
>>                             anchors.fill: parent
>>                             sourceItem: gradientSource
>>                             hideSource: false
>>                             live: true
>>                         }
>>                     }
>>
>>                     Label {
>>                         font.pixelSize: Theme.fontSizeExtraSmall
>>                         wrapMode: Text.WordWrap
>>                         text: "Rectangle\nShaderEffectSource"
>>                     }
>>                 }
>>
>>                 Column {
>>                     spacing: Theme.paddingSmall
>>
>>                     ShaderEffect {
>>                         property variant source: gradientTexture
>>
>>                         width: 100
>>                         height: 100
>>
>>                         blending: false
>>                         cullMode: ShaderEffect.BackFaceCulling
>>                         fragmentShader: "
>>                             varying highp vec2 qt_TexCoord0;
>>                             uniform lowp float qt_Opacity;
>>                             uniform sampler2D source;
>>
>>                             void main() {
>>                                 gl_FragColor = texture2D(source,
>> qt_TexCoord0) * qt_Opacity;
>>                             }"
>>                     }
>>
>>                     Label {
>>                         font.pixelSize: Theme.fontSizeExtraSmall
>>                         text: "ShaderEffect"
>>                     }
>>                 }
>>             }
>>
>>             Button {
>>                 anchors.horizontalCenter: parent.horizontalCenter
>>                 text: "Blue gradient"
>>
>>                 onClicked: gradientSource.gradient =
>> gradientSource.gradients[0]
>>             }
>>
>>             Button {
>>                 anchors.horizontalCenter: parent.horizontalCenter
>>                 text: "Red gradient"
>>
>>                 onClicked: gradientSource.gradient =
>> gradientSource.gradients[1]
>>             }
>>         }
>>     }
>> }
>>
>> It doesn't work on device though (changing Reactangle's gradient doesn't
>> update the ShaderEffectSource).
>>
>>  Un-nesting the ShaderEffectSource from its source item (the Rectangle)
>> works fine both on emulator and on device:
>>
>> Page {
>>     id: page
>>
>>     SilicaFlickable {
>>         anchors.fill: parent
>>
>>         contentHeight: column.height
>>
>>         Column {
>>             id: column
>>
>>             anchors { top: parent.top; left: parent.left; right:
>> parent.right; leftMargin: Theme.paddingLarge; rightMargin:
>> Theme.paddingLarge; }
>>             spacing: Theme.paddingLarge
>>
>>             PageHeader {
>>                 title: qsTr("ShaderEffect Test")
>>             }
>>
>>             Row {
>>                 anchors.horizontalCenter: parent.horizontalCenter
>>                 spacing: Theme.paddingLarge
>>
>>                 Column {
>>                     spacing: Theme.paddingSmall
>>
>>                     Rectangle {
>>                         id: gradientSource
>>
>>                         property list<Gradient> gradients: [
>>                             Gradient {
>>                                 GradientStop { position: 0.0; color:
>> "black"; }
>>                                 GradientStop { position: 1.0; color:
>> "blue"; }
>>                             },
>>
>>                             Gradient {
>>                                 GradientStop { position: 0.0; color:
>> "black"; }
>>                                 GradientStop { position: 1.0; color:
>> "red"; }
>>                             }
>>                         ]
>>
>>                         width: 100
>>                         height: 100
>>
>>                         gradient: gradients[0]
>>                     }
>>
>>                     Label {
>>                         font.pixelSize: Theme.fontSizeExtraSmall
>>                         text: "Rectangle"
>>                     }
>>                 }
>>
>>                 Column {
>>                     spacing: Theme.paddingSmall
>>
>>                     ShaderEffectSource {
>>                         id: gradientTexture
>>
>>                         width: 100
>>                         height: 100
>>                         sourceItem: gradientSource
>>                         hideSource: false
>>                         live: true
>>                     }
>>
>>                     Label {
>>                         font.pixelSize: Theme.fontSizeExtraSmall
>>                         text: "ShaderEffectSource"
>>                     }
>>                 }
>>
>>                 Column {
>>                     spacing: Theme.paddingSmall
>>
>>                     ShaderEffect {
>>                         property variant source: gradientTexture
>>
>>                         width: 100
>>                         height: 100
>>
>>                         blending: false
>>                         cullMode: ShaderEffect.BackFaceCulling
>>                         fragmentShader: "
>>                             varying highp vec2 qt_TexCoord0;
>>                             uniform lowp float qt_Opacity;
>>                             uniform sampler2D source;
>>
>>                             void main() {
>>                                 gl_FragColor = texture2D(source,
>> qt_TexCoord0) * qt_Opacity;
>>                             }"
>>                     }
>>
>>                     Label {
>>                         font.pixelSize: Theme.fontSizeExtraSmall
>>                         text: "ShaderEffect"
>>                     }
>>                 }
>>             }
>>
>>             Button {
>>                 anchors.horizontalCenter: parent.horizontalCenter
>>                 text: "Blue gradient"
>>
>>                 onClicked: gradientSource.gradient =
>> gradientSource.gradients[0]
>>             }
>>
>>             Button {
>>                 anchors.horizontalCenter: parent.horizontalCenter
>>                 text: "Red gradient"
>>
>>                 onClicked: gradientSource.gradient =
>> gradientSource.gradients[1]
>>             }
>>         }
>>     }
>> }
>>
>>  Is it a bug?
>>
>> --
>> Luca Donaggio
>>
>
>
>
> --
> Luca Donaggio
>
>
> _______________________________________________
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to devel-unsubscribe at lists.sailfishos.org
>
>
>
> _______________________________________________
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to
> devel-unsubscribe at lists.sailfishos.org
>



-- 
Luca Donaggio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20150210/17ba42e8/attachment-0001.html>


More information about the Devel mailing list