compositor: only UpdateImages that accepts SmallVec and add helpers for single image (#37730)

Before we only offered helper to add single image (no update or delete)
that got special IPC message, now we simplify this by offering all ops
helpers for dealing with single image (that happens most of the time),
that simply uses `update_images` under the hood. We also optimize for
this use case by using `SmallVec<[ImageUpdate; 1]>` to avoid alloc.

Testing: Just refactor, but code is covered by WPT tests

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev 2025-06-26 16:57:15 +02:00 committed by GitHub
parent 3c16db2642
commit 4dded465a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 36 additions and 42 deletions

View file

@ -23,7 +23,7 @@ use canvas_traits::webgl::{
WebGLVersion, WebGLVertexArrayId, YAxisTreatment,
};
use compositing_traits::{
CrossProcessCompositorApi, ImageUpdate, SerializableImageData, WebrenderExternalImageRegistry,
CrossProcessCompositorApi, SerializableImageData, WebrenderExternalImageRegistry,
WebrenderImageHandlerType,
};
use euclid::default::Size2D;
@ -719,8 +719,7 @@ impl WebGLThread {
fn remove_webgl_context(&mut self, context_id: WebGLContextId) {
// Release webrender image keys.
if let Some(info) = self.cached_context_info.remove(&context_id) {
self.compositor_api
.update_images(vec![ImageUpdate::DeleteImage(info.image_key)]);
self.compositor_api.delete_image(info.image_key);
}
// We need to make the context current so its resources can be disposed of.
@ -929,11 +928,7 @@ impl WebGLThread {
let image_data = Self::external_image_data(context_id, image_buffer_kind);
self.compositor_api
.update_images(vec![ImageUpdate::UpdateImage(
info.image_key,
descriptor,
image_data,
)]);
.update_image(info.image_key, descriptor, image_data);
}
/// Helper function to create a `ImageDescriptor`.