
Skia: an open source 2D graphics library - striking
https://skia.org/
======
git-pull
Aseprite switched to Skia a year or so ago
([https://github.com/aseprite/aseprite](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...](https://github.com/aseprite/aseprite/issues/1598#issuecomment-341869884)

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 bit since, but back when
I last tried, it required grabbing depot tools, checking out a source tree and
a ton of other dependencies.

I am the original person that got Aseprite building on FreeBSD - but now I
can't build it on any platform at all. Skia has too many points of failure in
the build process. (Here's another issue where I spend hours trying to figure
out what's going on
[https://github.com/aseprite/aseprite/issues/1081](https://github.com/aseprite/aseprite/issues/1081))

Every other graphics library (SDL2, Allegro, SFML) can work with CMake.

Another pain point: Skia isn't on any package managers to my knowledge. Here's
the debian RFP
[https://bugs.debian.org/818180](https://bugs.debian.org/818180).

~~~
gaze
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.

~~~
alkonaut
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++

~~~
pjmlp
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.

------
guessmyname
With all the fuss with "modern" text editors built on top of web engines, I
feel the need to remind you all that one of the fastest graphical code editors
that I have ever used — SublimeText — was built using Skia for the rendering.
I believe many people have noticed how smooth the interface and most of the
operations feel, a very good selling point if you want to build a GUI in the
future.

~~~
alkonaut
If I understod correctly (which isn’t certain) Skia is also the rendering
backend for chromium. Chromium is used as the rendering bits for electron.
Electron is how you make these apps on “web engines”. So all those editors
based on web engines likely render through Skia...

~~~
cheez
I believe Skia was originally used in Android as well.

~~~
on_and_off
Isn't it still the case ?

------
throwaway2016a
For anyone thinking of skipping looking at this one. I was not interested
either until I read this part:

> It serves as the graphics engine for Google Chrome and Chrome OS, Android,
> Mozilla Firefox and Firefox OS, and many other products.

~~~
j_s
Similar situation to the freetype/harfbuzz all-but-Microsoft/Apple (open
source) monoculture.

I'm interested to understand more about how some categories of software
libraries don't foster multiple strong open source alternatives, while others
do.

~~~
gatmne
I was thinking about this recently. I think this type of consolidation starts
to make sense if you think of software as mathematics. A formula gets devised,
iterated upon and refined, adopted, and then finally built upon.

It makes more sense to adapt a standard formula to a given use case than it is
to derive a custom formula from the ground up. I suspect the reason why its
not the case for software is because of copyright and IP laws.

Likewise, I expect mathematics wouldn't have advanced as much as it has had
there been IP laws enacted for mathematics. People would too limited by the
licensing terms for their Leibniz™ and Euler™ formulas to be able to be able
to build the next step.

~~~
bjz_
There are many degrees of freedom to work on when it comes to mathematics,
many perspectives to look at the same problem. Some are elegant, some are
ugly, others are painful to work with, and make future progress hard. Just as
it is with software. We constantly need to reassess our foundations, and not
get too coupled to a single perspective, lest it drive us into a corner and
stifle further innovation.

------
bch
Ugh... This build system is _horrible_.

bash-dependent meta-builder for ninja-build working in git checkouts. Are both
actual releases and traditional build systems _that_ out of fashion?

~~~
bch
You guys are killing me. After downloading twenty-some git repos(?) as
dependencies (most of which my system already has), this (I’ll try to quit
complaining about this better mousetrap now):

kamloops$ gn Traceback (most recent call last): File
"/home/bch/work/skia/src/vendor/depot_tools/gn.py", line 38, in <module>
sys.exit(main(sys.argv)) File
"/home/bch/work/skia/src/vendor/depot_tools/gn.py", line 22, in main bin_path
= gclient_utils.GetBuildtoolsPlatformBinaryPath() File
"/home/bch/work/skia/src/vendor/depot_tools/gclient_utils.py", line 749, in
GetBuildtoolsPlatformBinaryPath raise Error('Unknown platform: ' \+
sys.platform) gclient_utils.Error: Unknown platform: netbsd8

~~~
hwc
> After downloading twenty-some git repos(?) as dependencies (most of which my
> system already has)

Skia statically links in copies of these dependencies for _testing purposes
only_. There is a mode ("is_official_build") that will search for your system
libraies.

~~~
bch
Ah. I used that flag on first build attempt (which failed), then did a
“tools/git-sync-deps” to pacify the build system (w/o any flags), wherein the
repo cloning did commence.

------
pjmlp
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.

~~~
1inuxoid
This can't be intentional, right?

~~~
pjmlp
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.

~~~
mdwrigh2
Skia does not have a stable ABI, which is a requirement for inclusion in the
NDK:
[https://github.com/google/skia/blob/master/experimental/c-ap...](https://github.com/google/skia/blob/master/experimental/c-api-
example/c.md)

~~~
pjmlp
It has a stable API for Java clients on Android, if Google actually would care
they could expose that one.

And in any case, creating a 2D abstraction layer stable API on top of
platforms specific version APIs, specially given that all NDK APIs are C based
even if written in C++, it is not rocket science, rather a matter of wanting
to do it.

------
adelarsq
Also there is a Rust adapted version
[https://github.com/servo/skia](https://github.com/servo/skia), used on Servo

~~~
metajack
For a few things. These days most of Servo rendering is done on the GPU by
WebRender. I think we only use Skia for canvas right now.

Hopefully we'll drop it altogether once Pathfinder is completed.

~~~
tsuru
Will it be possible for others to use webrender/Pathfinder similar to Skia or
Cairo? Or is it pretty connected to servo?

~~~
fleetfox
Not sure about Pathfinder but WebRender for sure, it's already usable outside
of servo. People are attempting GUI toolkits and other things.

------
matt2000
Among all the other things mentioned in the comments, AFAIK this is the
rendering engine for [https://flutter.io/](https://flutter.io/) too

~~~
Skylled
Which means it's also used in most Fuchsia projects.

------
Matheus28
I've used it to create a desktop port of [http://diep.io/](http://diep.io/).
It's great (easy to use, reasonably documented), but it's a pretty big
dependency (I don't remember exactly, but I think like 20 MB or so?). Since
diep.io uses the canvas 2d API, porting was pretty straight forward. The
performance on desktop is unsurprisingly many times faster than the browser.

~~~
electricslpnsld
What motivated your choice of Skia over WebGL?

~~~
Matheus28
You mean canvas 2d? If you're making a 2d game, it's good enough and looks
really nice. Performance is good enough in most cases. Because of some OpenGL
gotchas in some drivers (macOS mostly), some operations are a lot slower in
those OSes (I have a demo that runs at 3 fps on my macbook, and >144 fps on my
windows). It's easier to use canvas 2d as you don't have to deal with any of
that.

------
robert_foss
There are alternatives to Skia that are even faster like FastUIDraw.

[https://www.x.org/wiki/Events/XDC2016/Program/rogovin_fast_u...](https://www.x.org/wiki/Events/XDC2016/Program/rogovin_fast_ui_draw/)
[https://github.com/intel/fastuidraw](https://github.com/intel/fastuidraw)

------
bratsche
There is also a .NET binding for Windows and Xamarin:
[https://www.nuget.org/packages/SkiaSharp/](https://www.nuget.org/packages/SkiaSharp/)

~~~
voltagex_
Has anyone used this? Are there any examples?

~~~
alkonaut
I’m converting a large desktop (CAD) app from GDI+ to SkiaSharp at the moment.
Really liking the Api and the quality of the C# wrapper. Also maps very well
to GDI concepts so a conversion is fairly painless.

~~~
voltagex_
Cool. Are you able to share any more details? I'm guessing this isn't a
standard WinForms app. What advantages does moving away from GDI+ give you?

~~~
alkonaut
It’s a winforms app, and there isn’t much nonstandard about it other than that
large performance sensitive drawing apps are perhaps quite nonstandard to
begin with. We want to handle some large cad scenarios in it (e.g smooth
pan/zoom in drawings with 500k lines), it’s not the default use case, but it
happens. The main advandtage over gdi+ ) is better support for retained mode
drawing (record/playback style drawing), more efficient automatic culling,
etc.

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

~~~
ttd
Skia (via SkiaSharp) is the rendering backend for my vector graphics
diagramming application ([https://vexlio.com](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.

~~~
tenken
Looks like a nice project. For my own (web development) kind of projects I
love to diagram infrastructure, Classes, etc.

But, I do nearly all my work on Linux -- which is a pity because I'd love to
try out a tool like Vexlio.

For now I guess I'll continue to stick with yEd, because it actually works
everywhere (java works).

------
roel_v
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.

~~~
bjz_
The Firefox and Servo team are currently hard at work on Pathfinder, which
should solve this for both fonts and SVG. It'll run on the GPU like WebRender
which is super exciting:
[https://github.com/pcwalton/pathfinder](https://github.com/pcwalton/pathfinder)
\- alas it's still a WIP at the moment.

~~~
roel_v
That's very interesting, didn't know about this. It seems like it'll take
substantial time for this to stabilize though. But still, something to revisit
next time I'm evaluating options.

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

~~~
PeCaN
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/](https://fiddle.skia.org/) if you want to try it
out.

~~~
percentcer
I have a little 2d game that I'd like to port over to Skia. What did you end
up using to handle input and audio and other gamey things?

~~~
megaman22
I would think SDL would be an easy cross-platform choice there.

------
ahartmetz
Somehow the text it renders looks worse than all the other common graphics
libraries on Linux - which all use FreeType and Harfbuzz. I am not sure what
QtWebEngine does differently, because it uses Blink and the text looks fine.

~~~
hwc
"looks worse" is a pretty nebulous statement. Can you go into detail? Do you
think text in Chrome looks bad?

~~~
ahartmetz
It seems like lack if subpixel rendering plus the spacing between letters is
somehow screwed. Really hard to put a finger on it, it just looks wrong to me.
I do think that text in Chrome looks bad on Linux. I could compare magnified
screenshots now but I'm too lazy, sorry. Don't care much about Chrome anyway.

------
mamcx
How good/hard to build an UI library (like bootstrap) on it? I'm already on
F#/C# so I don't will have issues with building it (I imagine!)

------
Taniwha
So back in the early 90s Apple had a graphics library called "skia" \- are
these related?

~~~
speps
See this post from earlier:
[https://news.ycombinator.com/item?id=16148185](https://news.ycombinator.com/item?id=16148185)

------
FascinatedBox
The roadmap needs to be updated. It's for 2016-2017.

~~~
hcmiller
It has been updated with the doc of high level themes we are chasing for 2018.

------
nbsd4lyfe
just a heads up, skia doesn't work on big endian.

