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

Some more documentation for in the rasterizer #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nical
Copy link
Contributor

@nical nical commented Mar 30, 2022

Some of it requires a bit more attention than the previous PR.

  • The value stored in B is multiplied by 2 (so that it matches the derivative formula at t=0), which is compensated by not multplying B by two later when it is used.
  • Some code was written as foo * (1 << (16 - SAMPLE_SHIFT) got reformulated as dot2_to_dot16(foo). I didn't do it initially because I wasn't sure whether the doing foo * 1 << bar instead of simply foo << bar was indicative of something that I had missed but I think it makes better sense in the new formulation.
  • I removed the comment saying "we'll iterate t from 0..1 (0-256)". As far as I can tell we aren't manipulating the curve parameter t anywhere. This comment had me puzzled for a while, if it indeed conveys something meaningful I think it needs to be rephrased.

//C = edge.y1;
e.dy = 2 * (A >> shift) + 2 * B * (1 << (16 - SAMPLE_SHIFT));
e.dy = 2 * (A >> shift) + dot2_to_dot16(B);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the skia equivalent looks simpler: https://github.com/RazrFalcon/tiny-skia/blob/afa3172310bb7a30e44911ef825f06dd900a4d85/src/edge.rs#L234 (note the comment above about preserving a bit by not multiplying by two and compensating in the curve shift).

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

Successfully merging this pull request may close these issues.

1 participant