|
2 | 2 |
|
3 | 3 | use crate::avm1::{Object as Avm1Object, StageObject as Avm1StageObject}; |
4 | 4 | use crate::avm2::{Object as Avm2Object, StageObject as Avm2StageObject}; |
5 | | -use crate::backend::render::BitmapHandle; |
| 5 | +use crate::backend::render::BitmapInfo; |
6 | 6 | use crate::backend::video::{EncodedFrame, VideoStreamHandle}; |
7 | 7 | use crate::bounding_box::BoundingBox; |
8 | 8 | use crate::collect::CollectWrapper; |
@@ -40,7 +40,7 @@ pub struct VideoData<'gc> { |
40 | 40 | stream: VideoStream, |
41 | 41 |
|
42 | 42 | /// The last decoded frame in the video stream. |
43 | | - decoded_frame: Option<(u32, CollectWrapper<BitmapHandle>)>, |
| 43 | + decoded_frame: Option<(u32, CollectWrapper<BitmapInfo>)>, |
44 | 44 |
|
45 | 45 | /// AVM representation of this video player. |
46 | 46 | object: Option<AvmObject<'gc>>, |
@@ -248,7 +248,6 @@ impl<'gc> Video<'gc> { |
248 | 248 | context |
249 | 249 | .video |
250 | 250 | .decode_video_stream_frame(*stream, encframe, context.renderer) |
251 | | - .map(|bi| bi.handle) |
252 | 251 | } |
253 | 252 | None => { |
254 | 253 | if let Some((_old_id, old_frame)) = &read.decoded_frame { |
@@ -415,9 +414,19 @@ impl<'gc> TDisplayObject<'gc> for Video<'gc> { |
415 | 414 | context.transform_stack.push(&*self.transform()); |
416 | 415 |
|
417 | 416 | if let Some((_frame_id, ref bitmap)) = self.0.read().decoded_frame { |
| 417 | + let mut transform = context.transform_stack.transform().clone(); |
| 418 | + let bounds = self.self_bounds(); |
| 419 | + |
| 420 | + // The actual decoded frames might be different in size than the declared |
| 421 | + // bounds of the VideoStream tag, so a final scale adjustment has to be done. |
| 422 | + transform.matrix *= Matrix::scale( |
| 423 | + bounds.width().to_pixels() as f32 / bitmap.0.width as f32, |
| 424 | + bounds.height().to_pixels() as f32 / bitmap.0.height as f32, |
| 425 | + ); |
| 426 | + |
418 | 427 | context |
419 | 428 | .renderer |
420 | | - .render_bitmap(bitmap.0, context.transform_stack.transform(), false); |
| 429 | + .render_bitmap(bitmap.0.handle, &transform, false); |
421 | 430 | } else { |
422 | 431 | log::warn!("Video has no decoded frame to render."); |
423 | 432 | } |
|
0 commit comments