~ubuntu-branches/ubuntu/saucy/qtdeclarative-opensource-src/saucy

« back to all changes in this revision

Viewing changes to tests/manual/scenegraph_lancelot/data/shaders/hiddensource/unhidden_2.qml

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 14:17:19 UTC
  • Revision ID: package-import@ubuntu.com-20130205141719-qqeyml8wslpyez52
Tags: upstream-5.0.1
ImportĀ upstreamĀ versionĀ 5.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
 
 
3
Item {
 
4
    width: 320
 
5
    height: 480
 
6
 
 
7
    Rectangle {
 
8
        id: draggee
 
9
        width: 200
 
10
        height: 80
 
11
        x: 100
 
12
        y: 360
 
13
        gradient: Gradient {
 
14
            GradientStop { position: 0.0; color: "steelBlue" }
 
15
            GradientStop { position: 0.49; color: "white" }
 
16
            GradientStop { position: 0.5; color: "gray" }
 
17
            GradientStop { position: 1.0; color: "darkGray" }
 
18
        }
 
19
        radius: 20
 
20
        border.width: 2
 
21
        border.color: "black"
 
22
        Text {
 
23
            anchors.centerIn: parent
 
24
            font.pixelSize: 40
 
25
            text: "Position 2"
 
26
        }
 
27
    }
 
28
 
 
29
    ShaderEffectSource {
 
30
        id: source
 
31
        sourceItem: draggee
 
32
        hideSource: false
 
33
        property real margins: 6
 
34
        sourceRect: Qt.rect(-margins, -margins, sourceItem.width + 2 * margins, sourceItem.height + 2 * margins)
 
35
        smooth: true
 
36
    }
 
37
 
 
38
    ShaderEffect{
 
39
        id: effect
 
40
        anchors.fill: source.sourceItem
 
41
        anchors.margins: -source.margins
 
42
        property variant source: source
 
43
        property variant offset: Qt.size(4 / width, 4 / height)
 
44
        property variant delta: Qt.size(0.5 / width, 0.5 / height)
 
45
 
 
46
        fragmentShader: "
 
47
            uniform lowp sampler2D source;
 
48
            uniform highp vec2 offset;
 
49
            uniform highp vec2 delta;
 
50
            varying highp vec2 qt_TexCoord0;
 
51
            uniform lowp float qt_Opacity;
 
52
            void main() {
 
53
                highp vec2 delta2 = vec2(delta.x, -delta.y);
 
54
                lowp float shadow = 0.25 * (texture2D(source, qt_TexCoord0 - offset + delta).a
 
55
                                  + texture2D(source, qt_TexCoord0 - offset - delta).a
 
56
                                  + texture2D(source, qt_TexCoord0 - offset + delta2).a
 
57
                                  + texture2D(source, qt_TexCoord0 - offset - delta2).a);
 
58
                lowp vec4 color = texture2D(source, qt_TexCoord0);
 
59
                gl_FragColor = mix(vec4(vec3(0.), 0.5 * shadow), color, color.a);
 
60
            }
 
61
            "
 
62
    }
 
63
}
 
64
 
 
65
 
 
66