Skia vs Cairo vs Direct2D, which is the most feature rich?

Abrar Borno picture Abrar Borno · Oct 2, 2017 · Viewed 9.7k times · Source

A just curious question.
I'm aware that:
Skia, Cairo: library
Direct2D: API
But without any additional components, exclusively on Windows platform, which bears the most features? I'm not talking about performance or programming simplicity.
Is there any possibility that Cairo could use D2D as the rendering backend on Windows platform?

Answer

c-smile picture c-smile · Nov 21, 2017

I am using all three in my Sciter as graphics backends so you can compare them in action.

As of today:

Feature set:

Skia and Direct2D are on par by feature set. And both are feature wise supersets of Cairo.

From these three, only Direct2D (Direct2D v 1.1) supports printing. Skia and Cairo instead are capable of PDF generation so for real printing you will need 3rd party tools.

3D integration:

Direct2D has good integration with DirectX - they can work on the same DXGI device.

But it is far not that trivial to integrate Skia with existing 3D OpenGL code. Even Skia can work with OpenGL backend it changes state of OpenGL device and that creates problems.

Performance:

With Direct2D you can reach 60-250 FPS.

On Windows, Skia when used with OpenGL backend, surprisingly, but may work better than Direct2D. But YMMV.

Platforms:

On Windows I'd suggest to use Direct2D or Skia.

On MacOS - definitely Skia with OpenGL backend. It is significantly better than Mac's native CoreGraphics.

On Linux/GTK: use Cairo as this is the default rendering API on GTK/Gnome3. And Cairo works there pretty well.