Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUse Pathfinder for 2d canvas rendering #22957
Comments
|
@highfive assign me |
|
Hey @shanavas786! Thanks for your interest in working on this issue. It's now assigned to you! |
|
After adding
But cargo successfully builds Am i missing something ? |
|
Try runny ng |
|
it didn't help
|
|
Sorry for the delay. This is caused by a mistake in the png crate, where they rely on a feature from the |
|
I filed image-rs/image-png#106 upstream to fix it. |
|
|
|
I think this is a bit heavier for me. It would be better if someone can mentor. |
|
Servo 54f54d1 can be built without errors with |
|
I have created a demo project by duplicating the included demo for SVG and reusing it to render Most of the turtle-renderer is copied directly from the svg-renderer demo. |
|
https://github.com/pcwalton/pathfinder/blob/master/examples/canvas_minimal/src/main.rs should also be a good reference. |
|
There are four main parts to this work:
|
|
@highfive assign me |
|
Hey @pylbrecht! Thanks for your interest in working on this issue. It's now assigned to you! |
|
Relevant code as stated by @jdm in #servo:
|
|
@jdm suggested https://github.com/jrmuizel/raqote might be another option. This way we just need to replace azure with raqote. |
|
After skimming through raqote and canvas_data.rs, I found some differences, which may or may not be important:
Please note that I did not dive deep into the code yet, just been looking at function names etc. Although I'm very tempted to just start hacking and see where I end up, it might be more reasonable to identify crucial functionality first. So, what are absolute must-haves and what can we leave open to be implemented in the future? |
|
I don't know that there are any particular must-haves. It's good to know that raqote has some missing pieces that will affect us. We should file issues about the path builder methods for sure; what does "more stuff" mean, exactly? |
At first glance: rect handling, stroke options, and shadows, but there could be more. |
|
|
Progress update: Work done so far:
Due to life doing its thing (girlfriend back from vacation, moving to new appartment in two weeks, working on my thesis, etc.) my time is somewhat limited (again). I'm still very determined to keep working on this though, just at a slower pace, I guess. |
|
Could you file a new issue tracking the raqote conversion? It would be good to keep this one focused on Pathfinder. |
|
Would implementing a generic backend fall under this issue or should I move this to the new issue, as well? |
|
If you're planning on writing a generic backend for 2d graphics you may want to consider https://github.com/linebender/piet. Currently a Raqote backend is in the works and potentially a Pathfinder or Azure backend could be implemented |
|
So many options.. Honestly, I feel a bit lost of what solution to approach right now. |
|
We don't actually want to end up with a generic backend. It's a stop along the way to replacing our current backend with raqote, which is where we want to end up in the short term. |
Implement CanvasRenderingContext2d.fillText The PR consists of broadly two main changes: - Implementation of Canvas2dRenderingContext.font - Basic implementation of Canvas2dRenderingContext.fillText Although I am not fully sure about the long term goals for the canvas backend in Servo, I assumed limited scope for font and text handling (should support simple text drawing with font selection) in the current implementation as I believe a more complete implementation would eventually be brought in as a part of #22957. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #11681 - [x] There are tests for these changes
Implement CanvasRenderingContext2d.fillText The PR consists of broadly two main changes: - Implementation of Canvas2dRenderingContext.font - Basic implementation of Canvas2dRenderingContext.fillText Although I am not fully sure about the long term goals for the canvas backend in Servo, I assumed limited scope for font and text handling (should support simple text drawing with font selection) in the current implementation as I believe a more complete implementation would eventually be brought in as a part of #22957. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #11681 - [x] There are tests for these changes
Implement CanvasRenderingContext2d.fillText The PR consists of broadly two main changes: - Implementation of Canvas2dRenderingContext.font - Basic implementation of Canvas2dRenderingContext.fillText Although I am not fully sure about the long term goals for the canvas backend in Servo, I assumed limited scope for font and text handling (should support simple text drawing with font selection) in the current implementation as I believe a more complete implementation would eventually be brought in as a part of #22957. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #11681 - [x] There are tests for these changes
Implement CanvasRenderingContext2d.fillText The PR consists of broadly two main changes: - Implementation of Canvas2dRenderingContext.font - Basic implementation of Canvas2dRenderingContext.fillText Although I am not fully sure about the long term goals for the canvas backend in Servo, I assumed limited scope for font and text handling (should support simple text drawing with font selection) in the current implementation as I believe a more complete implementation would eventually be brought in as a part of #22957. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #11681 - [x] There are tests for these changes

Right now our 2d canvas rendering relies on a very old fork of Azure (https://github.com/servo/rust-azure/), which itself relies upon a very old fork of Skia (https://github.com/servo/rust-azure/). The operations that the 2d canvas allows are not complicated and it should be possible to use Pathfinder as the rendering backend instead. This would have several useful results:
I'm marking this as "hard" not because I actually believe it will be hard, per se, but it's going to require a bunch of investigation and poking and prodding to understand how to fit Pathfinder into Servo's canvas rendering pipeline. It could be fun, though!