forked from flutter-team-archive/engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathporter_duff_blend.frag
More file actions
52 lines (44 loc) · 1.43 KB
/
Copy pathporter_duff_blend.frag
File metadata and controls
52 lines (44 loc) · 1.43 KB
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
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
precision mediump float;
#include <impeller/blending.glsl>
#include <impeller/color.glsl>
#include <impeller/texture.glsl>
#include <impeller/types.glsl>
uniform f16sampler2D texture_sampler_dst;
uniform FragInfo {
float16_t src_coeff;
float16_t src_coeff_dst_alpha;
float16_t dst_coeff;
float16_t dst_coeff_src_alpha;
float16_t dst_coeff_src_color;
float16_t input_alpha;
float16_t output_alpha;
float supports_decal_sampler_address_mode;
}
frag_info;
in vec2 v_texture_coords;
in f16vec4 v_color;
out f16vec4 frag_color;
f16vec4 Sample(f16sampler2D texture_sampler, vec2 texture_coords) {
#ifdef IMPELLER_TARGET_OPENGLES
if (frag_info.supports_decal_sampler_address_mode > 0.0) {
return texture(texture_sampler, texture_coords);
} else {
return IPHalfSampleDecal(texture_sampler, texture_coords);
}
#else
return texture(texture_sampler, texture_coords);
#endif
}
void main() {
f16vec4 dst =
texture(texture_sampler_dst, v_texture_coords) * frag_info.input_alpha;
f16vec4 src = v_color;
frag_color =
src * (frag_info.src_coeff + dst.a * frag_info.src_coeff_dst_alpha) +
dst * (frag_info.dst_coeff + src.a * frag_info.dst_coeff_src_alpha +
src * frag_info.dst_coeff_src_color);
frag_color *= frag_info.output_alpha;
}