Skip to content

Commit

Permalink
Revert changing the meaning of size(::GLMakie.Screen)
Browse files Browse the repository at this point in the history
This was causing problems with setting up the stream size for video
outputs. Instead, just grab the scene size where necessary explicitly.
  • Loading branch information
jmert committed Jan 7, 2023
1 parent 0c76603 commit 20ca7a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions GLMakie/src/picking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function pick_native(screen::Screen, rect::Rect2i)
glReadBuffer(GL_COLOR_ATTACHMENT1)
rx, ry = minimum(rect)
rw, rh = widths(rect)
w, h = size(screen)
w, h = size(screen.root_scene)
if rx > 0 && ry > 0 && rx + rw <= w && ry + rh <= h
rx, ry, rw, rh = round.(Int, screen.px_per_unit[] .* (rx, ry, rw, rh))
sid = zeros(SelectionID{UInt32}, rw, rh)
Expand All @@ -31,7 +31,7 @@ function pick_native(screen::Screen, xy::Vec{2, Float64})
glBindFramebuffer(GL_FRAMEBUFFER, fb.id[1])
glReadBuffer(GL_COLOR_ATTACHMENT1)
x, y = floor.(Int, xy)
w, h = size(screen)
w, h = size(screen.root_scene)
if x > 0 && y > 0 && x <= w && y <= h
x, y = round.(Int, screen.px_per_unit[] .* (x, y))
sid = Base.RefValue{SelectionID{UInt32}}()
Expand Down Expand Up @@ -65,7 +65,7 @@ end
# Skips one set of allocations
function Makie.pick_closest(scene::Scene, screen::Screen, xy, range)
isopen(screen) || return (nothing, 0)
w, h = size(screen)
w, h = size(scene)
((1.0 <= xy[1] <= w) && (1.0 <= xy[2] <= h)) || return (nothing, 0)

x0, y0 = max.(1, floor.(Int, xy .- range))
Expand Down Expand Up @@ -95,7 +95,7 @@ end
# Skips some allocations
function Makie.pick_sorted(scene::Scene, screen::Screen, xy, range)
isopen(screen) || return (nothing, 0)
w, h = size(screen)
w, h = size(scene)
if !((1.0 <= xy[1] <= w) && (1.0 <= xy[2] <= h))
return Tuple{AbstractPlot, Int}[]
end
Expand Down
6 changes: 3 additions & 3 deletions GLMakie/src/rendering.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function setup!(screen::Screen)
glEnable(GL_SCISSOR_TEST)
if isopen(screen)
if isopen(screen) && !isnothing(screen.root_scene)
sf = screen.px_per_unit[]
glScissor(0, 0, round.(Int, size(screen) .* sf)...)
glScissor(0, 0, round.(Int, size(screen.root_scene) .* sf)...)
glClearColor(1, 1, 1, 1)
glClear(GL_COLOR_BUFFER_BIT)
for (id, scene) in screen.screens
Expand Down Expand Up @@ -47,7 +47,7 @@ function render_frame(screen::Screen; resize_buffers=true)
fb = screen.framebuffer
if resize_buffers && !isnothing(screen.root_scene)
sf = screen.px_per_unit[]
resize!(fb, round.(Int, sf .* size(screen))...)
resize!(fb, round.(Int, sf .* size(screen.root_scene))...)
end

# prepare stencil (for sub-scenes)
Expand Down
4 changes: 2 additions & 2 deletions GLMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ Base.wait(scene::Scene) = wait(Makie.getscreen(scene))
Base.show(io::IO, screen::Screen) = print(io, "GLMakie.Screen(...)")

Base.isopen(x::Screen) = isopen(x.glscreen)
Base.size(x::Screen) = !isnothing(x.root_scene) ? size(x.root_scene) : (0, 0)
Base.size(x::Screen) = size(x.framebuffer)

function Makie.insertplots!(screen::Screen, scene::Scene)
ShaderAbstractions.switch_context!(screen.glscreen)
Expand Down Expand Up @@ -801,7 +801,7 @@ function scalechangecb(screen, window, xscale, yscale)
screen.px_per_unit[] = sf
end
screen.scalefactor[] = sf
resize!(screen, size(screen)...)
resize!(screen, size(screen.root_scene)...)
return
end

Expand Down

0 comments on commit 20ca7a0

Please sign in to comment.