mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
pixels: Move Snapshot
and related data structures to pixels
(#37590)
1. The `shared` directory is for the "_traits" crates, which will likely be moved out of this directly at some point and renamed "_api". These crates expose the API of crates to avoid circular dependencies. `Snapshot` isn't really this. 2. `Snapshot` is essentially a specialied kind of `Image` so it makes sense that it is grouped with other image-related things in `pixels`. Testing: This should not change any behavior so is covered by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
80a7de8c9c
commit
309485d2db
32 changed files with 123 additions and 154 deletions
|
@ -20,7 +20,7 @@ use euclid::vec2;
|
|||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::image_cache::{ImageCache, ImageResponse};
|
||||
use net_traits::request::CorsSettings;
|
||||
use pixels::PixelFormat;
|
||||
use pixels::{PixelFormat, Snapshot, SnapshotAlphaMode, SnapshotPixelFormat};
|
||||
use profile_traits::ipc as profiled_ipc;
|
||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||
use style::color::{AbsoluteColor, ColorFlags, ColorSpace};
|
||||
|
@ -330,7 +330,7 @@ impl CanvasState {
|
|||
&self,
|
||||
url: ServoUrl,
|
||||
cors_setting: Option<CorsSettings>,
|
||||
) -> Option<snapshot::Snapshot> {
|
||||
) -> Option<Snapshot> {
|
||||
let img = match self.request_image_from_cache(url, cors_setting) {
|
||||
ImageResponse::Loaded(image, _) => {
|
||||
if let Some(image) = image.as_raster_image() {
|
||||
|
@ -350,15 +350,15 @@ impl CanvasState {
|
|||
|
||||
let size = Size2D::new(img.metadata.width, img.metadata.height);
|
||||
let format = match img.format {
|
||||
PixelFormat::BGRA8 => snapshot::PixelFormat::BGRA,
|
||||
PixelFormat::RGBA8 => snapshot::PixelFormat::RGBA,
|
||||
PixelFormat::BGRA8 => SnapshotPixelFormat::BGRA,
|
||||
PixelFormat::RGBA8 => SnapshotPixelFormat::RGBA,
|
||||
pixel_format => unimplemented!("unsupported pixel format ({:?})", pixel_format),
|
||||
};
|
||||
let alpha_mode = snapshot::AlphaMode::Transparent {
|
||||
let alpha_mode = SnapshotAlphaMode::Transparent {
|
||||
premultiplied: false,
|
||||
};
|
||||
|
||||
Some(snapshot::Snapshot::from_vec(
|
||||
Some(Snapshot::from_vec(
|
||||
size.cast(),
|
||||
format,
|
||||
alpha_mode,
|
||||
|
@ -393,10 +393,10 @@ impl CanvasState {
|
|||
self.send_canvas_2d_msg(Canvas2dMsg::GetImageData(rect, canvas_size, sender));
|
||||
let mut snapshot = receiver.recv().unwrap().to_owned();
|
||||
snapshot.transform(
|
||||
snapshot::AlphaMode::Transparent {
|
||||
SnapshotAlphaMode::Transparent {
|
||||
premultiplied: false,
|
||||
},
|
||||
snapshot::PixelFormat::RGBA,
|
||||
SnapshotPixelFormat::RGBA,
|
||||
);
|
||||
snapshot.to_vec()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue