Remove old shaders, updates for WR feature and API changes.

This commit is contained in:
Glenn Watson 2016-11-25 06:28:21 +10:00
parent fb98acbc4d
commit 3d67c1cf4c
74 changed files with 34 additions and 3061 deletions

View file

@ -23,4 +23,4 @@ serde_derive = "0.8"
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]

View file

@ -36,4 +36,4 @@ features = ["serde_derive"]
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]

View file

@ -39,7 +39,7 @@ util = {path = "../util"}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]
[target.'cfg(not(target_os = "windows"))'.dependencies]
gaol = {git = "https://github.com/servo/gaol"}

View file

@ -45,7 +45,7 @@ xi-unicode = "0.0.1"
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]
[target.'cfg(target_os = "macos")'.dependencies]
byteorder = "0.5"
@ -61,4 +61,4 @@ servo-fontconfig = "0.2.1"
simd = {git = "https://github.com/huonw/simd"}
[target.'cfg(target_os = "windows")'.dependencies]
dwrote = {git = "https://github.com/vvuk/dwrote-rs"}
dwrote = "0.1.1"

View file

@ -50,4 +50,4 @@ util = {path = "../util"}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]

View file

@ -8,7 +8,7 @@
// completely converting layout to directly generate WebRender display lists, for example.
use app_units::Au;
use euclid::{Matrix4D, Point2D, Rect, Size2D, TypedRect};
use euclid::{Point2D, Rect, Size2D};
use gfx::display_list::{BorderRadii, BoxShadowClipMode, ClippingRegion};
use gfx::display_list::{DisplayItem, DisplayList, DisplayListTraversal, StackingContextType};
use gfx_traits::{FragmentType, ScrollPolicy, ScrollRootId};
@ -362,20 +362,11 @@ impl WebRenderDisplayItemConverter for DisplayItem {
}
DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(),
DisplayItem::PushScrollRoot(ref item) => {
let overflow = TypedRect::new(Point2D::zero(), item.scroll_root.size);
let context = webrender_traits::StackingContext::new(
webrender_traits::ScrollPolicy::Scrollable,
item.scroll_root.clip.to_rectf(),
overflow.to_rectf(),
0,
&Matrix4D::identity(),
&Matrix4D::identity(),
mix_blend_mode::T::normal.to_blend_mode(),
filter::T::new(Vec::new()).to_filter_ops(),
&mut frame_builder.auxiliary_lists_builder);
builder.push_stacking_context(context);
builder.push_scroll_layer(item.scroll_root.clip.to_rectf(),
item.scroll_root.size.to_sizef(),
frame_builder.next_scroll_layer_id(item.scroll_root.id));
}
DisplayItem::PopScrollRoot(_) => builder.pop_stacking_context(),
DisplayItem::PopScrollRoot(_) => builder.pop_scroll_layer(),
}
}
}

View file

@ -42,4 +42,4 @@ util = {path = "../util"}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]

View file

@ -21,4 +21,4 @@ servo_url = {path = "../url"}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]

View file

@ -21,4 +21,4 @@ serde_derive = "0.8"
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]

View file

@ -47,7 +47,7 @@ websocket = "0.17"
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]
[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]
tinyfiledialogs = {git = "https://github.com/jdm/tinyfiledialogs"}

View file

@ -33,4 +33,4 @@ cookie = {version = "0.2.5", features = ["serialize-rustc"]}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]

View file

@ -83,4 +83,4 @@ xml5ever = {version = "0.2", features = ["unstable"]}
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["nightly", "serde_derive"]
features = ["nightly", "serde_derive", "ipc"]

View file

@ -71,7 +71,7 @@ features = ["serde_derive"]
[dependencies.webrender_traits]
git = "https://github.com/servo/webrender"
default_features = false
features = ["serde_derive"]
features = ["serde_derive", "ipc"]
[target.'cfg(not(target_os = "android"))'.dependencies]
sig = "0.1"

31
ports/cef/Cargo.lock generated
View file

@ -560,21 +560,7 @@ dependencies = [
[[package]]
name = "dwrote"
version = "0.1.1"
source = "git+https://github.com/vvuk/dwrote-rs#a1876467bba65029d497dba219192260ee8c3d5d"
dependencies = [
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_codegen 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "dwrote"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -720,7 +706,6 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-freetype-sys 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -781,7 +766,7 @@ dependencies = [
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.1 (git+https://github.com/vvuk/dwrote-rs)",
"dwrote 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"fontsan 0.3.2 (git+https://github.com/servo/fontsan)",
@ -2802,7 +2787,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.10.0"
source = "git+https://github.com/servo/webrender#fa97cfc54d042acf6732e242a07ede506196f114"
source = "git+https://github.com/servo/webrender#a237f9b7c261e253fe0bcbd00a38abf0f8f5dfbd"
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)",
@ -2811,7 +2796,7 @@ dependencies = [
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2828,15 +2813,16 @@ dependencies = [
[[package]]
name = "webrender_traits"
version = "0.10.0"
source = "git+https://github.com/servo/webrender#fa97cfc54d042acf6732e242a07ede506196f114"
source = "git+https://github.com/servo/webrender#a237f9b7c261e253fe0bcbd00a38abf0f8f5dfbd"
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)",
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"offscreen_gl_context 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2988,8 +2974,7 @@ dependencies = [
"checksum dlib 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8bd015f00d33d7e4ff66f1589fb824ccf3ccb10209b66c7b756f26ba9aa90215"
"checksum dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd841b58510c9618291ffa448da2e4e0f699d984d436122372f446dae62263d"
"checksum dwmapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07c4c7cc7b396419bc0a4d90371d0cee16cb5053b53647d287c0b728000c41fe"
"checksum dwrote 0.1.1 (git+https://github.com/vvuk/dwrote-rs)" = "<none>"
"checksum dwrote 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c85f0fecf7e4d1f47b25a84adbdb5bfa9662e51c0d0fb59935a0147ace261216"
"checksum dwrote 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8e46f81d58183d91a9d2dbd020538d8aef38e7d291aeae336d7f3ac15f941c0"
"checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec"
"checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91"
"checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81"

30
ports/servo/Cargo.lock generated
View file

@ -589,21 +589,7 @@ dependencies = [
[[package]]
name = "dwrote"
version = "0.1.1"
source = "git+https://github.com/vvuk/dwrote-rs#a1876467bba65029d497dba219192260ee8c3d5d"
dependencies = [
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_codegen 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "dwrote"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -790,7 +776,6 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-freetype-sys 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -851,7 +836,7 @@ dependencies = [
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.1 (git+https://github.com/vvuk/dwrote-rs)",
"dwrote 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"fontsan 0.3.2 (git+https://github.com/servo/fontsan)",
@ -3003,7 +2988,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.10.0"
source = "git+https://github.com/servo/webrender#fa97cfc54d042acf6732e242a07ede506196f114"
source = "git+https://github.com/servo/webrender#a237f9b7c261e253fe0bcbd00a38abf0f8f5dfbd"
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)",
@ -3012,7 +2997,7 @@ dependencies = [
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"freetype 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3029,15 +3014,16 @@ dependencies = [
[[package]]
name = "webrender_traits"
version = "0.10.0"
source = "git+https://github.com/servo/webrender#fa97cfc54d042acf6732e242a07ede506196f114"
source = "git+https://github.com/servo/webrender#a237f9b7c261e253fe0bcbd00a38abf0f8f5dfbd"
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)",
"core-graphics 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dwrote 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"offscreen_gl_context 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3191,7 +3177,7 @@ dependencies = [
"checksum dlib 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8bd015f00d33d7e4ff66f1589fb824ccf3ccb10209b66c7b756f26ba9aa90215"
"checksum dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd841b58510c9618291ffa448da2e4e0f699d984d436122372f446dae62263d"
"checksum dwmapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07c4c7cc7b396419bc0a4d90371d0cee16cb5053b53647d287c0b728000c41fe"
"checksum dwrote 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c85f0fecf7e4d1f47b25a84adbdb5bfa9662e51c0d0fb59935a0147ace261216"
"checksum dwrote 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8e46f81d58183d91a9d2dbd020538d8aef38e7d291aeae336d7f3ac15f941c0"
"checksum encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec"
"checksum encoding-index-japanese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91"
"checksum encoding-index-korean 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81"

View file

@ -1,65 +0,0 @@
#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/. */
flat varying vec4 vClipRect;
flat varying vec4 vClipRadius;
flat varying vec4 vClipMaskUvRect;
flat varying vec4 vClipMaskLocalRect;
#ifdef WR_VERTEX_SHADER
void write_clip(ClipData clip) {
vClipRect = vec4(clip.rect.rect.xy, clip.rect.rect.xy + clip.rect.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);
//TODO: interpolate the final mask UV
vec2 texture_size = textureSize(sMask, 0);
vClipMaskUvRect = clip.mask_data.uv_rect / texture_size.xyxy;
vClipMaskLocalRect = clip.mask_data.local_rect; //TODO: transform
}
#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));
float nudge = 0.5 * pixels_per_fragment;
vec4 distances = vec4(d_tl, d_tr, d_br, d_bl) - vClipRadius + nudge;
bvec4 is_out = bvec4(pos.x < ref_tl.x && pos.y < ref_tl.y,
pos.x > ref_tr.x && pos.y < ref_tr.y,
pos.x > ref_br.x && pos.y > ref_br.y,
pos.x < ref_bl.x && pos.y > ref_bl.y);
float distance_from_border = dot(vec4(is_out),
max(vec4(0.0, 0.0, 0.0, 0.0), 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;
float border_alpha = 1.0 - smoothstep(0.0, 1.0, distance_from_border);
bool repeat_mask = false; //TODO
vec2 vMaskUv = (pos - vClipMaskLocalRect.xy) / vClipMaskLocalRect.zw;
vec2 clamped_mask_uv = repeat_mask ? fract(vMaskUv) :
clamp(vMaskUv, vec2(0.0, 0.0), vec2(1.0, 1.0));
vec2 source_uv = clamped_mask_uv * vClipMaskUvRect.zw + vClipMaskUvRect.xy;
float mask_alpha = texture(sMask, source_uv).r; //careful: texture has type A8
return border_alpha * mask_alpha;
}
#endif

View file

@ -1,40 +0,0 @@
#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/. */
// TODO(gw): Write a fast path blur that handles smaller blur radii
// with a offset / weight uniform table and a constant
// loop iteration count!
// TODO(gw): Make use of the bilinear sampling trick to reduce
// the number of texture fetches needed for a gaussian blur.
float gauss(float x, float sigma) {
return (1.0 / sqrt(6.283185307179586 * sigma * sigma)) * exp(-(x * x) / (2.0 * sigma * sigma));
}
void main(void) {
vec4 sample = texture(sCache, vUv);
vec4 color = vec4(sample.rgb * sample.a, sample.a) * gauss(0.0, vSigma);
for (int i=1 ; i < vBlurRadius ; ++i) {
vec2 offset = vec2(float(i)) * vOffsetScale;
vec2 st0 = clamp(vUv.xy + offset, vUvRect.xy, vUvRect.zw);
vec4 color0 = texture(sCache, vec3(st0, vUv.z));
vec2 st1 = clamp(vUv.xy - offset, vUvRect.xy, vUvRect.zw);
vec4 color1 = texture(sCache, vec3(st1, vUv.z));
// Alpha must be premultiplied in order to properly blur the alpha channel.
float weight = gauss(float(i), vSigma);
color += vec4(color0.rgb * color0.a, color0.a) * weight;
color += vec4(color1.rgb * color1.a, color1.a) * weight;
}
// Unpremultiply the alpha.
color.rgb /= color.a;
oFragColor = color;
}

View file

@ -1,10 +0,0 @@
#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/. */
varying vec3 vUv;
flat varying vec4 vUvRect;
flat varying vec2 vOffsetScale;
flat varying float vSigma;
flat varying int vBlurRadius;

View file

@ -1,45 +0,0 @@
#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/. */
// Applies a separable gaussian blur in one direction, as specified
// by the dir field in the blur command.
#define DIR_HORIZONTAL 0
#define DIR_VERTICAL 1
void main(void) {
BlurCommand cmd = fetch_blur(gl_InstanceID);
RenderTaskData task = fetch_render_task(cmd.task_id);
RenderTaskData src_task = fetch_render_task(cmd.src_task_id);
vec4 local_rect = task.data0;
vec2 pos = mix(local_rect.xy,
local_rect.xy + local_rect.zw,
aPosition.xy);
vec2 texture_size = textureSize(sCache, 0).xy;
vUv.z = src_task.data1.x;
vBlurRadius = int(task.data1.y);
vSigma = task.data1.y * 0.5;
switch (cmd.dir) {
case DIR_HORIZONTAL:
vOffsetScale = vec2(1.0 / texture_size.x, 0.0);
break;
case DIR_VERTICAL:
vOffsetScale = vec2(0.0, 1.0 / texture_size.y);
break;
}
vUvRect = vec4(src_task.data0.xy, src_task.data0.xy + src_task.data0.zw);
vUvRect /= texture_size.xyxy;
vec2 uv0 = src_task.data0.xy / texture_size;
vec2 uv1 = (src_task.data0.xy + src_task.data0.zw) / texture_size;
vUv.xy = mix(uv0, uv1, aPosition.xy);
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
}

View file

@ -1,148 +0,0 @@
#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/. */
// See http://asciimath.org to render the equations here.
// The Gaussian function used for blurring:
//
// G_sigma(x) = 1/sqrt(2 pi sigma^2) e^(-x^2/(2 sigma^2))
float gauss(float x, float sigma) {
float sigmaPow2 = sigma * sigma;
return 1.0 / sqrt(6.283185307179586 * sigmaPow2) * exp(-(x * x) / (2.0 * sigmaPow2));
}
// An approximation of the error function, which is related to the integral of the Gaussian
// function:
//
// "erf"(x) = 2/sqrt(pi) int_0^x e^(-t^2) dt
// ~~ 1 - 1 / (1 + a_1 x + a_2 x^2 + a_3 x^3 + a_4 x^4)^4
//
// where:
//
// a_1 = 0.278393, a_2 = 0.230389, a_3 = 0.000972, a_4 = 0.078108
//
// This approximation is accurate to `5 xx 10^-4`, more than accurate enough for our purposes.
//
// See: https://en.wikipedia.org/wiki/Error_function#Approximation_with_elementary_functions
float erf(float x) {
bool negative = x < 0.0;
if (negative)
x = -x;
float x2 = x * x;
float x3 = x2 * x;
float x4 = x2 * x2;
float denom = 1.0 + 0.278393 * x + 0.230389 * x2 + 0.000972 * x3 + 0.078108 * x4;
float result = 1.0 - 1.0 / (denom * denom * denom * denom);
return negative ? -result : result;
}
// A useful helper for calculating integrals of the Gaussian function via the error function:
//
// "erf"_sigma(x) = 2 int 1/sqrt(2 pi sigma^2) e^(-x^2/(2 sigma^2)) dx
// = "erf"(x/(sigma sqrt(2)))
float erfSigma(float x, float sigma) {
return erf(x / (sigma * 1.4142135623730951));
}
// Returns the blurred color value from the box itself (not counting any rounded corners). `p_0` is
// the vector distance to the top left corner of the box; `p_1` is the vector distance to its
// bottom right corner.
//
// "colorFromRect"_sigma(p_0, p_1)
// = int_{p_{0_y}}^{p_{1_y}} int_{p_{1_x}}^{p_{0_x}} G_sigma(y) G_sigma(x) dx dy
// = 1/4 ("erf"_sigma(p_{1_x}) - "erf"_sigma(p_{0_x}))
// ("erf"_sigma(p_{1_y}) - "erf"_sigma(p_{0_y}))
float colorFromRect(vec2 p0, vec2 p1, float sigma) {
return (erfSigma(p1.x, sigma) - erfSigma(p0.x, sigma)) *
(erfSigma(p1.y, sigma) - erfSigma(p0.y, sigma)) / 4.0;
}
// Returns the `x` coordinate on the ellipse with the given radii for the given `y` coordinate:
//
// "ellipsePoint"(y, y_0, a, b) = a sqrt(1 - ((y - y_0) / b)^2)
float ellipsePoint(float y, float y0, vec2 radii) {
float bStep = (y - y0) / radii.y;
return radii.x * sqrt(1.0 - bStep * bStep);
}
// A helper function to compute the value that needs to be subtracted to accommodate the border
// corners.
//
// "colorCutout"_sigma(x_{0_l}, x_{0_r}, y_0, y_{min}, y_{max}, a, b)
// = int_{y_{min}}^{y_{max}}
// int_{x_{0_r} + "ellipsePoint"(y, y_0, a, b)}^{x_{0_r} + a} G_sigma(y) G_sigma(x) dx
// + int_{x_{0_l} - a}^{x_{0_l} - "ellipsePoint"(y, y_0, a, b)} G_sigma(y) G_sigma(x)
// dx dy
// = int_{y_{min}}^{y_{max}} 1/2 G_sigma(y)
// ("erf"_sigma(x_{0_r} + a) - "erf"_sigma(x_{0_r} + "ellipsePoint"(y, y_0, a, b)) +
// "erf"_sigma(x_{0_l} - "ellipsePoint"(y, y_0, a, b)) - "erf"_sigma(x_{0_l} - a))
//
// with the outer integral evaluated numerically.
float colorCutoutGeneral(float x0l,
float x0r,
float y0,
float yMin,
float yMax,
vec2 radii,
float sigma) {
float sum = 0.0;
for (float y = yMin; y <= yMax; y += 1.0) {
float xEllipsePoint = ellipsePoint(y, y0, radii);
sum += gauss(y, sigma) *
(erfSigma(x0r + radii.x, sigma) - erfSigma(x0r + xEllipsePoint, sigma) +
erfSigma(x0l - xEllipsePoint, sigma) - erfSigma(x0l - radii.x, sigma));
}
return sum / 2.0;
}
// The value that needs to be subtracted to accommodate the top border corners.
float colorCutoutTop(float x0l, float x0r, float y0, vec2 radii, float sigma) {
return colorCutoutGeneral(x0l, x0r, y0, y0, y0 + radii.y, radii, sigma);
}
// The value that needs to be subtracted to accommodate the bottom border corners.
float colorCutoutBottom(float x0l, float x0r, float y0, vec2 radii, float sigma) {
return colorCutoutGeneral(x0l, x0r, y0, y0 - radii.y, y0, radii, sigma);
}
// The blurred color value for the point at `pos` with the top left corner of the box at
// `p_{0_"rect"}` and the bottom right corner of the box at `p_{1_"rect"}`.
float color(vec2 pos, vec2 p0Rect, vec2 p1Rect, vec2 radii, float sigma) {
// Compute the vector distances `p_0` and `p_1`.
vec2 p0 = p0Rect - pos, p1 = p1Rect - pos;
// Compute the basic color `"colorFromRect"_sigma(p_0, p_1)`. This is all we have to do if
// the box is unrounded.
float cRect = colorFromRect(p0, p1, sigma);
if (radii.x == 0.0 || radii.y == 0.0)
return cRect;
// Compute the inner corners of the box, taking border radii into account: `x_{0_l}`,
// `y_{0_t}`, `x_{0_r}`, and `y_{0_b}`.
float x0l = p0.x + radii.x;
float y0t = p1.y - radii.y;
float x0r = p1.x - radii.x;
float y0b = p0.y + radii.y;
// Compute the final color:
//
// "colorFromRect"_sigma(p_0, p_1) -
// ("colorCutoutTop"_sigma(x_{0_l}, x_{0_r}, y_{0_t}, a, b) +
// "colorCutoutBottom"_sigma(x_{0_l}, x_{0_r}, y_{0_b}, a, b))
float cCutoutTop = colorCutoutTop(x0l, x0r, y0t, radii, sigma);
float cCutoutBottom = colorCutoutBottom(x0l, x0r, y0b, radii, sigma);
return cRect - (cCutoutTop + cCutoutBottom);
}
void main(void) {
vec2 pos = vPos.xy;
vec2 p0Rect = vBoxShadowRect.xy, p1Rect = vBoxShadowRect.zw;
vec2 radii = vBorderRadii.xy;
float sigma = vBlurRadius / 2.0;
float value = color(pos, p0Rect, p1Rect, radii, sigma);
value = max(value, 0.0);
oFragColor = vec4(1.0, 1.0, 1.0, vInverted == 1.0 ? 1.0 - value : value);
}

View file

@ -1,10 +0,0 @@
#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/. */
varying vec2 vPos;
flat varying vec2 vBorderRadii;
flat varying float vBlurRadius;
flat varying vec4 vBoxShadowRect;
flat varying float vInverted;

View file

@ -1,31 +0,0 @@
#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/. */
void main(void) {
CachePrimitiveInstance cpi = fetch_cache_instance(gl_InstanceID);
RenderTaskData task = fetch_render_task(cpi.render_task_index);
BoxShadow bs = fetch_boxshadow(cpi.specific_prim_index);
vec2 p0 = task.data0.xy;
vec2 p1 = p0 + task.data0.zw;
vec2 pos = mix(p0, p1, aPosition.xy);
vBorderRadii = bs.border_radius_edge_size_blur_radius_inverted.xx;
vBlurRadius = bs.border_radius_edge_size_blur_radius_inverted.z;
vInverted = bs.border_radius_edge_size_blur_radius_inverted.w;
vBoxShadowRect = vec4(bs.bs_rect.xy, bs.bs_rect.xy + bs.bs_rect.zw);
// The fragment shader expects logical units, beginning at where the
// blur radius begins.
// The first path of the equation gets the virtual position in
// logical pixels within the patch rectangle (accounting for
// bilinear offset). Then we add the start position of the
// box shadow rect and subtract the blur radius to get the
// virtual coordinates that the FS expects.
vPos = (pos - 1.0 - p0) / uDevicePixelRatio + bs.bs_rect.xy - vec2(2.0 * vBlurRadius);
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
}

View file

@ -1,9 +0,0 @@
#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/. */
void main(void) {
float a = texture(sColor0, vUv).a;
oFragColor = vec4(vColor.rgb, vColor.a * a);
}

View file

@ -1,7 +0,0 @@
#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/. */
varying vec2 vUv;
flat varying vec4 vColor;

View file

@ -1,35 +0,0 @@
#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/. */
// Draw a text run to a cache target. These are always
// drawn un-transformed. These are used for effects such
// as text-shadow.
void main(void) {
CachePrimitiveInstance cpi = fetch_cache_instance(gl_InstanceID);
RenderTaskData task = fetch_render_task(cpi.render_task_index);
TextRun text = fetch_text_run(cpi.specific_prim_index);
Glyph glyph = fetch_glyph(cpi.sub_index);
PrimitiveGeometry pg = fetch_prim_geometry(cpi.global_prim_index);
// Glyphs size is already in device-pixels.
// The render task origin is in device-pixels. Offset that by
// the glyph offset, relative to its primitive bounding rect.
vec2 size = glyph.uv_rect.zw - glyph.uv_rect.xy;
vec2 origin = task.data0.xy + uDevicePixelRatio * (glyph.offset.xy - pg.local_rect.xy);
vec4 local_rect = vec4(origin, size);
vec2 texture_size = vec2(textureSize(sColor0, 0));
vec2 st0 = glyph.uv_rect.xy / texture_size;
vec2 st1 = glyph.uv_rect.zw / texture_size;
vec2 pos = mix(local_rect.xy,
local_rect.xy + local_rect.zw,
aPosition.xy);
vUv = mix(st0, st1, aPosition.xy);
vColor = text.color;
gl_Position = uTransform * vec4(pos, 0.0, 1.0);
}

View file

@ -1,8 +0,0 @@
/* 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/. */
void main(void)
{
oFragColor = vColor;
}

View file

@ -1,11 +0,0 @@
/* 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/. */
void main(void)
{
vColor = aColorRectTL;
vec4 pos = vec4(aPosition, 1.0);
pos.xy = floor(pos.xy * uDevicePixelRatio + 0.5) / uDevicePixelRatio;
gl_Position = uTransform * pos;
}

View file

@ -1,13 +0,0 @@
/* 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/. */
void main(void)
{
#ifdef SERVO_ES2
float alpha = texture(sColor0, vColorTexCoord.xy).a;
#else
float alpha = texture(sColor0, vColorTexCoord.xy).r;
#endif
oFragColor = vec4(vColor.xyz, vColor.w * alpha);
}

View file

@ -1,12 +0,0 @@
/* 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/. */
void main(void)
{
vColor = aColorRectTL;
vColorTexCoord = aColorTexCoordRectTop.xy;
vec4 pos = vec4(aPosition, 1.0);
pos.xy = floor(pos.xy * uDevicePixelRatio + 0.5) / uDevicePixelRatio;
gl_Position = uTransform * pos;
}

View file

@ -1,698 +0,0 @@
#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/. */
#define PST_TOP_LEFT 0
#define PST_TOP 1
#define PST_TOP_RIGHT 2
#define PST_RIGHT 3
#define PST_BOTTOM_RIGHT 4
#define PST_BOTTOM 5
#define PST_BOTTOM_LEFT 6
#define PST_LEFT 7
#define BORDER_LEFT 0
#define BORDER_TOP 1
#define BORDER_RIGHT 2
#define BORDER_BOTTOM 3
#define UV_NORMALIZED uint(0)
#define UV_PIXEL uint(1)
// Border styles as defined in webrender_traits/types.rs
#define BORDER_STYLE_NONE 0
#define BORDER_STYLE_SOLID 1
#define BORDER_STYLE_DOUBLE 2
#define BORDER_STYLE_DOTTED 3
#define BORDER_STYLE_DASHED 4
#define BORDER_STYLE_HIDDEN 5
#define BORDER_STYLE_GROOVE 6
#define BORDER_STYLE_RIDGE 7
#define BORDER_STYLE_INSET 8
#define BORDER_STYLE_OUTSET 9
#define MAX_STOPS_PER_ANGLE_GRADIENT 8
uniform sampler2DArray sCache;
#ifdef WR_VERTEX_SHADER
#define VECS_PER_LAYER 13
#define VECS_PER_RENDER_TASK 2
#define VECS_PER_PRIM_GEOM 2
#define GRADIENT_HORIZONTAL 0
#define GRADIENT_VERTICAL 1
#define GRADIENT_ROTATED 2
uniform sampler2D sLayers;
uniform sampler2D sRenderTasks;
uniform sampler2D sPrimGeometry;
uniform sampler2D sClips;
uniform sampler2D sData16;
uniform sampler2D sData32;
uniform sampler2D sData64;
uniform sampler2D sData128;
ivec2 get_fetch_uv(int index, int vecs_per_item) {
int items_per_row = WR_MAX_VERTEX_TEXTURE_WIDTH / vecs_per_item;
int y = index / items_per_row;
int x = vecs_per_item * (index % items_per_row);
return ivec2(x, y);
}
ivec2 get_fetch_uv_1(int index) {
return get_fetch_uv(index, 1);
}
ivec2 get_fetch_uv_2(int index) {
return get_fetch_uv(index, 2);
}
ivec2 get_fetch_uv_4(int index) {
return get_fetch_uv(index, 4);
}
ivec2 get_fetch_uv_8(int index) {
return get_fetch_uv(index, 8);
}
struct Layer {
mat4 transform;
mat4 inv_transform;
vec4 local_clip_rect;
vec4 screen_vertices[4];
};
layout(std140) uniform Data {
ivec4 int_data[WR_MAX_UBO_VECTORS];
};
Layer fetch_layer(int index) {
Layer layer;
// Create a UV base coord for each 8 texels.
// This is required because trying to use an offset
// of more than 8 texels doesn't work on some versions
// of OSX.
ivec2 uv = get_fetch_uv(index, VECS_PER_LAYER);
ivec2 uv0 = ivec2(uv.x + 0, uv.y);
ivec2 uv1 = ivec2(uv.x + 8, uv.y);
layer.transform[0] = texelFetchOffset(sLayers, uv0, 0, ivec2(0, 0));
layer.transform[1] = texelFetchOffset(sLayers, uv0, 0, ivec2(1, 0));
layer.transform[2] = texelFetchOffset(sLayers, uv0, 0, ivec2(2, 0));
layer.transform[3] = texelFetchOffset(sLayers, uv0, 0, ivec2(3, 0));
layer.inv_transform[0] = texelFetchOffset(sLayers, uv0, 0, ivec2(4, 0));
layer.inv_transform[1] = texelFetchOffset(sLayers, uv0, 0, ivec2(5, 0));
layer.inv_transform[2] = texelFetchOffset(sLayers, uv0, 0, ivec2(6, 0));
layer.inv_transform[3] = texelFetchOffset(sLayers, uv0, 0, ivec2(7, 0));
layer.local_clip_rect = texelFetchOffset(sLayers, uv1, 0, ivec2(0, 0));
layer.screen_vertices[0] = texelFetchOffset(sLayers, uv1, 0, ivec2(1, 0));
layer.screen_vertices[1] = texelFetchOffset(sLayers, uv1, 0, ivec2(2, 0));
layer.screen_vertices[2] = texelFetchOffset(sLayers, uv1, 0, ivec2(3, 0));
layer.screen_vertices[3] = texelFetchOffset(sLayers, uv1, 0, ivec2(4, 0));
return layer;
}
struct RenderTaskData {
vec4 data0;
vec4 data1;
};
RenderTaskData fetch_render_task(int index) {
RenderTaskData task;
ivec2 uv = get_fetch_uv(index, VECS_PER_RENDER_TASK);
task.data0 = texelFetchOffset(sRenderTasks, uv, 0, ivec2(0, 0));
task.data1 = texelFetchOffset(sRenderTasks, uv, 0, ivec2(1, 0));
return task;
}
struct Tile {
vec4 screen_origin_task_origin;
vec4 size_target_index;
};
Tile fetch_tile(int index) {
RenderTaskData task = fetch_render_task(index);
Tile tile;
tile.screen_origin_task_origin = task.data0;
tile.size_target_index = task.data1;
return tile;
}
struct Gradient {
vec4 start_end_point;
vec4 kind;
};
Gradient fetch_gradient(int index) {
Gradient gradient;
ivec2 uv = get_fetch_uv_2(index);
gradient.start_end_point = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
gradient.kind = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
return gradient;
}
struct GradientStop {
vec4 color;
vec4 offset;
};
GradientStop fetch_gradient_stop(int index) {
GradientStop stop;
ivec2 uv = get_fetch_uv_2(index);
stop.color = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
stop.offset = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
return stop;
}
struct Glyph {
vec4 offset;
vec4 uv_rect;
};
Glyph fetch_glyph(int index) {
Glyph glyph;
ivec2 uv = get_fetch_uv_2(index);
glyph.offset = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
glyph.uv_rect = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
return glyph;
}
struct Border {
vec4 style;
vec4 widths;
vec4 colors[4];
vec4 radii[2];
};
Border fetch_border(int index) {
Border border;
ivec2 uv = get_fetch_uv_8(index);
border.style = texelFetchOffset(sData128, uv, 0, ivec2(0, 0));
border.widths = texelFetchOffset(sData128, uv, 0, ivec2(1, 0));
border.colors[0] = texelFetchOffset(sData128, uv, 0, ivec2(2, 0));
border.colors[1] = texelFetchOffset(sData128, uv, 0, ivec2(3, 0));
border.colors[2] = texelFetchOffset(sData128, uv, 0, ivec2(4, 0));
border.colors[3] = texelFetchOffset(sData128, uv, 0, ivec2(5, 0));
border.radii[0] = texelFetchOffset(sData128, uv, 0, ivec2(6, 0));
border.radii[1] = texelFetchOffset(sData128, uv, 0, ivec2(7, 0));
return border;
}
vec4 fetch_instance_geometry(int index) {
ivec2 uv = get_fetch_uv_1(index);
vec4 rect = texelFetchOffset(sData16, uv, 0, ivec2(0, 0));
return rect;
}
struct PrimitiveGeometry {
vec4 local_rect;
vec4 local_clip_rect;
};
PrimitiveGeometry fetch_prim_geometry(int index) {
PrimitiveGeometry pg;
ivec2 uv = get_fetch_uv(index, VECS_PER_PRIM_GEOM);
pg.local_rect = texelFetchOffset(sPrimGeometry, uv, 0, ivec2(0, 0));
pg.local_clip_rect = texelFetchOffset(sPrimGeometry, uv, 0, ivec2(1, 0));
return pg;
}
struct PrimitiveInstance {
int global_prim_index;
int specific_prim_index;
int render_task_index;
int layer_index;
int clip_address;
int sub_index;
ivec2 user_data;
};
PrimitiveInstance fetch_instance(int index) {
PrimitiveInstance pi;
int offset = index * 2;
ivec4 data0 = int_data[offset + 0];
ivec4 data1 = int_data[offset + 1];
pi.global_prim_index = data0.x;
pi.specific_prim_index = data0.y;
pi.render_task_index = data0.z;
pi.layer_index = data0.w;
pi.clip_address = data1.x;
pi.sub_index = data1.y;
pi.user_data = data1.zw;
return pi;
}
struct BlurCommand {
int task_id;
int src_task_id;
int dir;
};
BlurCommand fetch_blur(int index) {
BlurCommand blur;
int offset = index * 1;
ivec4 data0 = int_data[offset + 0];
blur.task_id = data0.x;
blur.src_task_id = data0.y;
blur.dir = data0.z;
return blur;
}
struct CachePrimitiveInstance {
int global_prim_index;
int specific_prim_index;
int render_task_index;
int sub_index;
};
CachePrimitiveInstance fetch_cache_instance(int index) {
CachePrimitiveInstance cpi;
int offset = index * 1;
ivec4 data0 = int_data[offset + 0];
cpi.global_prim_index = data0.x;
cpi.specific_prim_index = data0.y;
cpi.render_task_index = data0.z;
cpi.sub_index = data0.w;
return cpi;
}
struct Primitive {
Layer layer;
Tile tile;
vec4 local_rect;
vec4 local_clip_rect;
int prim_index;
int clip_index;
// when sending multiple primitives of the same type (e.g. border segments)
// this index allows the vertex shader to recognize the difference
int sub_index;
ivec2 user_data;
};
Primitive load_primitive(int index) {
Primitive prim;
PrimitiveInstance pi = fetch_instance(index);
prim.layer = fetch_layer(pi.layer_index);
prim.tile = fetch_tile(pi.render_task_index);
PrimitiveGeometry pg = fetch_prim_geometry(pi.global_prim_index);
prim.local_rect = pg.local_rect;
prim.local_clip_rect = pg.local_clip_rect;
prim.prim_index = pi.specific_prim_index;
prim.clip_index = pi.clip_address;
prim.sub_index = pi.sub_index;
prim.user_data = pi.user_data;
return prim;
}
struct ClipRect {
vec4 rect;
vec4 dummy;
};
ClipRect fetch_clip_rect(int index) {
ClipRect rect;
ivec2 uv = get_fetch_uv_2(index);
rect.rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
//rect.dummy = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
rect.dummy = vec4(0.0, 0.0, 0.0, 0.0);
return rect;
}
struct ImageMaskData {
vec4 uv_rect;
vec4 local_rect;
};
ImageMaskData fetch_mask_data(int index) {
ImageMaskData info;
ivec2 uv = get_fetch_uv_2(index);
info.uv_rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
info.local_rect = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
return info;
}
struct ClipCorner {
vec4 rect;
vec4 outer_inner_radius;
};
ClipCorner fetch_clip_corner(int index) {
ClipCorner corner;
ivec2 uv = get_fetch_uv_2(index);
corner.rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
corner.outer_inner_radius = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
return corner;
}
struct ClipData {
ClipRect rect;
ClipCorner top_left;
ClipCorner top_right;
ClipCorner bottom_left;
ClipCorner bottom_right;
ImageMaskData mask_data;
};
ClipData fetch_clip(int index) {
ClipData clip;
clip.rect = fetch_clip_rect(index + 0);
clip.top_left = fetch_clip_corner(index + 1);
clip.top_right = fetch_clip_corner(index + 2);
clip.bottom_left = fetch_clip_corner(index + 3);
clip.bottom_right = fetch_clip_corner(index + 4);
clip.mask_data = fetch_mask_data(index + 5);
return clip;
}
// Return the intersection of the plane (set up by "normal" and "point")
// with the ray (set up by "ray_origin" and "ray_dir"),
// writing the resulting scaler into "t".
bool ray_plane(vec3 normal, vec3 point, vec3 ray_origin, vec3 ray_dir, out float t)
{
float denom = dot(normal, ray_dir);
if (denom > 1e-6) {
vec3 d = point - ray_origin;
t = dot(d, normal) / denom;
return t >= 0.0;
}
return false;
}
// Apply the inverse transform "inv_transform"
// to the reference point "ref" in CSS space,
// producing a local point on a layer plane,
// set by a base point "a" and a normal "n".
vec4 untransform(vec2 ref, vec3 n, vec3 a, mat4 inv_transform) {
vec3 p = vec3(ref, -10000.0);
vec3 d = vec3(0, 0, 1.0);
float t = 0.0;
// get an intersection of the layer plane with Z axis vector,
// originated from the "ref" point
ray_plane(n, a, p, d, t);
float z = p.z + d.z * t; // Z of the visible point on the layer
vec4 r = inv_transform * vec4(ref, z, 1.0);
return r;
}
// Given a CSS space position, transform it back into the layer space.
vec4 get_layer_pos(vec2 pos, Layer layer) {
// get 3 of the layer corners in CSS space
vec3 a = layer.screen_vertices[0].xyz / layer.screen_vertices[0].w;
vec3 b = layer.screen_vertices[3].xyz / layer.screen_vertices[3].w;
vec3 c = layer.screen_vertices[2].xyz / layer.screen_vertices[2].w;
// get the normal to the layer plane
vec3 n = normalize(cross(b-a, c-a));
return untransform(pos, n, a, layer.inv_transform);
}
vec2 clamp_rect(vec2 point, vec4 rect) {
return clamp(point, rect.xy, rect.xy + rect.zw);
}
struct Rect {
vec2 p0;
vec2 p1;
};
struct VertexInfo {
Rect local_rect;
vec2 local_clamped_pos;
vec2 global_clamped_pos;
};
VertexInfo write_vertex(vec4 instance_rect,
vec4 local_clip_rect,
Layer layer,
Tile tile) {
vec2 p0 = floor(0.5 + instance_rect.xy * uDevicePixelRatio) / uDevicePixelRatio;
vec2 p1 = floor(0.5 + (instance_rect.xy + instance_rect.zw) * uDevicePixelRatio) / uDevicePixelRatio;
vec2 local_pos = mix(p0, p1, aPosition.xy);
vec2 cp0 = floor(0.5 + local_clip_rect.xy * uDevicePixelRatio) / uDevicePixelRatio;
vec2 cp1 = floor(0.5 + (local_clip_rect.xy + local_clip_rect.zw) * uDevicePixelRatio) / uDevicePixelRatio;
local_pos = clamp(local_pos, cp0, cp1);
local_pos = clamp_rect(local_pos, layer.local_clip_rect);
vec4 world_pos = layer.transform * vec4(local_pos, 0, 1);
world_pos.xyz /= world_pos.w;
vec2 device_pos = world_pos.xy * uDevicePixelRatio;
vec2 clamped_pos = clamp(device_pos,
tile.screen_origin_task_origin.xy,
tile.screen_origin_task_origin.xy + tile.size_target_index.xy);
vec4 local_clamped_pos = layer.inv_transform * vec4(clamped_pos / uDevicePixelRatio, world_pos.z, 1);
local_clamped_pos.xyz /= local_clamped_pos.w;
vec2 final_pos = clamped_pos + tile.screen_origin_task_origin.zw - tile.screen_origin_task_origin.xy;
gl_Position = uTransform * vec4(final_pos, 0, 1);
VertexInfo vi = VertexInfo(Rect(p0, p1), local_clamped_pos.xy, clamped_pos.xy);
return vi;
}
#ifdef WR_FEATURE_TRANSFORM
struct TransformVertexInfo {
vec3 local_pos;
vec4 clipped_local_rect;
};
TransformVertexInfo write_transform_vertex(vec4 instance_rect,
vec4 local_clip_rect,
Layer layer,
Tile tile) {
vec2 lp0_base = instance_rect.xy;
vec2 lp1_base = instance_rect.xy + instance_rect.zw;
vec2 lp0 = clamp_rect(clamp_rect(lp0_base, local_clip_rect),
layer.local_clip_rect);
vec2 lp1 = clamp_rect(clamp_rect(lp1_base, local_clip_rect),
layer.local_clip_rect);
vec4 clipped_local_rect = vec4(lp0, lp1 - lp0);
vec2 p0 = lp0;
vec2 p1 = vec2(lp1.x, lp0.y);
vec2 p2 = vec2(lp0.x, lp1.y);
vec2 p3 = lp1;
vec4 t0 = layer.transform * vec4(p0, 0, 1);
vec4 t1 = layer.transform * vec4(p1, 0, 1);
vec4 t2 = layer.transform * vec4(p2, 0, 1);
vec4 t3 = layer.transform * vec4(p3, 0, 1);
vec2 tp0 = t0.xy / t0.w;
vec2 tp1 = t1.xy / t1.w;
vec2 tp2 = t2.xy / t2.w;
vec2 tp3 = t3.xy / t3.w;
// compute a CSS space aligned bounding box
vec2 min_pos = min(min(tp0.xy, tp1.xy), min(tp2.xy, tp3.xy));
vec2 max_pos = max(max(tp0.xy, tp1.xy), max(tp2.xy, tp3.xy));
// clamp to the tile boundaries, in device space
vec2 min_pos_clamped = clamp(min_pos * uDevicePixelRatio,
tile.screen_origin_task_origin.xy,
tile.screen_origin_task_origin.xy + tile.size_target_index.xy);
vec2 max_pos_clamped = clamp(max_pos * uDevicePixelRatio,
tile.screen_origin_task_origin.xy,
tile.screen_origin_task_origin.xy + tile.size_target_index.xy);
// compute the device space position of this vertex
vec2 clamped_pos = mix(min_pos_clamped,
max_pos_clamped,
aPosition.xy);
// compute the point position in side the layer, in CSS space
vec4 layer_pos = get_layer_pos(clamped_pos / uDevicePixelRatio, layer);
// apply the task offset
vec2 final_pos = clamped_pos + tile.screen_origin_task_origin.zw - tile.screen_origin_task_origin.xy;
gl_Position = uTransform * vec4(final_pos, 0, 1);
return TransformVertexInfo(layer_pos.xyw, clipped_local_rect);
}
#endif //WR_FEATURE_TRANSFORM
struct Rectangle {
vec4 color;
};
Rectangle fetch_rectangle(int index) {
Rectangle rect;
ivec2 uv = get_fetch_uv_1(index);
rect.color = texelFetchOffset(sData16, uv, 0, ivec2(0, 0));
return rect;
}
struct TextRun {
vec4 color;
};
TextRun fetch_text_run(int index) {
TextRun text;
ivec2 uv = get_fetch_uv_1(index);
text.color = texelFetchOffset(sData16, uv, 0, ivec2(0, 0));
return text;
}
struct Image {
vec4 st_rect; // Location of the image texture in the texture atlas.
vec4 stretch_size_and_tile_spacing; // Size of the actual image and amount of space between
// tiled instances of this image.
};
Image fetch_image(int index) {
Image image;
ivec2 uv = get_fetch_uv_2(index);
image.st_rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
image.stretch_size_and_tile_spacing = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
return image;
}
struct BoxShadow {
vec4 src_rect;
vec4 bs_rect;
vec4 color;
vec4 border_radius_edge_size_blur_radius_inverted;
};
BoxShadow fetch_boxshadow(int index) {
BoxShadow bs;
ivec2 uv = get_fetch_uv_4(index);
bs.src_rect = texelFetchOffset(sData64, uv, 0, ivec2(0, 0));
bs.bs_rect = texelFetchOffset(sData64, uv, 0, ivec2(1, 0));
bs.color = texelFetchOffset(sData64, uv, 0, ivec2(2, 0));
bs.border_radius_edge_size_blur_radius_inverted = texelFetchOffset(sData64, uv, 0, ivec2(3, 0));
return bs;
}
struct Blend {
ivec4 src_id_target_id_op_amount;
};
Blend fetch_blend(int index) {
Blend blend;
int offset = index * 1;
blend.src_id_target_id_op_amount = int_data[offset + 0];
return blend;
}
struct Composite {
ivec4 src0_src1_target_id_op;
};
Composite fetch_composite(int index) {
Composite composite;
int offset = index * 1;
composite.src0_src1_target_id_op = int_data[offset + 0];
return composite;
}
#endif
#ifdef WR_FRAGMENT_SHADER
float distance_from_rect(vec2 p, vec2 origin, vec2 size) {
vec2 clamped = clamp(p, origin, origin + size);
return distance(clamped, p);
}
vec2 init_transform_fs(vec3 local_pos, vec4 local_rect, out float fragment_alpha) {
fragment_alpha = 1.0;
vec2 pos = local_pos.xy / local_pos.z;
float border_distance = distance_from_rect(pos, local_rect.xy, local_rect.zw);
if (border_distance != 0.0) {
float delta = length(fwidth(local_pos.xy));
fragment_alpha = 1.0 - smoothstep(0.0, 1.0, border_distance / delta * 2.0);
}
return pos;
}
#endif

View file

@ -1,39 +0,0 @@
/* 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/. */
float offset(int index) {
return vOffsets[index / 4][index % 4];
}
float linearStep(float lo, float hi, float x) {
float d = hi - lo;
float v = x - lo;
if (d != 0.0) {
v /= d;
}
return clamp(v, 0.0, 1.0);
}
void main(void) {
float angle = atan(-vEndPoint.y + vStartPoint.y,
vEndPoint.x - vStartPoint.x);
float sa = sin(angle);
float ca = cos(angle);
float sx = vStartPoint.x * ca - vStartPoint.y * sa;
float ex = vEndPoint.x * ca - vEndPoint.y * sa;
float d = ex - sx;
float x = vPos.x * ca - vPos.y * sa;
oFragColor = mix(vColors[0],
vColors[1],
linearStep(sx + d * offset(0), sx + d * offset(1), x));
for (int i=1 ; i < vStopCount-1 ; ++i) {
oFragColor = mix(oFragColor,
vColors[i+1],
linearStep(sx + d * offset(i), sx + d * offset(i+1), x));
}
}

View file

@ -1,11 +0,0 @@
/* 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 int vStopCount;
flat varying float vAngle;
flat varying vec2 vStartPoint;
flat varying vec2 vEndPoint;
varying vec2 vPos;
flat varying vec4 vColors[MAX_STOPS_PER_ANGLE_GRADIENT];
flat varying vec4 vOffsets[MAX_STOPS_PER_ANGLE_GRADIENT/4];

View file

@ -1,32 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
Gradient gradient = fetch_gradient(prim.prim_index);
VertexInfo vi = write_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vStopCount = int(prim.user_data.x);
vPos = vi.local_clamped_pos;
// Snap the start/end points to device pixel units.
// I'm not sure this is entirely correct, but the
// old render path does this, and it is needed to
// make the angle gradient ref tests pass. It might
// be better to fix this higher up in DL construction
// and not snap here?
vStartPoint = floor(0.5 + gradient.start_end_point.xy * uDevicePixelRatio) / uDevicePixelRatio;
vEndPoint = floor(0.5 + gradient.start_end_point.zw * uDevicePixelRatio) / uDevicePixelRatio;
for (int i=0 ; i < vStopCount ; ++i) {
GradientStop stop = fetch_gradient_stop(prim.sub_index + i);
vColors[i] = stop.color;
vOffsets[i/4][i%4] = stop.offset.x;
}
}

View file

@ -1,138 +0,0 @@
/* 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/. */
vec3 rgbToHsv(vec3 c) {
float value = max(max(c.r, c.g), c.b);
float chroma = value - min(min(c.r, c.g), c.b);
if (chroma == 0.0) {
return vec3(0.0);
}
float saturation = chroma / value;
float hue;
if (c.r == value)
hue = (c.g - c.b) / chroma;
else if (c.g == value)
hue = 2.0 + (c.b - c.r) / chroma;
else // if (c.b == value)
hue = 4.0 + (c.r - c.g) / chroma;
hue *= 1.0/6.0;
if (hue < 0.0)
hue += 1.0;
return vec3(hue, saturation, value);
}
vec3 hsvToRgb(vec3 c) {
if (c.s == 0.0) {
return vec3(c.z);
}
float hue = c.x * 6.0;
int sector = int(hue);
float residualHue = hue - float(sector);
vec3 pqt = c.z * vec3(1.0 - c.y, 1.0 - c.y * residualHue, 1.0 - c.y * (1.0 - residualHue));
switch (sector) {
case 0:
return vec3(c.z, pqt.z, pqt.x);
case 1:
return vec3(pqt.y, c.z, pqt.x);
case 2:
return vec3(pqt.x, c.z, pqt.z);
case 3:
return vec3(pqt.x, pqt.y, c.z);
case 4:
return vec3(pqt.z, pqt.x, c.z);
default:
return vec3(c.z, pqt.x, pqt.y);
}
}
vec4 Blur(float radius, vec2 direction) {
// TODO(gw): Support blur in WR2!
return vec4(1.0);
}
vec4 Contrast(vec4 Cs, float amount) {
return vec4(Cs.rgb * amount - 0.5 * amount + 0.5, 1.0);
}
vec4 Grayscale(vec4 Cs, float amount) {
float ia = 1.0 - amount;
return mat4(vec4(0.2126 + 0.7874 * ia, 0.2126 - 0.2126 * ia, 0.2126 - 0.2126 * ia, 0.0),
vec4(0.7152 - 0.7152 * ia, 0.7152 + 0.2848 * ia, 0.7152 - 0.7152 * ia, 0.0),
vec4(0.0722 - 0.0722 * ia, 0.0722 - 0.0722 * ia, 0.0722 + 0.9278 * ia, 0.0),
vec4(0.0, 0.0, 0.0, 1.0)) * Cs;
}
vec4 HueRotate(vec4 Cs, float amount) {
vec3 CsHsv = rgbToHsv(Cs.rgb);
CsHsv.x = mod(CsHsv.x + amount / 6.283185307179586, 1.0);
return vec4(hsvToRgb(CsHsv), Cs.a);
}
vec4 Invert(vec4 Cs, float amount) {
return mix(Cs, vec4(1.0, 1.0, 1.0, Cs.a) - vec4(Cs.rgb, 0.0), amount);
}
vec4 Saturate(vec4 Cs, float amount) {
return vec4(hsvToRgb(min(vec3(1.0, amount, 1.0) * rgbToHsv(Cs.rgb), vec3(1.0))), Cs.a);
}
vec4 Sepia(vec4 Cs, float amount) {
float ia = 1.0 - amount;
return mat4(vec4(0.393 + 0.607 * ia, 0.349 - 0.349 * ia, 0.272 - 0.272 * ia, 0.0),
vec4(0.769 - 0.769 * ia, 0.686 + 0.314 * ia, 0.534 - 0.534 * ia, 0.0),
vec4(0.189 - 0.189 * ia, 0.168 - 0.168 * ia, 0.131 + 0.869 * ia, 0.0),
vec4(0.0, 0.0, 0.0, 1.0)) * Cs;
}
vec4 Brightness(vec4 Cs, float amount) {
return vec4(Cs.rgb * amount, Cs.a);
}
vec4 Opacity(vec4 Cs, float amount) {
return vec4(Cs.rgb, Cs.a * amount);
}
void main(void) {
vec4 Cs = texture(sCache, vUv);
if (Cs.a == 0.0) {
discard;
}
switch (vOp) {
case 0:
// Gaussian blur is specially handled:
oFragColor = Cs;// Blur(vAmount, vec2(0,0));
break;
case 1:
oFragColor = Contrast(Cs, vAmount);
break;
case 2:
oFragColor = Grayscale(Cs, vAmount);
break;
case 3:
oFragColor = HueRotate(Cs, vAmount);
break;
case 4:
oFragColor = Invert(Cs, vAmount);
break;
case 5:
oFragColor = Saturate(Cs, vAmount);
break;
case 6:
oFragColor = Sepia(Cs, vAmount);
break;
case 7:
oFragColor = Brightness(Cs, vAmount);
break;
case 8:
oFragColor = Opacity(Cs, vAmount);
break;
}
}

View file

@ -1,7 +0,0 @@
/* 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/. */
varying vec3 vUv;
flat varying float vAmount;
flat varying int vOp;

View file

@ -1,28 +0,0 @@
#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/. */
void main(void) {
Blend blend = fetch_blend(gl_InstanceID);
Tile src = fetch_tile(blend.src_id_target_id_op_amount.x);
Tile dest = fetch_tile(blend.src_id_target_id_op_amount.y);
vec2 dest_origin = dest.screen_origin_task_origin.zw -
dest.screen_origin_task_origin.xy +
src.screen_origin_task_origin.xy;
vec2 local_pos = mix(dest_origin,
dest_origin + src.size_target_index.xy,
aPosition.xy);
vec2 texture_size = vec2(textureSize(sCache, 0));
vec2 st0 = src.screen_origin_task_origin.zw / texture_size;
vec2 st1 = (src.screen_origin_task_origin.zw + src.size_target_index.xy) / texture_size;
vUv = vec3(mix(st0, st1, aPosition.xy), src.size_target_index.z);
vOp = blend.src_id_target_id_op_amount.z;
vAmount = blend.src_id_target_id_op_amount.w / 65535.0;
gl_Position = uTransform * vec4(local_pos, 0, 1);
}

View file

@ -1,335 +0,0 @@
#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/. */
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;
}
}
vec4 get_fragment_color(float distanceFromMixLine, float pixelsPerFragment) {
// Here we are mixing between the two border colors. We need to convert
// distanceFromMixLine it to pixel space to properly anti-alias and then push
// it between the limits accepted by `mix`.
float colorMix = min(max(distanceFromMixLine / pixelsPerFragment, -0.5), 0.5) + 0.5;
return mix(vHorizontalColor, vVerticalColor, colorMix);
}
float alpha_for_solid_border(float distance_from_ref,
float inner_radius,
float outer_radius,
float pixels_per_fragment) {
// We want to start anti-aliasing one pixel in from the border.
float nudge = pixels_per_fragment;
inner_radius += nudge;
outer_radius -= nudge;
if (distance_from_ref < outer_radius && distance_from_ref > inner_radius) {
return 1.0;
}
float distance_from_border = max(distance_from_ref - outer_radius,
inner_radius - distance_from_ref);
// 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);
}
float alpha_for_solid_border_corner(vec2 local_pos,
float inner_radius,
float outer_radius,
float pixels_per_fragment) {
float distance_from_ref = distance(vRefPoint, local_pos);
return alpha_for_solid_border(distance_from_ref, inner_radius, outer_radius, pixels_per_fragment);
}
vec4 draw_dotted_edge(vec2 local_pos, vec4 piece_rect, float pixels_per_fragment) {
// We don't use pixels_per_fragment here, since it can change along the edge
// of a transformed border edge. We want this calculation to be consistent
// across the entire edge so that the positioning of the dots stays the same.
float two_pixels = 2.0 * length(fwidth(vLocalPos.xy));
// Circle diameter is stroke width, minus a couple pixels to account for anti-aliasing.
float circle_diameter = max(piece_rect.z - two_pixels, min(piece_rect.z, two_pixels));
// We want to spread the circles across the edge, but keep one circle diameter at the end
// reserved for two half-circles which connect to the corners.
float edge_available = piece_rect.w - (circle_diameter * 2.0);
float number_of_circles = floor(edge_available / (circle_diameter * 2.0));
// Here we are initializing the distance from the y coordinate of the center of the circle to
// the closest end half-circle.
vec2 relative_pos = local_pos - piece_rect.xy;
float y_distance = min(relative_pos.y, piece_rect.w - relative_pos.y);
if (number_of_circles > 0.0) {
// Spread the circles throughout the edge, to distribute the extra space evenly. We want
// to ensure that we have at last two pixels of space for each circle so that they aren't
// touching.
float space_for_each_circle = ceil(max(edge_available / number_of_circles, two_pixels));
float first_half_circle_space = circle_diameter;
float circle_index = (relative_pos.y - first_half_circle_space) / space_for_each_circle;
circle_index = floor(clamp(circle_index, 0.0, number_of_circles - 1.0));
float circle_y_pos =
circle_index * space_for_each_circle + (space_for_each_circle / 2.0) + circle_diameter;
y_distance = min(abs(circle_y_pos - relative_pos.y), y_distance);
}
float distance_from_circle_center = length(vec2(relative_pos.x - (piece_rect.z / 2.0), y_distance));
float distance_from_circle_edge = distance_from_circle_center - (circle_diameter / 2.0);
// Don't anti-alias if the circle diameter is small to avoid a blur of color.
if (circle_diameter < two_pixels && distance_from_circle_edge > 0.0)
return vec4(0.0);
// Move the distance back into pixels.
distance_from_circle_edge /= pixels_per_fragment;
float alpha = 1.0 - smoothstep(0.0, 1.0, min(1.0, max(0.0, distance_from_circle_edge)));
return vHorizontalColor * vec4(1.0, 1.0, 1.0, alpha);
}
vec4 draw_dashed_edge(float position, float border_width, float pixels_per_fragment) {
// TODO: Investigate exactly what FF does.
float size = border_width * 3.0;
float segment = floor(position / size);
float alpha = alpha_for_solid_border(position,
segment * size,
(segment + 1.0) * size,
pixels_per_fragment);
if (mod(segment + 2.0, 2.0) == 0.0) {
return vHorizontalColor * vec4(1.0, 1.0, 1.0, 1.0 - alpha);
} else {
return vHorizontalColor * vec4(1.0, 1.0, 1.0, alpha);
}
}
void draw_dashed_or_dotted_border(vec2 local_pos, float distance_from_mix_line) {
// This is the conversion factor for transformations and device pixel scaling.
float pixels_per_fragment = length(fwidth(local_pos.xy));
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 = get_fragment_color(distance_from_mix_line, pixels_per_fragment);
if (vRadii.x > 0.0) {
oFragColor *= vec4(1.0, 1.0, 1.0, alpha_for_solid_border_corner(local_pos,
vRadii.z,
vRadii.x,
pixels_per_fragment));
}
break;
}
case PST_BOTTOM:
case PST_TOP: {
if (vBorderStyle == BORDER_STYLE_DASHED) {
oFragColor = draw_dashed_edge(vLocalPos.x - vPieceRect.x,
vPieceRect.w,
pixels_per_fragment);
} else {
oFragColor = draw_dotted_edge(local_pos.yx, vPieceRect.yxwz, pixels_per_fragment);
}
break;
}
case PST_LEFT:
case PST_RIGHT:
{
if (vBorderStyle == BORDER_STYLE_DASHED) {
oFragColor = draw_dashed_edge(vLocalPos.y - vPieceRect.y,
vPieceRect.z,
pixels_per_fragment);
} else {
oFragColor = draw_dotted_edge(local_pos.xy, vPieceRect.xyzw, pixels_per_fragment);
}
break;
}
}
}
vec4 draw_double_edge(float pos,
float len,
float distance_from_mix_line,
float pixels_per_fragment) {
float total_border_width = len;
float one_third_width = total_border_width / 3.0;
// Contribution of the outer border segment.
float alpha = alpha_for_solid_border(pos,
total_border_width - one_third_width,
total_border_width,
pixels_per_fragment);
// Contribution of the inner border segment.
alpha += alpha_for_solid_border(pos, 0.0, one_third_width, pixels_per_fragment);
return get_fragment_color(distance_from_mix_line, pixels_per_fragment) * vec4(1.0, 1.0, 1.0, alpha);
}
vec4 draw_double_edge_vertical(vec2 local_pos,
float distance_from_mix_line,
float pixels_per_fragment) {
// Get our position within this specific segment
float position = local_pos.x - vLocalRect.x;
return draw_double_edge(position, vLocalRect.z, distance_from_mix_line, pixels_per_fragment);
}
vec4 draw_double_edge_horizontal(vec2 local_pos,
float distance_from_mix_line,
float pixels_per_fragment) {
// Get our position within this specific segment
float position = local_pos.y - vLocalRect.y;
return draw_double_edge(position, vLocalRect.w, distance_from_mix_line, pixels_per_fragment);
}
vec4 draw_double_edge_corner_with_radius(vec2 local_pos,
float distance_from_mix_line,
float pixels_per_fragment) {
float total_border_width = vRadii.x - vRadii.z;
float one_third_width = total_border_width / 3.0;
// Contribution of the outer border segment.
float alpha = alpha_for_solid_border_corner(local_pos,
vRadii.x - one_third_width,
vRadii.x,
pixels_per_fragment);
// Contribution of the inner border segment.
alpha += alpha_for_solid_border_corner(local_pos,
vRadii.z,
vRadii.z + one_third_width,
pixels_per_fragment);
return get_fragment_color(distance_from_mix_line, pixels_per_fragment) * vec4(1.0, 1.0, 1.0, alpha);
}
vec4 draw_double_edge_corner(vec2 local_pos,
float distance_from_mix_line,
float pixels_per_fragment) {
if (vRadii.x > 0.0) {
return draw_double_edge_corner_with_radius(local_pos,
distance_from_mix_line,
pixels_per_fragment);
}
bool is_vertical = (vBorderPart == PST_TOP_LEFT) ? distance_from_mix_line < 0.0 :
distance_from_mix_line >= 0.0;
if (is_vertical) {
return draw_double_edge_vertical(local_pos, distance_from_mix_line, pixels_per_fragment);
} else {
return draw_double_edge_horizontal(local_pos, distance_from_mix_line, pixels_per_fragment);
}
}
void draw_double_border(float distance_from_mix_line, vec2 local_pos) {
float pixels_per_fragment = length(fwidth(local_pos.xy));
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(local_pos, distance_from_mix_line, pixels_per_fragment);
break;
}
case PST_BOTTOM:
case PST_TOP:
{
oFragColor = draw_double_edge_horizontal(local_pos,
distance_from_mix_line,
pixels_per_fragment);
break;
}
case PST_LEFT:
case PST_RIGHT:
{
oFragColor = draw_double_edge_vertical(local_pos,
distance_from_mix_line,
pixels_per_fragment);
break;
}
}
}
void draw_solid_border(float distanceFromMixLine, vec2 localPos) {
switch (vBorderPart) {
case PST_TOP_LEFT:
case PST_TOP_RIGHT:
case PST_BOTTOM_LEFT:
case PST_BOTTOM_RIGHT: {
// This is the conversion factor for transformations and device pixel scaling.
float pixelsPerFragment = length(fwidth(localPos.xy));
oFragColor = get_fragment_color(distanceFromMixLine, pixelsPerFragment);
if (vRadii.x > 0.0) {
float alpha = alpha_for_solid_border_corner(localPos, vRadii.z, vRadii.x, pixelsPerFragment);
oFragColor *= vec4(1.0, 1.0, 1.0, alpha);
}
break;
}
default:
oFragColor = vHorizontalColor;
discard_pixels_in_rounded_borders(localPos);
}
}
// TODO: Investigate performance of this shader and see
// if it's worthwhile splitting it / removing branches etc.
void main(void) {
#ifdef WR_FEATURE_TRANSFORM
float alpha = 0.0;
vec2 local_pos = init_transform_fs(vLocalPos, vLocalRect, alpha);
#else
vec2 local_pos = vLocalPos;
#endif
#ifdef WR_FEATURE_TRANSFORM
// TODO(gw): Support other border styles for transformed elements.
float distance_from_mix_line = (local_pos.x - vPieceRect.x) * vPieceRect.w -
(local_pos.y - vPieceRect.y) * vPieceRect.z;
distance_from_mix_line /= vPieceRectHypotenuseLength;
#else
float distance_from_mix_line = vDistanceFromMixLine;
#endif
switch (vBorderStyle) {
case BORDER_STYLE_DASHED:
case BORDER_STYLE_DOTTED:
draw_dashed_or_dotted_border(local_pos, distance_from_mix_line);
break;
case BORDER_STYLE_DOUBLE:
draw_double_border(distance_from_mix_line, local_pos);
break;
case BORDER_STYLE_OUTSET:
case BORDER_STYLE_INSET:
case BORDER_STYLE_SOLID:
case BORDER_STYLE_NONE:
draw_solid_border(distance_from_mix_line, local_pos);
break;
default:
discard;
}
#ifdef WR_FEATURE_TRANSFORM
oFragColor *= vec4(1.0, 1.0, 1.0, alpha);
#endif
}

View file

@ -1,31 +0,0 @@
#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/. */
// 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
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 int vBorderStyle;
flat varying int vBorderPart; // Which part of the border we're drawing.
flat varying vec4 vPieceRect;
// These are in device space
#ifdef WR_FEATURE_TRANSFORM
varying vec3 vLocalPos; // The clamped position in local space.
flat varying float vPieceRectHypotenuseLength;
#else
varying vec2 vLocalPos; // The clamped position in local space.
// These two are interpolated
varying float vDistanceFromMixLine; // This is the distance from the line where two colors
// meet in border corners.
#endif

View file

@ -1,216 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
Border border = fetch_border(prim.prim_index);
int sub_part = prim.sub_index;
vec2 tl_outer = prim.local_rect.xy;
vec2 tl_inner = tl_outer + vec2(max(border.radii[0].x, border.widths.x),
max(border.radii[0].y, border.widths.y));
vec2 tr_outer = vec2(prim.local_rect.x + prim.local_rect.z,
prim.local_rect.y);
vec2 tr_inner = tr_outer + vec2(-max(border.radii[0].z, border.widths.z),
max(border.radii[0].w, border.widths.y));
vec2 br_outer = vec2(prim.local_rect.x + prim.local_rect.z,
prim.local_rect.y + prim.local_rect.w);
vec2 br_inner = br_outer - vec2(max(border.radii[1].x, border.widths.z),
max(border.radii[1].y, border.widths.w));
vec2 bl_outer = vec2(prim.local_rect.x,
prim.local_rect.y + prim.local_rect.w);
vec2 bl_inner = bl_outer + vec2(max(border.radii[1].z, border.widths.x),
-max(border.radii[1].w, border.widths.w));
vec4 segment_rect;
switch (sub_part) {
case PST_TOP_LEFT:
segment_rect = vec4(tl_outer, tl_inner - tl_outer);
break;
case PST_TOP_RIGHT:
segment_rect = vec4(tr_inner.x,
tr_outer.y,
tr_outer.x - tr_inner.x,
tr_inner.y - tr_outer.y);
break;
case PST_BOTTOM_RIGHT:
segment_rect = vec4(br_inner, br_outer - br_inner);
break;
case PST_BOTTOM_LEFT:
segment_rect = vec4(bl_outer.x,
bl_inner.y,
bl_inner.x - bl_outer.x,
bl_outer.y - bl_inner.y);
break;
case PST_LEFT:
segment_rect = vec4(tl_outer.x,
tl_inner.y,
border.widths.x,
bl_inner.y - tl_inner.y);
break;
case PST_RIGHT:
segment_rect = vec4(tr_outer.x - border.widths.z,
tr_inner.y,
border.widths.z,
br_inner.y - tr_inner.y);
break;
case PST_BOTTOM:
segment_rect = vec4(bl_inner.x,
bl_outer.y - border.widths.w,
br_inner.x - bl_inner.x,
border.widths.w);
break;
case PST_TOP:
segment_rect = vec4(tl_inner.x,
tl_outer.y,
tr_inner.x - tl_inner.x,
border.widths.y);
break;
}
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(segment_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalPos = vi.local_pos;
// Local space
vLocalRect = vi.clipped_local_rect;
#else
VertexInfo vi = write_vertex(segment_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalPos = vi.local_clamped_pos.xy;
// Local space
vLocalRect = prim.local_rect;
#endif
switch (sub_part) {
case PST_LEFT:
vBorderStyle = int(border.style.x);
vHorizontalColor = border.colors[BORDER_LEFT];
vVerticalColor = border.colors[BORDER_LEFT];
vRadii = vec4(0.0);
break;
case PST_TOP_LEFT:
vBorderStyle = int(border.style.x);
vHorizontalColor = border.colors[BORDER_LEFT];
vVerticalColor = border.colors[BORDER_TOP];
vRadii = vec4(border.radii[0].xy,
border.radii[0].xy - border.widths.xy);
break;
case PST_TOP:
vBorderStyle = int(border.style.y);
vHorizontalColor = border.colors[BORDER_TOP];
vVerticalColor = border.colors[BORDER_TOP];
vRadii = vec4(0.0);
break;
case PST_TOP_RIGHT:
vBorderStyle = int(border.style.y);
vHorizontalColor = border.colors[BORDER_TOP];
vVerticalColor = border.colors[BORDER_RIGHT];
vRadii = vec4(border.radii[0].zw,
border.radii[0].zw - border.widths.zy);
break;
case PST_RIGHT:
vBorderStyle = int(border.style.z);
vHorizontalColor = border.colors[BORDER_RIGHT];
vVerticalColor = border.colors[BORDER_RIGHT];
vRadii = vec4(0.0);
break;
case PST_BOTTOM_RIGHT:
vBorderStyle = int(border.style.z);
vHorizontalColor = border.colors[BORDER_BOTTOM];
vVerticalColor = border.colors[BORDER_RIGHT];
vRadii = vec4(border.radii[1].xy,
border.radii[1].xy - border.widths.zw);
break;
case PST_BOTTOM:
vBorderStyle = int(border.style.w);
vHorizontalColor = border.colors[BORDER_BOTTOM];
vVerticalColor = border.colors[BORDER_BOTTOM];
vRadii = vec4(0.0);
break;
case PST_BOTTOM_LEFT:
vBorderStyle = int(border.style.w);
vHorizontalColor = border.colors[BORDER_BOTTOM];
vVerticalColor = border.colors[BORDER_LEFT];
vRadii = vec4(border.radii[1].zw,
border.radii[1].zw - border.widths.xw);
break;
}
float x0, y0, x1, y1;
switch (sub_part) {
// These are the layer tile part PrimitivePart as uploaded by the tiling.rs
case PST_TOP_LEFT:
x0 = segment_rect.x;
y0 = segment_rect.y;
// These are width / heights
x1 = segment_rect.x + segment_rect.z;
y1 = segment_rect.y + segment_rect.w;
// The radius here is the border-radius. This is 0, so vRefPoint will
// just be the top left (x,y) corner.
vRefPoint = vec2(x0, y0) + vRadii.xy;
break;
case PST_TOP_RIGHT:
x0 = segment_rect.x + segment_rect.z;
y0 = segment_rect.y;
x1 = segment_rect.x;
y1 = segment_rect.y + segment_rect.w;
vRefPoint = vec2(x0, y0) + vec2(-vRadii.x, vRadii.y);
break;
case PST_BOTTOM_LEFT:
x0 = segment_rect.x;
y0 = segment_rect.y + segment_rect.w;
x1 = segment_rect.x + segment_rect.z;
y1 = segment_rect.y;
vRefPoint = vec2(x0, y0) + vec2(vRadii.x, -vRadii.y);
break;
case PST_BOTTOM_RIGHT:
x0 = segment_rect.x;
y0 = segment_rect.y;
x1 = segment_rect.x + segment_rect.z;
y1 = segment_rect.y + segment_rect.w;
vRefPoint = vec2(x1, y1) + vec2(-vRadii.x, -vRadii.y);
break;
case PST_TOP:
case PST_LEFT:
case PST_BOTTOM:
case PST_RIGHT:
vRefPoint = segment_rect.xy;
x0 = segment_rect.x;
y0 = segment_rect.y;
x1 = segment_rect.x + segment_rect.z;
y1 = segment_rect.y + segment_rect.w;
break;
}
// y1 - y0 is the height of the corner / line
// x1 - x0 is the width of the corner / line.
float width = x1 - x0;
float height = y1 - y0;
vBorderPart = sub_part;
vPieceRect = vec4(x0, y0, width, height);
// The fragment shader needs to calculate the distance from the bisecting line
// to properly mix border colors. For transformed borders, we calculate this distance
// in the fragment shader itself. For non-transformed borders, we can use the
// interpolator.
#ifdef WR_FEATURE_TRANSFORM
vPieceRectHypotenuseLength = sqrt(pow(width, 2.0) + pow(height, 2.0));
#else
vDistanceFromMixLine = (vi.local_clamped_pos.x - x0) * height -
(vi.local_clamped_pos.y - y0) * width;
#endif
}

View file

@ -1,9 +0,0 @@
/* 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/. */
void main(void) {
vec2 uv = min(vec2(1.0), vMirrorPoint - abs(vUv.xy - vMirrorPoint));
uv = mix(vCacheUvRectCoords.xy, vCacheUvRectCoords.zw, uv);
oFragColor = vColor * texture(sCache, vec3(uv, vUv.z));
}

View file

@ -1,9 +0,0 @@
/* 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 vColor;
varying vec3 vUv;
flat varying vec2 vMirrorPoint;
flat varying vec4 vCacheUvRectCoords;

View file

@ -1,31 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
BoxShadow bs = fetch_boxshadow(prim.prim_index);
vec4 segment_rect = fetch_instance_geometry(prim.sub_index);
VertexInfo vi = write_vertex(segment_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
RenderTaskData child_task = fetch_render_task(prim.user_data.x);
vUv.z = child_task.data1.x;
// Constant offsets to inset from bilinear filtering border.
vec2 patch_origin = child_task.data0.xy + vec2(1.0);
vec2 patch_size_device_pixels = child_task.data0.zw - vec2(2.0);
vec2 patch_size = patch_size_device_pixels / uDevicePixelRatio;
vUv.xy = (vi.local_clamped_pos - prim.local_rect.xy) / patch_size;
vMirrorPoint = 0.5 * prim.local_rect.zw / patch_size;
vec2 texture_size = vec2(textureSize(sCache, 0));
vCacheUvRectCoords = vec4(patch_origin, patch_origin + patch_size_device_pixels) / texture_size.xyxy;
vColor = bs.color;
}

View file

@ -1,7 +0,0 @@
/* 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/. */
void main(void) {
oFragColor = texture(sCache, vUv);
}

View file

@ -1,5 +0,0 @@
/* 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/. */
varying vec3 vUv;

View file

@ -1,27 +0,0 @@
#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/. */
// Draw a cached primitive (e.g. a blurred text run) from the
// target cache to the framebuffer, applying tile clip boundaries.
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
VertexInfo vi = write_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
RenderTaskData child_task = fetch_render_task(prim.user_data.x);
vUv.z = child_task.data1.x;
vec2 texture_size = vec2(textureSize(sCache, 0));
vec2 uv0 = child_task.data0.xy / texture_size;
vec2 uv1 = (child_task.data0.xy + child_task.data0.zw) / texture_size;
vec2 f = (vi.local_clamped_pos - prim.local_rect.xy) / prim.local_rect.zw;
vUv.xy = mix(uv0, uv1, f);
}

View file

@ -1,7 +0,0 @@
/* 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/. */
void main(void) {
oFragColor = vec4(1, 1, 1, 1);
}

View file

@ -1,3 +0,0 @@
/* 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/. */

View file

@ -1,16 +0,0 @@
#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/. */
layout(std140) uniform Data {
uvec4 data[WR_MAX_UBO_VECTORS];
};
void main() {
vec4 rect = vec4(data[gl_InstanceID]);
vec4 pos = vec4(mix(rect.xy, rect.xy + rect.zw, aPosition.xy), 0, 1);
gl_Position = uTransform * pos;
}

View file

@ -1,216 +0,0 @@
#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/. */
float gauss(float x, float sigma) {
if (sigma == 0.0)
return 1.0;
return (1.0 / sqrt(6.283185307179586 * sigma * sigma)) * exp(-(x * x) / (2.0 * sigma * sigma));
}
vec3 Multiply(vec3 Cb, vec3 Cs) {
return Cb * Cs;
}
vec3 Screen(vec3 Cb, vec3 Cs) {
return Cb + Cs - (Cb * Cs);
}
vec3 HardLight(vec3 Cb, vec3 Cs) {
vec3 m = Multiply(Cb, 2.0 * Cs);
vec3 s = Screen(Cb, 2.0 * Cs - 1.0);
vec3 edge = vec3(0.5, 0.5, 0.5);
return mix(m, s, step(edge, Cs));
}
// TODO: Worth doing with mix/step? Check GLSL output.
float ColorDodge(float Cb, float Cs) {
if (Cb == 0.0)
return 0.0;
else if (Cs == 1.0)
return 1.0;
else
return min(1.0, Cb / (1.0 - Cs));
}
// TODO: Worth doing with mix/step? Check GLSL output.
float ColorBurn(float Cb, float Cs) {
if (Cb == 1.0)
return 1.0;
else if (Cs == 0.0)
return 0.0;
else
return 1.0 - min(1.0, (1.0 - Cb) / Cs);
}
float SoftLight(float Cb, float Cs) {
if (Cs <= 0.5) {
return Cb - (1.0 - 2.0 * Cs) * Cb * (1.0 - Cb);
} else {
float D;
if (Cb <= 0.25)
D = ((16.0 * Cb - 12.0) * Cb + 4.0) * Cb;
else
D = sqrt(Cb);
return Cb + (2.0 * Cs - 1.0) * (D - Cb);
}
}
vec3 Difference(vec3 Cb, vec3 Cs) {
return abs(Cb - Cs);
}
vec3 Exclusion(vec3 Cb, vec3 Cs) {
return Cb + Cs - 2.0 * Cb * Cs;
}
// These functions below are taken from the spec.
// There's probably a much quicker way to implement
// them in GLSL...
float Sat(vec3 c) {
return max(c.r, max(c.g, c.b)) - min(c.r, min(c.g, c.b));
}
float Lum(vec3 c) {
vec3 f = vec3(0.3, 0.59, 0.11);
return dot(c, f);
}
vec3 ClipColor(vec3 C) {
float L = Lum(C);
float n = min(C.r, min(C.g, C.b));
float x = max(C.r, max(C.g, C.b));
if (n < 0.0)
C = L + (((C - L) * L) / (L - n));
if (x > 1.0)
C = L + (((C - L) * (1.0 - L)) / (x - L));
return C;
}
vec3 SetLum(vec3 C, float l) {
float d = l - Lum(C);
return ClipColor(C + d);
}
void SetSatInner(inout float Cmin, inout float Cmid, inout float Cmax, float s) {
if (Cmax > Cmin) {
Cmid = (((Cmid - Cmin) * s) / (Cmax - Cmin));
Cmax = s;
} else {
Cmid = 0.0;
Cmax = 0.0;
}
Cmin = 0.0;
}
vec3 SetSat(vec3 C, float s) {
if (C.r <= C.g) {
if (C.g <= C.b) {
SetSatInner(C.r, C.g, C.b, s);
} else {
if (C.r <= C.b) {
SetSatInner(C.r, C.b, C.g, s);
} else {
SetSatInner(C.b, C.r, C.g, s);
}
}
} else {
if (C.r <= C.b) {
SetSatInner(C.g, C.r, C.b, s);
} else {
if (C.g <= C.b) {
SetSatInner(C.g, C.b, C.r, s);
} else {
SetSatInner(C.b, C.g, C.r, s);
}
}
}
return C;
}
vec3 Hue(vec3 Cb, vec3 Cs) {
return SetLum(SetSat(Cs, Sat(Cb)), Lum(Cb));
}
vec3 Saturation(vec3 Cb, vec3 Cs) {
return SetLum(SetSat(Cb, Sat(Cs)), Lum(Cb));
}
vec3 Color(vec3 Cb, vec3 Cs) {
return SetLum(Cs, Lum(Cb));
}
vec3 Luminosity(vec3 Cb, vec3 Cs) {
return SetLum(Cb, Lum(Cs));
}
void main(void) {
vec4 Cb = texture(sCache, vUv0);
if (vUv1.x < vUv1Rect.x ||
vUv1.x > vUv1Rect.z ||
vUv1.y < vUv1Rect.y ||
vUv1.y > vUv1Rect.w) {
oFragColor = Cb;
return;
}
vec4 Cs = texture(sCache, vUv1);
// Return yellow if none of the branches match (shouldn't happen).
vec4 result = vec4(1.0, 1.0, 0.0, 1.0);
switch (vOp) {
case 2:
result.rgb = Screen(Cb.rgb, Cs.rgb);
break;
case 3:
result.rgb = HardLight(Cs.rgb, Cb.rgb); // Overlay is inverse of Hardlight
break;
case 6:
result.r = ColorDodge(Cb.r, Cs.r);
result.g = ColorDodge(Cb.g, Cs.g);
result.b = ColorDodge(Cb.b, Cs.b);
break;
case 7:
result.r = ColorBurn(Cb.r, Cs.r);
result.g = ColorBurn(Cb.g, Cs.g);
result.b = ColorBurn(Cb.b, Cs.b);
break;
case 8:
result.rgb = HardLight(Cb.rgb, Cs.rgb);
break;
case 9:
result.r = SoftLight(Cb.r, Cs.r);
result.g = SoftLight(Cb.g, Cs.g);
result.b = SoftLight(Cb.b, Cs.b);
break;
case 10:
result.rgb = Difference(Cb.rgb, Cs.rgb);
break;
case 11:
result.rgb = Exclusion(Cb.rgb, Cs.rgb);
break;
case 12:
result.rgb = Hue(Cb.rgb, Cs.rgb);
break;
case 13:
result.rgb = Saturation(Cb.rgb, Cs.rgb);
break;
case 14:
result.rgb = Color(Cb.rgb, Cs.rgb);
break;
case 15:
result.rgb = Luminosity(Cb.rgb, Cs.rgb);
break;
}
oFragColor = result;
}

View file

@ -1,8 +0,0 @@
/* 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/. */
varying vec3 vUv0;
varying vec3 vUv1;
flat varying vec4 vUv1Rect;
flat varying int vOp;

View file

@ -1,33 +0,0 @@
#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/. */
void main(void) {
Composite composite = fetch_composite(gl_InstanceID);
Tile src0 = fetch_tile(composite.src0_src1_target_id_op.x);
Tile src1 = fetch_tile(composite.src0_src1_target_id_op.y);
Tile dest = fetch_tile(composite.src0_src1_target_id_op.z);
vec2 local_pos = mix(dest.screen_origin_task_origin.zw,
dest.screen_origin_task_origin.zw + dest.size_target_index.xy,
aPosition.xy);
vec2 texture_size = vec2(textureSize(sCache, 0));
vec2 st0 = src0.screen_origin_task_origin.zw / texture_size;
vec2 st1 = (src0.screen_origin_task_origin.zw + src0.size_target_index.xy) / texture_size;
vUv0 = vec3(mix(st0, st1, aPosition.xy), src0.size_target_index.z);
st0 = vec2(src1.screen_origin_task_origin.zw) / texture_size;
st1 = vec2(src1.screen_origin_task_origin.zw + src1.size_target_index.xy) / texture_size;
vec2 local_virtual_pos = mix(dest.screen_origin_task_origin.xy,
dest.screen_origin_task_origin.xy + dest.size_target_index.xy,
aPosition.xy);
vec2 f = (local_virtual_pos - src1.screen_origin_task_origin.xy) / src1.size_target_index.xy;
vUv1 = vec3(mix(st0, st1, f), src1.size_target_index.z);
vUv1Rect = vec4(st0, st1);
vOp = composite.src0_src1_target_id_op.w;
gl_Position = uTransform * vec4(local_pos, 0, 1);
}

View file

@ -1,15 +0,0 @@
/* 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/. */
void main(void) {
#ifdef WR_FEATURE_TRANSFORM
float alpha = 0.0;
vec2 local_pos = init_transform_fs(vLocalPos, vLocalRect, alpha);
#else
float alpha = 1.0;
vec2 local_pos = vPos;
#endif
oFragColor = vColor * vec4(1, 1, 1, alpha);
}

View file

@ -1,12 +0,0 @@
/* 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/. */
varying vec4 vColor;
#ifdef WR_FEATURE_TRANSFORM
varying vec3 vLocalPos;
flat varying vec4 vLocalRect;
#else
varying vec2 vPos;
#endif

View file

@ -1,68 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
Gradient gradient = fetch_gradient(prim.prim_index);
GradientStop g0 = fetch_gradient_stop(prim.sub_index + 0);
GradientStop g1 = fetch_gradient_stop(prim.sub_index + 1);
vec4 segment_rect;
switch (int(gradient.kind.x)) {
case GRADIENT_HORIZONTAL:
float x0 = mix(gradient.start_end_point.x,
gradient.start_end_point.z,
g0.offset.x);
float x1 = mix(gradient.start_end_point.x,
gradient.start_end_point.z,
g1.offset.x);
segment_rect.yw = prim.local_rect.yw;
segment_rect.x = x0;
segment_rect.z = x1 - x0;
break;
case GRADIENT_VERTICAL:
float y0 = mix(gradient.start_end_point.y,
gradient.start_end_point.w,
g0.offset.x);
float y1 = mix(gradient.start_end_point.y,
gradient.start_end_point.w,
g1.offset.x);
segment_rect.xz = prim.local_rect.xz;
segment_rect.y = y0;
segment_rect.w = y1 - y0;
break;
}
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(segment_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalRect = vi.clipped_local_rect;
vLocalPos = vi.local_pos;
vec2 f = (vi.local_pos.xy - prim.local_rect.xy) / prim.local_rect.zw;
#else
VertexInfo vi = write_vertex(segment_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vec2 f = (vi.local_clamped_pos - segment_rect.xy) / segment_rect.zw;
vPos = vi.local_clamped_pos;
#endif
switch (int(gradient.kind.x)) {
case GRADIENT_HORIZONTAL:
vColor = mix(g0.color, g1.color, f.x);
break;
case GRADIENT_VERTICAL:
vColor = mix(g0.color, g1.color, f.y);
break;
case GRADIENT_ROTATED:
vColor = vec4(1.0, 0.0, 1.0, 1.0);
break;
}
}

View file

@ -1,16 +0,0 @@
/* 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/. */
void main(void) {
#ifdef WR_FEATURE_TRANSFORM
float alpha = 0.0;
vec2 local_pos = init_transform_fs(vLocalPos, vLocalRect, alpha);
#else
float alpha = 1.0;
vec2 local_pos = vPos;
#endif
alpha = min(alpha, do_clip(local_pos));
oFragColor = vColor * vec4(1, 1, 1, alpha);
}

View file

@ -1,12 +0,0 @@
/* 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/. */
varying vec4 vColor;
#ifdef WR_FEATURE_TRANSFORM
varying vec3 vLocalPos;
flat varying vec4 vLocalRect;
#else
varying vec2 vPos;
#endif

View file

@ -1,71 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
Gradient gradient = fetch_gradient(prim.prim_index);
GradientStop g0 = fetch_gradient_stop(prim.sub_index + 0);
GradientStop g1 = fetch_gradient_stop(prim.sub_index + 1);
vec4 segment_rect;
switch (int(gradient.kind.x)) {
case GRADIENT_HORIZONTAL:
float x0 = mix(gradient.start_end_point.x,
gradient.start_end_point.z,
g0.offset.x);
float x1 = mix(gradient.start_end_point.x,
gradient.start_end_point.z,
g1.offset.x);
segment_rect.yw = prim.local_rect.yw;
segment_rect.x = x0;
segment_rect.z = x1 - x0;
break;
case GRADIENT_VERTICAL:
float y0 = mix(gradient.start_end_point.y,
gradient.start_end_point.w,
g0.offset.x);
float y1 = mix(gradient.start_end_point.y,
gradient.start_end_point.w,
g1.offset.x);
segment_rect.xz = prim.local_rect.xz;
segment_rect.y = y0;
segment_rect.w = y1 - y0;
break;
}
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(segment_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalRect = vi.clipped_local_rect;
vLocalPos = vi.local_pos;
vec2 f = (vi.local_pos.xy - prim.local_rect.xy) / prim.local_rect.zw;
#else
VertexInfo vi = write_vertex(segment_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vec2 f = (vi.local_clamped_pos - segment_rect.xy) / segment_rect.zw;
vPos = vi.local_clamped_pos;
#endif
switch (int(gradient.kind.x)) {
case GRADIENT_HORIZONTAL:
vColor = mix(g0.color, g1.color, f.x);
break;
case GRADIENT_VERTICAL:
vColor = mix(g0.color, g1.color, f.y);
break;
case GRADIENT_ROTATED:
vColor = vec4(1.0, 0.0, 1.0, 1.0);
break;
}
ClipData clip = fetch_clip(prim.clip_index);
write_clip(clip);
}

View file

@ -1,29 +0,0 @@
#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/. */
void main(void) {
#ifdef WR_FEATURE_TRANSFORM
float alpha = 0.0;
vec2 pos = init_transform_fs(vLocalPos, vLocalRect, alpha);
// We clamp the texture coordinate calculation here to the local rectangle boundaries,
// which makes the edge of the texture stretch instead of repeat.
vec2 relative_pos_in_rect =
clamp(pos, vLocalRect.xy, vLocalRect.xy + vLocalRect.zw) - vLocalRect.xy;
#else
float alpha = 1.0;;
vec2 relative_pos_in_rect = vLocalPos;
#endif
// We calculate the particular tile this fragment belongs to, taking into
// account the spacing in between tiles. We only paint if our fragment does
// not fall into that spacing.
vec2 position_in_tile = mod(relative_pos_in_rect, vStretchSize + vTileSpacing);
vec2 st = vTextureOffset + ((position_in_tile / vStretchSize) * vTextureSize);
alpha = alpha * float(all(bvec2(step(position_in_tile, vStretchSize))));
oFragColor = vec4(1, 1, 1, alpha) * texture(sColor0, st);
}

View file

@ -1,16 +0,0 @@
/* 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 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.
#ifdef WR_FEATURE_TRANSFORM
varying vec3 vLocalPos;
flat varying vec4 vLocalRect;
flat varying vec2 vStretchSize;
#else
varying vec2 vLocalPos;
flat varying vec2 vStretchSize;
#endif

View file

@ -1,34 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
Image image = fetch_image(prim.prim_index);
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalRect = vi.clipped_local_rect;
vLocalPos = vi.local_pos;
#else
VertexInfo vi = write_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalPos = vi.local_clamped_pos - vi.local_rect.p0;
#endif
// vUv will contain how many times this image has wrapped around the image size.
vec2 texture_size = vec2(textureSize(sColor0, 0));
vec2 st0 = image.st_rect.xy / texture_size;
vec2 st1 = image.st_rect.zw / texture_size;
vTextureSize = st1 - st0;
vTextureOffset = st0;
vTileSpacing = image.stretch_size_and_tile_spacing.zw;
vStretchSize = image.stretch_size_and_tile_spacing.xy;
}

View file

@ -1,32 +0,0 @@
#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/. */
void main(void) {
#ifdef WR_FEATURE_TRANSFORM
float alpha = 1.f;
vec2 local_pos = init_transform_fs(vLocalPos, vLocalRect, alpha);
// We clamp the texture coordinate calculation here to the local rectangle boundaries,
// which makes the edge of the texture stretch instead of repeat.
vec2 relative_pos_in_rect =
clamp(local_pos, vLocalRect.xy, vLocalRect.xy + vLocalRect.zw) - vLocalRect.xy;
#else
float alpha = 1.f;
vec2 local_pos = vLocalPos;
vec2 relative_pos_in_rect = vLocalPos - vLocalRect.xy;
#endif
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
// not fall into that spacing.
vec2 position_in_tile = mod(relative_pos_in_rect, vStretchSize + vTileSpacing);
vec2 st = vTextureOffset + ((position_in_tile / vStretchSize) * vTextureSize);
alpha = alpha * float(all(bvec2(step(position_in_tile, vStretchSize))));
oFragColor = texture(sColor0, st) * vec4(1, 1, 1, alpha);
}

View file

@ -1,17 +0,0 @@
#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/. */
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 vLocalRect;
#ifdef WR_FEATURE_TRANSFORM
varying vec3 vLocalPos;
#else
varying vec2 vLocalPos;
varying vec2 vUv; // Location within the CSS box to draw.
#endif

View file

@ -1,38 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
Image image = fetch_image(prim.prim_index);
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalRect = vi.clipped_local_rect;
vLocalPos = vi.local_pos;
#else
VertexInfo vi = write_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalRect = prim.local_rect;
vLocalPos = vi.local_clamped_pos;
#endif
ClipData clip = fetch_clip(prim.clip_index);
write_clip(clip);
// vUv will contain how many times this image has wrapped around the image size.
vec2 texture_size = vec2(textureSize(sColor0, 0));
vec2 st0 = image.st_rect.xy / texture_size;
vec2 st1 = image.st_rect.zw / texture_size;
vTextureSize = st1 - st0;
vTextureOffset = st0;
vTileSpacing = image.stretch_size_and_tile_spacing.zw;
vStretchSize = image.stretch_size_and_tile_spacing.xy;
}

View file

@ -1,13 +0,0 @@
/* 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/. */
void main(void) {
#ifdef WR_FEATURE_TRANSFORM
float alpha = 0.0;
init_transform_fs(vLocalPos, vLocalRect, alpha);
oFragColor = vec4(1, 1, 1, alpha) * vColor;
#else
oFragColor = vColor;
#endif
}

View file

@ -1,10 +0,0 @@
/* 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/. */
varying vec4 vColor;
#ifdef WR_FEATURE_TRANSFORM
varying vec3 vLocalPos;
flat varying vec4 vLocalRect;
#endif

View file

@ -1,23 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
Rectangle rect = fetch_rectangle(prim.prim_index);
vColor = rect.color;
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalRect = vi.clipped_local_rect;
vLocalPos = vi.local_pos;
#else
write_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
#endif
}

View file

@ -1,15 +0,0 @@
/* 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/. */
void main(void) {
float alpha = 1.f;
#ifdef WR_FEATURE_TRANSFORM
vec2 local_pos = init_transform_fs(vPos, vLocalRect, alpha);
#else
vec2 local_pos = vPos;
#endif
alpha = min(alpha, do_clip(local_pos));
oFragColor = vColor * vec4(1, 1, 1, alpha);
}

View file

@ -1,14 +0,0 @@
#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/. */
varying vec4 vColor;
#ifdef WR_FEATURE_TRANSFORM
varying vec3 vPos;
flat varying vec4 vLocalRect;
#else
varying vec2 vPos;
#endif

View file

@ -1,27 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
Rectangle rect = fetch_rectangle(prim.prim_index);
vColor = rect.color;
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalRect = vi.clipped_local_rect;
vPos = vi.local_pos;
#else
VertexInfo vi = write_vertex(prim.local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vPos = vi.local_clamped_pos;
#endif
ClipData clip = fetch_clip(prim.clip_index);
write_clip(clip);
}

View file

@ -1,17 +0,0 @@
/* 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/. */
void main(void) {
#ifdef WR_FEATURE_SUBPIXEL_AA
oFragColor = texture(sColor0, vUv);
#else
float a = texture(sColor0, vUv).a;
#ifdef WR_FEATURE_TRANSFORM
float alpha = 0.0;
init_transform_fs(vLocalPos, vLocalRect, alpha);
a *= alpha;
#endif
oFragColor = vec4(vColor.rgb, vColor.a * a);
#endif
}

View file

@ -1,11 +0,0 @@
/* 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 vColor;
varying vec2 vUv;
#ifdef WR_FEATURE_TRANSFORM
varying vec3 vLocalPos;
flat varying vec4 vLocalRect;
#endif

View file

@ -1,34 +0,0 @@
#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/. */
void main(void) {
Primitive prim = load_primitive(gl_InstanceID);
TextRun text = fetch_text_run(prim.prim_index);
Glyph glyph = fetch_glyph(prim.sub_index);
vec4 local_rect = vec4(glyph.offset.xy, (glyph.uv_rect.zw - glyph.uv_rect.xy) / uDevicePixelRatio);
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vLocalRect = vi.clipped_local_rect;
vLocalPos = vi.local_pos;
vec2 f = (vi.local_pos.xy / vi.local_pos.z - local_rect.xy) / local_rect.zw;
#else
VertexInfo vi = write_vertex(local_rect,
prim.local_clip_rect,
prim.layer,
prim.tile);
vec2 f = (vi.local_clamped_pos - vi.local_rect.p0) / (vi.local_rect.p1 - vi.local_rect.p0);
#endif
vec2 texture_size = vec2(textureSize(sColor0, 0));
vec2 st0 = glyph.uv_rect.xy / texture_size;
vec2 st1 = glyph.uv_rect.zw / texture_size;
vColor = text.color;
vUv = mix(st0, st1, f);
}

View file

@ -1,51 +0,0 @@
/* 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/. */
//======================================================================================
// Vertex shader attributes and uniforms
//======================================================================================
#ifdef WR_VERTEX_SHADER
#define varying out
// Uniform inputs
uniform mat4 uTransform; // Orthographic projection
uniform float uDevicePixelRatio;
// Attribute inputs
in vec3 aPosition;
#endif
//======================================================================================
// Fragment shader attributes and uniforms
//======================================================================================
#ifdef WR_FRAGMENT_SHADER
precision highp float;
#define varying in
// Uniform inputs
// Fragment shader outputs
out vec4 oFragColor;
#endif
//======================================================================================
// Shared shader uniforms
//======================================================================================
uniform sampler2D sColor0;
uniform sampler2D sColor1;
uniform sampler2D sColor2;
uniform sampler2D sMask;
//======================================================================================
// Interpolator definitions
//======================================================================================
//======================================================================================
// VS only types and UBOs
//======================================================================================
//======================================================================================
// VS only functions
//======================================================================================

View file

@ -1,64 +0,0 @@
/* 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/. */
//======================================================================================
// Vertex shader attributes and uniforms
//======================================================================================
#ifdef WR_VERTEX_SHADER
in vec4 aColorTexCoordRectTop;
in vec4 aColorRectTL;
// box-shadow
in vec4 aBorderPosition;
in vec4 aBorderRadii;
in float aBlurRadius;
// blur
in vec2 aDestTextureSize;
in vec2 aSourceTextureSize;
#endif
//======================================================================================
// Fragment shader attributes and uniforms
//======================================================================================
#ifdef WR_FRAGMENT_SHADER
uniform vec2 uDirection;
#endif
//======================================================================================
// Interpolator definitions
//======================================================================================
// Hacks to be removed (needed for text etc)
varying vec2 vColorTexCoord;
varying vec4 vColor;
// box_shadow
varying vec2 vPosition;
varying vec4 vBorderPosition;
varying vec4 vBorderRadii;
varying float vBlurRadius;
// blur
varying vec2 vSourceTextureSize;
varying vec2 vDestTextureSize;
//======================================================================================
// VS only types and UBOs
//======================================================================================
//======================================================================================
// VS only functions
//======================================================================================
//======================================================================================
// FS only functions
//======================================================================================
#ifdef WR_FRAGMENT_SHADER
void SetFragColor(vec4 color) {
oFragColor = color;
}
#endif