mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
webgpu: implement get image for webgpu canvas (#35237)
* Implement `get_image_data` for WebGPU canvas Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Update expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Add docs 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:
parent
42b581a6f6
commit
35835af857
6 changed files with 50 additions and 40 deletions
|
@ -420,10 +420,7 @@ impl HTMLCanvasElement {
|
|||
return None;
|
||||
},
|
||||
#[cfg(feature = "webgpu")]
|
||||
Some(&CanvasContext::WebGPU(_)) => {
|
||||
// TODO: add a method in GPUCanvasContext to get the pixels.
|
||||
return None;
|
||||
},
|
||||
Some(CanvasContext::WebGPU(context)) => Some(context.get_ipc_image()),
|
||||
Some(CanvasContext::Placeholder(context)) => {
|
||||
let (sender, receiver) =
|
||||
ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||
|
@ -450,9 +447,8 @@ impl HTMLCanvasElement {
|
|||
Some(CanvasContext::WebGL2(ref context)) => {
|
||||
context.base_context().get_image_data(self.get_size())
|
||||
},
|
||||
//TODO: Add method get_image_data to GPUCanvasContext
|
||||
#[cfg(feature = "webgpu")]
|
||||
Some(CanvasContext::WebGPU(_)) => None,
|
||||
Some(CanvasContext::WebGPU(ref context)) => Some(context.get_image_data()),
|
||||
Some(CanvasContext::Placeholder(_)) | None => {
|
||||
// Each pixel is fully-transparent black.
|
||||
Some(vec![0; (self.Width() * self.Height() * 4) as usize])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue