Skip to content

Commit 92079e6

Browse files
avm2: Remove three more uses of coerce_to_object, used in Stage3D texture handling
1 parent 4a12bda commit 92079e6

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

core/src/avm2/globals/flash/display3D/textures/cube_texture.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ pub fn upload_from_bitmap_data<'gc>(
8383
args: &[Value<'gc>],
8484
) -> Result<Value<'gc>, Error<'gc>> {
8585
if let Some(texture) = this.as_texture() {
86-
if let Some(source) = args[0].coerce_to_object(activation)?.as_bitmap_data() {
86+
let source_obj = args.get_object(activation, 0, "source")?;
87+
88+
if let Some(source) = source_obj.as_bitmap_data() {
8789
let side = args[1].coerce_to_u32(activation)?;
8890
let mip_level = args[2].coerce_to_u32(activation)?;
8991
if mip_level == 0 {

core/src/avm2/globals/flash/display3D/textures/rectangle_texture.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ pub fn upload_from_bitmap_data<'gc>(
2525
args: &[Value<'gc>],
2626
) -> Result<Value<'gc>, Error<'gc>> {
2727
if let Some(texture) = this.as_texture() {
28-
if let Some(source) = args[0].coerce_to_object(activation)?.as_bitmap_data() {
28+
let source_obj = args.get_object(activation, 0, "source")?;
29+
30+
if let Some(source) = source_obj.as_bitmap_data() {
2931
texture.context3d().copy_bitmapdata_to_texture(
3032
source.sync(activation.context.renderer),
3133
texture.handle(),

core/src/avm2/globals/flash/display3D/textures/texture.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ pub fn upload_from_bitmap_data<'gc>(
117117
args: &[Value<'gc>],
118118
) -> Result<Value<'gc>, Error<'gc>> {
119119
if let Some(texture) = this.as_texture() {
120-
if let Some(source) = args[0].coerce_to_object(activation)?.as_bitmap_data() {
120+
let source_obj = args.get_object(activation, 0, "source")?;
121+
122+
if let Some(source) = source_obj.as_bitmap_data() {
121123
let mip_level = args[1].coerce_to_u32(activation)?;
122124
if mip_level == 0 {
123125
texture.context3d().copy_bitmapdata_to_texture(

0 commit comments

Comments
 (0)