From 76993809650dc6dd84880697e7d00e7a09b0056b Mon Sep 17 00:00:00 2001 From: Mason Chang Date: Thu, 4 Aug 2016 17:57:19 -0700 Subject: [PATCH] update servo to use webrender shaders --- components/servo/Cargo.lock | 2 +- ports/cef/Cargo.lock | 2 +- resources/shaders/ps_angle_gradient.fs.glsl | 2 +- resources/shaders/ps_border.fs.glsl | 10 ++++++---- resources/shaders/ps_border.vs.glsl | 4 +--- resources/shaders/ps_box_shadow.vs.glsl | 4 ++-- resources/shaders/ps_gradient.vs.glsl | 2 +- resources/shaders/shared.glsl | 6 +++--- resources/shaders/shared_other.glsl | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index 599a7697656..6a1927a08a7 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -2554,7 +2554,7 @@ dependencies = [ [[package]] name = "webrender" version = "0.1.0" -source = "git+https://github.com/servo/webrender#eebe599cab295271900d7fbbe3017232dcbba867" +source = "git+https://github.com/servo/webrender#66b7134918a56c561cbdf72ab284f5da83459ec4" dependencies = [ "app_units 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index e432c544ca4..76b49f1f76a 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -2416,7 +2416,7 @@ dependencies = [ [[package]] name = "webrender" version = "0.1.0" -source = "git+https://github.com/servo/webrender#eebe599cab295271900d7fbbe3017232dcbba867" +source = "git+https://github.com/servo/webrender#66b7134918a56c561cbdf72ab284f5da83459ec4" dependencies = [ "app_units 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/resources/shaders/ps_angle_gradient.fs.glsl b/resources/shaders/ps_angle_gradient.fs.glsl index 944b90979f6..70f42a19551 100644 --- a/resources/shaders/ps_angle_gradient.fs.glsl +++ b/resources/shaders/ps_angle_gradient.fs.glsl @@ -21,7 +21,7 @@ void main(void) { float sa = sin(angle); float ca = cos(angle); - float sx = vStartPoint.x * ca - vStartPoint.y * sa; + float sx = vStartPoint.x * ca - vStartPoint.y * sa; float ex = vEndPoint.x * ca - vEndPoint.y * sa; float d = ex - sx; diff --git a/resources/shaders/ps_border.fs.glsl b/resources/shaders/ps_border.fs.glsl index 042b56f1d0a..4661694aed3 100644 --- a/resources/shaders/ps_border.fs.glsl +++ b/resources/shaders/ps_border.fs.glsl @@ -28,7 +28,7 @@ vec4 draw_dotted_edge() { // like firefox. float circleSpacing = diameter * 2.2; - vec2 size = vec2(vBorders.z, vBorders.w); + vec2 size = vBorders.zw; // Get our position within this specific segment vec2 position = vDevicePos - vBorders.xy; @@ -68,15 +68,16 @@ vec2 get_dashed_nudge_factor(vec2 dash_size, bool is_corner) { bool xAxisFudge = vBorders.z > vBorders.w; if (xAxisFudge) { return vec2(dash_size.x / 2.0, 0); - } else { - return vec2(0.0, dash_size.y / 2.0); } + + return vec2(0.0, dash_size.y / 2.0); } vec4 draw_dashed_edge(bool is_corner) { // Everything here should be in device pixels. // We want the dot to be roughly the size of the whole border spacing // 5.5 here isn't a magic number, it's just what mostly looks like FF/Chrome + // TODO: Investigate exactly what FF does. float dash_interval = min(vBorders.w, vBorders.z) * 5.5; vec2 edge_size = vec2(vBorders.z, vBorders.w); vec2 dash_size = vec2(dash_interval / 2.0, dash_interval / 2.0); @@ -143,6 +144,8 @@ void draw_dashed_border(void) { } } +// TODO: Investigate performance of this shader and see +// if it's worthwhile splitting it / removing branches etc. void main(void) { if (vRadii.x > 0.0 && (distance(vRefPoint, vLocalPos) > vRadii.x || @@ -178,7 +181,6 @@ void main(void) { default: { discard; - break; } } } diff --git a/resources/shaders/ps_border.vs.glsl b/resources/shaders/ps_border.vs.glsl index 99026b74eff..ad34c02737f 100644 --- a/resources/shaders/ps_border.vs.glsl +++ b/resources/shaders/ps_border.vs.glsl @@ -107,7 +107,5 @@ void main(void) { vDevicePos = vi.global_clamped_pos; // These are in device space - vBorders = vec4(border.info.local_rect.x, border.info.local_rect.y, - border.info.local_rect.z, - border.info.local_rect.w) * uDevicePixelRatio; + vBorders = border.info.local_rect * uDevicePixelRatio; } diff --git a/resources/shaders/ps_box_shadow.vs.glsl b/resources/shaders/ps_box_shadow.vs.glsl index cfcdacfa675..9662502e14d 100644 --- a/resources/shaders/ps_box_shadow.vs.glsl +++ b/resources/shaders/ps_box_shadow.vs.glsl @@ -4,8 +4,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ struct BoxShadow { - PrimitiveInfo info; - vec4 color; + PrimitiveInfo info; + vec4 color; vec4 border_radii_blur_radius_inverted; vec4 bs_rect; vec4 src_rect; diff --git a/resources/shaders/ps_gradient.vs.glsl b/resources/shaders/ps_gradient.vs.glsl index 60977165a2c..cee41fdf5d6 100644 --- a/resources/shaders/ps_gradient.vs.glsl +++ b/resources/shaders/ps_gradient.vs.glsl @@ -7,7 +7,7 @@ #define DIR_VERTICAL uint(1) struct Gradient { - PrimitiveInfo info; + PrimitiveInfo info; vec4 color0; vec4 color1; uvec4 dir; diff --git a/resources/shaders/shared.glsl b/resources/shaders/shared.glsl index 4696272d0f4..2eb73d6b46d 100644 --- a/resources/shaders/shared.glsl +++ b/resources/shaders/shared.glsl @@ -9,11 +9,11 @@ #define varying out // Uniform inputs - uniform mat4 uTransform; // Orthographic projection - uniform float uDevicePixelRatio; + uniform mat4 uTransform; // Orthographic projection + uniform float uDevicePixelRatio; // Attribute inputs - in vec3 aPosition; + in vec3 aPosition; #endif //====================================================================================== diff --git a/resources/shaders/shared_other.glsl b/resources/shaders/shared_other.glsl index 847fd1c143c..c6f8286b6f8 100644 --- a/resources/shaders/shared_other.glsl +++ b/resources/shaders/shared_other.glsl @@ -11,8 +11,8 @@ // box-shadow in vec4 aBorderPosition; - in vec4 aBorderRadii; - in float aBlurRadius; + in vec4 aBorderRadii; + in float aBlurRadius; // blur in vec2 aDestTextureSize;