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 Skia Canvas instead of Surface where possible #188
Use Skia Canvas instead of Surface where possible #188
Conversation
Well, it will create a pretty horrible PDF. There are plans on making a proper PDF target, but it will not be implemented any time soon. As for the patch, C-API should be updated too. It requires |
I've added a check for Skia C-API build. Turns out it was missing. |
We're using it to render just graphics. Text, links and other things we do directly with Skia. It works really well, thank you for the awesome library! I've just pushed a commit to update the Skia C-API. I don't have a machine that can run |
I see. As long as you are fine with results - it's ok. I just wanted to point out that it's quite limited. Especially when you have text and layers. But as long as you only have shapes without opacity - you should be fine. |
Thanks for the info! We don't have text, although perhaps we will run into opacity, I guess if we can detect that we might rasterise those cases. |
I think that build will fail, because there are no pub unsafe fn from_ptr(ptr: *mut ffi::skiac_canvas) -> Option<Canvas> {
if ptr.is_null() {
None
} else {
Some(Canvas(ptr))
}
} to the |
@JaFenix Hi! Is this change fine for you? |
Ah, good catch, thanks. I didn't realise I had to |
@RazrFalcon what do you think about adding something like this: typedef struct sk_canvas_t sk_canvas_t; (matching their offical C API https://github.com/google/skia/blob/master/include/c/sk_types.h#L153) void resvg_skia_render_to_canvas(const resvg_render_tree *tree,
const resvg_options *opt,
resvg_size size,
- void *canvas);
+ skia_canvas_t * canvas); So at the call site you might know at compile time about a type mismatch. |
It's C. The are not compile time guaranties. And you would call resvg via C++ anyway, so there is no difference. |
Sorry about the failed builds. I'm having trouble running the tests locally, or building anything except the main package. Do they only work on linux? |
No problem. No, they should work on any platform. |
Awesome, thanks for reviewing 🎉 I suppose we can merge it once @JaFenix gives the okay? |
Yes, he added the Skia backend initially and I do not want to break it for him. |
Hi, I don't think this will break anything, because the surface instance that's passed in doesn't seem to be used for anything, other than to deliver a canvas. Changing our C++ caller to pass in the canvas won't be a problem. OK to merge 👌 |
Thanks for a quick response. |
Hey, I've made some changes to allow you to use Skia's Canvas wherever possible. This allows you to use resvg with PDFs 🎉.
https://skia.org/user/api/skcanvas_creation
Something like this: