Codifying the backend interface #2011
asinghvi17
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Collecting from the current code of CairoMakie and GLMakie, and my experience writing GRMakie, this is a basic overview of what I think the "backend interface" which all backends must satisfy looks like now. Please correct me (or this post) if there are any incorrect statements here!
Each backend must implement the Makie backend interface. Let us consider an imaginary backend,
ImaginaryMakie.jl
. To be compliant with the backend interface, and thus a functioning backend for Makie, this package must implement, at a minimum,ImaginaryBackend <: Makie.AbstractBackend
type.ImaginaryMakie.activate!(...)
function, which can be called with no arguments (i.e., all arguments should have a default value). This function must be called in the package's__init__
method. It must, at a minimum, setMakie.current_backend[] = b::ImaginaryBackend
.ImaginaryScreen <: Makie.AbstractScreen
type, which contains everything needed to display a Scene. When the Scene is displayed using anImaginaryScreen
, that screen is pushed toscene.current_screens
.GeometryBasics.widths(scr::ImaginaryScreen)::NTuple{2, Int}
Makie.colorbuffer(screen::ImaginaryScreen)::Matrix{RGB}
which quickly rasterizes the screen to an RGB matrix.Makie.backend_display(x::ImaginaryBackend, scene::Scene)::ImaginaryScreen
which displaysscene
to a backend screen. Semantically, this should be used to bring up an interactive screen.Makie.backend_show(backend::ImaginaryBackend, io::IO, mime::MIME, scene::Scene)::ImaginaryScreen
for all MIME types which the backend can handle.Makie.backend_showable(backend::ImaginaryBackend, mime::MIME, scene::Scene)
for those MIME types.Base.delete!(screen::ImaginaryScreen, scene::Scene, plot::AbstractPlot)
.lines
,linesegments
,scatter
,text
,heatmap
,image
,mesh
,surface
,volume
). An arbitrary plotp
can be decomposed into atomics by descending down the tree formed byp.plots
and its elements. Some of these atomics (surface
,volume
) can be ignored if the backend only supports 2D plots, but it is recommended that a warning be added in that case.When rendering Scenes, the
ImaginaryBackend
must render a rectangle filled with the background color, the plots inscene.plots
, and its children inscene.children
. There is no proscribed order in which this must be done, but common sense applies.Beyond these few methods, Makie is completely blind to how the backend arranges itself. Note that this includes how the atomic plot types are rendered, or if any plot types are rendered before full decomposition into atomics.
Beta Was this translation helpful? Give feedback.
All reactions