compositor: Move WebRender-ish messages and types to webrender_traits (#32315)

* Move WebRender related types to `webrender_traits`

This refactor moves several WebRender related types
from `compositing_traits`, `script_traits` and `net_traits`
crates to the `webrender_traits` crate.

This change also moves the `Image` type and associated
function out of `net_traits` and into the `pixels` crate.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

* Move `script_traits::WebrenderIpcSender` to `webrender_traits::WebRenderScriptApi`

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Mukilan Thiyagarajan 2024-05-20 16:05:18 +05:30 committed by GitHub
parent c2076580f3
commit 2af6fe0b30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 666 additions and 617 deletions

View file

@ -26,8 +26,9 @@ use style::values::computed::font;
use style_traits::values::ToCss;
use webrender_api::units::{DeviceIntSize, RectExt as RectExt_};
use webrender_api::{ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey};
use webrender_traits::ImageUpdate;
use crate::canvas_paint_thread::{AntialiasMode, ImageUpdate, WebrenderApi};
use crate::canvas_paint_thread::{AntialiasMode, WebrenderApi};
use crate::raqote_backend::Repetition;
/// The canvas data stores a state machine for the current status of
@ -1082,13 +1083,13 @@ impl<'a> CanvasData<'a> {
match self.image_key {
Some(image_key) => {
debug!("Updating image {:?}.", image_key);
updates.push(ImageUpdate::Update(image_key, descriptor, data));
updates.push(ImageUpdate::UpdateImage(image_key, descriptor, data));
},
None => {
let Some(key) = self.webrender_api.generate_key() else {
return;
};
updates.push(ImageUpdate::Add(key, descriptor, data));
updates.push(ImageUpdate::AddImage(key, descriptor, data));
self.image_key = Some(key);
debug!("New image {:?}.", self.image_key);
},
@ -1097,7 +1098,7 @@ impl<'a> CanvasData<'a> {
if let Some(image_key) =
mem::replace(&mut self.very_old_image_key, self.old_image_key.take())
{
updates.push(ImageUpdate::Delete(image_key));
updates.push(ImageUpdate::DeleteImage(image_key));
}
self.webrender_api.update_images(updates);
@ -1215,10 +1216,10 @@ impl<'a> Drop for CanvasData<'a> {
fn drop(&mut self) {
let mut updates = vec![];
if let Some(image_key) = self.old_image_key.take() {
updates.push(ImageUpdate::Delete(image_key));
updates.push(ImageUpdate::DeleteImage(image_key));
}
if let Some(image_key) = self.very_old_image_key.take() {
updates.push(ImageUpdate::Delete(image_key));
updates.push(ImageUpdate::DeleteImage(image_key));
}
self.webrender_api.update_images(updates);