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

Optimize pixel overwrite #157

Open
RazrFalcon opened this issue Aug 20, 2020 · 7 comments
Open

Optimize pixel overwrite #157

RazrFalcon opened this issue Aug 20, 2020 · 7 comments

Comments

@RazrFalcon
Copy link
Contributor

RazrFalcon commented Aug 20, 2020

Skip blending when color is opaque or blending mode is Source/Clear. This is what skia and cairo do. And the results are pretty radical:

test opaque_fill_skia      ... bench:      47,662 ns/iter (+/- 1,119)
test opaque_fill_cairo     ... bench:      45,804 ns/iter (+/- 263)
test opaque_fill_raqote    ... bench:   2,432,875 ns/iter (+/- 51,948)

test source_fill_skia      ... bench:      50,663 ns/iter (+/- 207)
test source_fill_cairo     ... bench:      48,839 ns/iter (+/- 354)
test source_fill_raqote    ... bench:     678,795 ns/iter (+/- 10,330)
@jrmuizel
Copy link
Owner

Can you change the benchmark harness to use fill_rect() instead of fill(). Raqote intentionally doesn't try to detect rectangular paths like Cairo and Skia do.

@RazrFalcon
Copy link
Contributor Author

Current benchmarks are unaffected by this optimization.

@jrmuizel
Copy link
Owner

Hmmm. That's a bit surprising. Can you commit the change and I'll take a look.

@RazrFalcon
Copy link
Contributor Author

What change?

@jrmuizel
Copy link
Owner

Using fill_rect() instead of fill()

@RazrFalcon
Copy link
Contributor Author

RazrFalcon commented Aug 20, 2020

Yes, fill_rect will be faster, but cairo and skia results are independent from the shape in this case.

Here are results of filling a star:

test source_fill_skia      ... bench:      32,676 ns/iter (+/- 440)
test source_fill_cairo     ... bench:      43,970 ns/iter (+/- 858)
test source_fill_raqote    ... bench:     465,450 ns/iter (+/- 6,622)

They are even faster here, because there are less scanlines.

@jrmuizel
Copy link
Owner

Ah, ok this will probably be best to look into after #158 is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants