~ubuntu-branches/ubuntu/wily/webbrowser-app/wily-proposed

« back to all changes in this revision

Viewing changes to src/Ubuntu/Browser/EmbeddedProgressBar.qml

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-06-05 05:03:05 UTC
  • Revision ID: package-import@ubuntu.com-20130605050305-qgpd9x3s01m06dca
Tags: upstream-0.20daily13.06.05
ImportĀ upstreamĀ versionĀ 0.20daily13.06.05

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
4
 * This file is part of webbrowser-app.
 
5
 *
 
6
 * webbrowser-app is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * webbrowser-app is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 2.0
 
20
 
 
21
ShaderEffect {
 
22
    property real minimumValue
 
23
    property real maximumValue
 
24
    property real value
 
25
 
 
26
    property alias source: __source.sourceItem
 
27
 
 
28
    property color bgColor
 
29
    property color fgColor
 
30
 
 
31
    anchors.fill: source
 
32
 
 
33
    cullMode: ShaderEffect.BackFaceCulling
 
34
 
 
35
    property var _source: ShaderEffectSource {
 
36
        id: __source
 
37
        hideSource: true
 
38
    }
 
39
    property real _progress: value / (maximumValue - minimumValue)
 
40
 
 
41
    fragmentShader: "
 
42
        varying highp vec2 qt_TexCoord0;
 
43
        uniform sampler2D _source;
 
44
        uniform highp vec4 bgColor;
 
45
        uniform highp vec4 fgColor;
 
46
        uniform lowp float qt_Opacity;
 
47
        uniform lowp float _progress;
 
48
        void main() {
 
49
            highp vec4 color = texture2D(_source, qt_TexCoord0);
 
50
            if (qt_TexCoord0.x <= _progress) {
 
51
                highp float luminance = dot(vec3(0.2126, 0.7152, 0.0722), color.rgb);
 
52
                gl_FragColor = mix(fgColor, bgColor, luminance) * color.a * qt_Opacity;
 
53
            } else {
 
54
                gl_FragColor = color * qt_Opacity;
 
55
            }
 
56
        }
 
57
    "
 
58
}