Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update webrender + shaders. #12887

Merged
merged 1 commit into from Aug 17, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

@@ -56,6 +56,57 @@ vec4 draw_dotted_edge() {
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
// the size of the border-size, but we need to draw
// 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
// if it's worthwhile splitting it / removing branches etc.
void main(void) {
@@ -178,6 +255,11 @@ void main(void) {
oFragColor = mix(vHorizontalColor, vVerticalColor, color);
break;
}
case BORDER_STYLE_DOUBLE:
{
draw_double_border();
break;
}
default:
{
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 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 vLocalBorders; // The rect of the border (x, y, w, h) in local space.

// for corners, this is the beginning of the corner.
// For the lines, this is the top left of the line.
@@ -103,6 +103,9 @@ void main(void) {
// Local space
vLocalPos = vi.local_clamped_pos.xy;

// Local space
vLocalBorders = border.info.local_rect;

// These are in device space
vDevicePos = vi.global_clamped_pos;

@@ -6,7 +6,7 @@
struct Glyph {
PrimitiveInfo info;
vec4 color;
vec4 st_rect;
ivec4 uv_rect;
};

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 texture_size = textureSize(sDiffuse, 0);
vec2 st0 = glyph.uv_rect.xy / texture_size;
vec2 st1 = glyph.uv_rect.zw / texture_size;

vColor = glyph.color;
vUv = mix(glyph.st_rect.xy,
glyph.st_rect.zw,
f);
vUv = mix(st0, st1, f);
}
@@ -25,13 +25,17 @@
#define varying in

// Uniform inputs
uniform sampler2D sDiffuse;
uniform sampler2D sMask;

// Fragment shader outputs
out vec4 oFragColor;
#endif

//======================================================================================
// Shared shader uniforms
//======================================================================================
uniform sampler2D sDiffuse;

//======================================================================================
// Interpolator definitions
//======================================================================================
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.