mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update webrender to get clip_shared changes.
This commit is contained in:
parent
f96718d03d
commit
6925c6246f
13 changed files with 60 additions and 61 deletions
4
components/servo/Cargo.lock
generated
4
components/servo/Cargo.lock
generated
|
@ -2658,7 +2658,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webrender"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/servo/webrender#b31b4cf76324bfbe82d27a059e1330ef5ae34c35"
|
||||
source = "git+https://github.com/servo/webrender#dff3e5dbcc3a40b3c5db37bf2e31422c61bf6dde"
|
||||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2683,7 +2683,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webrender_traits"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/servo/webrender#b31b4cf76324bfbe82d27a059e1330ef5ae34c35"
|
||||
source = "git+https://github.com/servo/webrender#dff3e5dbcc3a40b3c5db37bf2e31422c61bf6dde"
|
||||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
4
ports/cef/Cargo.lock
generated
4
ports/cef/Cargo.lock
generated
|
@ -2516,7 +2516,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webrender"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/servo/webrender#b31b4cf76324bfbe82d27a059e1330ef5ae34c35"
|
||||
source = "git+https://github.com/servo/webrender#dff3e5dbcc3a40b3c5db37bf2e31422c61bf6dde"
|
||||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bincode 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -2541,7 +2541,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "webrender_traits"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/servo/webrender#b31b4cf76324bfbe82d27a059e1330ef5ae34c35"
|
||||
source = "git+https://github.com/servo/webrender#dff3e5dbcc3a40b3c5db37bf2e31422c61bf6dde"
|
||||
dependencies = [
|
||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
50
resources/shaders/clip_shared.glsl
Normal file
50
resources/shaders/clip_shared.glsl
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
flat varying vec4 vClipRect;
|
||||
flat varying vec4 vClipRadius;
|
||||
|
||||
#ifdef WR_VERTEX_SHADER
|
||||
void write_clip(Clip clip) {
|
||||
vClipRect = vec4(clip.rect.xy, clip.rect.xy + clip.rect.zw);
|
||||
vClipRadius = vec4(clip.top_left.outer_inner_radius.x,
|
||||
clip.top_right.outer_inner_radius.x,
|
||||
clip.bottom_right.outer_inner_radius.x,
|
||||
clip.bottom_left.outer_inner_radius.x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
float do_clip(vec2 pos) {
|
||||
vec2 ref_tl = vClipRect.xy + vec2( vClipRadius.x, vClipRadius.x);
|
||||
vec2 ref_tr = vClipRect.zy + vec2(-vClipRadius.y, vClipRadius.y);
|
||||
vec2 ref_br = vClipRect.zw + vec2(-vClipRadius.z, -vClipRadius.z);
|
||||
vec2 ref_bl = vClipRect.xw + vec2( vClipRadius.w, -vClipRadius.w);
|
||||
|
||||
float d_tl = distance(pos, ref_tl);
|
||||
float d_tr = distance(pos, ref_tr);
|
||||
float d_br = distance(pos, ref_br);
|
||||
float d_bl = distance(pos, ref_bl);
|
||||
|
||||
float pixels_per_fragment = length(fwidth(pos.xy));
|
||||
// TODO: compute the `nudge` separately for X and Y
|
||||
float nudge = 0.5 * pixels_per_fragment;
|
||||
|
||||
bool out0 = pos.x < ref_tl.x && pos.y < ref_tl.y && d_tl > vClipRadius.x - nudge;
|
||||
bool out1 = pos.x > ref_tr.x && pos.y < ref_tr.y && d_tr > vClipRadius.y - nudge;
|
||||
bool out2 = pos.x > ref_br.x && pos.y > ref_br.y && d_br > vClipRadius.z - nudge;
|
||||
bool out3 = pos.x < ref_bl.x && pos.y > ref_bl.y && d_bl > vClipRadius.w - nudge;
|
||||
|
||||
vec4 distances = vec4(d_tl, d_tr, d_br, d_bl) - vClipRadius + nudge;
|
||||
float distance_from_border = dot(vec4(out0, out1, out2, out3), distances);
|
||||
|
||||
// Move the distance back into pixels.
|
||||
distance_from_border /= pixels_per_fragment;
|
||||
|
||||
// Apply a more gradual fade out to transparent.
|
||||
//distance_from_border -= 0.5;
|
||||
|
||||
return 1.0 - smoothstep(0.0, 1.0, distance_from_border);
|
||||
}
|
||||
#endif
|
|
@ -545,39 +545,6 @@ Composite fetch_composite(int index) {
|
|||
#endif
|
||||
|
||||
#ifdef WR_FRAGMENT_SHADER
|
||||
float do_clip(vec2 pos, vec4 clip_rect, vec4 radius) {
|
||||
vec2 ref_tl = clip_rect.xy + vec2( radius.x, radius.x);
|
||||
vec2 ref_tr = clip_rect.zy + vec2(-radius.y, radius.y);
|
||||
vec2 ref_br = clip_rect.zw + vec2(-radius.z, -radius.z);
|
||||
vec2 ref_bl = clip_rect.xw + vec2( radius.w, -radius.w);
|
||||
|
||||
float d_tl = distance(pos, ref_tl);
|
||||
float d_tr = distance(pos, ref_tr);
|
||||
float d_br = distance(pos, ref_br);
|
||||
float d_bl = distance(pos, ref_bl);
|
||||
|
||||
float pixels_per_fragment = length(fwidth(pos.xy));
|
||||
float nudge = 0.5 * pixels_per_fragment;
|
||||
|
||||
bool out0 = pos.x < ref_tl.x && pos.y < ref_tl.y && d_tl > radius.x - nudge;
|
||||
bool out1 = pos.x > ref_tr.x && pos.y < ref_tr.y && d_tr > radius.y - nudge;
|
||||
bool out2 = pos.x > ref_br.x && pos.y > ref_br.y && d_br > radius.z - nudge;
|
||||
bool out3 = pos.x < ref_bl.x && pos.y > ref_bl.y && d_bl > radius.w - nudge;
|
||||
|
||||
float distance_from_border = (float(out0) * (d_tl - radius.x + nudge)) +
|
||||
(float(out1) * (d_tr - radius.y + nudge)) +
|
||||
(float(out2) * (d_br - radius.z + nudge)) +
|
||||
(float(out3) * (d_bl - radius.w + nudge));
|
||||
|
||||
// Move the distance back into pixels.
|
||||
distance_from_border /= pixels_per_fragment;
|
||||
|
||||
// Apply a more gradual fade out to transparent.
|
||||
//distance_from_border -= 0.5;
|
||||
|
||||
return smoothstep(1.0, 0.0, distance_from_border);
|
||||
}
|
||||
|
||||
float squared_distance_from_rect(vec2 p, vec2 origin, vec2 size) {
|
||||
vec2 clamped = clamp(p, origin, origin + size);
|
||||
return distance(clamped, p);
|
||||
|
|
|
@ -11,7 +11,7 @@ void main(void) {
|
|||
vec2 local_pos = vPos;
|
||||
#endif
|
||||
|
||||
alpha = min(alpha, do_clip(local_pos, vClipRect, vClipRadius));
|
||||
alpha = min(alpha, do_clip(local_pos));
|
||||
oFragColor = mix(vColor0, vColor1, vF) * vec4(1, 1, 1, alpha);
|
||||
|
||||
#ifdef WR_FEATURE_TRANSFORM
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
flat varying vec4 vColor0;
|
||||
flat varying vec4 vColor1;
|
||||
flat varying vec4 vClipRect;
|
||||
flat varying vec4 vClipRadius;
|
||||
varying float vF;
|
||||
|
||||
#ifdef WR_FEATURE_TRANSFORM
|
|
@ -29,11 +29,7 @@ void main(void) {
|
|||
break;
|
||||
}
|
||||
|
||||
vClipRect = vec4(gradient.clip.rect.xy, gradient.clip.rect.xy + gradient.clip.rect.zw);
|
||||
vClipRadius = vec4(gradient.clip.top_left.outer_inner_radius.x,
|
||||
gradient.clip.top_right.outer_inner_radius.x,
|
||||
gradient.clip.bottom_right.outer_inner_radius.x,
|
||||
gradient.clip.bottom_left.outer_inner_radius.x);
|
||||
write_clip(gradient.clip);
|
||||
|
||||
vColor0 = gradient.color0;
|
||||
vColor1 = gradient.color1;
|
|
@ -19,7 +19,7 @@ void main(void) {
|
|||
vec2 relative_pos_in_rect = vLocalPos - vLocalRect.xy;
|
||||
#endif
|
||||
|
||||
alpha = min(alpha, do_clip(local_pos, vClipRect, vClipRadius));
|
||||
alpha = min(alpha, do_clip(local_pos));
|
||||
|
||||
// We calculate the particular tile this fragment belongs to, taking into
|
||||
// account the spacing in between tiles. We only paint if our fragment does
|
||||
|
|
|
@ -6,8 +6,6 @@ flat varying vec2 vTextureOffset; // Offset of this image into the texture atlas
|
|||
flat varying vec2 vTextureSize; // Size of the image in the texture atlas.
|
||||
flat varying vec2 vTileSpacing; // Amount of space between tiled instances of this image.
|
||||
flat varying vec2 vStretchSize;
|
||||
flat varying vec4 vClipRect;
|
||||
flat varying vec4 vClipRadius;
|
||||
flat varying vec4 vLocalRect;
|
||||
|
||||
#ifdef WR_FEATURE_TRANSFORM
|
||||
|
|
|
@ -15,11 +15,7 @@ void main(void) {
|
|||
vLocalRect = image.info.local_rect;
|
||||
#endif
|
||||
|
||||
vClipRect = vec4(image.clip.rect.xy, image.clip.rect.xy + image.clip.rect.zw);
|
||||
vClipRadius = vec4(image.clip.top_left.outer_inner_radius.x,
|
||||
image.clip.top_right.outer_inner_radius.x,
|
||||
image.clip.bottom_right.outer_inner_radius.x,
|
||||
image.clip.bottom_left.outer_inner_radius.x);
|
||||
write_clip(image.clip);
|
||||
|
||||
vec2 st0 = image.st_rect.xy;
|
||||
vec2 st1 = image.st_rect.zw;
|
||||
|
|
|
@ -11,6 +11,6 @@ void main(void) {
|
|||
vec2 local_pos = vPos;
|
||||
#endif
|
||||
|
||||
alpha = min(alpha, do_clip(local_pos, vClipRect, vClipRadius));
|
||||
alpha = min(alpha, do_clip(local_pos));
|
||||
oFragColor = vColor * vec4(1, 1, 1, alpha);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
varying vec4 vColor;
|
||||
flat varying vec4 vClipRect;
|
||||
flat varying vec4 vClipRadius;
|
||||
|
||||
#ifdef WR_FEATURE_TRANSFORM
|
||||
varying vec3 vPos;
|
||||
|
|
|
@ -15,11 +15,7 @@ void main(void) {
|
|||
vPos = vi.local_clamped_pos;
|
||||
#endif
|
||||
|
||||
vClipRect = vec4(rect.clip.rect.xy, rect.clip.rect.xy + rect.clip.rect.zw);
|
||||
vClipRadius = vec4(rect.clip.top_left.outer_inner_radius.x,
|
||||
rect.clip.top_right.outer_inner_radius.x,
|
||||
rect.clip.bottom_right.outer_inner_radius.x,
|
||||
rect.clip.bottom_left.outer_inner_radius.x);
|
||||
write_clip(rect.clip);
|
||||
|
||||
vColor = rect.color;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue