Skip to content

Commit

Permalink
Merge branch 'sd/beta-20' into sd/axis-converts
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch authored Nov 10, 2023
2 parents db2f0be + 8cfd95d commit bb073ce
Show file tree
Hide file tree
Showing 230 changed files with 7,400 additions and 2,664 deletions.
41 changes: 34 additions & 7 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
name: CompatHelper
on:
schedule:
- cron: '0 0 * * *' # Everyday at midnight
- cron: 0 0 * * *
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
with:
version: '1'
arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main(subdirs=["", "MakieCore", "GLMakie", "WGLMakie", "CairoMakie", "RPRMakie"])
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
# COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }}
4 changes: 4 additions & 0 deletions .github/workflows/compilation-benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches:
- master
- sd/beta-20
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
benchmark:
name: ${{ matrix.package }}
Expand All @@ -26,6 +29,7 @@ jobs:
- uses: julia-actions/setup-julia@v1
with:
version: '1'
include-all-prereleases: true
arch: x64
- uses: julia-actions/cache@v1
- name: Benchmark
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/wglmakie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
using Pkg;
# dev mono repo versions
pkg"dev . ./MakieCore ./WGLMakie ./ReferenceTests"
pkg"add JSServe#sd/fixes"
- name: Run the tests
continue-on-error: true
run: >
Expand Down
5 changes: 4 additions & 1 deletion CairoMakie/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[compat]
Cairo = "1.0.4"
Expand All @@ -25,7 +25,10 @@ FreeType = "3, 4.0"
GeometryBasics = "0.4.1"
Makie = "=0.20.0"
PrecompileTools = "1.0"
SHA = "0.7, 1.6, 1.7"
julia = "1.3"
Base64 = "1.0, 1.6"
LinearAlgebra = "1.0, 1.6"

[extras]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand Down
20 changes: 11 additions & 9 deletions CairoMakie/src/infrastructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ end

function prepare_for_scene(screen::Screen, scene::Scene)

# get the root area to correct for its pixel size when translating
root_area = Makie.root(scene).px_area[]

root_area_height = widths(root_area)[2]
scene_area = pixelarea(scene)[]
# get the root area to correct for its size when translating
root_area_height = widths(Makie.root(scene))[2]
scene_area = viewport(scene)[]
scene_height = widths(scene_area)[2]
scene_x_origin, scene_y_origin = scene_area.origin

Expand All @@ -103,7 +101,7 @@ function prepare_for_scene(screen::Screen, scene::Scene)
top_offset = root_area_height - scene_height - scene_y_origin
Cairo.translate(screen.context, scene_x_origin, top_offset)

# clip the scene to its pixelarea
# clip the scene to its viewport
Cairo.rectangle(screen.context, 0, 0, widths(scene_area)...)
Cairo.clip(screen.context)

Expand All @@ -116,7 +114,7 @@ function draw_background(screen::Screen, scene::Scene)
if scene.clear[]
bg = scene.backgroundcolor[]
Cairo.set_source_rgba(cr, red(bg), green(bg), blue(bg), alpha(bg));
r = pixelarea(scene)[]
r = viewport(scene)[]
Cairo.rectangle(cr, origin(r)..., widths(r)...) # background
fill(cr)
end
Expand Down Expand Up @@ -148,8 +146,8 @@ end
function draw_plot_as_image(scene::Scene, screen::Screen, primitive::Combined, scale::Number = 1)
# you can provide `p.rasterize = scale::Int` or `p.rasterize = true`, both of which are numbers

# Extract scene width in pixels
w, h = Int.(scene.px_area[].widths)
# Extract scene width in device indepentent units
w, h = size(scene)
# Create a new Screen which renders directly to an image surface,
# specifically for the plot's parent scene.
scr = Screen(scene; px_per_unit = scale)
Expand Down Expand Up @@ -178,3 +176,7 @@ end
function draw_atomic(::Scene, ::Screen, x)
@warn "$(typeof(x)) is not supported by cairo right now"
end

function draw_atomic(::Scene, ::Screen, x::Makie.PlotList)
# Doesn't need drawing
end
36 changes: 31 additions & 5 deletions CairoMakie/src/overrides.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,26 @@ function draw_poly(scene::Scene, screen::Screen, poly, points_list::Vector{<:Vec
end

draw_poly(scene::Scene, screen::Screen, poly, rect::Rect2) = draw_poly(scene, screen, poly, [rect])
draw_poly(scene::Scene, screen::Screen, poly, bezierpath::BezierPath) = draw_poly(scene, screen, poly, [bezierpath])

function draw_poly(scene::Scene, screen::Screen, poly, rects::Vector{<:Rect2})
function draw_poly(scene::Scene, screen::Screen, poly, shapes::Vector{<:Union{Rect2,BezierPath}})
model = poly.model[]
space = to_value(get(poly, :space, :data))
projected_rects = project_rect.(Ref(scene), space, rects, Ref(model))
projected_shapes = project_shape.(Ref(scene), space, shapes, Ref(model))

color = to_cairo_color(poly.color[], poly)

linestyle = Makie.convert_attribute(poly.linestyle[], key"linestyle"())
if isnothing(linestyle)
linestyle_diffed = nothing
elseif linestyle isa AbstractVector{Float64}
elseif linestyle isa AbstractVector{<:Real}
linestyle_diffed = diff(Float64.(linestyle))
else
error("Wrong type for linestyle: $(poly.linestyle[]).")
end
strokecolor = to_cairo_color(poly.strokecolor[], poly)
broadcast_foreach(projected_rects, color, strokecolor, poly.strokewidth[]) do r, c, sc, sw
Cairo.rectangle(screen.context, origin(r)..., widths(r)...)
broadcast_foreach(projected_shapes, color, strokecolor, poly.strokewidth[]) do shape, c, sc, sw
create_shape_path!(screen.context, shape)
set_source(screen.context, c)
Cairo.fill_preserve(screen.context)
isnothing(linestyle_diffed) || Cairo.set_dash(screen.context, linestyle_diffed .* sw)
Expand All @@ -101,6 +102,31 @@ function draw_poly(scene::Scene, screen::Screen, poly, rects::Vector{<:Rect2})
end
end

function project_shape(scene, space, shape::BezierPath, model)
commands = Makie.PathCommand[]
for cmd in shape.commands
if cmd isa EllipticalArc
bezier = Makie.elliptical_arc_to_beziers(cmd)
for b in bezier.commands
push!(commands, project_command(b, scene, space, model))
end
else
push!(commands, project_command(cmd, scene, space, model))
end
end
BezierPath(commands)
end

function create_shape_path!(ctx, r::Rect2)
Cairo.rectangle(ctx, origin(r)..., widths(r)...)
end

function create_shape_path!(ctx, b::BezierPath)
for cmd in b.commands
path_command(ctx, cmd)
end
end

function polypath(ctx, polygon)
isempty(polygon) && return nothing
ext = decompose(Point2f, polygon.exterior)
Expand Down
6 changes: 6 additions & 0 deletions CairoMakie/src/precompiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ let
include(shared_precompile)
end
end
precompile(draw_atomic_scatter, (Scene, Cairo.CairoContext, Tuple{typeof(identity),typeof(identity)},
Vector{ColorTypes.RGBA{Float32}}, Vec{2,Float32}, ColorTypes.RGBA{Float32},
Float32, BezierPath, Vec{2,Float32}, Quaternionf,
Mat4f, Vector{Point{2,Float32}},
Mat4f, Makie.FreeTypeAbstraction.FTFont, Symbol,
Symbol))
Loading

0 comments on commit bb073ce

Please sign in to comment.