core: Skip a gpu->cpu sync in set_pixels_from_byte_array if we're filling the whole bmd

This commit is contained in:
Nathan Adams 2023-03-31 18:35:45 +02:00 committed by Mike Welsh
parent fcaf462423
commit b07bf84da5
1 changed files with 8 additions and 2 deletions

View File

@ -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 {