Skip to content

Commit

Permalink
Fix for some new intermittent ref test failures.
Browse files Browse the repository at this point in the history
This ensures that text run glyphs are added to the texture cache
in the same order between runs, to remove a source of floating
point accuracy issues in the rasterizer.
  • Loading branch information
gw3583 committed Dec 12, 2016
1 parent 56255e6 commit ca1533a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 9 additions & 1 deletion webrender/src/resource_cache.rs
Expand Up @@ -61,7 +61,7 @@ pub struct CacheItem {
pub uv1: DevicePoint,
}

#[derive(Clone, Hash, PartialEq, Eq, Debug)]
#[derive(Clone, Hash, PartialEq, Eq, Debug, Ord, PartialOrd)]
pub struct RenderedGlyphKey {
pub key: GlyphKey,
pub render_mode: FontRenderMode,
Expand Down Expand Up @@ -737,6 +737,14 @@ fn spawn_glyph_cache_thread() -> (Sender<GlyphCacheMsg>, Receiver<GlyphCacheResu
result: glyph,
});
}
// Ensure that the glyphs are always processed in the same
// order for a given text run (since iterating a hash set doesn't
// guarantee order). This can show up as very small float inaccuacry
// differences in rasterizers due to the different coordinates
// that text runs get associated with by the texture cache allocator.
rasterized_glyphs.sort_by(|a, b| {
a.key.cmp(&b.key)
});
result_tx.send(GlyphCacheResultMsg::EndFrame(cache, rasterized_glyphs)).unwrap();
}
}
Expand Down
6 changes: 3 additions & 3 deletions webrender_traits/src/types.rs
Expand Up @@ -224,17 +224,17 @@ pub enum FilterOp {
Sepia(f32),
}

#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize, Ord, PartialOrd)]
pub struct FontKey(u32, u32);

#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Ord, PartialOrd)]
pub enum FontRenderMode {
Mono,
Alpha,
Subpixel,
}

#[derive(Clone, Hash, PartialEq, Eq, Debug, Deserialize, Serialize)]
#[derive(Clone, Hash, PartialEq, Eq, Debug, Deserialize, Serialize, Ord, PartialOrd)]
pub struct GlyphKey {
pub font_key: FontKey,
// The font size is in *device* pixels, not logical pixels.
Expand Down

0 comments on commit ca1533a

Please sign in to comment.