From b07bf84da51ac20fa90929e1012efe5ab033c41e Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Fri, 31 Mar 2023 18:35:45 +0200 Subject: [PATCH] core: Skip a gpu->cpu sync in set_pixels_from_byte_array if we're filling the whole bmd --- core/src/bitmap/operations.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/bitmap/operations.rs b/core/src/bitmap/operations.rs index 7cf17ad55..022a434e6 100644 --- a/core/src/bitmap/operations.rs +++ b/core/src/bitmap/operations.rs @@ -1364,9 +1364,15 @@ pub fn set_pixels_from_byte_array<'gc>( ) -> Result<(), EofError> { let mut region = PixelRegion::for_region_i32(x, y, width, height); region.clamp(target.width(), target.height()); - let transparency = target.transparency(); - let target = target.sync(); + + 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 + } else { + // If we're filling a partial region, finish any gpu->cpu sync + target.sync() + }; let mut write = target.write(context.gc_context); if region.width() > 0 && region.height() > 0 {