linebender / linebender/resvg

Add support for opacity flattening

Open
#141 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

optimization
Dominant language
Rust
Stars
4.1k
Forks
348
Avg merge
1d 14h
Merged PRs (30d)
3

Description

It's pretty common for a single element to have an 'opacity' style. Instead of drawing these elements as groups it can be much more performant to draw directly with the opacity either by baking the opacity into a solid color or using something like opacity in the DrawOptions of the raqote backend.

This is an optimization that's done by both Chrome and Firefox. e.g.
https://searchfox.org/mozilla-central/rev/1133b6716d9a8131c09754f3f29288484896b8b6/layout/painting/nsDisplayList.cpp

I suspect that doing this would have a pretty noticeable performance impact on the test.svg from https://github.com/RazrFalcon/resvg/pull/137 as it has lots of single element opacity styling

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue description and the linked Mozilla painting reference to understand opacity flattening approaches. Use the test.svg mentioned in the issue to evaluate the existing rendering behavior and performance; done means single-element opacity can be rendered directly without unnecessary groups while preserving output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.