mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
canvas: Make GetImageData simple and only IPC message to obtain pixels (#38274)
Currently we had `GetImageData` and `SendPixels` to obtain pixels from script thread. This PR unifies those into single `GetImageData` that does not need canvas size and has optional rect (for obtaining sub image). Testing: Existing WPT tests Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
77f85f390e
commit
8b2a5fca54
5 changed files with 26 additions and 63 deletions
|
@ -723,12 +723,8 @@ impl<DrawTarget: GenericDrawTarget> CanvasData<DrawTarget> {
|
|||
/// canvas_size: The size of the canvas we're reading from
|
||||
/// read_rect: The area of the canvas we want to read from
|
||||
#[allow(unsafe_code)]
|
||||
pub(crate) fn read_pixels(
|
||||
&mut self,
|
||||
read_rect: Option<Rect<u32>>,
|
||||
canvas_size: Option<Size2D<u32>>,
|
||||
) -> Snapshot {
|
||||
let canvas_size = canvas_size.unwrap_or(self.drawtarget.get_size().cast());
|
||||
pub(crate) fn read_pixels(&mut self, read_rect: Option<Rect<u32>>) -> Snapshot {
|
||||
let canvas_size = self.drawtarget.get_size().cast();
|
||||
|
||||
if let Some(read_rect) = read_rect {
|
||||
let canvas_rect = Rect::from_size(canvas_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue