@@ -11,14 +11,15 @@ use crate::context::{RenderContext, UpdateContext};
1111use crate :: display_object:: { DisplayObjectBase , DisplayObjectPtr , DisplayObjectWeak } ;
1212use crate :: prelude:: * ;
1313use crate :: tag_utils:: SwfMovie ;
14+ use crate :: utils:: HasPrefixField ;
1415use crate :: vminterface:: Instantiator ;
1516use core:: fmt;
1617use gc_arena:: barrier:: unlock;
1718use gc_arena:: lock:: { Lock , RefLock } ;
1819use gc_arena:: { Collect , Gc , GcCell , GcWeak , Mutation } ;
1920use ruffle_render:: backend:: RenderBackend ;
2021use ruffle_render:: bitmap:: { BitmapFormat , PixelSnapping } ;
21- use std:: cell:: { Cell , Ref , RefMut } ;
22+ use std:: cell:: Cell ;
2223use std:: sync:: Arc ;
2324
2425#[ derive( Clone , Debug , Collect , Copy ) ]
@@ -96,13 +97,22 @@ impl fmt::Debug for Bitmap<'_> {
9697 }
9798}
9899
99- #[ derive( Clone , Collect ) ]
100+ #[ derive( Clone , Collect , HasPrefixField ) ]
100101#[ collect( no_drop) ]
102+ #[ repr( C , align( 8 ) ) ]
101103pub struct BitmapGraphicData < ' gc > {
102104 base : RefLock < DisplayObjectBase < ' gc > > ,
103- id : CharacterId ,
104105 movie : Arc < SwfMovie > ,
105106
107+ /// The AVM2 side of this object.
108+ ///
109+ /// AVM1 code cannot directly reference `Bitmap`s, so this does not support
110+ /// storing an AVM1 object.
111+ avm2_object : Lock < Option < Avm2Object < ' gc > > > ,
112+
113+ /// The class associated with this Bitmap.
114+ avm2_bitmap_class : Lock < BitmapClass < ' gc > > ,
115+
106116 /// The current bitmap data object.
107117 bitmap_data : Lock < BitmapDataWrapper < ' gc > > ,
108118
@@ -112,20 +122,13 @@ pub struct BitmapGraphicData<'gc> {
112122 width : Cell < u32 > ,
113123 height : Cell < u32 > ,
114124
125+ id : CharacterId ,
126+
115127 /// Whether or not bitmap smoothing is enabled.
116128 smoothing : Cell < bool > ,
117129
118130 /// How to snap this bitmap to the pixel grid
119131 pixel_snapping : Cell < PixelSnapping > ,
120-
121- /// The AVM2 side of this object.
122- ///
123- /// AVM1 code cannot directly reference `Bitmap`s, so this does not support
124- /// storing an AVM1 object.
125- avm2_object : Lock < Option < Avm2Object < ' gc > > > ,
126-
127- /// The class associated with this Bitmap.
128- avm2_bitmap_class : Lock < BitmapClass < ' gc > > ,
129132}
130133
131134impl < ' gc > Bitmap < ' gc > {
@@ -301,12 +304,8 @@ impl<'gc> Bitmap<'gc> {
301304}
302305
303306impl < ' gc > TDisplayObject < ' gc > for Bitmap < ' gc > {
304- fn base ( & self ) -> Ref < ' _ , DisplayObjectBase < ' gc > > {
305- self . 0 . base . borrow ( )
306- }
307-
308- fn base_mut < ' a > ( & ' a self , mc : & Mutation < ' gc > ) -> RefMut < ' a , DisplayObjectBase < ' gc > > {
309- unlock ! ( Gc :: write( mc, self . 0 ) , BitmapGraphicData , base) . borrow_mut ( )
307+ fn gc_base ( self ) -> Gc < ' gc , RefLock < DisplayObjectBase < ' gc > > > {
308+ HasPrefixField :: as_prefix_gc ( self . 0 )
310309 }
311310
312311 fn instantiate ( self , gc_context : & Mutation < ' gc > ) -> DisplayObject < ' gc > {
0 commit comments