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.
The Scene::set_transform method was only introduced because of an old
rustc bug around mutating properties across crates. Now that the rustc
bug is fixed, we can stop calling this method.
but don't do much on their own, they just make it easier to
implement the work to come (web fonts, performance improvments
in terms of font loading and memory usage).
- Font identifier on Linux/Android is now the font file path.
This is a temporary measure, but simplifies things a lot for now.
- Remove FontListHandleMethods trait in favour of free functions.
- FontList::refresh() has no knowledge of FontFamily etc. Instead it takes
a closure that the caller provides.
- FontList::load_variations_for_family no longer creates the font
handle. Instead it takes a closure and provides the name of the font
identifier for the variations it finds.
- Remove path_from_identifier() - it's no longer required.
- create_font_from_identifier() takes an Option<Style>, allowing it to be
used to create fonts for family matching purposes where the font size is
not important.
Tested on Linux + Mac. Builds on Android but not able to confirm it's working correctly.
Instead of having two parallel trees of CompositorLayers and
ContainerLayers, transform CompositorLayer to CompositorData and move
tiling logic to rust-layers.
When Skia is running on a green task, it can sometimes be
rescheduled onto a different OS thread. This creates problems with
the memory pool implementation in Skia, which uses TLS for
storing the per thread memory pool information. Free'ing a
pool allocation from a different OS thread than it was
allocated on can cause heap corruption.
FIXME: When we update rustc, switch the task failure
message to using the new NativeTaskBuilder interface so that
it can use the same send_on_failure function as green tasks.