Skip to content

Commit

Permalink
avm2: Remove three more uses of coerce_to_object, used in Stage3D t…
Browse files Browse the repository at this point in the history
…exture handling
  • Loading branch information
Lord-McSweeney authored and Lord-McSweeney committed Oct 22, 2024
1 parent 4a12bda commit 92079e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ pub fn upload_from_bitmap_data<'gc>(
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(texture) = this.as_texture() {
if let Some(source) = args[0].coerce_to_object(activation)?.as_bitmap_data() {
let source_obj = args.get_object(activation, 0, "source")?;

if let Some(source) = source_obj.as_bitmap_data() {
let side = args[1].coerce_to_u32(activation)?;
let mip_level = args[2].coerce_to_u32(activation)?;
if mip_level == 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ pub fn upload_from_bitmap_data<'gc>(
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(texture) = this.as_texture() {
if let Some(source) = args[0].coerce_to_object(activation)?.as_bitmap_data() {
let source_obj = args.get_object(activation, 0, "source")?;

if let Some(source) = source_obj.as_bitmap_data() {
texture.context3d().copy_bitmapdata_to_texture(
source.sync(activation.context.renderer),
texture.handle(),
Expand Down
4 changes: 3 additions & 1 deletion core/src/avm2/globals/flash/display3D/textures/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ pub fn upload_from_bitmap_data<'gc>(
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(texture) = this.as_texture() {
if let Some(source) = args[0].coerce_to_object(activation)?.as_bitmap_data() {
let source_obj = args.get_object(activation, 0, "source")?;

if let Some(source) = source_obj.as_bitmap_data() {
let mip_level = args[1].coerce_to_u32(activation)?;
if mip_level == 0 {
texture.context3d().copy_bitmapdata_to_texture(
Expand Down

0 comments on commit 92079e6

Please sign in to comment.