aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/gfx/render_task.rs
diff options
context:
space:
mode:
authorGlenn Watson <gw@intuitionlibrary.com>2014-07-04 07:53:25 +1000
committerGlenn Watson <gw@intuitionlibrary.com>2014-07-07 14:25:21 +1000
commit12978eeb50d8f727bc020bcdd0534e80d7890c7f (patch)
treeb33c8659a0faf66765fef9cc016ac766a44007f5 /src/components/gfx/render_task.rs
parente62637fee2f1c9627468dde81a68df1dd40b6bc9 (diff)
downloadservo-12978eeb50d8f727bc020bcdd0534e80d7890c7f.tar.gz
servo-12978eeb50d8f727bc020bcdd0534e80d7890c7f.zip
Next stage of refactoring font system. This commit introduces
the font cache task, and adapts client code to use it. It also cleans up some existing code paths. - Fonts are only read once from disk while in use (they are discarded if the reference count reaches zero, however). This saves memory and prevents unnecessary reading from disk. - It will be easier to add web font support, as all fonts are created and managed in a single place and the entire pipeline ensures that only one in-memory copy of font data is required. An overview of how the pieces fit together: FontTemplate - A structure containing everything that is required to create (and select) font handles. This structure is shared among all matching font handles (via Arc). FontTemplateData - A platform specific structure that contains the actual font data inside a template (this is a byte array on Linux/Android, CTFont on Mac). FontHandle - An opaque, platform specific handle to a font instance. Each FontHandle contains an Arc<> reference to the FontTemplate it was created from. FontCache - This is a separate task, that is responsible for loading and caching FontTemplate structures. There is one FontCache per constellation. It is only ever accessed via the FontContext described below. FontContext - This is the public interface to the FontCache and is used by the layout and render code to create font handles. These must *not* be shared between threads. There is typically one FontContext per thread/task.
Diffstat (limited to 'src/components/gfx/render_task.rs')
-rw-r--r--src/components/gfx/render_task.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/components/gfx/render_task.rs b/src/components/gfx/render_task.rs
index 8048db3b70d..d6c31bce048 100644
--- a/src/components/gfx/render_task.rs
+++ b/src/components/gfx/render_task.rs
@@ -7,7 +7,7 @@
use buffer_map::BufferMap;
use display_list::optimizer::DisplayListOptimizer;
use display_list::DisplayList;
-use font_context::{FontContext, FontContextInfo};
+use font_context::FontContext;
use render_context::RenderContext;
use azure::azure_hl::{B8G8R8A8, Color, DrawTarget, StolenGLResources};
@@ -34,6 +34,7 @@ use servo_util::time::{TimeProfilerChan, profile};
use servo_util::time;
use std::comm::{Receiver, Sender, channel};
use sync::Arc;
+use font_cache_task::FontCacheTask;
/// Information about a layer that layout sends to the painting task.
pub struct RenderLayer {
@@ -144,12 +145,15 @@ impl<C:RenderListener + Send> RenderTask<C> {
port: Receiver<Msg>,
compositor: C,
constellation_chan: ConstellationChan,
+ font_cache_task: FontCacheTask,
failure_msg: Failure,
opts: Opts,
time_profiler_chan: TimeProfilerChan,
shutdown_chan: Sender<()>) {
let ConstellationChan(c) = constellation_chan.clone();
+ let fc = font_cache_task.clone();
+
let mut task_opts = TaskOpts::new();
task_opts.name = Some("RenderTask".into_maybe_owned());
task_opts.on_exit = Some(proc(result: task::Result) {
@@ -172,11 +176,7 @@ impl<C:RenderListener + Send> RenderTask<C> {
port: port,
compositor: compositor,
constellation_chan: constellation_chan,
- font_ctx: box FontContext::new(FontContextInfo {
- backend: opts.render_backend.clone(),
- needs_font_list: false,
- time_profiler_chan: time_profiler_chan.clone(),
- }),
+ font_ctx: box FontContext::new(fc.clone()),
opts: opts,
time_profiler_chan: time_profiler_chan,