Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a glyph cache thread. #565

Merged
merged 1 commit into from Nov 28, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Introduce a glyph cache thread.

This is the first step towards making the glyph cache more efficient
and also run asynchronously to allow rendering to continue if the
glyph rasterizing becomes a bottleneck (e.g. during animated zooms).

Previously, we collected the list of glyphs that were required for
a frame, and ran a rayon loop to rasterize any that weren't in the
glyph cache. However, this meant that the glyph rasterizion could
not start until we knew the list of all required glyphs.

Now, all requests for text run glyphs are sent immediately to the
glyph cache thread. The glyph cache thread uses a worker thread
pool to immediately begin rasterizing any uncached glyphs as soon
as they are requested.

In the future, the idea is that instead of waiting at the block()
method for all pending glyphs to be rasterized, the backend thread
will instead receive small numbers of glyphs as they are rasterized.
This will allow the backend thread to make a decision that glyph
rasterizing is taking too long for this frame, and that we should
just draw a frame with the currently cached glyph sizes available.
When this occurs, the glyph cache thread will signal that a new frame
should be rendered when it completes rasterizing any pending glyphs.
This will allow us to keep rendering at 60fps during zoom, even
if the glyph rasterizing threads can't keep up (at a quality
tradeoff of using lower resolution glyphs).
  • Loading branch information
gw3583 committed Nov 28, 2016
commit f1c81fe270b52fa0f0a562c6e83c568f3b653297

Some generated files are not rendered by default. Learn more.

@@ -25,8 +25,8 @@ lazy_static = "0.2"
log = "0.3"
num-traits = "0.1.32"
offscreen_gl_context = {version = "0.5", features = ["serde_serialization", "osmesa"]}
rayon = "0.5"
time = "0.1"
threadpool = "1.3.2"
webrender_traits = {path = "../webrender_traits", default-features = false}
bitflags = "0.7"

@@ -169,7 +169,7 @@ pub const ANGLE_FLOAT_TO_FIXED: f32 = 65535.0;
pub const ORTHO_NEAR_PLANE: f32 = -1000000.0;
pub const ORTHO_FAR_PLANE: f32 = 1000000.0;


#[derive(Clone)]
pub enum FontTemplate {
Raw(Arc<Vec<u8>>),
Native(NativeFontHandle),
@@ -122,7 +122,7 @@ extern crate time;
extern crate webrender_traits;
extern crate offscreen_gl_context;
extern crate byteorder;
extern crate rayon;
extern crate threadpool;

pub use renderer::{ExternalImage, ExternalImageSource, ExternalImageHandler};
pub use renderer::{Renderer, RendererOptions};
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.