mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +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
|
@ -60,11 +60,10 @@ use net_traits::{
|
|||
CoreResourceMsg, CoreResourceThread, FetchResponseListener, IpcSend, ReferrerPolicy,
|
||||
ResourceThreads, fetch_async,
|
||||
};
|
||||
use pixels::{CorsStatus, PixelFormat};
|
||||
use pixels::{CorsStatus, PixelFormat, Snapshot, SnapshotAlphaMode, SnapshotPixelFormat};
|
||||
use profile_traits::{ipc as profile_ipc, mem as profile_mem, time as profile_time};
|
||||
use script_bindings::interfaces::GlobalScopeHelpers;
|
||||
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||
use snapshot::Snapshot;
|
||||
use timers::{TimerEventRequest, TimerId};
|
||||
use url::Origin;
|
||||
use uuid::Uuid;
|
||||
|
@ -3084,13 +3083,13 @@ impl GlobalScope {
|
|||
|
||||
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,
|
||||
};
|
||||
|
||||
|
@ -3278,13 +3277,13 @@ impl GlobalScope {
|
|||
|
||||
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,
|
||||
};
|
||||
|
||||
|
@ -3319,13 +3318,13 @@ impl GlobalScope {
|
|||
return p;
|
||||
}
|
||||
|
||||
let alpha_mode = snapshot::AlphaMode::Transparent {
|
||||
let alpha_mode = SnapshotAlphaMode::Transparent {
|
||||
premultiplied: false,
|
||||
};
|
||||
|
||||
let snapshot = Snapshot::from_vec(
|
||||
image_data.get_size().cast(),
|
||||
snapshot::PixelFormat::RGBA,
|
||||
SnapshotPixelFormat::RGBA,
|
||||
alpha_mode,
|
||||
image_data.to_vec(),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue