webgpu: Factor out swapchain to separate file (#33367)

* Move some stuff to swapchain.rs

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Use typed WebGPUContextId instead of u64

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Extract create_swapchain function and move more stuff in it

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* extract destroy_swapchain

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* extract swapchain_present

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* extract update_wr_image callback

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* fixup

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-09-09 15:29:04 +02:00 committed by GitHub
parent 938fd8c12f
commit 687f356db9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 403 additions and 328 deletions

View file

@ -153,6 +153,7 @@ use servo_rand::{random, Rng, ServoRng, SliceRandom};
use servo_url::{Host, ImmutableOrigin, ServoUrl};
use style_traits::CSSPixel;
use tracing::{span, Level};
use webgpu::swapchain::WGPUImageMap;
use webgpu::{self, WebGPU, WebGPURequest, WebGPUResponse};
use webrender::{RenderApi, RenderApiSender};
use webrender_api::DocumentId;
@ -219,7 +220,7 @@ struct WebrenderWGPU {
webrender_external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
/// WebGPU data that supplied to Webrender for rendering
wgpu_image_map: Arc<Mutex<HashMap<u64, webgpu::PresentationData>>>,
wgpu_image_map: WGPUImageMap,
}
/// Servo supports multiple top-level browsing contexts or “webviews”, so `Constellation` needs to
@ -552,7 +553,7 @@ pub struct InitialConstellationState {
/// User agent string to report in network requests.
pub user_agent: Cow<'static, str>,
pub wgpu_image_map: Arc<Mutex<HashMap<u64, webgpu::PresentationData>>>,
pub wgpu_image_map: WGPUImageMap,
}
/// Data needed for webdriver