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:
Martin Robinson 2025-06-20 16:47:06 +02:00 committed by GitHub
parent 80a7de8c9c
commit 309485d2db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 123 additions and 154 deletions

View file

@ -34,7 +34,7 @@ use half::f16;
use ipc_channel::ipc::IpcSharedMemory;
use itertools::Itertools;
use log::{debug, error, trace, warn};
use pixels::{self, PixelFormat, unmultiply_inplace};
use pixels::{self, PixelFormat, SnapshotAlphaMode, unmultiply_inplace};
use surfman::chains::{PreserveBuffer, SwapChains, SwapChainsAPI};
use surfman::{
self, Adapter, Connection, Context, ContextAttributeFlags, ContextAttributes, Device,
@ -1215,8 +1215,8 @@ impl WebGLImpl {
)
};
let alpha_mode = match (attributes.alpha, attributes.premultiplied_alpha) {
(true, premultiplied) => snapshot::AlphaMode::Transparent { premultiplied },
(false, _) => snapshot::AlphaMode::Opaque,
(true, premultiplied) => SnapshotAlphaMode::Transparent { premultiplied },
(false, _) => SnapshotAlphaMode::Opaque,
};
sender
.send((IpcSharedMemory::from_bytes(&pixels), alpha_mode))