From 941da846b27aec0c6e7e5fb3a4370287a684bf0e Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Sat, 12 Oct 2024 17:55:00 +0200 Subject: [PATCH 1/2] Write colorbuffer directly to io if it fits in format --- src/ffmpeg-util.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ffmpeg-util.jl b/src/ffmpeg-util.jl index b7e7b1bb55c..2bb14ffad61 100644 --- a/src/ffmpeg-util.jl +++ b/src/ffmpeg-util.jl @@ -286,8 +286,12 @@ function recordframe!(io::VideoStream) # Make no copy if already Matrix{RGB{N0f8}} # There may be a 1px padding for odd dimensions xdim, ydim = size(glnative) - copy!(view(io.buffer, 1:xdim, 1:ydim), glnative) - write(io.io, io.buffer) + if eltype(glnative) == eltype(io.buffer) && size(glnative) == size(io.buffer) + write(io.io, glnative) + else + copy!(view(io.buffer, 1:xdim, 1:ydim), glnative) + write(io.io, io.buffer) + end next_tick!(io.tick_controller) return end From d22e95a7ea9a758288ce0b3bab0f67b2d59b4fc4 Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Sat, 12 Oct 2024 18:08:13 +0200 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07748f71d63..53eb7848b01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] +- Improved performance of `record` by avoiding unnecessary copying in common cases [#4475](https://github.com/MakieOrg/Makie.jl/pull/4475). + ## [0.21.14] - 2024-10-11 - Fixed relocatability of GLMakie [#4461](https://github.com/MakieOrg/Makie.jl/pull/4461).