mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +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
|
@ -2,12 +2,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use canvas_traits::canvas::{Canvas2dMsg, CanvasId, CanvasMsg, FromScriptMsg};
|
||||
use canvas_traits::canvas::{Canvas2dMsg, CanvasId, CanvasMsg};
|
||||
use dom_struct::dom_struct;
|
||||
use euclid::default::Size2D;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use pixels::Snapshot;
|
||||
use profile_traits::ipc;
|
||||
use script_bindings::inheritance::Castable;
|
||||
use servo_url::ServoUrl;
|
||||
use webrender_api::ImageKey;
|
||||
|
@ -162,10 +161,9 @@ impl CanvasContext for CanvasRenderingContext2D {
|
|||
return None;
|
||||
}
|
||||
|
||||
let (sender, receiver) = ipc::channel(self.global().time_profiler_chan().clone()).unwrap();
|
||||
let msg = CanvasMsg::FromScript(FromScriptMsg::SendPixels(sender), self.get_canvas_id());
|
||||
self.canvas_state.get_ipc_renderer().send(msg).unwrap();
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.canvas_state
|
||||
.send_canvas_2d_msg(Canvas2dMsg::GetImageData(None, sender));
|
||||
Some(receiver.recv().unwrap().to_owned())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue