5
5
6
6
#ifdef WR_VERTEX_SHADER
7
7
8
+ #define SEGMENT_ALL 0
9
+ #define SEGMENT_CORNER_TL 1
10
+ #define SEGMENT_CORNER_TR 2
11
+ #define SEGMENT_CORNER_BL 3
12
+ #define SEGMENT_CORNER_BR 4
13
+
8
14
in int aClipRenderTaskIndex;
9
15
in int aClipLayerIndex;
10
16
in int aClipDataIndex;
11
- in int aClipBaseTaskIndex ;
17
+ in int aClipSegmentIndex ;
12
18
13
19
struct CacheClipInstance {
14
20
int render_task_index;
15
21
int layer_index;
16
22
int data_index;
17
- int base_task_index ;
23
+ int segment_index ;
18
24
};
19
25
20
26
CacheClipInstance fetch_clip_item(int index) {
@@ -23,7 +29,7 @@ CacheClipInstance fetch_clip_item(int index) {
23
29
cci.render_task_index = aClipRenderTaskIndex;
24
30
cci.layer_index = aClipLayerIndex;
25
31
cci.data_index = aClipDataIndex;
26
- cci.base_task_index = aClipBaseTaskIndex ;
32
+ cci.segment_index = aClipSegmentIndex ;
27
33
28
34
return cci;
29
35
}
@@ -32,23 +38,54 @@ CacheClipInstance fetch_clip_item(int index) {
32
38
// which is the intersection of all clip instances of a given primitive
33
39
TransformVertexInfo write_clip_tile_vertex(vec4 local_clip_rect,
34
40
Layer layer,
35
- ClipArea area) {
41
+ ClipArea area,
42
+ int segment_index) {
36
43
vec2 lp0_base = local_clip_rect.xy;
37
44
vec2 lp1_base = local_clip_rect.xy + local_clip_rect.zw;
38
45
39
46
vec2 lp0 = clamp_rect(lp0_base, layer.local_clip_rect);
40
47
vec2 lp1 = clamp_rect(lp1_base, layer.local_clip_rect);
41
48
vec4 clipped_local_rect = vec4 (lp0, lp1 - lp0);
42
49
43
- vec2 final_pos = mix (area.task_bounds.xy, area.task_bounds.zw, aPosition.xy);
50
+ vec2 outer_p0 = area.screen_origin_target_index.xy;
51
+ vec2 outer_p1 = outer_p0 + area.task_bounds.zw - area.task_bounds.xy;
52
+ vec2 inner_p0 = area.inner_rect.xy;
53
+ vec2 inner_p1 = area.inner_rect.zw;
54
+
55
+ vec2 p0, p1;
56
+ switch (segment_index) {
57
+ case SEGMENT_ALL:
58
+ p0 = outer_p0;
59
+ p1 = outer_p1;
60
+ break ;
61
+ case SEGMENT_CORNER_TL:
62
+ p0 = outer_p0;
63
+ p1 = inner_p0;
64
+ break ;
65
+ case SEGMENT_CORNER_BL:
66
+ p0 = vec2 (outer_p0.x, outer_p1.y);
67
+ p1 = vec2 (inner_p0.x, inner_p1.y);
68
+ break ;
69
+ case SEGMENT_CORNER_TR:
70
+ p0 = vec2 (outer_p1.x, outer_p1.y);
71
+ p1 = vec2 (inner_p1.x, inner_p1.y);
72
+ break ;
73
+ case SEGMENT_CORNER_BR:
74
+ p0 = vec2 (outer_p1.x, outer_p0.y);
75
+ p1 = vec2 (inner_p1.x, inner_p0.y);
76
+ break ;
77
+ }
78
+
79
+ vec2 actual_pos = mix (p0, p1, aPosition.xy);
80
+
81
+ vec4 layer_pos = get_layer_pos(actual_pos / uDevicePixelRatio, layer);
44
82
45
83
// compute the point position in side the layer, in CSS space
46
- vec2 clamped_pos = final_pos + area.screen_origin_target_index.xy - area.task_bounds.xy;
47
- vec4 layer_pos = get_layer_pos(clamped_pos / uDevicePixelRatio, layer);
84
+ vec2 vertex_pos = actual_pos + area.task_bounds.xy - area.screen_origin_target_index.xy;
48
85
49
- gl_Position = uTransform * vec4 (final_pos , 0.0 , 1 );
86
+ gl_Position = uTransform * vec4 (vertex_pos , 0.0 , 1 );
50
87
51
- return TransformVertexInfo(layer_pos.xyw, clamped_pos , clipped_local_rect);
88
+ return TransformVertexInfo(layer_pos.xyw, actual_pos , clipped_local_rect);
52
89
}
53
90
54
91
#endif // WR_VERTEX_SHADER
0 commit comments