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,29 +335,31 @@ pub fn fill_rect<'gc>(
.coerce_to_object(activation);
if let Some(bitmap_data) = this.as_bitmap_data_object() {
if let Some(color_val) = args.get(1) {
let color = color_val.coerce_to_i32(activation)?;
if !bitmap_data.disposed() {
if let Some(color_val) = args.get(1) {
let color = color_val.coerce_to_i32(activation)?;
let x = rectangle.get("x", activation)?.coerce_to_i32(activation)?;
let y = rectangle.get("y", activation)?.coerce_to_i32(activation)?;
let width = rectangle
.get("width", activation)?
.coerce_to_i32(activation)?;
let height = rectangle
.get("height", activation)?
.coerce_to_i32(activation)?;
let x = rectangle.get("x", activation)?.coerce_to_i32(activation)?;
let y = rectangle.get("y", activation)?.coerce_to_i32(activation)?;
let width = rectangle
.get("width", activation)?
.coerce_to_i32(activation)?;
let height = rectangle
.get("height", activation)?
.coerce_to_i32(activation)?;
operations::fill_rect(
&mut activation.context,
bitmap_data.bitmap_data_wrapper(),
x,
y,
width,
height,
color,
);
operations::fill_rect(
&mut activation.context,
bitmap_data.bitmap_data_wrapper(),
x,
y,
width,
height,
color,
);
}
return Ok(Value::Undefined);
}
return Ok(Value::Undefined);
}
Ok((-1).into())

View File

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

View File

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