core/avm1: Coerce Rectangle and Point parameter fields to f64 first

This commit is contained in:
TÖRÖK Attila 2021-04-22 01:15:09 +02:00 committed by Mike Welsh
parent 22306cc8d9
commit 3f583088a2
1 changed files with 26 additions and 24 deletions

View File

@ -521,14 +521,14 @@ pub fn color_transform<'gc>(
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
.coerce_to_object(activation); .coerce_to_object(activation);
let x = rectangle.get("x", activation)?.coerce_to_i32(activation)?; let x = rectangle.get("x", activation)?.coerce_to_f64(activation)? as i32;
let y = rectangle.get("y", activation)?.coerce_to_i32(activation)?; let y = rectangle.get("y", activation)?.coerce_to_f64(activation)? as i32;
let width = rectangle let width = rectangle
.get("width", activation)? .get("width", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let height = rectangle let height = rectangle
.get("height", activation)? .get("height", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let min_x = x.max(0) as u32; let min_x = x.max(0) as u32;
let end_x = (x + width) as u32; let end_x = (x + width) as u32;
@ -689,24 +689,24 @@ pub fn copy_pixels<'gc>(
let src_min_x = source_rect let src_min_x = source_rect
.get("x", activation)? .get("x", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let src_min_y = source_rect let src_min_y = source_rect
.get("y", activation)? .get("y", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let src_width = source_rect let src_width = source_rect
.get("width", activation)? .get("width", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let src_height = source_rect let src_height = source_rect
.get("height", activation)? .get("height", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let dest_point = args let dest_point = args
.get(2) .get(2)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
.coerce_to_object(activation); .coerce_to_object(activation);
let dest_x = dest_point.get("x", activation)?.coerce_to_i32(activation)?; let dest_x = dest_point.get("x", activation)?.coerce_to_f64(activation)? as i32;
let dest_y = dest_point.get("y", activation)?.coerce_to_i32(activation)?; let dest_y = dest_point.get("y", activation)?.coerce_to_f64(activation)? as i32;
if let Some(src_bitmap) = source_bitmap.as_bitmap_data_object() { if let Some(src_bitmap) = source_bitmap.as_bitmap_data_object() {
if !src_bitmap.disposed() { if !src_bitmap.disposed() {
@ -731,11 +731,13 @@ pub fn copy_pixels<'gc>(
let alpha_x = alpha_point let alpha_x = alpha_point
.get("x", activation)? .get("x", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)?
as i32;
let alpha_y = alpha_point let alpha_y = alpha_point
.get("y", activation)? .get("y", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)?
as i32;
let alpha_bitmap = args let alpha_bitmap = args
.get(3) .get(3)
@ -818,24 +820,24 @@ pub fn merge<'gc>(
let src_min_x = source_rect let src_min_x = source_rect
.get("x", activation)? .get("x", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let src_min_y = source_rect let src_min_y = source_rect
.get("y", activation)? .get("y", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let src_width = source_rect let src_width = source_rect
.get("width", activation)? .get("width", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let src_height = source_rect let src_height = source_rect
.get("height", activation)? .get("height", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let dest_point = args let dest_point = args
.get(2) .get(2)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
.coerce_to_object(activation); .coerce_to_object(activation);
let dest_x = dest_point.get("x", activation)?.coerce_to_i32(activation)?; let dest_x = dest_point.get("x", activation)?.coerce_to_f64(activation)? as i32;
let dest_y = dest_point.get("y", activation)?.coerce_to_i32(activation)?; let dest_y = dest_point.get("y", activation)?.coerce_to_f64(activation)? as i32;
let red_mult = args let red_mult = args
.get(3) .get(3)
@ -910,24 +912,24 @@ pub fn palette_map<'gc>(
let src_min_x = source_rect let src_min_x = source_rect
.get("x", activation)? .get("x", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let src_min_y = source_rect let src_min_y = source_rect
.get("y", activation)? .get("y", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let src_width = source_rect let src_width = source_rect
.get("width", activation)? .get("width", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let src_height = source_rect let src_height = source_rect
.get("height", activation)? .get("height", activation)?
.coerce_to_i32(activation)?; .coerce_to_f64(activation)? as i32;
let dest_point = args let dest_point = args
.get(2) .get(2)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
.coerce_to_object(activation); .coerce_to_object(activation);
let dest_x = dest_point.get("x", activation)?.coerce_to_i32(activation)?; let dest_x = dest_point.get("x", activation)?.coerce_to_f64(activation)? as i32;
let dest_y = dest_point.get("y", activation)?.coerce_to_i32(activation)?; let dest_y = dest_point.get("y", activation)?.coerce_to_f64(activation)? as i32;
let mut get_channel = |index: usize, shift: usize| -> Result<[u32; 256], Error<'gc>> { let mut get_channel = |index: usize, shift: usize| -> Result<[u32; 256], Error<'gc>> {
let arg = args.get(index).unwrap_or(&Value::Null); let arg = args.get(index).unwrap_or(&Value::Null);