core: Move get_pixel32 from BitmapData to bitmap_data_operations
This commit is contained in:
parent
31f46c6acf
commit
758d8f1492
|
@ -180,7 +180,8 @@ pub fn get_pixel32<'gc>(
|
||||||
if let (Some(x_val), Some(y_val)) = (args.get(0), args.get(1)) {
|
if let (Some(x_val), Some(y_val)) = (args.get(0), args.get(1)) {
|
||||||
let x = x_val.coerce_to_u32(activation)?;
|
let x = x_val.coerce_to_u32(activation)?;
|
||||||
let y = y_val.coerce_to_u32(activation)?;
|
let y = y_val.coerce_to_u32(activation)?;
|
||||||
let col: i32 = bitmap_data.bitmap_data().read().get_pixel32(x, y).into();
|
let col =
|
||||||
|
bitmap_data_operations::get_pixel32(bitmap_data.bitmap_data_wrapper(), x, y);
|
||||||
return Ok(col.into());
|
return Ok(col.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,10 +364,10 @@ pub fn get_pixel32<'gc>(
|
||||||
this: Option<Object<'gc>>,
|
this: Option<Object<'gc>>,
|
||||||
args: &[Value<'gc>],
|
args: &[Value<'gc>],
|
||||||
) -> Result<Value<'gc>, Error<'gc>> {
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) {
|
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data_wrapper()) {
|
||||||
let x = args.get_u32(activation, 0)?;
|
let x = args.get_u32(activation, 0)?;
|
||||||
let y = args.get_u32(activation, 1)?;
|
let y = args.get_u32(activation, 1)?;
|
||||||
let pixel = i32::from(bitmap_data.read().get_pixel32(x, y));
|
let pixel = bitmap_data_operations::get_pixel32(bitmap_data, x, y);
|
||||||
return Ok((pixel as u32).into());
|
return Ok((pixel as u32).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -556,14 +556,6 @@ impl<'gc> BitmapData<'gc> {
|
||||||
x >= 0 && x < self.width() as i32 && y >= 0 && y < self.height() as i32
|
x >= 0 && x < self.width() as i32 && y >= 0 && y < self.height() as i32
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_pixel32(&self, x: u32, y: u32) -> Color {
|
|
||||||
if x < self.width && y < self.height {
|
|
||||||
self.get_pixel32_raw(x, y).to_un_multiplied_alpha()
|
|
||||||
} else {
|
|
||||||
Color(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_pixel(&self, x: u32, y: u32) -> i32 {
|
pub fn get_pixel(&self, x: u32, y: u32) -> i32 {
|
||||||
if x < self.width && y < self.height {
|
if x < self.width && y < self.height {
|
||||||
self.get_pixel32_raw(x, y)
|
self.get_pixel32_raw(x, y)
|
||||||
|
|
|
@ -67,3 +67,12 @@ pub fn set_pixel32<'gc>(
|
||||||
);
|
);
|
||||||
write.set_cpu_dirty(PixelRegion::for_pixel(x, y));
|
write.set_cpu_dirty(PixelRegion::for_pixel(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_pixel32(target: BitmapDataWrapper, x: u32, y: u32) -> i32 {
|
||||||
|
if target.disposed() || x >= target.width() || y >= target.height() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
let target = target.sync();
|
||||||
|
let read = target.read();
|
||||||
|
read.get_pixel32_raw(x, y).to_un_multiplied_alpha().into()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue