summaryrefslogtreecommitdiff
path: root/shaders/skia/1408.shader_test
blob: 1789de3712f3fdd275524d3277dfe68a3346620e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
[require]
GLSL >= 1.40

[fragment shader]
#version 140

#extension GL_ARB_fragment_coord_conventions : require
layout(origin_upper_left) in vec4 gl_FragCoord;
out vec4 sk_FragColor;
uniform vec4 uCoordTransformMatrix_1_Stage0;
uniform vec4 uCoordTransformMatrix_2_Stage0;
uniform vec4 usubset_Stage1_c0_c0;
uniform vec4 uclamp_Stage1_c0_c0;
uniform vec4 uboundsUniform_Stage2_c1_c0;
uniform float uxInvZoom_Stage2_c1_c0;
uniform float uyInvZoom_Stage2_c1_c0;
uniform float uxInvInset_Stage2_c1_c0;
uniform float uyInvInset_Stage2_c1_c0;
uniform vec2 uoffset_Stage2_c1_c0;
uniform sampler2D uTextureSampler_0_Stage1;
uniform sampler2D uTextureSampler_0_Stage2;
noperspective in vec4 vcolor_Stage0;
noperspective in vec3 vTransformedCoords_0_Stage0;
noperspective in float vinCoverage_Stage0;
vec4 TextureEffect_Stage1_c0_c0(vec4 _input, vec2 _coords) {
    _coords = _coords * uCoordTransformMatrix_1_Stage0.xz + uCoordTransformMatrix_1_Stage0.yw;
    vec4 _output;
    vec2 inCoord = _coords;
    vec2 subsetCoord;
    subsetCoord.x = mod(inCoord.x - usubset_Stage1_c0_c0.x, usubset_Stage1_c0_c0.z - usubset_Stage1_c0_c0.x) + usubset_Stage1_c0_c0.x;
    subsetCoord.y = mod(inCoord.y - usubset_Stage1_c0_c0.y, usubset_Stage1_c0_c0.w - usubset_Stage1_c0_c0.y) + usubset_Stage1_c0_c0.y;
    vec2 clampedCoord;
    clampedCoord.x = clamp(subsetCoord.x, uclamp_Stage1_c0_c0.x, uclamp_Stage1_c0_c0.z);
    clampedCoord.y = clamp(subsetCoord.y, uclamp_Stage1_c0_c0.y, uclamp_Stage1_c0_c0.w);
    vec4 textureColor = texture(uTextureSampler_0_Stage1, clampedCoord);
    _output = _input * textureColor;
    return _output;
}
vec4 MagnifierEffect_Stage2_c1_c0(vec4 _input, vec2 _coords) {
    _coords = _coords * uCoordTransformMatrix_2_Stage0.xz + uCoordTransformMatrix_2_Stage0.yw;
    vec4 _output;
    vec2 coord = _coords;
    vec2 zoom_coord = uoffset_Stage2_c1_c0 + coord * vec2(uxInvZoom_Stage2_c1_c0, uyInvZoom_Stage2_c1_c0);
    vec2 delta = (coord - uboundsUniform_Stage2_c1_c0.xy) * uboundsUniform_Stage2_c1_c0.zw;
    delta = min(delta, vec2(1.0, 1.0) - delta);
    delta *= vec2(uxInvInset_Stage2_c1_c0, uyInvInset_Stage2_c1_c0);
    float weight = 0.0;
    if (delta.x < 2.0 && delta.y < 2.0) {
        delta = vec2(2.0, 2.0) - delta;
        float dist = length(delta);
        dist = max(2.0 - dist, 0.0);
        weight = min(dist * dist, 1.0);
    } else {
        vec2 delta_squared = delta * delta;
        weight = min(min(delta_squared.x, delta_squared.y), 1.0);
    }
    _output = texture(uTextureSampler_0_Stage2, mix(coord, zoom_coord, weight));
    return _output;
}
void main() {
    vec4 outputCoverage_Stage0;
    {
        float alpha = 1.0;
        alpha = vinCoverage_Stage0;
        outputCoverage_Stage0 = vec4(alpha);
    }
    vec4 output_Stage1;
    {
        vec2 vTransformedCoords_0_Stage0_ensure2D = vTransformedCoords_0_Stage0.xy / vTransformedCoords_0_Stage0.z;
        float coord = vTransformedCoords_0_Stage0_ensure2D.y - 0.5;
        float f = fract(coord);
        coord += 0.5 - f;
        float f2 = f * f;
        vec4 w = mat4(0.055555555555555552, 0.88888888888888884, 0.055555555555555552, 0.0, -0.5, 0.0, 0.5, 0.0, 0.83333333333333337, -2.0, 1.5, -0.33333333333333331, -0.3888888888888889, 1.1666666666666667, -1.1666666666666667, 0.3888888888888889) * vec4(1.0, f, f2, f2 * f);
        vec4 c[4];
        c[0] = TextureEffect_Stage1_c0_c0(vec4(1.0), vec2(vTransformedCoords_0_Stage0_ensure2D.x, coord + -1.0));
        c[1] = TextureEffect_Stage1_c0_c0(vec4(1.0), vec2(vTransformedCoords_0_Stage0_ensure2D.x, coord));
        c[2] = TextureEffect_Stage1_c0_c0(vec4(1.0), vec2(vTransformedCoords_0_Stage0_ensure2D.x, coord + 1.0));
        c[3] = TextureEffect_Stage1_c0_c0(vec4(1.0), vec2(vTransformedCoords_0_Stage0_ensure2D.x, coord + 2.0));
        vec4 bicubicColor = ((c[0] * w.x + c[1] * w.y) + c[2] * w.z) + c[3] * w.w;
        bicubicColor.xyz = max(vec3(0.0), min(bicubicColor.xyz, bicubicColor.www));
        output_Stage1 = bicubicColor * outputCoverage_Stage0;
    }
    vec4 output_Stage2;
    {
        output_Stage2 = MagnifierEffect_Stage2_c1_c0(output_Stage1, gl_FragCoord.xy);
    }
    {
        sk_FragColor = output_Stage2;
    }
}

[vertex shader]
#version 140

uniform vec4 sk_RTAdjust;
uniform mat3 uCoordTransformMatrix_0_Stage0;
in vec2 inPosition;
in vec4 inColor;
in float inCoverage;
noperspective out vec4 vcolor_Stage0;
noperspective out vec3 vTransformedCoords_0_Stage0;
noperspective out float vinCoverage_Stage0;
void main() {
    vec4 color = inColor;
    vcolor_Stage0 = color;
    vec2 pos2 = inPosition;
    vTransformedCoords_0_Stage0 = uCoordTransformMatrix_0_Stage0 * vec3(inPosition, 1.0);
    vinCoverage_Stage0 = inCoverage;
    gl_Position = vec4(pos2.x, pos2.y, 0.0, 1.0);
    gl_Position = vec4(gl_Position.xy * sk_RTAdjust.xz + gl_Position.ww * sk_RTAdjust.yw, 0.0, gl_Position.w);
}