core: Remove disposed checks from operations, it's responsibility of avm1 and avm2 to handle it their own way

This commit is contained in:
Nathan Adams 2023-03-31 15:49:13 +02:00
parent 66e2eb77e5
commit fd702dabcc
3 changed files with 31 additions and 34 deletions

View File

@ -335,6 +335,7 @@ pub fn fill_rect<'gc>(
.coerce_to_object(activation); .coerce_to_object(activation);
if let Some(bitmap_data) = this.as_bitmap_data_object() { if let Some(bitmap_data) = this.as_bitmap_data_object() {
if !bitmap_data.disposed() {
if let Some(color_val) = args.get(1) { if let Some(color_val) = args.get(1) {
let color = color_val.coerce_to_i32(activation)?; let color = color_val.coerce_to_i32(activation)?;
@ -359,6 +360,7 @@ pub fn fill_rect<'gc>(
} }
return Ok(Value::Undefined); return Ok(Value::Undefined);
} }
}
Ok((-1).into()) Ok((-1).into())
} }

View File

@ -352,6 +352,7 @@ pub fn get_pixel32<'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_wrapper()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data_wrapper()) {
bitmap_data.check_valid(activation)?;
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 = operations::get_pixel32(bitmap_data, x, y); let pixel = operations::get_pixel32(bitmap_data, x, y);
@ -384,6 +385,8 @@ pub fn set_pixel32<'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_wrapper()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data_wrapper()) {
bitmap_data.check_valid(activation)?;
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 color = args.get_i32(activation, 2)?; let color = args.get_i32(activation, 2)?;
@ -541,6 +544,7 @@ pub fn noise<'gc>(
let gray_scale = args.get_bool(4); let gray_scale = args.get_bool(4);
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data_wrapper()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data_wrapper()) {
bitmap_data.check_valid(activation)?;
let random_seed = args.get_i32(activation, 0)?; let random_seed = args.get_i32(activation, 0)?;
operations::noise( operations::noise(
&mut activation.context, &mut activation.context,
@ -950,6 +954,7 @@ pub fn fill_rect<'gc>(
let color = args.get_i32(activation, 1)?; let color = args.get_i32(activation, 1)?;
if let Some(bitmap_data) = this.and_then(|this| this.as_bitmap_data_wrapper()) { if let Some(bitmap_data) = this.and_then(|this| this.as_bitmap_data_wrapper()) {
bitmap_data.check_valid(activation)?;
let x = rectangle let x = rectangle
.get_public_property("x", activation)? .get_public_property("x", activation)?
.coerce_to_i32(activation)?; .coerce_to_i32(activation)?;

View File

@ -31,10 +31,6 @@ pub fn fill_rect<'gc>(
height: i32, height: i32,
color: i32, color: i32,
) { ) {
if target.disposed() {
return;
}
let mut rect = PixelRegion::for_region_i32(x, y, width, height); let mut rect = PixelRegion::for_region_i32(x, y, width, height);
rect.clamp(target.width(), target.height()); rect.clamp(target.width(), target.height());
@ -67,7 +63,7 @@ pub fn set_pixel32<'gc>(
y: u32, y: u32,
color: i32, color: i32,
) { ) {
if target.disposed() || x >= target.width() || y >= target.height() { if x >= target.width() || y >= target.height() {
return; return;
} }
let target = target.sync(); let target = target.sync();
@ -82,7 +78,7 @@ pub fn set_pixel32<'gc>(
} }
pub fn get_pixel32(target: BitmapDataWrapper, x: u32, y: u32) -> i32 { pub fn get_pixel32(target: BitmapDataWrapper, x: u32, y: u32) -> i32 {
if target.disposed() || x >= target.width() || y >= target.height() { if x >= target.width() || y >= target.height() {
return 0; return 0;
} }
let read = target.read_area(PixelRegion::for_pixel(x, y)); let read = target.read_area(PixelRegion::for_pixel(x, y));
@ -113,7 +109,7 @@ pub fn set_pixel<'gc>(
} }
pub fn get_pixel(target: BitmapDataWrapper, x: u32, y: u32) -> i32 { pub fn get_pixel(target: BitmapDataWrapper, x: u32, y: u32) -> i32 {
if target.disposed() || x >= target.width() || y >= target.height() { if x >= target.width() || y >= target.height() {
return 0; return 0;
} }
let read = target.read_area(PixelRegion::for_pixel(x, y)); let read = target.read_area(PixelRegion::for_pixel(x, y));
@ -130,7 +126,7 @@ pub fn flood_fill<'gc>(
y: u32, y: u32,
color: i32, color: i32,
) { ) {
if target.disposed() || x >= target.width() || y >= target.height() { if x >= target.width() || y >= target.height() {
return; return;
} }
let target = target.sync(); let target = target.sync();
@ -174,9 +170,6 @@ pub fn noise<'gc>(
channel_options: ChannelOptions, channel_options: ChannelOptions,
gray_scale: bool, gray_scale: bool,
) { ) {
if target.disposed() {
return;
}
let (target, _) = target.overwrite_cpu_pixels_from_gpu(context); let (target, _) = target.overwrite_cpu_pixels_from_gpu(context);
let mut write = target.write(context.gc_context); let mut write = target.write(context.gc_context);
@ -247,9 +240,6 @@ pub fn perlin_noise<'gc>(
grayscale: bool, grayscale: bool,
offsets: Vec<(f64, f64)>, // must contain `num_octaves` values offsets: Vec<(f64, f64)>, // must contain `num_octaves` values
) { ) {
if target.disposed() {
return;
}
let (target, _) = target.overwrite_cpu_pixels_from_gpu(context); let (target, _) = target.overwrite_cpu_pixels_from_gpu(context);
let mut write = target.write(context.gc_context); let mut write = target.write(context.gc_context);