mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Update webrender + shaders.
This commit is contained in:
parent
cb01d37338
commit
1242a0df69
7 changed files with 99 additions and 7 deletions
2
components/servo/Cargo.lock
generated
2
components/servo/Cargo.lock
generated
|
@ -2594,7 +2594,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webrender"
|
name = "webrender"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/servo/webrender#c84b6eb466dc6802b2b85cff481a5a08a9efadc1"
|
source = "git+https://github.com/servo/webrender#16e427ec2955f0a5f47b279a30b48eaa885d57fb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
2
ports/cef/Cargo.lock
generated
2
ports/cef/Cargo.lock
generated
|
@ -2454,7 +2454,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "webrender"
|
name = "webrender"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/servo/webrender#c84b6eb466dc6802b2b85cff481a5a08a9efadc1"
|
source = "git+https://github.com/servo/webrender#16e427ec2955f0a5f47b279a30b48eaa885d57fb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -56,6 +56,57 @@ vec4 draw_dotted_edge() {
|
||||||
return mix(white, circleColor, circleColor.a);
|
return mix(white, circleColor, circleColor.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec4 draw_double_edge(float pos, float len) {
|
||||||
|
// Devided border to 3 parts, draw color on first and third part,
|
||||||
|
// leave second part blank.
|
||||||
|
float one_third_len = len / 3.0;
|
||||||
|
|
||||||
|
float in_first_part = step(pos, one_third_len);
|
||||||
|
float in_third_part = step(len - one_third_len, pos);
|
||||||
|
|
||||||
|
// The result of this should be 1.0 if we're in the 1st or 3rd part.
|
||||||
|
// And 0.0 for the blank part.
|
||||||
|
float should_fill = in_first_part + in_third_part;
|
||||||
|
|
||||||
|
float color_weight = step(0.0, vF);
|
||||||
|
vec4 color = mix(vHorizontalColor, vVerticalColor, color_weight);
|
||||||
|
|
||||||
|
vec4 white = vec4(1.0, 1.0, 1.0, 1.0);
|
||||||
|
return mix(white, color, should_fill);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 draw_double_edge_vertical() {
|
||||||
|
// Get our position within this specific segment
|
||||||
|
float position = vLocalPos.x - vLocalBorders.x;
|
||||||
|
return draw_double_edge(position, vLocalBorders.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 draw_double_edge_horizontal() {
|
||||||
|
// Get our position within this specific segment
|
||||||
|
float position = vLocalPos.y - vLocalBorders.y;
|
||||||
|
return draw_double_edge(position, vLocalBorders.w);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 draw_double_edge_with_radius() {
|
||||||
|
// Get our position within this specific segment
|
||||||
|
float position = distance(vRefPoint, vLocalPos) - vRadii.z;
|
||||||
|
float len = vRadii.x - vRadii.z;
|
||||||
|
return draw_double_edge(position, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 draw_double_edge_corner() {
|
||||||
|
if (vRadii.x > 0) {
|
||||||
|
return draw_double_edge_with_radius();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_vertical = (vBorderPart == PST_TOP_LEFT) ? vF < 0 : vF >= 0;
|
||||||
|
if (is_vertical) {
|
||||||
|
return draw_double_edge_vertical();
|
||||||
|
} else {
|
||||||
|
return draw_double_edge_horizontal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Our current edge calculation is based only on
|
// Our current edge calculation is based only on
|
||||||
// the size of the border-size, but we need to draw
|
// the size of the border-size, but we need to draw
|
||||||
// the dashes in the center of the segment we're drawing.
|
// the dashes in the center of the segment we're drawing.
|
||||||
|
@ -144,6 +195,32 @@ void draw_dashed_border(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw_double_border(void) {
|
||||||
|
switch (vBorderPart) {
|
||||||
|
// These are the layer tile part PrimitivePart as uploaded by the tiling.rs
|
||||||
|
case PST_TOP_LEFT:
|
||||||
|
case PST_TOP_RIGHT:
|
||||||
|
case PST_BOTTOM_LEFT:
|
||||||
|
case PST_BOTTOM_RIGHT:
|
||||||
|
{
|
||||||
|
oFragColor = draw_double_edge_corner();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PST_BOTTOM:
|
||||||
|
case PST_TOP:
|
||||||
|
{
|
||||||
|
oFragColor = draw_double_edge_horizontal();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PST_LEFT:
|
||||||
|
case PST_RIGHT:
|
||||||
|
{
|
||||||
|
oFragColor = draw_double_edge_vertical();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Investigate performance of this shader and see
|
// TODO: Investigate performance of this shader and see
|
||||||
// if it's worthwhile splitting it / removing branches etc.
|
// if it's worthwhile splitting it / removing branches etc.
|
||||||
void main(void) {
|
void main(void) {
|
||||||
|
@ -178,6 +255,11 @@ void main(void) {
|
||||||
oFragColor = mix(vHorizontalColor, vVerticalColor, color);
|
oFragColor = mix(vHorizontalColor, vVerticalColor, color);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case BORDER_STYLE_DOUBLE:
|
||||||
|
{
|
||||||
|
draw_double_border();
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
discard;
|
discard;
|
||||||
|
|
|
@ -16,6 +16,7 @@ flat varying vec4 vRadii; // The border radius from CSS border-radiu
|
||||||
varying vec2 vLocalPos; // The clamped position in local space.
|
varying vec2 vLocalPos; // The clamped position in local space.
|
||||||
varying vec2 vDevicePos; // The clamped position in device space.
|
varying vec2 vDevicePos; // The clamped position in device space.
|
||||||
flat varying vec4 vBorders; // the rect of the border in (x, y, width, height) form
|
flat varying vec4 vBorders; // the rect of the border in (x, y, width, height) form
|
||||||
|
flat varying vec4 vLocalBorders; // The rect of the border (x, y, w, h) in local space.
|
||||||
|
|
||||||
// for corners, this is the beginning of the corner.
|
// for corners, this is the beginning of the corner.
|
||||||
// For the lines, this is the top left of the line.
|
// For the lines, this is the top left of the line.
|
||||||
|
|
|
@ -103,6 +103,9 @@ void main(void) {
|
||||||
// Local space
|
// Local space
|
||||||
vLocalPos = vi.local_clamped_pos.xy;
|
vLocalPos = vi.local_clamped_pos.xy;
|
||||||
|
|
||||||
|
// Local space
|
||||||
|
vLocalBorders = border.info.local_rect;
|
||||||
|
|
||||||
// These are in device space
|
// These are in device space
|
||||||
vDevicePos = vi.global_clamped_pos;
|
vDevicePos = vi.global_clamped_pos;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
struct Glyph {
|
struct Glyph {
|
||||||
PrimitiveInfo info;
|
PrimitiveInfo info;
|
||||||
vec4 color;
|
vec4 color;
|
||||||
vec4 st_rect;
|
ivec4 uv_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(std140) uniform Items {
|
layout(std140) uniform Items {
|
||||||
|
@ -19,8 +19,10 @@ void main(void) {
|
||||||
|
|
||||||
vec2 f = (vi.local_clamped_pos - vi.local_rect.p0) / (vi.local_rect.p1 - vi.local_rect.p0);
|
vec2 f = (vi.local_clamped_pos - vi.local_rect.p0) / (vi.local_rect.p1 - vi.local_rect.p0);
|
||||||
|
|
||||||
|
vec2 texture_size = textureSize(sDiffuse, 0);
|
||||||
|
vec2 st0 = glyph.uv_rect.xy / texture_size;
|
||||||
|
vec2 st1 = glyph.uv_rect.zw / texture_size;
|
||||||
|
|
||||||
vColor = glyph.color;
|
vColor = glyph.color;
|
||||||
vUv = mix(glyph.st_rect.xy,
|
vUv = mix(st0, st1, f);
|
||||||
glyph.st_rect.zw,
|
|
||||||
f);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,17 @@
|
||||||
#define varying in
|
#define varying in
|
||||||
|
|
||||||
// Uniform inputs
|
// Uniform inputs
|
||||||
uniform sampler2D sDiffuse;
|
|
||||||
uniform sampler2D sMask;
|
uniform sampler2D sMask;
|
||||||
|
|
||||||
// Fragment shader outputs
|
// Fragment shader outputs
|
||||||
out vec4 oFragColor;
|
out vec4 oFragColor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//======================================================================================
|
||||||
|
// Shared shader uniforms
|
||||||
|
//======================================================================================
|
||||||
|
uniform sampler2D sDiffuse;
|
||||||
|
|
||||||
//======================================================================================
|
//======================================================================================
|
||||||
// Interpolator definitions
|
// Interpolator definitions
|
||||||
//======================================================================================
|
//======================================================================================
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue