mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.52k stars 538 forks source link

Add SVG support to SkiaSharp #120

Closed Emasoft closed 8 years ago

Emasoft commented 8 years ago

I think that full SVG support should be added to the SkiaSharp library, including SVG Animations ( https://svgwg.org/specs/animations/ ).

If SkiaSharp is going to be the engine behind Xamarin.Forms (and the whole WPF crossplatform), then SVG support is as necessary as PNG or JPG support. You cannot treat SVG as a external option, something that you can delegate to a secondary framework made by amateurs. It is the main vector image format around. 90% of all vector graphic resources (icons, graphic elements, UI skins, animations, backgrounds, etc...) are made in SVG, exported in SVG and distributed in SVG. Artists and designers are used to save their vector images in SVG format. App design tools like Sketch or AdobeXD export the app design storyboards as SVG files, ready to be imported in the app. Popular mobile apps like Viber use SVG SMIL animations extensively for ALL their awesome animated stickers. With the advent of the modern high density display jungle, everybody is dropping bitmap assets for SVG assets. Intro animations for the "Onboarding" phase of new apps are now often made with SVG SMIL animated clips. The new popular SVG morphing algorithms are now used by many design tools to create animated visual transitions easily between UI states, just by choosing a start and an end SVG image. From those two inbetweens are automatically generated at 60 fps, for a smooth and modern UI. No vector framework is going to succeed with developers without SVG support, no more than a bitmap imaging framework without PNG or JPG support. Other crossplatform 2D libraries like NGraphics for example already support SVG. This is very urgent, otherwise Xamarin.Forms is going to be more and more detached from the needs of modern app development.

gentledepp commented 8 years ago

It is also my opinion, that SVG is a very important backend (I believe it is called this way in Skia?). It is even way more important than the PDF support you added recently. So I am hoping this won't be too much effort? (fingerscrossed)

We are already creating our own port of a SVG library using SkiaSharp. However, our goal is to have a vector-graphics based editor for mobile platforms. So advanced animations and filters will not be provided by us and also, as it is not native and includes all the callbacks and a rather compliated object model, it surely won't be fast enough for the purposes mentioned by @Emasoft

Nevertheless, you guys are doing a great job! I really love SkiaSharp. It even made me try to work with C++ and C again ;-)

migueldeicaza commented 8 years ago

SVG is not supported by Skia itself, and thus is outside the scope of this project.

Nothing is preventing an additional library from being created that can load SVG files, but it is not part of the SkiaSharp project, unless you get Google to add SVG support directly to Skia. Which is rather unlikely for reasons stated somewhere else on the bug reporting system.

gentledepp commented 8 years ago

That is a good point, @migueldeicaza. Nevertheless, it would be a superb addition to the Xamarin toolset. As I am not planning to work fulltime on our SVG port, we will, however, never implement things as animations and the like. Also, as it is a full blown SVG rendering and editing framework, it will never be as fast as a pure render lib. But I would be very happy to see our efforts supported by you :)

Emasoft commented 8 years ago

@gentledepp Unfortunately I think that Skia is a dead end after all. I don't know why Miguel picked it, but nobody uses it on Android anymore because it is not hardware accelerated. We need an hardware accelerated crossplatform solution, like NGraphics (it uses the native calls of iOS and Android sdk on mobile, that are hardware accelerated, and DX on Windows), not an old and slow lib like Skia. If I were in Miguel, I would buy NGraphics and start developing a cross platform WPF implementation with it, so that XAML code in Xamarin.Forms would be the same on all platforms, and SVG support in Xamarin.Forms would be obtained as a bonus. Currently Xamarin.Forms is too slow (even using the XAMLC), and you need hacks like the TwinTechs FastCell library to get even a decent listview scroll speed. Porting Skia to C# as a Xamarin library is a waste of time. Miguel should just hire Frank A. Krueger and some other passionate developer like you, and start to invest massively in NGraphics as the next backbone of Xamarin.Forms.

mattleibow commented 8 years ago

@emasoft, skia is hardware accelerated, but we have not yet brought that up to the C# binding layer. We were focussing on bringing functionality and features.

migueldeicaza commented 8 years ago

There are many incorrect statements made about SkiaSharp on @Emasoft 's previous comment. This sort of misinformation is not helpful, here are some corrections to clear the record:

For the purpose of letting emotions cool off, I am adding a temporary ban for Emasoft for more comments.

gentledepp commented 8 years ago

Thank you for making this clear. I personally am totally amazed by your efforts. You guys are doing a great job :-)

Am 02.08.2016 21:52 schrieb "Miguel de Icaza" notifications@github.com:

There are many incorrect statements made about SkiaSharp on @Emasoft https://github.com/Emasoft 's previous comment. This sort of misinformation is not helpful, here are some corrections to clear the record:

-

Everyone uses Skia on Android, it is the graphics library that powers every drawing call on Android.

Further, it is the engine that powers Google Chrome.

Hardware acceleration for 2D has limitations compared to the expectations of most people. Including CoreGraphics, where only a handful of operations are hardware accelerated.

When NGraphics delegates to the native code on Android, it is delegating to the system installed version of Skia

When NGraphics delegates to native code on iOS, it delegates to CoreGraphics, which only has support for doing some hardware acceleration (layer composition to a large extent, the rest is software rendered).

Support for GPU primitives in Skia is something we have not bound.

SkiaSharp is not a C# port of the native API, it is a wrapper of the native API.

SVG support is an independent effort from SkiaSharp, as stated on the comemnts.

Xamarin.Forms does not use SkiaSharp, so it is irrelevant to this discussion.

For the purpose of letting emotions cool off, I am adding a temporary ban for Emasoft for more comments.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mono/SkiaSharp/issues/120#issuecomment-237022955, or mute the thread https://github.com/notifications/unsubscribe-auth/ABHwx-lYMX0l3euEF8nsmzn4VL9yhVFcks5qb5_xgaJpZM4JVxNo .

migueldeicaza commented 7 years ago

Svg support is now available as SkiaSharp.Svg

danwalmsley commented 5 years ago

https://github.com/wieslawsoltes/Svg.Skia