From 4477d6533182c08cea5a34a23fdcaec5996c4fb9 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sun, 2 Apr 2023 21:16:50 +0200 Subject: [PATCH] core: Made overwrite_cpu_pixels_from_gpu take in MutationContext instead of &mut UpdateContext --- core/src/avm1/globals/bitmap_data.rs | 4 ++-- core/src/bitmap/bitmap_data.rs | 6 +++--- core/src/bitmap/operations.rs | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/src/avm1/globals/bitmap_data.rs b/core/src/avm1/globals/bitmap_data.rs index b12bcbced..51da3a403 100644 --- a/core/src/avm1/globals/bitmap_data.rs +++ b/core/src/avm1/globals/bitmap_data.rs @@ -79,7 +79,7 @@ pub fn constructor<'gc>( if let Some(bitmap_data) = this.as_bitmap_data_object() { let (sync, _) = bitmap_data .bitmap_data() - .overwrite_cpu_pixels_from_gpu(&mut activation.context); + .overwrite_cpu_pixels_from_gpu(activation.context.gc_context); sync.write(activation.context.gc_context).init_pixels( width, height, @@ -1363,7 +1363,7 @@ pub fn load_bitmap<'gc>( .as_bitmap_data_object() .unwrap() .bitmap_data() - .overwrite_cpu_pixels_from_gpu(&mut activation.context); + .overwrite_cpu_pixels_from_gpu(activation.context.gc_context); sync.write(activation.context.gc_context) .set_pixels(width, height, true, pixels); diff --git a/core/src/bitmap/bitmap_data.rs b/core/src/bitmap/bitmap_data.rs index 6122239eb..407f66281 100644 --- a/core/src/bitmap/bitmap_data.rs +++ b/core/src/bitmap/bitmap_data.rs @@ -232,7 +232,7 @@ enum DirtyState { mod wrapper { use crate::avm2::{Object as Avm2Object, Value as Avm2Value}; - use crate::context::{RenderContext, UpdateContext}; + use crate::context::RenderContext; use gc_arena::{Collect, GcCell, MutationContext}; use ruffle_render::backend::RenderBackend; use ruffle_render::bitmap::{BitmapHandle, PixelRegion}; @@ -344,9 +344,9 @@ mod wrapper { #[allow(clippy::type_complexity)] pub fn overwrite_cpu_pixels_from_gpu( &self, - context: &mut UpdateContext<'_, 'gc>, + mc: MutationContext<'gc, '_>, ) -> (GcCell<'gc, BitmapData<'gc>>, Option) { - let mut write = self.0.write(context.gc_context); + let mut write = self.0.write(mc); let dirty_rect = match write.dirty_state { DirtyState::GpuModified(_, rect) => { write.dirty_state = DirtyState::Clean; diff --git a/core/src/bitmap/operations.rs b/core/src/bitmap/operations.rs index 8cf3f1104..8c070c379 100644 --- a/core/src/bitmap/operations.rs +++ b/core/src/bitmap/operations.rs @@ -40,7 +40,7 @@ pub fn fill_rect<'gc>( let target = if rect.width() == target.width() && rect.height() == target.height() { // If we're filling the whole region, we can discard the gpu data - target.overwrite_cpu_pixels_from_gpu(context).0 + target.overwrite_cpu_pixels_from_gpu(context.gc_context).0 } else { // If we're filling a partial region, finish any gpu->cpu sync target.sync() @@ -177,7 +177,7 @@ pub fn noise<'gc>( channel_options: ChannelOptions, gray_scale: bool, ) { - let (target, _) = target.overwrite_cpu_pixels_from_gpu(context); + let (target, _) = target.overwrite_cpu_pixels_from_gpu(context.gc_context); let mut write = target.write(context.gc_context); let true_seed = if seed <= 0 { @@ -247,7 +247,7 @@ pub fn perlin_noise<'gc>( grayscale: bool, offsets: Vec<(f64, f64)>, // must contain `num_octaves` values ) { - let (target, _) = target.overwrite_cpu_pixels_from_gpu(context); + let (target, _) = target.overwrite_cpu_pixels_from_gpu(context.gc_context); let mut write = target.write(context.gc_context); let turb = Turbulence::from_seed(random_seed); @@ -1184,7 +1184,7 @@ pub fn apply_filter<'gc>( filter: Filter, ) { let source_handle = source.bitmap_handle(context.gc_context, context.renderer); - let (target, _) = target.overwrite_cpu_pixels_from_gpu(context); + let (target, _) = target.overwrite_cpu_pixels_from_gpu(context.gc_context); let mut write = target.write(context.gc_context); let dest = write.bitmap_handle(context.renderer).unwrap(); @@ -1293,7 +1293,7 @@ pub fn draw<'gc>( commands }; - let (target, include_dirty_area) = target.overwrite_cpu_pixels_from_gpu(context); + let (target, include_dirty_area) = target.overwrite_cpu_pixels_from_gpu(context.gc_context); let mut write = target.write(context.gc_context); // If we have another dirty area to preserve, expand this to include it if let Some(old) = include_dirty_area { @@ -1375,7 +1375,7 @@ pub fn set_pixels_from_byte_array<'gc>( let target = if region.width() == target.width() && region.height() == target.height() { // If we're filling the whole region, we can discard the gpu data - target.overwrite_cpu_pixels_from_gpu(context).0 + target.overwrite_cpu_pixels_from_gpu(context.gc_context).0 } else { // If we're filling a partial region, finish any gpu->cpu sync target.sync()