From bf76264b35b4cfbb8e60f82b18f8759c46af8ee7 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 5 Nov 2024 16:27:59 +0100 Subject: [PATCH] Introduce isclosed(scene), conditionally use `Bonito.LargeUpdate` (#4569) * try large update for Samplers (e.g. heatmap data update) * introduce isclosed + conditionally use Bonito.LargeUpdate * fix tests * add changelog * allow new Bonito versions --- CHANGELOG.md | 1 + GLMakie/test/unit_tests.jl | 3 +++ WGLMakie/Project.toml | 2 +- WGLMakie/src/serialization.jl | 5 +++-- src/scenes.jl | 12 ++++++++++-- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d73e4b9b8be..207f05f34a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +- Introduce `isclosed(scene)`, conditionally use `Bonito.LargeUpdate` [#4569](https://github.com/MakieOrg/Makie.jl/pull/4569). - Allow plots to move between scenes in SpecApi [#4132](https://github.com/MakieOrg/Makie.jl/pull/4132). - Added empty constructor to all backends for `Screen` allowing `display(Makie.current_backend().Screen(), fig)` [#4561](https://github.com/MakieOrg/Makie.jl/pull/4561). - Added `subsup` and `left_subsup` functions that offer stacked sub- and superscripts for `rich` text which means this style can be used with arbitrary fonts and is not limited to fonts supported by MathTeXEngine.jl [#4489](https://github.com/MakieOrg/Makie.jl/pull/4489). diff --git a/GLMakie/test/unit_tests.jl b/GLMakie/test/unit_tests.jl index 2da385dbbe3..2f7a380570c 100644 --- a/GLMakie/test/unit_tests.jl +++ b/GLMakie/test/unit_tests.jl @@ -89,6 +89,9 @@ end # assure we correctly close screen and remove it from plot @test getscreen(ax.scene) === nothing @test !events(ax.scene).window_open[] + # Because of on(scene.events.window_open) in scene, we need to free all scenes first + # to have 0 listeners + empty!(fig) @test isempty(events(ax.scene).window_open.listeners) # Test singleton screen replacement diff --git a/WGLMakie/Project.toml b/WGLMakie/Project.toml index bf3a3d33a64..2c617453b8f 100644 --- a/WGLMakie/Project.toml +++ b/WGLMakie/Project.toml @@ -20,7 +20,7 @@ ShaderAbstractions = "65257c39-d410-5151-9873-9b3e5be5013e" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] -Bonito = "3.2.4" +Bonito = "3.2.4, 4" Colors = "0.11, 0.12, 0.13" FileIO = "1.1" FreeTypeAbstraction = "0.10" diff --git a/WGLMakie/src/serialization.jl b/WGLMakie/src/serialization.jl index 527e361750b..5453cee762a 100644 --- a/WGLMakie/src/serialization.jl +++ b/WGLMakie/src/serialization.jl @@ -222,12 +222,13 @@ function register_geometry_updates(@nospecialize(plot), update_buffer::Observabl end function uniform_updater(@nospecialize(plot), uniforms::Dict) - updater = Observable(Any[:none, []]) + updater = Observable{Any}(Any[:none, []]) for (name, value) in uniforms if value isa Sampler on(plot, ShaderAbstractions.updater(value).update) do (f, args) if f === ShaderAbstractions.update! - updater[] = [name, [Int32[size(value.data)...], serialize_three(args[1])]] + update = [name, [Int32[size(value.data)...], serialize_three(args[1])]] + updater[] = isdefined(Bonito, :LargeUpdate) ? Bonito.LargeUpdate(update) : update end return end diff --git a/src/scenes.jl b/src/scenes.jl index fd1f12d16de..b98e3db675c 100644 --- a/src/scenes.jl +++ b/src/scenes.jl @@ -93,6 +93,7 @@ mutable struct Scene <: AbstractScene cycler::Cycler conversions::DimConversions + isclosed::Bool function Scene( parent::Union{Nothing, Scene}, @@ -131,13 +132,21 @@ mutable struct Scene <: AbstractScene convert(Vector{AbstractLight}, lights), deregister_callbacks, Cycler(), - DimConversions() + DimConversions(), + false ) + on(scene, events.window_open) do open + if !open + scene.isclosed = true + end + end finalizer(free, scene) return scene end end +isclosed(scene::Scene) = scene.isclosed + # on & map versions that deregister when scene closes! function Observables.on(@nospecialize(f), @nospecialize(scene::Union{Plot,Scene}), @nospecialize(observable::Observable); update=false, priority=0) to_deregister = on(f, observable; update=update, priority=priority)::Observables.ObserverFunction @@ -538,7 +547,6 @@ end # return # end - function move_to!(plot::Plot, scene::Scene) if plot.parent === scene return