diff --git a/CairoMakie/src/infrastructure.jl b/CairoMakie/src/infrastructure.jl index 40bcb33847f..0aa4216e353 100644 --- a/CairoMakie/src/infrastructure.jl +++ b/CairoMakie/src/infrastructure.jl @@ -173,6 +173,7 @@ function cairo_draw(screen::CairoScreen, scene::Scene) # only prepare for scene when it changes # this should reduce the number of unnecessary clipping masks etc. pparent = p.parent::Scene + pparent.visible[] || continue if pparent != last_scene Cairo.restore(screen.context) Cairo.save(screen.context) @@ -390,7 +391,7 @@ function Makie.backend_show(x::CairoBackend, io::IO, ::MIME"image/png", scene::S # while relative line and font sizes are unaffected px_per_unit = get(io, :px_per_unit, x.px_per_unit) antialias = get(io, :antialias, x.antialias) - + # create an ARGB surface, to speed up drawing ops. screen = CairoScreen(scene; device_scaling_factor = px_per_unit, antialias = antialias) cairo_draw(screen, scene) diff --git a/GLMakie/src/rendering.jl b/GLMakie/src/rendering.jl index 288eb064c18..ea23022d61a 100644 --- a/GLMakie/src/rendering.jl +++ b/GLMakie/src/rendering.jl @@ -227,7 +227,7 @@ function GLAbstraction.render(filter_elem_func, screen::GLScreen) found, scene = id2scene(screen, screenid) found || continue - + scene.visible[] || continue a = pixelarea(scene)[] glViewport(minimum(a)..., widths(a)...) if scene.clear diff --git a/ReferenceTests/src/tests/short_tests.jl b/ReferenceTests/src/tests/short_tests.jl index 867237cb97c..d4103814562 100644 --- a/ReferenceTests/src/tests/short_tests.jl +++ b/ReferenceTests/src/tests/short_tests.jl @@ -222,3 +222,13 @@ end Colorbar(f[1, 1]; size = 200) f end + +@reference_test "scene visibility" begin + f, ax, pl = scatter(1:4, markersize=200) + ax2, pl = scatter(f[1, 2][1, 1], 1:4, color=1:4, markersize=200) + ax3, pl = scatter(f[1, 2][2, 1], 1:4, color=1:4, markersize=200) + ax3.scene.visible[] = false + ax2.scene.visible[] = false + ax2.blockscene.visible[] = false + f +end diff --git a/WGLMakie/src/serialization.jl b/WGLMakie/src/serialization.jl index 05f1650dd18..f1dad93b487 100644 --- a/WGLMakie/src/serialization.jl +++ b/WGLMakie/src/serialization.jl @@ -255,6 +255,7 @@ function serialize_scene(scene::Scene, serialized_scenes=[]) else nothing end + serialized = Dict(:pixelarea => pixel_area, :backgroundcolor => lift(hexcolor, scene.backgroundcolor), :clearscene => scene.clear, diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index 8e65a44a817..54b5517e335 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -71,7 +71,7 @@ const WGLMakie = (function () { 0.0, 0.0, 0.0, 1.0 ); const id = new THREE.Uniform(new THREE.Matrix4()); - + if (plot_data.cam_space == "data") { plot_data.uniforms.view = cam.view; plot_data.uniforms.projection = cam.projection; @@ -446,7 +446,7 @@ const WGLMakie = (function () { scene.pixelarea = data.pixelarea; scene.backgroundcolor = data.backgroundcolor; scene.clearscene = data.clearscene; - + scene.visible = data.visible; const cam = { view: new THREE.Uniform(new THREE.Matrix4()), projection: new THREE.Uniform(new THREE.Matrix4()), @@ -599,7 +599,7 @@ const WGLMakie = (function () { function render_scene(renderer, scene, cam) { renderer.autoClear = scene.clearscene; const area = JSServe.get_observable(scene.pixelarea); - if (area) { + if (area && JSServe.get_observable(scene.visible)) { const [x, y, w, h] = area.map(t => t / pixelRatio); renderer.setViewport(x, y, w, h); renderer.setScissor(x, y, w, h);