mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Merge 892edc0048
into 7439fa18d3
This commit is contained in:
commit
dbd503fd35
14 changed files with 69 additions and 69 deletions
|
@ -447,7 +447,7 @@ impl<'a, B: Backend> CanvasData<'a, B> {
|
|||
pub(crate) fn draw_image(
|
||||
&mut self,
|
||||
image_data: &[u8],
|
||||
image_size: Size2D<u64>,
|
||||
image_size: Size2D<u32>,
|
||||
dest_rect: Rect<f64>,
|
||||
source_rect: Rect<f64>,
|
||||
smoothing_enabled: bool,
|
||||
|
@ -457,7 +457,7 @@ impl<'a, B: Backend> CanvasData<'a, B> {
|
|||
let source_rect = source_rect.ceil();
|
||||
// It discards the extra pixels (if any) that won't be painted
|
||||
let image_data = if Rect::from_size(image_size.to_f64()).contains_rect(&source_rect) {
|
||||
pixels::rgba8_get_rect(image_data, image_size, source_rect.to_u64()).into()
|
||||
pixels::rgba8_get_rect(image_data, image_size, source_rect.to_u32()).into()
|
||||
} else {
|
||||
image_data.into()
|
||||
};
|
||||
|
@ -1221,7 +1221,7 @@ impl<'a, B: Backend> CanvasData<'a, B> {
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||
pub(crate) fn put_image_data(&mut self, mut imagedata: Vec<u8>, rect: Rect<u64>) {
|
||||
pub(crate) fn put_image_data(&mut self, mut imagedata: Vec<u8>, rect: Rect<u32>) {
|
||||
assert_eq!(imagedata.len() % 4, 0);
|
||||
assert_eq!(rect.size.area() as usize, imagedata.len() / 4);
|
||||
pixels::rgba8_byte_swap_and_premultiply_inplace(&mut imagedata);
|
||||
|
@ -1310,8 +1310,8 @@ impl<'a, B: Backend> CanvasData<'a, B> {
|
|||
#[allow(unsafe_code)]
|
||||
pub(crate) fn read_pixels(
|
||||
&self,
|
||||
read_rect: Option<Rect<u64>>,
|
||||
canvas_size: Option<Size2D<u64>>,
|
||||
read_rect: Option<Rect<u32>>,
|
||||
canvas_size: Option<Size2D<u32>>,
|
||||
) -> Snapshot {
|
||||
let canvas_size = canvas_size.unwrap_or(self.drawtarget.get_size().cast());
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ impl<'a> CanvasPaintThread<'a> {
|
|||
Canvas2dMsg::DrawEmptyImage(image_size, dest_rect, source_rect) => {
|
||||
self.canvas(canvas_id).draw_image(
|
||||
&vec![0; image_size.area() as usize * 4],
|
||||
image_size.to_u64(),
|
||||
image_size,
|
||||
dest_rect,
|
||||
source_rect,
|
||||
false,
|
||||
|
@ -203,10 +203,10 @@ impl<'a> CanvasPaintThread<'a> {
|
|||
) => {
|
||||
let image_data = self
|
||||
.canvas(canvas_id)
|
||||
.read_pixels(Some(source_rect.to_u64()), Some(image_size.to_u64()));
|
||||
.read_pixels(Some(source_rect.to_u32()), Some(image_size));
|
||||
self.canvas(other_canvas_id).draw_image(
|
||||
image_data.data(),
|
||||
source_rect.size.to_u64(),
|
||||
source_rect.size.to_u32(),
|
||||
dest_rect,
|
||||
source_rect,
|
||||
smoothing,
|
||||
|
@ -398,7 +398,7 @@ impl Canvas<'_> {
|
|||
fn draw_image(
|
||||
&mut self,
|
||||
data: &[u8],
|
||||
size: Size2D<u64>,
|
||||
size: Size2D<u32>,
|
||||
dest_rect: Rect<f64>,
|
||||
source_rect: Rect<f64>,
|
||||
smoothing_enabled: bool,
|
||||
|
@ -418,8 +418,8 @@ impl Canvas<'_> {
|
|||
|
||||
fn read_pixels(
|
||||
&mut self,
|
||||
read_rect: Option<Rect<u64>>,
|
||||
canvas_size: Option<Size2D<u64>>,
|
||||
read_rect: Option<Rect<u32>>,
|
||||
canvas_size: Option<Size2D<u32>>,
|
||||
) -> snapshot::Snapshot {
|
||||
match self {
|
||||
Canvas::Raqote(canvas_data) => canvas_data.read_pixels(read_rect, canvas_size),
|
||||
|
@ -612,7 +612,7 @@ impl Canvas<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn put_image_data(&mut self, unwrap: Vec<u8>, rect: Rect<u64>) {
|
||||
fn put_image_data(&mut self, unwrap: Vec<u8>, rect: Rect<u32>) {
|
||||
match self {
|
||||
Canvas::Raqote(canvas_data) => canvas_data.put_image_data(unwrap, rect),
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ pub fn compute_rgba8_byte_length_if_within_limit(width: usize, height: usize) ->
|
|||
.filter(|v| *v <= MAX_IMAGE_BYTE_LENGTH)
|
||||
}
|
||||
|
||||
pub fn rgba8_get_rect(pixels: &[u8], size: Size2D<u64>, rect: Rect<u64>) -> Cow<[u8]> {
|
||||
pub fn rgba8_get_rect(pixels: &[u8], size: Size2D<u32>, rect: Rect<u32>) -> Cow<[u8]> {
|
||||
assert!(!rect.is_empty());
|
||||
assert!(Rect::from_size(size).contains_rect(&rect));
|
||||
assert_eq!(pixels.len() % 4, 0);
|
||||
|
@ -106,18 +106,18 @@ pub fn multiply_u8_color(a: u8, b: u8) -> u8 {
|
|||
|
||||
pub fn clip(
|
||||
mut origin: Point2D<i32>,
|
||||
mut size: Size2D<u64>,
|
||||
surface: Size2D<u64>,
|
||||
) -> Option<Rect<u64>> {
|
||||
mut size: Size2D<u32>,
|
||||
surface: Size2D<u32>,
|
||||
) -> Option<Rect<u32>> {
|
||||
if origin.x < 0 {
|
||||
size.width = size.width.saturating_sub(-origin.x as u64);
|
||||
size.width = size.width.saturating_sub(-origin.x as u32);
|
||||
origin.x = 0;
|
||||
}
|
||||
if origin.y < 0 {
|
||||
size.height = size.height.saturating_sub(-origin.y as u64);
|
||||
size.height = size.height.saturating_sub(-origin.y as u32);
|
||||
origin.y = 0;
|
||||
}
|
||||
let origin = Point2D::new(origin.x as u64, origin.y as u64);
|
||||
let origin = Point2D::new(origin.x as u32, origin.y as u32);
|
||||
Rect::new(origin, size)
|
||||
.intersection(&Rect::from_size(surface))
|
||||
.filter(|rect| !rect.is_empty())
|
||||
|
|
|
@ -48,7 +48,7 @@ pub(crate) trait CanvasContext {
|
|||
true
|
||||
}
|
||||
|
||||
fn size(&self) -> Size2D<u64> {
|
||||
fn size(&self) -> Size2D<u32> {
|
||||
self.canvas().size()
|
||||
}
|
||||
|
||||
|
@ -73,12 +73,12 @@ pub(crate) trait CanvasContext {
|
|||
}
|
||||
|
||||
pub(crate) trait CanvasHelpers {
|
||||
fn size(&self) -> Size2D<u64>;
|
||||
fn size(&self) -> Size2D<u32>;
|
||||
fn canvas(&self) -> Option<&HTMLCanvasElement>;
|
||||
}
|
||||
|
||||
impl CanvasHelpers for HTMLCanvasElementOrOffscreenCanvas {
|
||||
fn size(&self) -> Size2D<u64> {
|
||||
fn size(&self) -> Size2D<u32> {
|
||||
match self {
|
||||
HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(canvas) => {
|
||||
canvas.get_size().cast()
|
||||
|
@ -164,7 +164,7 @@ impl CanvasContext for RenderingContext {
|
|||
}
|
||||
}
|
||||
|
||||
fn size(&self) -> Size2D<u64> {
|
||||
fn size(&self) -> Size2D<u32> {
|
||||
match self {
|
||||
RenderingContext::Placeholder(context) => (*context.context().unwrap()).size(),
|
||||
RenderingContext::Context2d(context) => context.size(),
|
||||
|
@ -251,7 +251,7 @@ impl CanvasContext for OffscreenRenderingContext {
|
|||
}
|
||||
}
|
||||
|
||||
fn size(&self) -> Size2D<u64> {
|
||||
fn size(&self) -> Size2D<u32> {
|
||||
match self {
|
||||
OffscreenRenderingContext::Context2d(context) => context.size(),
|
||||
}
|
||||
|
|
|
@ -383,7 +383,7 @@ impl CanvasState {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_rect(&self, canvas_size: Size2D<u64>, rect: Rect<u64>) -> Vec<u8> {
|
||||
pub(crate) fn get_rect(&self, canvas_size: Size2D<u32>, rect: Rect<u32>) -> Vec<u8> {
|
||||
assert!(self.origin_is_clean());
|
||||
assert!(Rect::from_size(canvas_size).contains_rect(&rect));
|
||||
|
||||
|
@ -531,11 +531,11 @@ impl CanvasState {
|
|||
};
|
||||
|
||||
// Step 4. Establish the source and destination rectangles.
|
||||
let video_size = snapshot.size().to_f64();
|
||||
let dw = dw.unwrap_or(video_size.width);
|
||||
let dh = dh.unwrap_or(video_size.height);
|
||||
let sw = sw.unwrap_or(video_size.width);
|
||||
let sh = sh.unwrap_or(video_size.height);
|
||||
let video_size = snapshot.size();
|
||||
let dw = dw.unwrap_or(video_size.width as f64);
|
||||
let dh = dh.unwrap_or(video_size.height as f64);
|
||||
let sw = sw.unwrap_or(video_size.width as f64);
|
||||
let sh = sh.unwrap_or(video_size.height as f64);
|
||||
|
||||
let (source_rect, dest_rect) =
|
||||
self.adjust_source_dest_rects(video_size, sx, sy, sw, sh, dx, dy, dw, dh);
|
||||
|
@ -577,7 +577,7 @@ impl CanvasState {
|
|||
let sw = sw.unwrap_or(canvas_size.width as f64);
|
||||
let sh = sh.unwrap_or(canvas_size.height as f64);
|
||||
|
||||
let image_size = Size2D::new(canvas_size.width as f64, canvas_size.height as f64);
|
||||
let image_size = Size2D::new(canvas_size.width, canvas_size.height);
|
||||
// 2. Establish the source and destination rectangles
|
||||
let (source_rect, dest_rect) =
|
||||
self.adjust_source_dest_rects(image_size, sx, sy, sw, sh, dx, dy, dw, dh);
|
||||
|
@ -632,7 +632,7 @@ impl CanvasState {
|
|||
let sw = sw.unwrap_or(canvas_size.width as f64);
|
||||
let sh = sh.unwrap_or(canvas_size.height as f64);
|
||||
|
||||
let image_size = Size2D::new(canvas_size.width as f64, canvas_size.height as f64);
|
||||
let image_size = Size2D::new(canvas_size.width, canvas_size.height);
|
||||
// 2. Establish the source and destination rectangles
|
||||
let (source_rect, dest_rect) =
|
||||
self.adjust_source_dest_rects(image_size, sx, sy, sw, sh, dx, dy, dw, dh);
|
||||
|
@ -702,12 +702,12 @@ impl CanvasState {
|
|||
let snapshot = self
|
||||
.fetch_image_data(url, cors_setting)
|
||||
.ok_or(Error::InvalidState)?;
|
||||
let image_size = snapshot.size().to_f64();
|
||||
let image_size = snapshot.size();
|
||||
|
||||
let dw = dw.unwrap_or(image_size.width);
|
||||
let dh = dh.unwrap_or(image_size.height);
|
||||
let sw = sw.unwrap_or(image_size.width);
|
||||
let sh = sh.unwrap_or(image_size.height);
|
||||
let dw = dw.unwrap_or(image_size.width as f64);
|
||||
let dh = dh.unwrap_or(image_size.height as f64);
|
||||
let sw = sw.unwrap_or(image_size.width as f64);
|
||||
let sh = sh.unwrap_or(image_size.height as f64);
|
||||
|
||||
// Establish the source and destination rectangles
|
||||
let (source_rect, dest_rect) =
|
||||
|
@ -741,7 +741,7 @@ impl CanvasState {
|
|||
#[allow(clippy::too_many_arguments)]
|
||||
fn adjust_source_dest_rects(
|
||||
&self,
|
||||
image_size: Size2D<f64>,
|
||||
image_size: Size2D<u32>,
|
||||
sx: f64,
|
||||
sy: f64,
|
||||
sw: f64,
|
||||
|
@ -766,7 +766,7 @@ impl CanvasState {
|
|||
// When the source rectangle is outside the source image,
|
||||
// the source rectangle must be clipped to the source image
|
||||
let source_rect_clipped = source_rect
|
||||
.intersection(&image_rect)
|
||||
.intersection(&image_rect.to_f64())
|
||||
.unwrap_or(Rect::zero());
|
||||
|
||||
// Width and height ratios between the non clipped and clipped source rectangles
|
||||
|
@ -1486,7 +1486,7 @@ impl CanvasState {
|
|||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn get_image_data(
|
||||
&self,
|
||||
canvas_size: Size2D<u64>,
|
||||
canvas_size: Size2D<u32>,
|
||||
global: &GlobalScope,
|
||||
sx: i32,
|
||||
sy: i32,
|
||||
|
@ -1506,7 +1506,7 @@ impl CanvasState {
|
|||
}
|
||||
|
||||
let (origin, size) = adjust_size_sign(Point2D::new(sx, sy), Size2D::new(sw, sh));
|
||||
let read_rect = match pixels::clip(origin, size.to_u64(), canvas_size) {
|
||||
let read_rect = match pixels::clip(origin, size.to_u32(), canvas_size) {
|
||||
Some(rect) => rect,
|
||||
None => {
|
||||
// All the pixels are outside the canvas surface.
|
||||
|
@ -1526,7 +1526,7 @@ impl CanvasState {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-context-2d-putimagedata
|
||||
pub(crate) fn put_image_data(
|
||||
&self,
|
||||
canvas_size: Size2D<u64>,
|
||||
canvas_size: Size2D<u32>,
|
||||
imagedata: &ImageData,
|
||||
dx: i32,
|
||||
dy: i32,
|
||||
|
@ -1547,7 +1547,7 @@ impl CanvasState {
|
|||
#[allow(unsafe_code, clippy::too_many_arguments)]
|
||||
pub(crate) fn put_image_data_(
|
||||
&self,
|
||||
canvas_size: Size2D<u64>,
|
||||
canvas_size: Size2D<u32>,
|
||||
imagedata: &ImageData,
|
||||
dx: i32,
|
||||
dy: i32,
|
||||
|
@ -1579,7 +1579,7 @@ impl CanvasState {
|
|||
Point2D::new(dirty_x, dirty_y),
|
||||
Size2D::new(dirty_width, dirty_height),
|
||||
);
|
||||
let src_rect = match pixels::clip(src_origin, src_size.to_u64(), imagedata_size.to_u64()) {
|
||||
let src_rect = match pixels::clip(src_origin, src_size.to_u32(), imagedata_size.to_u32()) {
|
||||
Some(rect) => rect,
|
||||
None => return,
|
||||
};
|
||||
|
|
|
@ -397,8 +397,8 @@ impl HTMLCanvasElement {
|
|||
// u32 can't panic, since the data comes from a canvas which is always smaller than
|
||||
// u32::MAX.
|
||||
let canvas_data = snapshot.data();
|
||||
let width = snapshot.size().width as u32;
|
||||
let height = snapshot.size().height as u32;
|
||||
let width = snapshot.size().width;
|
||||
let height = snapshot.size().height;
|
||||
|
||||
match image_type {
|
||||
EncodedImageType::Png => {
|
||||
|
|
|
@ -154,8 +154,8 @@ impl ImageData {
|
|||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub(crate) unsafe fn get_rect(&self, rect: Rect<u64>) -> Cow<[u8]> {
|
||||
pixels::rgba8_get_rect(self.as_slice(), self.get_size().to_u64(), rect)
|
||||
pub(crate) unsafe fn get_rect(&self, rect: Rect<u32>) -> Cow<[u8]> {
|
||||
pixels::rgba8_get_rect(self.as_slice(), self.get_size().to_u32(), rect)
|
||||
}
|
||||
|
||||
pub(crate) fn get_size(&self) -> Size2D<u32> {
|
||||
|
|
|
@ -72,8 +72,11 @@ impl OffscreenCanvas {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn get_size(&self) -> Size2D<u64> {
|
||||
Size2D::new(self.Width(), self.Height())
|
||||
pub(crate) fn get_size(&self) -> Size2D<u32> {
|
||||
Size2D::new(
|
||||
self.Width().try_into().unwrap_or(u32::MAX),
|
||||
self.Height().try_into().unwrap_or(u32::MAX),
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn origin_is_clean(&self) -> bool {
|
||||
|
|
|
@ -534,7 +534,7 @@ impl WebGL2RenderingContext {
|
|||
let src_origin = Point2D::new(x, y);
|
||||
let src_size = Size2D::new(width as u32, height as u32);
|
||||
let fb_size = Size2D::new(fb_width as u32, fb_height as u32);
|
||||
match pixels::clip(src_origin, src_size.to_u64(), fb_size.to_u64()) {
|
||||
match pixels::clip(src_origin, src_size.to_u32(), fb_size.to_u32()) {
|
||||
Some(rect) => rect.to_u32(),
|
||||
None => return,
|
||||
}
|
||||
|
@ -2183,7 +2183,7 @@ impl WebGL2RenderingContextMethods<crate::DomTypeHolder> for WebGL2RenderingCont
|
|||
let src_origin = Point2D::new(x, y);
|
||||
let src_size = Size2D::new(width as u32, height as u32);
|
||||
let fb_size = Size2D::new(fb_width as u32, fb_height as u32);
|
||||
if pixels::clip(src_origin, src_size.to_u64(), fb_size.to_u64()).is_none() {
|
||||
if pixels::clip(src_origin, src_size.to_u32(), fb_size.to_u32()).is_none() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3838,7 +3838,7 @@ impl WebGLRenderingContextMethods<crate::DomTypeHolder> for WebGLRenderingContex
|
|||
let src_origin = Point2D::new(x, y);
|
||||
let src_size = Size2D::new(width as u32, height as u32);
|
||||
let fb_size = Size2D::new(fb_width as u32, fb_height as u32);
|
||||
let src_rect = match pixels::clip(src_origin, src_size.to_u64(), fb_size.to_u64()) {
|
||||
let src_rect = match pixels::clip(src_origin, src_size.to_u32(), fb_size.to_u32()) {
|
||||
Some(rect) => rect,
|
||||
None => return,
|
||||
};
|
||||
|
|
|
@ -167,8 +167,8 @@ impl GPUCanvasContext {
|
|||
// causes FAIL on webgpu:web_platform,canvas,configure:usage:*
|
||||
usage: configuration.usage | GPUTextureUsageConstants::COPY_SRC,
|
||||
size: GPUExtent3D::GPUExtent3DDict(GPUExtent3DDict {
|
||||
width: size.width as u32,
|
||||
height: size.height as u32,
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
depthOrArrayLayers: 1,
|
||||
}),
|
||||
viewFormats: configuration.viewFormats.clone(),
|
||||
|
|
|
@ -129,10 +129,7 @@ impl XRWebGLLayer {
|
|||
HTMLCanvasElementOrOffscreenCanvas::HTMLCanvasElement(canvas) => canvas.get_size(),
|
||||
HTMLCanvasElementOrOffscreenCanvas::OffscreenCanvas(canvas) => {
|
||||
let size = canvas.get_size();
|
||||
Size2D::new(
|
||||
size.width.try_into().unwrap_or(0),
|
||||
size.height.try_into().unwrap_or(0),
|
||||
)
|
||||
Size2D::new(size.width, size.height)
|
||||
},
|
||||
};
|
||||
Size2D::from_untyped(size)
|
||||
|
|
|
@ -89,8 +89,8 @@ pub enum Canvas2dMsg {
|
|||
Arc(Point2D<f32>, f32, f32, f32, bool),
|
||||
ArcTo(Point2D<f32>, Point2D<f32>, f32),
|
||||
DrawImage(IpcSnapshot, Rect<f64>, Rect<f64>, bool),
|
||||
DrawEmptyImage(Size2D<f64>, Rect<f64>, Rect<f64>),
|
||||
DrawImageInOther(CanvasId, Size2D<f64>, Rect<f64>, Rect<f64>, bool),
|
||||
DrawEmptyImage(Size2D<u32>, Rect<f64>, Rect<f64>),
|
||||
DrawImageInOther(CanvasId, Size2D<u32>, Rect<f64>, Rect<f64>, bool),
|
||||
BeginPath,
|
||||
BezierCurveTo(Point2D<f32>, Point2D<f32>, Point2D<f32>),
|
||||
ClearRect(Rect<f32>),
|
||||
|
@ -102,14 +102,14 @@ pub enum Canvas2dMsg {
|
|||
FillPath(FillOrStrokeStyle, Vec<PathSegment>),
|
||||
FillText(String, f64, f64, Option<f64>, FillOrStrokeStyle, bool),
|
||||
FillRect(Rect<f32>, FillOrStrokeStyle),
|
||||
GetImageData(Rect<u64>, Size2D<u64>, IpcSender<IpcSnapshot>),
|
||||
GetImageData(Rect<u32>, Size2D<u32>, IpcSender<IpcSnapshot>),
|
||||
GetTransform(IpcSender<Transform2D<f32>>),
|
||||
IsPointInCurrentPath(f64, f64, FillRule, IpcSender<bool>),
|
||||
IsPointInPath(Vec<PathSegment>, f64, f64, FillRule, IpcSender<bool>),
|
||||
LineTo(Point2D<f32>),
|
||||
MoveTo(Point2D<f32>),
|
||||
MeasureText(String, IpcSender<TextMetrics>),
|
||||
PutImageData(Rect<u64>, IpcBytesReceiver),
|
||||
PutImageData(Rect<u32>, IpcBytesReceiver),
|
||||
QuadraticCurveTo(Point2D<f32>, Point2D<f32>),
|
||||
Rect(Rect<f32>),
|
||||
RestoreContext,
|
||||
|
|
|
@ -87,7 +87,7 @@ pub type IpcSnapshot = Snapshot<IpcSharedMemory>;
|
|||
/// <https://gpuweb.github.io/gpuweb/#abstract-opdef-get-a-copy-of-the-image-contents-of-a-context>
|
||||
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
|
||||
pub struct Snapshot<T = Data> {
|
||||
size: Size2D<u64>,
|
||||
size: Size2D<u32>,
|
||||
/// internal data (can be any format it will be converted on use if needed)
|
||||
data: T,
|
||||
/// RGBA/BGRA (reflect internal data)
|
||||
|
@ -97,7 +97,7 @@ pub struct Snapshot<T = Data> {
|
|||
}
|
||||
|
||||
impl<T> Snapshot<T> {
|
||||
pub const fn size(&self) -> Size2D<u64> {
|
||||
pub const fn size(&self) -> Size2D<u32> {
|
||||
self.size
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ impl Snapshot<Data> {
|
|||
}
|
||||
|
||||
/// Returns snapshot with provided size that is black transparent alpha
|
||||
pub fn cleared(size: Size2D<u64>) -> Self {
|
||||
pub fn cleared(size: Size2D<u32>) -> Self {
|
||||
Self {
|
||||
size,
|
||||
data: Data::Owned(vec![0; size.area() as usize * 4]),
|
||||
|
@ -143,7 +143,7 @@ impl Snapshot<Data> {
|
|||
}
|
||||
|
||||
pub fn from_vec(
|
||||
size: Size2D<u64>,
|
||||
size: Size2D<u32>,
|
||||
format: PixelFormat,
|
||||
alpha_mode: AlphaMode,
|
||||
data: Vec<u8>,
|
||||
|
@ -157,7 +157,7 @@ impl Snapshot<Data> {
|
|||
}
|
||||
|
||||
pub fn from_shared_memory(
|
||||
size: Size2D<u64>,
|
||||
size: Size2D<u32>,
|
||||
format: PixelFormat,
|
||||
alpha_mode: AlphaMode,
|
||||
ism: IpcSharedMemory,
|
||||
|
@ -177,7 +177,7 @@ impl Snapshot<Data> {
|
|||
/// This is safe if data is owned by this process only
|
||||
/// (ownership is transferred on send)
|
||||
pub unsafe fn from_shared_memory(
|
||||
size: Size2D<u64>,
|
||||
size: Size2D<u32>,
|
||||
format: PixelFormat,
|
||||
alpha_mode: AlphaMode,
|
||||
ism: IpcSharedMemory,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue