avm2: Hookup `DisplayObject.opaqueBackground`

This commit is contained in:
onkrot 2023-03-28 10:01:59 +05:00 committed by Mike Welsh
parent 8fa00de8a8
commit 5632ade09c
5 changed files with 35 additions and 14 deletions

View File

@ -1005,28 +1005,34 @@ pub fn set_cache_as_bitmap<'gc>(
/// `opaqueBackground`'s getter.
pub fn get_opaque_background<'gc>(
activation: &mut Activation<'_, 'gc>,
_this: Option<Object<'gc>>,
_activation: &mut Activation<'_, 'gc>,
this: Option<Object<'gc>>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm2_stub_getter!(
activation,
"flash.display.DisplayObject",
"opaqueBackground"
);
if let Some(color) = this
.and_then(|this| this.as_display_object())
.and_then(|this| this.opaque_background())
{
return Ok(color.to_rgb().into());
}
Ok(Value::Null)
}
/// `opaqueBackground`'s setter.
pub fn set_opaque_background<'gc>(
activation: &mut Activation<'_, 'gc>,
_this: Option<Object<'gc>>,
_args: &[Value<'gc>],
this: Option<Object<'gc>>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm2_stub_setter!(
activation,
"flash.display.DisplayObject",
"opaqueBackground"
);
if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let value = args.get(0).unwrap_or(&Value::Undefined);
let color = match value {
Value::Null | Value::Undefined => None,
value => Some(Color::from_rgb(value.coerce_to_u32(activation)?, 255)),
};
dobj.set_opaque_background(activation.context.gc_context, color);
}
Ok(Value::Undefined)
}

View File

@ -0,0 +1,6 @@
null
255
null
255
null
255

View File

@ -0,0 +1,9 @@
num_frames = 1
# FIXME - does not rendered correctly
ignore = true
[image_comparison]
tolerance = 1
[player_options]
with_renderer = { optional = true, sample_count = 1 }