ges: framepositioner: Make positioning properties doubles

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1410>
This commit is contained in:
Michiel Westerbeek 2024-03-18 20:38:56 +01:00 committed by Sebastian Dröge
parent 9e80250b49
commit c05563d22e

View file

@ -20,32 +20,32 @@ impl FrameCompositionMeta {
} }
#[inline] #[inline]
pub fn position(&self) -> (i32, i32) { pub fn position(&self) -> (f64, f64) {
(self.0.posx, self.0.posy) (self.0.posx, self.0.posy)
} }
#[inline] #[inline]
pub fn pos_x(&self) -> i32 { pub fn pos_x(&self) -> f64 {
self.0.posx self.0.posx
} }
#[inline] #[inline]
pub fn pos_y(&self) -> i32 { pub fn pos_y(&self) -> f64 {
self.0.posy self.0.posy
} }
#[inline] #[inline]
pub fn size(&self) -> (i32, i32) { pub fn size(&self) -> (f64, f64) {
(self.0.width, self.0.height) (self.0.width, self.0.height)
} }
#[inline] #[inline]
pub fn width(&self) -> i32 { pub fn width(&self) -> f64 {
self.0.width self.0.width
} }
#[inline] #[inline]
pub fn height(&self) -> i32 { pub fn height(&self) -> f64 {
self.0.height self.0.height
} }
@ -90,8 +90,8 @@ mod tests {
fn add_composition_meta( fn add_composition_meta(
buffer: &mut gst::BufferRef, buffer: &mut gst::BufferRef,
position: (i32, i32), position: (f64, f64),
size: (i32, i32), size: (f64, f64),
alpha: f64, alpha: f64,
zorder: u32, zorder: u32,
operator: i32, operator: i32,
@ -125,14 +125,14 @@ mod tests {
let mut buffer = gst::Buffer::with_size(320 * 240 * 4).unwrap(); let mut buffer = gst::Buffer::with_size(320 * 240 * 4).unwrap();
{ {
let _meta = let _meta =
add_composition_meta(buffer.get_mut().unwrap(), (42, 42), (20, 22), 0.42, 2, 42) add_composition_meta(buffer.get_mut().unwrap(), (42., 42.), (20., 22.), 0.42, 2, 42)
.unwrap(); .unwrap();
} }
{ {
let meta = buffer.meta::<FrameCompositionMeta>().unwrap(); let meta = buffer.meta::<FrameCompositionMeta>().unwrap();
assert_eq!(meta.position(), (42, 42)); assert_eq!(meta.position(), (42., 42.));
assert_eq!(meta.size(), (20, 22)); assert_eq!(meta.size(), (20., 22.));
assert_eq!(meta.alpha(), 0.42); assert_eq!(meta.alpha(), 0.42);
assert_eq!(meta.zorder(), 2); assert_eq!(meta.zorder(), 2);
assert_eq!(meta.operator(), 42); assert_eq!(meta.operator(), 42);