Update webrender to master, including shaders.

This updates webrender to include the webgl related changes
needed for this patch. There was an additional commit in
webrender before these landed, so also copy the shaders
for that change across. There is an interface change to
webrender push_image. For now, just pass zero, which is a
no-op to this function. A follow up commit will introduce
the servo specific changes to use this new interface.
This commit is contained in:
Glenn Watson 2016-09-21 08:24:59 +10:00
parent 87c9333abd
commit 6b1104e7f6
10 changed files with 61 additions and 39 deletions

View file

@ -427,9 +427,12 @@ impl WebRenderDisplayItemConverter for DisplayItem {
if let Some(id) = item.webrender_image.key {
if item.stretch_size.width > Au(0) &&
item.stretch_size.height > Au(0) {
// TODO(gw): Pass through the tile spacing once the other
// changes related to this land (parsing etc).
builder.push_image(item.base.bounds.to_rectf(),
item.base.clip.to_clip_region(frame_builder),
item.stretch_size.to_sizef(),
Size2D::zero(),
item.image_rendering.to_image_rendering(),
id);
}

View file

@ -2643,7 +2643,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.5.1"
source = "git+https://github.com/servo/webrender#61b8f8bfefd472bd71dd9a06c1d16dab28c1fcc0"
source = "git+https://github.com/servo/webrender#58b9e983a5e74ac1670fcf67f9c2ba68740ab2cc"
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)",
@ -2668,7 +2668,7 @@ dependencies = [
[[package]]
name = "webrender_traits"
version = "0.5.1"
source = "git+https://github.com/servo/webrender#61b8f8bfefd472bd71dd9a06c1d16dab28c1fcc0"
source = "git+https://github.com/servo/webrender#58b9e983a5e74ac1670fcf67f9c2ba68740ab2cc"
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)",

4
ports/cef/Cargo.lock generated
View file

@ -2503,7 +2503,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.5.1"
source = "git+https://github.com/servo/webrender#61b8f8bfefd472bd71dd9a06c1d16dab28c1fcc0"
source = "git+https://github.com/servo/webrender#58b9e983a5e74ac1670fcf67f9c2ba68740ab2cc"
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)",
@ -2528,7 +2528,7 @@ dependencies = [
[[package]]
name = "webrender_traits"
version = "0.5.1"
source = "git+https://github.com/servo/webrender#61b8f8bfefd472bd71dd9a06c1d16dab28c1fcc0"
source = "git+https://github.com/servo/webrender#58b9e983a5e74ac1670fcf67f9c2ba68740ab2cc"
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)",

View file

@ -375,38 +375,44 @@ PrimitiveInfo fetch_text_run_glyph(int index, out vec4 color, out vec4 uv_rect)
struct Image {
PrimitiveInfo info;
vec4 st_rect; // Location of the image texture in the texture atlas.
vec4 stretch_size_uvkind; // Size of the actual 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.
vec4 uvkind; // Type of texture coordinates.
};
Image fetch_image(int index) {
Image image;
int offset = index * 5;
int offset = index * 6;
image.info = unpack_prim_info(offset);
image.st_rect = data[offset + 3];
image.stretch_size_uvkind = data[offset + 4];
image.stretch_size_and_tile_spacing = data[offset + 4];
image.uvkind = data[offset + 5];
return image;
}
struct ImageClip {
PrimitiveInfo info;
vec4 st_rect; // Location of the image texture in the texture atlas.
vec4 stretch_size_uvkind; // Size of the actual 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.
vec4 uvkind; // Type of texture coordinates.
Clip clip;
};
ImageClip fetch_image_clip(int index) {
ImageClip image;
int offset = index * 14;
int offset = index * 15;
image.info = unpack_prim_info(offset);
image.st_rect = data[offset + 3];
image.stretch_size_uvkind = data[offset + 4];
image.clip = unpack_clip(offset + 5);
image.stretch_size_and_tile_spacing = data[offset + 4];
image.uvkind = data[offset + 5];
image.clip = unpack_clip(offset + 6);
return image;
}

View file

@ -11,16 +11,19 @@ void main(void) {
// We clamp the texture coordinate calculation here to the local rectangle boundaries,
// which makes the edge of the texture stretch instead of repeat.
vec2 uv = clamp(pos, vLocalRect.xy, vLocalRect.xy + vLocalRect.zw);
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))));
uv = (uv - vLocalRect.xy) / vStretchSize;
#else
vec2 uv = vUv;
#endif
vec2 st = vTextureOffset + vTextureSize * fract(uv);
#ifdef WR_FEATURE_TRANSFORM
oFragColor = vec4(1, 1, 1, alpha) * texture(sDiffuse, st);
#else
oFragColor = texture(sDiffuse, st);
#endif
}

View file

@ -4,11 +4,13 @@
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 vUv; // Location within the CSS box to draw.
varying vec2 vLocalPos;
flat varying vec2 vStretchSize;
#endif

View file

@ -10,17 +10,18 @@ void main(void) {
TransformVertexInfo vi = write_transform_vertex(image.info);
vLocalRect = vi.clipped_local_rect;
vLocalPos = vi.local_pos;
vStretchSize = image.stretch_size_uvkind.xy;
vStretchSize = image.stretch_size_and_tile_spacing.xy;
#else
VertexInfo vi = write_vertex(image.info);
vUv = (vi.local_clamped_pos - vi.local_rect.p0) / image.stretch_size_uvkind.xy;
vStretchSize = image.stretch_size_and_tile_spacing.xy;
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 st0 = image.st_rect.xy;
vec2 st1 = image.st_rect.zw;
switch (uint(image.stretch_size_uvkind.z)) {
switch (uint(image.uvkind.x)) {
case UV_NORMALIZED:
break;
case UV_PIXEL: {
@ -33,4 +34,5 @@ void main(void) {
vTextureSize = st1 - st0;
vTextureOffset = st0;
vTileSpacing = image.stretch_size_and_tile_spacing.zw;
}

View file

@ -11,17 +11,22 @@ void main(void) {
// We clamp the texture coordinate calculation here to the local rectangle boundaries,
// which makes the edge of the texture stretch instead of repeat.
vec2 uv = clamp(local_pos.xy, vLocalRect.xy, vLocalRect.xy + vLocalRect.zw);
uv = (uv - vLocalRect.xy) / vStretchSize;
vec2 pos_for_texture =
clamp(pos, vLocalRect.xy, vLocalRect.xy + vLocalRect.zw) - vLocalRect.xy;
#else
float alpha = 1;
vec2 local_pos = vLocalPos;
vec2 uv = vUv;
vec2 relative_pos_in_rect = vLocalPos - vLocalRect.xy;
#endif
vec2 st = vTextureOffset + vTextureSize * fract(uv);
alpha = min(alpha, do_clip(local_pos, vClipRect, vClipRadius));
// 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(sDiffuse, st) * vec4(1, 1, 1, alpha);
}

View file

@ -4,13 +4,14 @@
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 vClipRect;
flat varying vec4 vClipRadius;
flat varying vec4 vLocalRect;
#ifdef WR_FEATURE_TRANSFORM
varying vec3 vLocalPos;
flat varying vec4 vLocalRect;
flat varying vec2 vStretchSize;
#else
varying vec2 vLocalPos;
varying vec2 vUv; // Location within the CSS box to draw.

View file

@ -8,13 +8,11 @@ void main(void) {
#ifdef WR_FEATURE_TRANSFORM
TransformVertexInfo vi = write_transform_vertex(image.info);
vLocalRect = vi.clipped_local_rect;
vLocalPos = vi.local_pos;
vStretchSize = image.stretch_size_uvkind.xy;
#else
VertexInfo vi = write_vertex(image.info);
vUv = (vi.local_clamped_pos - vi.local_rect.p0) / image.stretch_size_uvkind.xy;
vLocalPos = vi.local_clamped_pos;
vLocalRect = image.info.local_rect;
#endif
vClipRect = vec4(image.clip.rect.xy, image.clip.rect.xy + image.clip.rect.zw);
@ -26,7 +24,7 @@ void main(void) {
vec2 st0 = image.st_rect.xy;
vec2 st1 = image.st_rect.zw;
switch (uint(image.stretch_size_uvkind.z)) {
switch (uint(image.uvkind.x)) {
case UV_NORMALIZED:
break;
case UV_PIXEL: {
@ -39,4 +37,6 @@ void main(void) {
vTextureSize = st1 - st0;
vTextureOffset = st0;
vStretchSize = image.stretch_size_and_tile_spacing.xy;
vTileSpacing = image.stretch_size_and_tile_spacing.zw;
}