Skip to content

Commit e7a66c5

Browse files
author
bors-servo
authored
Auto merge of #523 - glennw:resource-list-2, r=pcwalton
Remove ResourceList structure and usage. Previously, a resource list would be built at the start of the frame. This would allow glyphs missing from the texture cache to be rasterized. However, sometimes (e.g. with subpixel antialiasing) it's not possible to know right at the start of the frame exactly what needs to be rasterized yet. Instead, we now allow the resource cache to add requests during the prepare_prim_for_render() stage. Primitives that request resources are marked as needing a resolve operation. This allows primitives that request resources to update their UV coords etc before batching occurs (since texture IDs for resources must be known before batching can occur). This also lays most of the groundwork for running the resource cache rasterizer as a separate thread in the future. This will be used to ensure that if too many glyphs are requested in one frame, WR can continue running without blocking, using older glyphs and then re-render the scene when newer, high resolution glyphs are available. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/523) <!-- Reviewable:end -->
2 parents 25f657f + 17a3629 commit e7a66c5

File tree

12 files changed

+561
-533
lines changed

12 files changed

+561
-533
lines changed

webrender/res/clip_shared.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ void write_clip(ClipInfo clip) {
1616
clip.bottom_right.outer_inner_radius.x,
1717
clip.bottom_left.outer_inner_radius.x);
1818
//TODO: interpolate the final mask UV
19-
vClipMaskUvRect = clip.mask_info.uv_rect;
19+
vec2 texture_size = textureSize(sMask, 0);
20+
vClipMaskUvRect = clip.mask_info.uv_rect / texture_size.xyxy;
2021
vClipMaskLocalRect = clip.mask_info.local_rect; //TODO: transform
2122
}
2223
#endif

webrender/res/prim_shared.glsl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,6 @@ struct Image {
594594
vec4 st_rect; // Location of the image texture in the texture atlas.
595595
vec4 stretch_size_and_tile_spacing; // Size of the actual image and amount of space between
596596
// tiled instances of this image.
597-
bool has_pixel_coords;
598597
};
599598

600599
Image fetch_image(int index) {
@@ -605,9 +604,6 @@ Image fetch_image(int index) {
605604
image.st_rect = texelFetchOffset(sData32, uv, 0, ivec2(0, 0));
606605
image.stretch_size_and_tile_spacing = texelFetchOffset(sData32, uv, 0, ivec2(1, 0));
607606

608-
image.has_pixel_coords = image.st_rect.z < 0.0;
609-
image.st_rect.z = abs(image.st_rect.z);
610-
611607
return image;
612608
}
613609

webrender/res/ps_image.vs.glsl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,9 @@ void main(void) {
2323
#endif
2424

2525
// vUv will contain how many times this image has wrapped around the image size.
26-
vec2 st0 = image.st_rect.xy;
27-
vec2 st1 = image.st_rect.zw;
28-
29-
if (image.has_pixel_coords) {
30-
vec2 texture_size = vec2(textureSize(sDiffuse, 0));
31-
st0 /= texture_size;
32-
st1 /= texture_size;
33-
}
26+
vec2 texture_size = vec2(textureSize(sDiffuse, 0));
27+
vec2 st0 = image.st_rect.xy / texture_size;
28+
vec2 st1 = image.st_rect.zw / texture_size;
3429

3530
vTextureSize = st1 - st0;
3631
vTextureOffset = st0;

webrender/res/shared.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#define varying in
2626

2727
// Uniform inputs
28-
uniform sampler2D sMask;
2928

3029
// Fragment shader outputs
3130
out vec4 oFragColor;
@@ -35,6 +34,7 @@
3534
// Shared shader uniforms
3635
//======================================================================================
3736
uniform sampler2D sDiffuse;
37+
uniform sampler2D sMask;
3838

3939
//======================================================================================
4040
// Interpolator definitions

webrender/src/internal_types.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -475,24 +475,6 @@ pub struct PolygonPosColorUv {
475475
pub vertices: Vec<WorkVertex>,
476476
}
477477

478-
#[derive(PartialEq, Eq, Hash)]
479-
pub struct Glyph {
480-
pub size: Au,
481-
pub blur_radius: Au,
482-
pub index: u32,
483-
}
484-
485-
impl Glyph {
486-
#[inline]
487-
pub fn new(size: Au, blur_radius: Au, index: u32) -> Glyph {
488-
Glyph {
489-
size: size,
490-
blur_radius: blur_radius,
491-
index: index,
492-
}
493-
}
494-
}
495-
496478
#[derive(Debug, Clone)]
497479
#[repr(C)]
498480
pub struct PackedVertexForTextureCacheUpdate {

webrender/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ mod profiler;
6363
mod record;
6464
mod render_backend;
6565
mod resource_cache;
66-
mod resource_list;
6766
mod scene;
6867
mod spring;
6968
mod texture_cache;

webrender/src/platform/macos/font.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,18 @@ impl FontContext {
121121
size: Au,
122122
character: u32,
123123
device_pixel_ratio: f32) -> Option<GlyphDimensions> {
124-
self.get_ct_font(font_key, size, device_pixel_ratio).map(|ref ct_font| {
124+
self.get_ct_font(font_key, size, device_pixel_ratio).and_then(|ref ct_font| {
125125
let glyph = character as CGGlyph;
126126
let metrics = get_glyph_metrics(ct_font, glyph);
127-
GlyphDimensions {
128-
left: metrics.rasterized_left,
129-
top: metrics.rasterized_ascent,
130-
width: metrics.rasterized_width as u32,
131-
height: metrics.rasterized_height as u32,
127+
if metrics.rasterized_width == 0 || metrics.rasterized_height == 0 {
128+
None
129+
} else {
130+
Some(GlyphDimensions {
131+
left: metrics.rasterized_left,
132+
top: metrics.rasterized_ascent,
133+
width: metrics.rasterized_width as u32,
134+
height: metrics.rasterized_height as u32,
135+
})
132136
}
133137
})
134138
}

webrender/src/platform/unix/font.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,17 @@ impl FontContext {
115115
size: Au,
116116
character: u32,
117117
device_pixel_ratio: f32) -> Option<GlyphDimensions> {
118-
self.load_glyph(font_key, size, character, device_pixel_ratio).map(|slot| {
118+
self.load_glyph(font_key, size, character, device_pixel_ratio).and_then(|slot| {
119119
let metrics = unsafe { &(*slot).metrics };
120-
GlyphDimensions {
121-
left: (metrics.horiBearingX >> 6) as i32,
122-
top: (metrics.horiBearingY >> 6) as i32,
123-
width: (metrics.width >> 6) as u32,
124-
height: (metrics.height >> 6) as u32,
120+
if metrics.width == 0 || metrics.height == 0 {
121+
None
122+
} else {
123+
Some(GlyphDimensions {
124+
left: (metrics.horiBearingX >> 6) as i32,
125+
top: (metrics.horiBearingY >> 6) as i32,
126+
width: (metrics.width >> 6) as u32,
127+
height: (metrics.height >> 6) as u32,
128+
})
125129
}
126130
})
127131
}

0 commit comments

Comments
 (0)