mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Introduce snapshot concept of canvas (#36119)
Each canvas context returns snapshot instead of just raw bytes. This allows as to hold off conversions (BGRA <-> RGBA, (un)premultiply) to when/if they are actually needed. For example when loading snapshot into webgl we can load both RGBA and BGRA so no conversion is really needed. Currently whole thing is designed to be able to be extend on https://github.com/servo/ipc-channel/pull/356, to make less copies. Hence some commented out code. Fixes #35759 There are tests for these changes in WPT --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
b6967fc4c8
commit
73b778e67f
37 changed files with 724 additions and 251 deletions
|
@ -5,8 +5,8 @@
|
|||
//! Common interfaces for Canvas Contexts
|
||||
|
||||
use euclid::default::Size2D;
|
||||
use ipc_channel::ipc::IpcSharedMemory;
|
||||
use script_layout_interface::{HTMLCanvasData, HTMLCanvasDataSource};
|
||||
use snapshot::Snapshot;
|
||||
|
||||
use crate::dom::bindings::codegen::UnionTypes::HTMLCanvasElementOrOffscreenCanvas;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
|
@ -30,11 +30,10 @@ pub(crate) trait CanvasContext {
|
|||
|
||||
fn resize(&self);
|
||||
|
||||
fn get_image_data_as_shared_memory(&self) -> Option<IpcSharedMemory>;
|
||||
|
||||
fn get_image_data(&self) -> Option<Vec<u8>> {
|
||||
self.get_image_data_as_shared_memory().map(|sm| sm.to_vec())
|
||||
}
|
||||
/// Returns none if area of canvas is zero.
|
||||
///
|
||||
/// In case of other errors it returns cleared snapshot
|
||||
fn get_image_data(&self) -> Option<Snapshot>;
|
||||
|
||||
fn origin_is_clean(&self) -> bool {
|
||||
true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue