Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use premultiplied alpha for cairo argb surfaces #2304

Merged
merged 2 commits into from
Sep 27, 2022

Conversation

jkrumbiegel
Copy link
Member

@jkrumbiegel jkrumbiegel commented Sep 27, 2022

Description

Cairo needs premultiplied alpha for image ARGB32 image surfaces, while everywhere else they don't. So we never noticed, which has been leading to all kinds of artifacts with transparent bitmaps. This should fix all of those hopefully.

Before:

CairoMakie.activate!()
x = collect(0:2.0)
y = collect(0:2.0)
z = x .* y'
f = Figure()
ax = Axis(f[1, 1], title="CairoMakie", backgroundcolor = :white)
heatmap!(ax, x, y, z, colormap=(:viridis, 0.5))
f

grafik

After:

grafik

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@jkrumbiegel jkrumbiegel linked an issue Sep 27, 2022 that may be closed by this pull request
@jkrumbiegel
Copy link
Member Author

Should fix #2162 as well but I can't select that in the link menu for some reason

@MakieBot
Copy link
Collaborator

MakieBot commented Sep 27, 2022

Compile Times benchmark

Note, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running:

using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(display(fig))
using create display create display
GLMakie 21.40s (20.68, 22.08) 0.47+- 22.78s (21.83, 23.42) 0.59+- 21.20s (20.45, 22.26) 0.61+- 21.17ms (20.76, 21.92) 0.39+- 117.68ms (114.57, 121.11) 2.13+-
master 20.74s (19.58, 21.81) 0.71+- 22.78s (21.75, 23.81) 0.73+- 21.18s (20.61, 22.18) 0.53+- 21.14ms (20.47, 21.79) 0.56+- 116.21ms (114.63, 118.11) 1.57+-
evaluation +3.09%, 0.66s invariant (1.11d, 0.06p, 0.59std) -0.03%, -0.01s invariant (-0.01d, 0.98p, 0.66std) +0.06%, 0.01s invariant (0.02d, 0.97p, 0.57std) +0.13%, 0.03ms invariant (0.06d, 0.92p, 0.47std) +1.25%, 1.47ms invariant (0.79d, 0.17p, 1.85std)
CairoMakie 14.75s (13.32, 16.95) 1.25+- 19.96s (17.60, 23.18) 1.95+- 3.30s (2.90, 3.80) 0.32+- 17.91ms (16.25, 20.04) 1.36+- 26.90ms (25.29, 28.97) 1.61+-
master 14.58s (13.28, 15.68) 0.92+- 20.54s (18.42, 22.98) 1.39+- 3.32s (3.07, 3.73) 0.22+- 18.57ms (16.21, 20.49) 1.80+- 28.15ms (25.39, 30.33) 1.83+-
evaluation +1.10%, 0.16s invariant (0.15d, 0.79p, 1.08std) -2.89%, -0.58s invariant (-0.34d, 0.54p, 1.67std) -0.53%, -0.02s invariant (-0.06d, 0.91p, 0.27std) -3.68%, -0.66ms invariant (-0.41d, 0.46p, 1.58std) -4.63%, -1.25ms invariant (-0.72d, 0.20p, 1.72std)
WGLMakie 25.15s (24.42, 26.48) 0.78+- 36.52s (34.89, 37.85) 1.00+- 60.32s (58.52, 61.77) 1.18+- 34.63ms (33.30, 35.64) 0.79+- 2.14s (2.07, 2.24) 0.07+-
master 25.13s (24.08, 26.72) 1.01+- 36.21s (34.22, 39.37) 2.02+- 58.50s (56.08, 62.57) 2.39+- 34.75ms (33.63, 36.07) 0.84+- 2.15s (2.04, 2.21) 0.06+-
evaluation +0.08%, 0.02s invariant (0.02d, 0.97p, 0.90std) +0.85%, 0.31s invariant (0.19d, 0.72p, 1.51std) +3.02%, 1.82s invariant (0.97d, 0.10p, 1.78std) -0.34%, -0.12ms invariant (-0.15d, 0.79p, 0.81std) -0.33%, -0.01s invariant (-0.11d, 0.84p, 0.06std)

@SimonDanisch
Copy link
Member

Yay finally :)

Before:
before
With this PR:
after

@jkrumbiegel jkrumbiegel merged commit fb977a3 into master Sep 27, 2022
@jkrumbiegel jkrumbiegel deleted the jk/fix-transparent-bitmaps branch September 27, 2022 13:27
@jkrumbiegel jkrumbiegel mentioned this pull request Oct 8, 2022
5 tasks
t-bltg pushed a commit to t-bltg/Makie.jl that referenced this pull request Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants