diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index 7475dc7202c..0dce4c0a877 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -23,6 +23,6 @@ plugins = {path = "../plugins"} util = {path = "../util"} [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml index 63bd06e8baa..da23fa446a8 100644 --- a/components/canvas_traits/Cargo.toml +++ b/components/canvas_traits/Cargo.toml @@ -22,6 +22,6 @@ serde = {version = "0.8", features = ["unstable"]} serde_macros = "0.8" [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index cb8a8b9fe01..17dba1efad9 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -37,6 +37,6 @@ default-features = false features = ["serde_macros"] [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml index 84c0b46cd2f..947bef0e940 100644 --- a/components/constellation/Cargo.toml +++ b/components/constellation/Cargo.toml @@ -36,7 +36,7 @@ url = {version = "1.2", features = ["heap_size"]} util = {path = "../util"} [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index 91d62e7cdd1..e449fd4d6f3 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -47,7 +47,7 @@ util = {path = "../util"} xi-unicode = "0.0.1" [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index 5ecfc91cf2c..5b6baf33845 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -45,6 +45,6 @@ url = {version = "1.2", features = ["heap_size"]} util = {path = "../util"} [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml index a010ab77b03..623633ea5de 100644 --- a/components/layout_thread/Cargo.toml +++ b/components/layout_thread/Cargo.toml @@ -36,6 +36,6 @@ url = {version = "1.2", features = ["heap_size"]} util = {path = "../util"} [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/layout_traits/Cargo.toml b/components/layout_traits/Cargo.toml index a1161a347ee..c14cfd5e7f4 100644 --- a/components/layout_traits/Cargo.toml +++ b/components/layout_traits/Cargo.toml @@ -20,6 +20,6 @@ ipc-channel = "0.5" url = {version = "1.2", features = ["heap_size"]} [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/msg/Cargo.toml b/components/msg/Cargo.toml index f8795576a17..56f816a960f 100644 --- a/components/msg/Cargo.toml +++ b/components/msg/Cargo.toml @@ -23,6 +23,6 @@ serde_macros = "0.8" url = {version = "1.2", features = ["heap_size", "serde"]} [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index 1e7d90f10be..c87485feedd 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -43,7 +43,7 @@ uuid = {version = "0.3", features = ["v4"]} websocket = "0.17" [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 1109e977e0a..91c7a7fd2f6 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -75,6 +75,6 @@ websocket = "0.17" xml5ever = {version = "0.1.2", features = ["unstable"]} [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["nightly", "serde_macros"] diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index fae48436d9f..152277c7189 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -45,8 +45,8 @@ dependencies = [ "util 0.0.1", "util_tests 0.0.1", "webdriver_server 0.0.1", - "webrender 0.2.0 (git+https://github.com/servo/webrender)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender 0.4.0 (git+https://github.com/servo/webrender)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -222,7 +222,7 @@ dependencies = [ "offscreen_gl_context 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -239,7 +239,7 @@ dependencies = [ "plugins 0.0.1", "serde 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -330,8 +330,8 @@ dependencies = [ "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender 0.2.0 (git+https://github.com/servo/webrender)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender 0.4.0 (git+https://github.com/servo/webrender)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -363,7 +363,7 @@ dependencies = [ "style_traits 0.0.1", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -797,7 +797,7 @@ dependencies = [ "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", "xi-unicode 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1172,7 +1172,7 @@ dependencies = [ "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -1210,7 +1210,7 @@ dependencies = [ "style 0.0.1", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -1225,7 +1225,7 @@ dependencies = [ "script_traits 0.0.1", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -1384,7 +1384,7 @@ dependencies = [ "serde 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -1422,7 +1422,7 @@ dependencies = [ "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", "uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", "websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1941,7 +1941,7 @@ dependencies = [ "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", "uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", "websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", "xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2578,8 +2578,8 @@ dependencies = [ [[package]] name = "webrender" -version = "0.2.0" -source = "git+https://github.com/servo/webrender#16e427ec2955f0a5f47b279a30b48eaa885d57fb" +version = "0.4.0" +source = "git+https://github.com/servo/webrender#b8b719ad5d69249093f505cec8a7d5dac344b802" dependencies = [ "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)", @@ -2595,15 +2595,15 @@ dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped_threadpool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] name = "webrender_traits" -version = "0.3.0" -source = "git+https://github.com/servo/webrender_traits#4d5036748208733dbdad43b7faec27ccccbce9a6" +version = "0.4.0" +source = "git+https://github.com/servo/webrender#b8b719ad5d69249093f505cec8a7d5dac344b802" 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)", diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 12f930bdb00..bb60dc820d1 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -80,7 +80,7 @@ default-features = false features = ["serde_macros"] [dependencies.webrender_traits] -git = "https://github.com/servo/webrender_traits" +git = "https://github.com/servo/webrender" default_features = false features = ["serde_macros"] diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 0160bf2d6d8..5855f98d9e0 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -196,7 +196,7 @@ dependencies = [ "offscreen_gl_context 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "plugins 0.0.1", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -213,7 +213,7 @@ dependencies = [ "plugins 0.0.1", "serde 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -288,8 +288,8 @@ dependencies = [ "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender 0.2.0 (git+https://github.com/servo/webrender)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender 0.4.0 (git+https://github.com/servo/webrender)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -321,7 +321,7 @@ dependencies = [ "style_traits 0.0.1", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -714,7 +714,7 @@ dependencies = [ "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", "xi-unicode 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1080,7 +1080,7 @@ dependencies = [ "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -1111,7 +1111,7 @@ dependencies = [ "style 0.0.1", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -1126,7 +1126,7 @@ dependencies = [ "script_traits 0.0.1", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -1285,7 +1285,7 @@ dependencies = [ "serde 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_macros 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -1323,7 +1323,7 @@ dependencies = [ "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", "uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", "websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1793,7 +1793,7 @@ dependencies = [ "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", "uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", "websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", "xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1954,8 +1954,8 @@ dependencies = [ "url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "util 0.0.1", "webdriver_server 0.0.1", - "webrender 0.2.0 (git+https://github.com/servo/webrender)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender 0.4.0 (git+https://github.com/servo/webrender)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] @@ -2438,8 +2438,8 @@ dependencies = [ [[package]] name = "webrender" -version = "0.2.0" -source = "git+https://github.com/servo/webrender#16e427ec2955f0a5f47b279a30b48eaa885d57fb" +version = "0.4.0" +source = "git+https://github.com/servo/webrender#b8b719ad5d69249093f505cec8a7d5dac344b802" dependencies = [ "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)", @@ -2455,15 +2455,15 @@ dependencies = [ "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "scoped_threadpool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", - "webrender_traits 0.3.0 (git+https://github.com/servo/webrender_traits)", + "webrender_traits 0.4.0 (git+https://github.com/servo/webrender)", ] [[package]] name = "webrender_traits" -version = "0.3.0" -source = "git+https://github.com/servo/webrender_traits#4d5036748208733dbdad43b7faec27ccccbce9a6" +version = "0.4.0" +source = "git+https://github.com/servo/webrender#b8b719ad5d69249093f505cec8a7d5dac344b802" 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)", diff --git a/resources/shaders/ps_border.fs.glsl b/resources/shaders/ps_border.fs.glsl index 5ee736daf6a..80ebc55bc33 100644 --- a/resources/shaders/ps_border.fs.glsl +++ b/resources/shaders/ps_border.fs.glsl @@ -1,7 +1,12 @@ +#line 1 + /* 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/. */ +#ifdef WR_FEATURE_TRANSFORM + +#else // draw a circle at position aDesiredPos with a aRadius vec4 drawCircle(vec2 aPixel, vec2 aDesiredPos, float aRadius, vec3 aColor) { float farFromCenter = length(aDesiredPos - aPixel) - aRadius; @@ -77,14 +82,14 @@ vec4 draw_double_edge(float pos, float len) { 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); + float position = vLocalPos.x - vLocalRect.x; + return draw_double_edge(position, vLocalRect.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); + float position = vLocalPos.y - vLocalRect.y; + return draw_double_edge(position, vLocalRect.w); } vec4 draw_double_edge_with_radius() { @@ -220,49 +225,96 @@ void draw_double_border(void) { } } } +#endif + +void discard_pixels_in_rounded_borders(vec2 local_pos) { + float distanceFromRef = distance(vRefPoint, local_pos); + if (vRadii.x > 0.0 && (distanceFromRef > vRadii.x || distanceFromRef < vRadii.z)) { + discard; + } +} + +void draw_antialiased_solid_border_corner(vec2 local_pos) { + if (vRadii.x <= 0.0) { + return; + } + + // This is the conversion factor for transformations and device pixel scaling. + float pixelsPerFragment = length(fwidth(local_pos.xy)); + + float distanceFromRef = distance(vRefPoint, local_pos); + + // We want to start anti-aliasing one pixel in from the border. + float nudge = 1 * pixelsPerFragment; + float innerRadius = vRadii.z + nudge; + float outerRadius = vRadii.x - nudge; + + if (vRadii.x > 0.0 && (distanceFromRef > outerRadius || distanceFromRef < innerRadius)) { + float distanceFromBorder = max(distanceFromRef - outerRadius, + innerRadius - distanceFromRef); + // Move the distance back into pixels. + distanceFromBorder /= pixelsPerFragment; + + // Apply a more gradual fade out to transparent. + distanceFromBorder -= 0.5; + + oFragColor = oFragColor * vec4(1, 1, 1, smoothstep(1.0, 0, distanceFromBorder)); + } +} // 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 || - distance(vRefPoint, vLocalPos) < vRadii.z)) { - discard; - } +#ifdef WR_FEATURE_TRANSFORM + float alpha = 0; + vec2 local_pos = init_transform_fs(vLocalPos, vLocalRect, alpha); +#else + vec2 local_pos = vLocalPos; +#endif - switch (vBorderStyle) { - case BORDER_STYLE_DASHED: - { - draw_dashed_border(); - break; +#ifdef WR_FEATURE_TRANSFORM + // TODO(gw): Support other border styles for transformed elements. + discard_pixels_in_rounded_borders(local_pos); + float f = (local_pos.x - vSizeInfo.x) * vSizeInfo.w - (local_pos.y - vSizeInfo.y) * vSizeInfo.z; + oFragColor = vec4(1, 1, 1, alpha) * mix(vHorizontalColor, vVerticalColor, step(0.0, f)); +#else + switch (vBorderStyle) { + case BORDER_STYLE_DASHED: + discard_pixels_in_rounded_borders(local_pos); + draw_dashed_border(); + break; + case BORDER_STYLE_DOTTED: + discard_pixels_in_rounded_borders(local_pos); + draw_dotted_border(); + break; + case BORDER_STYLE_OUTSET: + case BORDER_STYLE_INSET: + discard_pixels_in_rounded_borders(local_pos); + oFragColor = mix(vVerticalColor, vHorizontalColor, step(0.0, vF)); + break; + case BORDER_STYLE_SOLID: + oFragColor = mix(vHorizontalColor, vVerticalColor, step(0.0, vF)); + switch (vBorderPart) { + case PST_TOP_LEFT: + case PST_TOP_RIGHT: + case PST_BOTTOM_LEFT: + case PST_BOTTOM_RIGHT: + draw_antialiased_solid_border_corner(local_pos); + break; + default: + discard_pixels_in_rounded_borders(local_pos); + } + break; + case BORDER_STYLE_NONE: + discard_pixels_in_rounded_borders(local_pos); + oFragColor = mix(vHorizontalColor, vVerticalColor, step(0.0, vF)); + break; + case BORDER_STYLE_DOUBLE: + discard_pixels_in_rounded_borders(local_pos); + draw_double_border(); + break; + default: + discard; } - case BORDER_STYLE_DOTTED: - { - draw_dotted_border(); - break; - } - case BORDER_STYLE_OUTSET: - case BORDER_STYLE_INSET: - { - float color = step(0.0, vF); - oFragColor = mix(vVerticalColor, vHorizontalColor, color); - break; - } - case BORDER_STYLE_NONE: - case BORDER_STYLE_SOLID: - { - float color = step(0.0, vF); - oFragColor = mix(vHorizontalColor, vVerticalColor, color); - break; - } - case BORDER_STYLE_DOUBLE: - { - draw_double_border(); - break; - } - default: - { - discard; - } - } +#endif } diff --git a/resources/shaders/ps_border.glsl b/resources/shaders/ps_border.glsl index 29a72371e74..da982249046 100644 --- a/resources/shaders/ps_border.glsl +++ b/resources/shaders/ps_border.glsl @@ -4,22 +4,27 @@ * 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/. */ -// These two are interpolated -varying float vF; // This is a weighting as we get closer to the bottom right corner? - // These are not changing. flat varying vec4 vVerticalColor; // The vertical color, e.g. top/bottom flat varying vec4 vHorizontalColor; // The horizontal color e.g. left/right flat varying vec4 vRadii; // The border radius from CSS border-radius - -// These are in device space -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. +flat varying vec4 vLocalRect; // 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. flat varying vec2 vRefPoint; flat varying uint vBorderStyle; flat varying uint vBorderPart; // Which part of the border we're drawing. + +// These are in device space +#ifdef WR_FEATURE_TRANSFORM +varying vec3 vLocalPos; // The clamped position in local space. +flat varying vec4 vSizeInfo; +#else +varying vec2 vLocalPos; // The clamped position in local space. + +// These two are interpolated +varying float vF; // This is a weighting as we get closer to the bottom right corner? +varying vec2 vDevicePos; // The clamped position in device space. +flat varying vec4 vBorders; // the rect of the border in (x, y, width, height) form +#endif diff --git a/resources/shaders/ps_border.vs.glsl b/resources/shaders/ps_border.vs.glsl index 65fae54f702..51eafed4911 100644 --- a/resources/shaders/ps_border.vs.glsl +++ b/resources/shaders/ps_border.vs.glsl @@ -34,7 +34,20 @@ uint get_border_style(Border a_border, uint a_edge) { void main(void) { Border border = borders[gl_InstanceID]; +#ifdef WR_FEATURE_TRANSFORM + TransformVertexInfo vi = write_transform_vertex(border.info); + vLocalPos = vi.local_pos; +#else VertexInfo vi = write_vertex(border.info); + vLocalPos = vi.local_clamped_pos.xy; +#endif + + // This is what was currently sent. + vVerticalColor = border.verticalColor; + vHorizontalColor = border.horizontalColor; + + // Local space + vLocalRect = border.info.local_rect; // Just our boring radius position. vRadii = border.radii; @@ -93,22 +106,16 @@ void main(void) { // x1 - x0 is the width of the corner / line. float width = x1 - x0; float height = y1 - y0; +#ifdef WR_FEATURE_TRANSFORM + vSizeInfo = vec4(x0, y0, width, height); +#else // This is just a weighting of the pixel colors it seems? vF = (vi.local_clamped_pos.x - x0) * height - (vi.local_clamped_pos.y - y0) * width; - // This is what was currently sent. - vVerticalColor = border.verticalColor; - vHorizontalColor = border.horizontalColor; - - // 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; // These are in device space vBorders = border.info.local_rect * uDevicePixelRatio; +#endif }