Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Nov 6, 2024
2 parents adc60bc + 4ff461e commit 2621be5
Show file tree
Hide file tree
Showing 96 changed files with 1,520 additions and 851 deletions.
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

## [Unreleased]

- Correctly render the tooltip triangle [#4560](https://github.com/MakieOrg/Makie.jl/pull/4560).
- 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).
- Added the `jitter_width` and `side_nudge` attributes to the `raincloud` plot definition, so that they can be used as kwargs [#4517]https://github.com/MakieOrg/Makie.jl/pull/4517)
- Expand PlotList plots to expose their child plots to the legend interface, allowing `axislegend`show plots within PlotSpecs as individual entries. [#4546](https://github.com/MakieOrg/Makie.jl/pull/4546)
- Implement S.Colorbar(plotspec) [#4520](https://github.com/MakieOrg/Makie.jl/pull/4520).
- Fixed a hang when `Record` was created inside a closure passed to `IOCapture.capture` [#4562](https://github.com/MakieOrg/Makie.jl/pull/4562).
- Added logical size annotation to `text/html` inline videos so that sizes are appropriate independent of the current `px_per_unit` value [#4563](https://github.com/MakieOrg/Makie.jl/pull/4563).

## [0.21.15] - 2024-10-25

Expand Down Expand Up @@ -167,7 +176,7 @@
- `boundingbox` overwrites must now include a secondary space argument to work `boundingbox(plot, space::Symbol = :data)` [#3723](https://github.com/MakieOrg/Makie.jl/pull/3723)
- `boundingbox` now always consider `transform_func` and `model`
- `data_limits(::Scatter)` and `boundingbox(::Scatter)` now consider marker transformations [#3716](https://github.com/MakieOrg/Makie.jl/pull/3716)
- **Breaking** Improved Float64 compatability of Axis [#3681](https://github.com/MakieOrg/Makie.jl/pull/3681)
- **Breaking** Improved Float64 compatibility of Axis [#3681](https://github.com/MakieOrg/Makie.jl/pull/3681)
- This added an extra conversion step which only takes effect when Float32 precision becomes relevant. In those cases code using `project()` functions will be wrong as the transformation is not applied. Use `project(plot_or_scene, ...)` or apply the conversion yourself beforehand with `Makie.f32_convert(plot_or_scene, transformed_point)` and use `patched_model = Makie.patch_model(plot_or_scene, model)`.
- `Makie.to_world(point, matrix, resolution)` has been deprecated in favor of `Makie.to_world(scene_or_plot, point)` to include float32 conversions.
- **Breaking** Reworked line shaders in GLMakie and WGLMakie [#3558](https://github.com/MakieOrg/Makie.jl/pull/3558)
Expand Down Expand Up @@ -228,7 +237,7 @@
## [0.20.7] - 2024-02-04

- Equalized alignment point of mirrored ticks to that of normal ticks [#3598](https://github.com/MakieOrg/Makie.jl/pull/3598).
- Fixed stack overflow error on conversion of gridlike data with missings [#3597](https://github.com/MakieOrg/Makie.jl/pull/3597).
- Fixed stack overflow error on conversion of gridlike data with `missing`s [#3597](https://github.com/MakieOrg/Makie.jl/pull/3597).
- Fixed mutation of CairoMakie src dir when displaying png files [#3588](https://github.com/MakieOrg/Makie.jl/pull/3588).
- Added better error messages for plotting into `FigureAxisPlot` and `AxisPlot` as Plots.jl users are likely to do [#3596](https://github.com/MakieOrg/Makie.jl/pull/3596).
- Added compat bounds for IntervalArithmetic.jl due to bug with DelaunayTriangulation.jl [#3595](https://github.com/MakieOrg/Makie.jl/pull/3595).
Expand All @@ -244,7 +253,7 @@
- Use plot plot instead of scene transform functions in CairoMakie, fixing missplaced h/vspan. [#3552](https://github.com/MakieOrg/Makie.jl/pull/3552)
- Fix error printing on shader error [#3530](https://github.com/MakieOrg/Makie.jl/pull/3530).
- Update pagefind to 1.0.4 for better headline search [#3534](https://github.com/MakieOrg/Makie.jl/pull/3534).
- Remove unecessary deps, e.g. Setfield [3546](https://github.com/MakieOrg/Makie.jl/pull/3546).
- Remove unnecessary deps, e.g. Setfield [3546](https://github.com/MakieOrg/Makie.jl/pull/3546).
- Don't clear args, rely on delete deregister_callbacks [#3543](https://github.com/MakieOrg/Makie.jl/pull/3543).
- Add interpolate keyword for Surface [#3541](https://github.com/MakieOrg/Makie.jl/pull/3541).
- Fix a DataInspector bug if inspector_label is used with RGB images [#3468](https://github.com/MakieOrg/Makie.jl/pull/3468).
Expand Down Expand Up @@ -589,7 +598,7 @@ role as `datalimits` in `violin` [#2137](https://github.com/MakieOrg/Makie.jl/pu
- **Breaking** Cleaned up `Scene` type [#1192](https://github.com/MakieOrg/Makie.jl/pull/1192), [#1393](https://github.com/MakieOrg/Makie.jl/pull/1393). The `Scene()` constructor doesn't create any axes or limits anymore. All keywords like `raw`, `show_axis` have been removed. A scene now always works like it did when using the deprecated `raw=true`. All the high level functionality like showing an axis and adding a 3d camera has been moved to `LScene`. See the new `Scene` tutorial for more info: https://docs.makie.org/dev/tutorials/scenes/.
- **Breaking** Lights got moved to `Scene`, see the [lighting docs](https://docs.makie.org/stable/documentation/lighting) and [RPRMakie examples](https://docs.makie.org/stable/documentation/backends/rprmakie/).
- Added ECDF plot [#1310](https://github.com/MakieOrg/Makie.jl/pull/1310).
- Added Order Independent Transparency to GLMakie [#1418](https://github.com/MakieOrg/Makie.jl/pull/1418), [#1506](https://github.com/MakieOrg/Makie.jl/pull/1506). This type of transparency is now used with `transpareny = true`. The old transparency handling is available with `transparency = false`.
- Added Order Independent Transparency to GLMakie [#1418](https://github.com/MakieOrg/Makie.jl/pull/1418), [#1506](https://github.com/MakieOrg/Makie.jl/pull/1506). This type of transparency is now used with `transparency = true`. The old transparency handling is available with `transparency = false`.
- Fixed blurry text in GLMakie and WGLMakie [#1494](https://github.com/MakieOrg/Makie.jl/pull/1494).
- Introduced a new experimental backend for ray tracing: [RPRMakie](https://docs.makie.org/stable/documentation/backends/rprmakie/).
- Added the `Cycled` type, which can be used to select the i-th value from the current cycler for a specific attribute [#1248](https://github.com/MakieOrg/Makie.jl/pull/1248).
Expand Down
6 changes: 4 additions & 2 deletions CairoMakie/src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ function Base.display(screen::Screen, scene::Scene; connect=false)
return screen
end

function Base.display(screen::Screen{IMAGE}, scene::Scene; connect=false)
function Base.display(screen::Screen{IMAGE}, scene::Scene; connect=false, screen_config...)
config = Makie.merge_screen_config(ScreenConfig, Dict{Symbol,Any}(screen_config))
screen = Makie.apply_screen_config!(screen, config, scene)
path = joinpath(mktempdir(), "display.png")
Makie.push_screen!(scene, screen)
cairo_draw(screen, scene)
Expand Down Expand Up @@ -80,7 +82,7 @@ function Makie.backend_show(screen::Screen{SVG}, io::IO, ::MIME"image/svg+xml",
# xlink:href="someid" (but not xlink:href="data:someothercontent" which is how image data is attached)
# url(#someid)
svg = replace(svg, r"((?:(?:id|xlink:href)=\"(?!data:)[^\"]+)|url\(#[^)]+)" => SubstitutionString("\\1-$salt"))

print(io, svg)
return screen
end
Expand Down
8 changes: 3 additions & 5 deletions CairoMakie/src/infrastructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ function cairo_draw(screen::Screen, scene::Scene)
draw_background(screen, scene)

allplots = Makie.collect_atomic_plots(scene; is_atomic_plot = is_cairomakie_atomic_plot)
zvals = Makie.zvalue2d.(allplots)
permute!(allplots, sortperm(zvals))

sort!(allplots; by=Makie.zvalue2d)
# If the backend is not a vector surface (i.e., PNG/ARGB),
# then there is no point in rasterizing twice.
should_rasterize = is_vector_backend(screen.surface)
Expand Down Expand Up @@ -120,7 +118,7 @@ function draw_background(screen::Screen, scene::Scene, root_h)
bg = scene.backgroundcolor[]
Cairo.set_source_rgba(cr, red(bg), green(bg), blue(bg), alpha(bg));
r = viewport(scene)[]
# Makie has (0,0) at bottom left, Cairo at top left. Makie extends up,
# Makie has (0,0) at bottom left, Cairo at top left. Makie extends up,
# Cairo down. Negative height breaks other backgrounds
x, y = origin(r); w, h = widths(r)
Cairo.rectangle(cr, x, root_h - y - h, w, h) # background
Expand Down Expand Up @@ -154,7 +152,7 @@ end
function draw_plot_as_image(scene::Scene, screen::Screen{RT}, primitive::Plot, scale::Number = 1) where RT
# you can provide `p.rasterize = scale::Int` or `p.rasterize = true`, both of which are numbers

# Extract scene width in device indepentent units
# Extract scene width in device independent units
w, h = size(scene)
# Create a new Screen which renders directly to an image surface,
# specifically for the plot's parent scene.
Expand Down
4 changes: 2 additions & 2 deletions CairoMakie/src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ end
function draw_mesh2D(screen, per_face_cols, vs::Vector{<: Point2}, fs::Vector{GLTriangleFace})

ctx = screen.context
# Priorize colors of the mesh if present
# Prioritize colors of the mesh if present
# This is a hack, which needs cleaning up in the Mesh plot type!

for (f, (c1, c2, c3)) in zip(fs, per_face_cols)
Expand Down Expand Up @@ -984,7 +984,7 @@ function draw_mesh3D(
meshuvs = map(uv -> uv_transform * to_ndim(Vec3f, uv, 1), meshuvs)
end

# Priorize colors of the mesh if present
# Prioritize colors of the mesh if present
color = hasproperty(mesh, :color) ? mesh.color : to_value(attributes.calculated_colors)
per_face_col = per_face_colors(color, matcap, meshfaces, meshnormals, meshuvs)

Expand Down
33 changes: 32 additions & 1 deletion CairoMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,31 @@ mutable struct Screen{SurfaceRenderType} <: Makie.MakieScreen
antialias::Int # cairo_antialias_t
visible::Bool
config::ScreenConfig

function Screen()
return new{IMAGE}()
end
function Screen{SurfaceRenderType}(
scene::Scene,
surface::Cairo.CairoSurface,
context::Cairo.CairoContext,
device_scaling_factor::Float64,
antialias::Int,
visible::Bool,
config::ScreenConfig
) where {SurfaceRenderType}

return new{SurfaceRenderType}(
scene,
surface,
context,
device_scaling_factor,
antialias,
visible,
config,
)
end

end

function Base.empty!(screen::Screen)
Expand All @@ -192,6 +217,7 @@ end
Base.close(screen::Screen) = empty!(screen)

function destroy!(screen::Screen)
isdefined(screen, :surface) || return
Cairo.destroy(screen.surface)
Cairo.destroy(screen.context)
end
Expand All @@ -200,7 +226,10 @@ function Base.isopen(screen::Screen)
return !(screen.surface.ptr == C_NULL || screen.context.ptr == C_NULL)
end

Base.size(screen::Screen) = round.(Int, (screen.surface.width, screen.surface.height))
function Base.size(screen::Screen)
isdefined(screen, :surface) || return (0, 0)
round.(Int, (screen.surface.width, screen.surface.height))
end
# we render the scene directly, since we have
# no screen dependent state like in e.g. opengl
Base.insert!(screen::Screen, scene::Scene, plot) = nothing
Expand Down Expand Up @@ -267,6 +296,7 @@ function Makie.apply_screen_config!(
destroy!(old_screen)
end
apply_config!(screen, config)
screen.scene = scene
return screen
end

Expand All @@ -275,6 +305,7 @@ function Makie.apply_screen_config!(screen::Screen, config::ScreenConfig, scene:
Makie.apply_screen_config!(screen, config, scene, nothing, MIME"image/png"())
end


function Screen(scene::Scene; screen_config...)
config = Makie.merge_screen_config(ScreenConfig, Dict{Symbol, Any}(screen_config))
return Screen(scene, config)
Expand Down
9 changes: 8 additions & 1 deletion CairoMakie/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ end
@testset "VideoStream & screen options" begin
N = 3
points = Observable(Point2f[])
f, ax, pl = scatter(points, axis=(type=Axis, aspect=DataAspect(), limits=(0.4, N + 0.6, 0.4, N + 0.6),), figure=(size=(600, 800),))
width = 600
height = 800
f, ax, pl = scatter(points, axis=(type=Axis, aspect=DataAspect(), limits=(0.4, N + 0.6, 0.4, N + 0.6),), figure=(size=(width, height),))

vio = Makie.VideoStream(f; format="mp4", px_per_unit=2.0, backend=CairoMakie)
tmp_path = vio.path
Expand All @@ -132,6 +134,11 @@ end
@test vio.screen.device_scaling_factor == 2.0

Makie.recordframe!(vio)

html = repr(MIME"text/html"(), vio)
@test occursin("width=\"$width\"", html)
@test occursin("height=\"$height\"", html)

save("test.mp4", vio)
save("test_2.mkv", vio)
save("test_3.mp4", vio)
Expand Down
2 changes: 1 addition & 1 deletion CairoMakie/test/svg_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ end
@test svg_isnt_rasterized(poly(MultiPolyWrapper([poly1, poly1]); color=[:red, :blue]))
end

@testset "reproducable svg ids" begin
@testset "reproducible svg ids" begin
# https://github.com/MakieOrg/Makie.jl/issues/2406
f, ax, sc = scatter(1:10)
save("test1.svg", f)
Expand Down
2 changes: 1 addition & 1 deletion GLMakie/src/GLAbstraction/AbstractGPUArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ max_dim(t) = error("max_dim not implemented for: $(typeof(t)). This happen

function (::Type{GPUArrayType})(data::Observable; kw...) where GPUArrayType <: GPUArray
gpu_mem = GPUArrayType(data[]; kw...)
# TODO merge these and handle update tracking during contruction
# TODO merge these and handle update tracking during construction
obs2 = on(new_data -> update!(gpu_mem, new_data), data)
if GPUArrayType <: TextureBuffer
push!(gpu_mem.buffer.observers, obs2)
Expand Down
2 changes: 1 addition & 1 deletion GLMakie/src/GLAbstraction/GLAbstraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export update! # updates a gpu array with a Julia array
export gpu_data # gets the data of a gpu array as a Julia Array

export RenderObject # An object which holds all GPU handles and datastructes to ready for rendering by calling render(obj)
export prerender! # adds a function to a RenderObject, which gets executed befor setting the OpenGL render state
export prerender! # adds a function to a RenderObject, which gets executed before setting the OpenGL render state
export postrender! # adds a function to a RenderObject, which gets executed after setting the OpenGL render states
export extract_renderable
export set_arg!
Expand Down
9 changes: 4 additions & 5 deletions GLMakie/src/GLAbstraction/GLRender.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ function render(list::Tuple)
return
end

function setup_clip_planes(robj)
N = to_value(get(robj.uniforms, :num_clip_planes, 0))
function setup_clip_planes(N::Integer)
for i in 0:min(7, N-1)
glEnable(GL_CLIP_DISTANCE0 + UInt32(i))
end
Expand All @@ -22,13 +21,13 @@ When rendering a specialised list of Renderables, we can do some optimizations
function render(list::Vector{RenderObject{Pre}}) where Pre
isempty(list) && return nothing
first(list).prerenderfunction()
setup_clip_planes(first(list))
vertexarray = first(list).vertexarray
program = vertexarray.program
glUseProgram(program.id)
bind(vertexarray)
for renderobject in list
renderobject.visible || continue # skip invisible
setup_clip_planes(to_value(get(renderobject.uniforms, :num_clip_planes, 0)))
# make sure we only bind new programs and vertexarray when it is actually
# different from the previous one
if renderobject.vertexarray != vertexarray
Expand Down Expand Up @@ -70,7 +69,7 @@ a lot of objects.
function render(renderobject::RenderObject, vertexarray=renderobject.vertexarray)
if renderobject.visible
renderobject.prerenderfunction()
setup_clip_planes(renderobject)
setup_clip_planes(to_value(get(renderobject.uniforms, :num_clip_planes, 0)))
program = vertexarray.program
glUseProgram(program.id)
for (key, value) in program.uniformloc
Expand Down Expand Up @@ -160,7 +159,7 @@ function renderinstanced(vao::GLVertexArray{GLBuffer{T}}, amount::Integer, primi
end

"""
Renders `amount` instances of an not indexed geoemtry geometry
Renders `amount` instances of an not indexed geometry geometry
"""
function renderinstanced(vao::GLVertexArray, amount::Integer, primitive=GL_TRIANGLES)
glDrawElementsInstanced(primitive, length(vao), GL_UNSIGNED_INT, C_NULL, amount)
Expand Down
8 changes: 4 additions & 4 deletions GLMakie/src/GLAbstraction/GLRenderObject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function (sp::StandardPrerender)()
glDepthFunc(GL_LEQUAL)
end

# Disable cullface for now, untill all rendering code is corrected!
# Disable cullface for now, until all rendering code is corrected!
glDisable(GL_CULL_FACE)
# glCullFace(GL_BACK)

Expand Down Expand Up @@ -69,14 +69,14 @@ function (sp::StandardPostrender)()
render(sp.vao, sp.primitive)
end

struct StandardPostrenderInstanced{T}
main::T
struct StandardPostrenderInstanced
n_instances::Observable{Int}
vao::GLVertexArray
primitive::GLenum
end

function (sp::StandardPostrenderInstanced)()
renderinstanced(sp.vao, to_value(sp.main), sp.primitive)
return renderinstanced(sp.vao, sp.n_instances[], sp.primitive)
end

struct EmptyPrerender end
Expand Down
4 changes: 2 additions & 2 deletions GLMakie/src/GLAbstraction/GLTexture.jl
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ default_colorformat_sym(::Type{T}) where {T <: Colorant} = default_colorformat_s
@generated function default_colorformat(::Type{T}) where T
sym = default_colorformat_sym(T)
if !isdefined(ModernGL, sym)
error("$T doesn't have a propper mapping to an OpenGL format")
error("$T doesn't have a proper mapping to an OpenGL format")
end
:($sym)
end
Expand Down Expand Up @@ -462,7 +462,7 @@ end
@generated function default_internalcolorformat(::Type{T}) where T
sym = default_internalcolorformat_sym(T)
if !isdefined(ModernGL, sym)
error("$T doesn't have a propper mapping to an OpenGL format")
error("$T doesn't have a proper mapping to an OpenGL format")
end
:($sym)
end
Expand Down
2 changes: 1 addition & 1 deletion GLMakie/src/GLAbstraction/GLTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function RenderObject(
program = gl_convert(to_value(program), data) # "compile" lazyshader
vertexarray = GLVertexArray(Dict(buffers), program)

# remove all uniforms not occuring in shader
# remove all uniforms not occurring in shader
# ssao, instances transparency are special for rendering passes. TODO do this more cleanly
special = Set([:ssao, :transparency, :instances, :fxaa, :num_clip_planes])
for k in setdiff(keys(data), keys(program.nametype))
Expand Down
Loading

0 comments on commit 2621be5

Please sign in to comment.