From c96664185be834aa74a3325e41f3721f225e2e01 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Mon, 2 Dec 2019 19:11:01 -0600 Subject: [PATCH 1/2] Add some precompiles --- src/Colors.jl | 3 +++ src/precompile.jl | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/precompile.jl diff --git a/src/Colors.jl b/src/Colors.jl index fc7a9197..ad7178d6 100644 --- a/src/Colors.jl +++ b/src/Colors.jl @@ -35,4 +35,7 @@ include("colormaps.jl") include("display.jl") include("colormatch.jl") +include("precompile.jl") +_precompile_() + end # module diff --git a/src/precompile.jl b/src/precompile.jl new file mode 100644 index 00000000..35afe82b --- /dev/null +++ b/src/precompile.jl @@ -0,0 +1,29 @@ +function _precompile_() + ccall(:jl_generating_output, Cint, ()) == 1 || return nothing + eltypes = (N0f8, N0f16, Float32, Float64) # eltypes of parametric colors + feltypes = (Float32, Float64) # floating-point eltypes + pctypes = (Gray, RGB, AGray, GrayA, ARGB, RGBA) # parametric colors + cctypes = (Gray24, AGray32, RGB24, ARGB32) # non-parametric colors + # conversions + ## to RGB + for T in eltypes, F in feltypes, C in (HSV,LCHab,LCHuv,Lab,Luv,XYZ) + @assert precompile(Tuple{typeof(convert),Type{RGB{T}},C{F}}) + end + ## to XYZ + for T in feltypes, F in feltypes, C in (HSV,LCHab,LCHuv,Lab,Luv,XYZ,RGB) + @assert precompile(Tuple{typeof(convert),Type{XYZ{T}},C{F}}) + end + for T in feltypes, F in (N0f8, N0f16) + @assert precompile(Tuple{typeof(convert),Type{XYZ{T}},RGB{F}}) + end + # parse + @assert precompile(Tuple{typeof(parse),Type{ColorTypes.Colorant},String}) + @assert precompile(Tuple{typeof(parse),Type{RGB{N0f8}},String}) + @assert precompile(Tuple{typeof(parse),Type{RGBA{N0f8}},String}) + # colordiff + for T in eltypes + @assert precompile(Tuple{typeof(colordiff),RGB{T},RGB{T}}) + end + @assert precompile(Tuple{typeof(colormap),String}) + @assert precompile(Tuple{typeof(distinguishable_colors),Int}) +end From eb734ea30c3ddb53fc59bbb9797be15b2c72ab3b Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Tue, 3 Dec 2019 04:14:59 -0600 Subject: [PATCH 2/2] Use `literal_pow` rather than `pow` in `Bezier` --- src/utilities.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utilities.jl b/src/utilities.jl index 6e5ee144..855e561a 100644 --- a/src/utilities.jl +++ b/src/utilities.jl @@ -69,7 +69,7 @@ end #Double quadratic Bezier curve function Bezier(t::T, p0::T, p2::T, q0::T, q1::T, q2::T) where T<:Real - B(t,a,b,c)=a*(1.0-t)^2.0+2.0b*(1.0-t)*t+c*t^2.0 + B(t,a,b,c)=a*(1.0-t)^2 + 2.0b*(1.0-t)*t + c*t^2 if t <= 0.5 return B(2.0t, p0, q0, q1) else #t > 0.5 @@ -79,7 +79,7 @@ end #Inverse double quadratic Bezier curve function invBezier(t::T, p0::T, p2::T, q0::T, q1::T, q2::T) where T<:Real - invB(t,a,b,c)=(a-b+sqrt(b^2.0-a*c+(a-2.0b+c)*t))/(a-2.0b+c) + invB(t,a,b,c)=(a-b+sqrt(b^2-a*c+(a-2.0b+c)*t))/(a-2.0b+c) if t < q1 return 0.5*invB(t,p0,q0,q1) else #t >= q1