Add a basic caching mechanism for ImageKeys. (#37369)

This creates a new method in shared/compositing/lib to generate image
keys that are send over the webview. This does not immediately return
the keys but goes over the constellation to receive the keys from the
IOCompositor. To make this more efficient, we now cache the keys in
image_cache in a simple FIFO order. The old blocking method stays intact
for now but got renamed to make the blocking clear.
The blocking calls that are left are in:
- `components/canvas/canvas_data.rs`
- `components/script/dom/htmlmediaelement.rs`

Testing: WPT tests should cover this as this doesn't change any
functionality.
Fixes: Was mentioned in
https://github.com/servo/servo/issues/37161#issuecomment-2915750051 and
part of https://github.com/servo/servo/issues/37086

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
Co-authored-by: gterzian <2792687+gterzian@users.noreply.github.com>
This commit is contained in:
Narfinger 2025-07-03 22:16:43 +09:00 committed by GitHub
parent 89bfa26f00
commit ca47cc2fa3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 392 additions and 70 deletions

View file

@ -149,6 +149,8 @@ pub struct Preferences {
/// Whether or not subpixel antialiasing is enabled for text rendering.
pub gfx_subpixel_text_antialiasing_enabled: bool,
pub gfx_texture_swizzling_enabled: bool,
/// The amount of image keys we request per batch for the image cache.
pub image_key_batch_size: i64,
/// Whether or not the DOM inspector should show shadow roots of user-agent shadow trees
pub inspector_show_servo_internal_shadow_roots: bool,
pub js_asmjs_enabled: bool,
@ -326,6 +328,7 @@ impl Preferences {
gfx_text_antialiasing_enabled: true,
gfx_subpixel_text_antialiasing_enabled: true,
gfx_texture_swizzling_enabled: true,
image_key_batch_size: 10,
inspector_show_servo_internal_shadow_roots: false,
js_asmjs_enabled: true,
js_asyncstack: false,