diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-09-25 22:15:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-25 20:15:47 +0000 |
commit | ac567645a75630830a99d90946e0e96d0a759ead (patch) | |
tree | 881ed64b131df03b06dc9e4db118a5356d745a43 /components/canvas | |
parent | 1daa0b4fc7a45f0020e6677c4e67fd78dd4f3eec (diff) | |
download | servo-ac567645a75630830a99d90946e0e96d0a759ead.tar.gz servo-ac567645a75630830a99d90946e0e96d0a759ead.zip |
fonts: Simplify `FontContext` in two ways that affect the unit test (#33541)
This is done by no longer forwarding compositor-bound messages through
SystemFontService and making `FontContext` non-generic:
- Messages from the `FontContext` to the `Compositor` no longer need to be
forwarded through the `SystemFontService`. Instead send these messages
directly through the script IPC channel to the `Compositor`.
- Instead of adding a mock `SystemFontServiceProxy`, simply implement a
mock `SystemFontService` on the other side of an IPC channel in the
`font_context` unit test. This allows making `FontContext`
non-generic, greatly simplifying the code. The extra complexity moves
into the unit test.
These changes necessitate adding a new kind of `FontIdentifier`,
`FontIdentifier::Mock` due to the fact that local fonts have
platform-specific identifiers. This avoids having to pretend like the
system font service can have web fonts -- which was always a bit of a
hack.
These two changes are combined into one PR because they both require
extensive and similar chages in the font_context unit test which
dependended on the details of both of them.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/canvas')
-rw-r--r-- | components/canvas/canvas_data.rs | 6 | ||||
-rw-r--r-- | components/canvas/canvas_paint_thread.rs | 13 |
2 files changed, 13 insertions, 6 deletions
diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index 33254113e56..4c58b269ca0 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -11,7 +11,7 @@ use euclid::default::{Box2D, Point2D, Rect, Size2D, Transform2D, Vector2D}; use euclid::point2; use fonts::{ ByteIndex, FontBaseline, FontContext, FontGroup, FontMetrics, FontRef, GlyphInfo, GlyphStore, - ShapingFlags, ShapingOptions, SystemFontServiceProxy, LAST_RESORT_GLYPH_ADVANCE, + ShapingFlags, ShapingOptions, LAST_RESORT_GLYPH_ADVANCE, }; use ipc_channel::ipc::{IpcSender, IpcSharedMemory}; use log::{debug, warn}; @@ -434,7 +434,7 @@ pub struct CanvasData<'a> { old_image_key: Option<ImageKey>, /// An old webrender image key that can be deleted when the current epoch ends. very_old_image_key: Option<ImageKey>, - font_context: Arc<FontContext<SystemFontServiceProxy>>, + font_context: Arc<FontContext>, } fn create_backend() -> Box<dyn Backend> { @@ -446,7 +446,7 @@ impl<'a> CanvasData<'a> { size: Size2D<u64>, webrender_api: Box<dyn WebrenderApi>, antialias: AntialiasMode, - font_context: Arc<FontContext<SystemFontServiceProxy>>, + font_context: Arc<FontContext>, ) -> CanvasData<'a> { let backend = create_backend(); let draw_target = backend.create_drawtarget(size); diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index 4f9007c9a52..5fec02a2b7a 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -17,7 +17,7 @@ use ipc_channel::router::ROUTER; use log::warn; use net_traits::ResourceThreads; use webrender_api::ImageKey; -use webrender_traits::ImageUpdate; +use webrender_traits::{ImageUpdate, WebRenderScriptApi}; use crate::canvas_data::*; @@ -37,7 +37,7 @@ pub struct CanvasPaintThread<'a> { canvases: HashMap<CanvasId, CanvasData<'a>>, next_canvas_id: CanvasId, webrender_api: Box<dyn WebrenderApi>, - font_context: Arc<FontContext<SystemFontServiceProxy>>, + font_context: Arc<FontContext>, } impl<'a> CanvasPaintThread<'a> { @@ -46,11 +46,18 @@ impl<'a> CanvasPaintThread<'a> { system_font_service: Arc<SystemFontServiceProxy>, resource_threads: ResourceThreads, ) -> CanvasPaintThread<'a> { + // This is only used for web fonts and currently canvas never uses web fonts. + let webrender_script_api = WebRenderScriptApi::dummy(); + CanvasPaintThread { canvases: HashMap::new(), next_canvas_id: CanvasId(0), webrender_api, - font_context: Arc::new(FontContext::new(system_font_service, resource_threads)), + font_context: Arc::new(FontContext::new( + system_font_service, + webrender_script_api, + resource_threads, + )), } } |