Live data from Hacker News

Skia: an open source 2D graphics library

skia.org

81–90 of 119 posts

Re: Skia: an open source 2D graphics library

#81
post #72

Fun fact, it is used in Android, but not exposed to the NDK. So C++ applications on Android that wish to use Skia, do have to use the Java API via JNI (android.graphics.Canvas) with the respective performance impact due to marshaling, or package their own Skia version, thus increasing their APK size and having to deal with a build system that only makes sense for Google employees.

This can't be intentional, right?

Google does not seem interested in making the NDK anything more than implementing Java native methods, 3D graphics, audio or porting code from other platforms.

Everything else should be done at Java level.

I understand from the point of view of security, but what is safer, provide bindings to libraries already validated and installed on the device or forcing devs to package something else?

Also even though they implement native APIs in nice C++ with RAII and stuff, it gets exposed as unsafe C APIs, so the security story isn't 100% correct.

Re: Skia: an open source 2D graphics library

#83
post #76
post #75

How about font rendering? Would I use freetype/harfbuzz with this? They're such a bitch to build on Windows. Currently I'm using DirectWrite but having portability would be a nice bonus, as it seems that the API of this isn't worse than Direct2D.

freetype and harfbuzz don't draw text. Freetype reads font files and gives you individual glyphs, and harfbuzz does "shaping". Pango does layout but also doesn't draw text.

I know, which is why I said 'font rendering' - but of course (for any practical purpose) that extends into drawing onto a context/canvas/whatever it's called in a specific ecosystem. Pango can draw to Cairo (modulus some very pedantic definitions of 'draw'), for example, but in some combinations of glyph rendering/layouting/drawing libraries you have to fiddle with getting one library to render as a path and then use generic path drawing routines to actually rasterize. I can't be bothered with that sort of minutiae, hence my question - how much (if at all) is this library integrated with other functionality to render, query the rendered form, and rasterize text.

I mean, say what you want about DirectWrite and the Direct2D environment - but at least it's very clear how things fit together and it works very well, even for niche use cases. In open source land, you spend days just puzzling together the pieces - let alone build them and getting them to actually do something useful from code. I've tried plenty over the last 15 years.

(edit: typos)

Re: Skia: an open source 2D graphics library

#85
post #12

This looks really useful! Does anyone know how this compares to something like Cairo?

Skia (via SkiaSharp) is the rendering backend for my vector graphics diagramming application ( https://vexlio.com ). I chose it in part because it had much better performance than Cairo when I was testing both. Also the MIT license was more appealing to me than Cairo's LGPL or Mozilla Public License.

Site looks great; well done!

Re: Skia: an open source 2D graphics library

#86

There is also a .NET binding for Windows and Xamarin: https://www.nuget.org/packages/SkiaSharp/

Has anyone used this? Are there any examples?

It's used as one of the backends for Avalonia UI https://github.com/AvaloniaUI/Avalonia/blob/master/readme.md

(Not affiliated but I love this project. If it wasn't still alpha I'd use it for absolutely everything)

Re: Skia: an open source 2D graphics library

#87
post #64
post #42

Aseprite switched to Skia a year or so ago ( https://github.com/aseprite/aseprite ). Regret it. Google doesn't care to maintain CMake support for it, so there goes pulling it in via source and building as a library dependency. https://github.com/aseprite/aseprite/issues/1598#issuecommen... You may ask, "why don't you just write your own CMake module like everyone else?" I've tried. I think the build system changed a…

It's true. Google has essentially made it as painful as possible to use Skia outside of the google ecosystem. The build system is what's mostly kept me from using it in personal projects.

Xamarins wrapper for C# made it a breeze to use from C# at least - just add the package. The same is likely true for all ecosystems with reasonable package management. It’s only ironic that C++ libs are hardest to use from...C++

Re: Skia: an open source 2D graphics library

#89
post #64

Earlier quoted context omitted.

It's true. Google has essentially made it as painful as possible to use Skia outside of the google ecosystem. The build system is what's mostly kept me from using it in personal projects.

Xamarins wrapper for C# made it a breeze to use from C# at least - just add the package. The same is likely true for all ecosystems with reasonable package management. It’s only ironic that C++ libs are hardest to use from...C++

Sadly a consequence of the C culture that was adopted in C++ regarding how libraries should be distributed, before the time of package managers.

Just checked, and Skia is not to be found anywhere across vcpkg, Conan, Hunter, Ubuntu, Debian.

So using C# sounds much better than having to understand Google specific build processes to compile it.

Re: Skia: an open source 2D graphics library

#90
post #7

C++ 11, nice. Does anyone use this? And if you do how does it compare to alternatives

Skia is probably the most popular 2D graphics library at the moment. I don't really know why this got on HN now. It's already extremely popular. I use it in a little WIP game engine. It's very pleasant, excellent little library. There's an online jsfiddle-esque demo here https://fiddle.skia.org/ if you want to try it out.

Not sure where it is popular.

Even I rather use SDL, written in C, than having to deal with getting to compile Skia across my platforms.

Then there is Cocos2d-x, SFML and OpenFrameworks as well.

Post reply on HN