Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Sep 26, 2023
1 parent 1bae189 commit 10cd1e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion GLMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ function apply_config!(screen::Screen, config::ScreenConfig; start_renderloop::B
else
stop_renderloop!(screen)
end

if !isnothing(screen.root_scene)
resize!(screen, size(screen.root_scene)...)
end
set_screen_visibility!(screen, config.visible)
return screen
end
Expand Down
6 changes: 5 additions & 1 deletion GLMakie/test/unit_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ end

# save at current size
@test screen.px_per_unit[] == 1
save(file, fig)
save(file, fig; px_per_unit=1)
img = load(file)
@test size(img) == (W, H)
# save with a different resolution
Expand All @@ -328,6 +328,10 @@ end
@test size(img) == (2W, 2H)
# writing to file should not effect the visible figure
@test_broken screen.px_per_unit[] == 1
# Make sure switching back resizes the screen correctly!
save(file, fig; px_per_unit=1)
img = load(file)
@test size(img) == (W, H)
end

# make sure there isn't a race between changing the scale factor and window_area updater
Expand Down
8 changes: 4 additions & 4 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,20 +456,20 @@ function colorbuffer(fig::FigureLike, format::ImageStorageFormat = JuliaNative;
end

# Fallback for any backend that will just use colorbuffer to write out an image
function backend_show(screen::MakieScreen, io::IO, m::MIME"image/png", scene::Scene)
function backend_show(screen::MakieScreen, io::IO, ::MIME"image/png", scene::Scene)
img = colorbuffer(screen)
FileIO.save(FileIO.Stream{FileIO.format"PNG"}(Makie.raw_io(io)), img)
return
end

function backend_show(screen::MakieScreen, io::IO, m::MIME"image/jpeg", scene::Scene)
img = colorbuffer(scene)
function backend_show(screen::MakieScreen, io::IO, ::MIME"image/jpeg", scene::Scene)
img = colorbuffer(screen)
FileIO.save(FileIO.Stream{FileIO.format"JPEG"}(Makie.raw_io(io)), img)
return
end

function backend_show(screen::MakieScreen, io::IO, ::Union{WEB_MIMES...}, scene::Scene)
w, h = widths(scene.px_area[])
w, h = size(scene)
png_io = IOBuffer()
backend_show(screen, png_io, MIME"image/png"(), scene)
b64 = Base64.base64encode(String(take!(png_io)))
Expand Down

0 comments on commit 10cd1e1

Please sign in to comment.