Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For noobs: what is Cairo?


Not just what 'aaronbrethorst said; Cairo isn't just a 2D graphics library, but it is the foundational 2D graphics library that underpins most of the modern GNU/Linux desktop: It's what's used by gstreamer, GTK+ 2, GTK+ 3, Java... and if an app manages to avoid using any infrastructure that uses Cairo (Qt doesn't), if the app does 2D graphics things then it's likely that the app uses Cairo directly.


There was even a proposal a few years ago to make Cairo part of the C++ standard library:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n407...


Can you tell me a bit more about how Java uses Cairo to draw? I was under the assumption that Java interface with the underlying OS to draw.


First of all, when I say "Java", I mean OpenJDK; things might be different in the Oracle side of the world.

My naive answer was going to be that, from Java's perspective libcairo is part of the underlying OS. But when I wrote my original post, I was taking the fact that libawt_xawt (the awt implementation for X11) links against Cairo at face-value. But looking a little closer at that, it only uses Cairo in its integration with GTK+ (as GTK+ uses Cairo).

Now, OpenJFX (which you could quibble about whether it's "part of" Java) uses Cairo extensively in its implementation of using HTML/CSS for Java UIs.


Um, no it doesn't. JavaFX/OpenJFX doesn't use Cairo anywhere. Some references appear in the codebase but only via the WebKit import.

Neither JavaFX nor OpenJDK use Cairo for drawing and AFAIK never have. I don't know where this idea comes from. They use a pure Java 2D engine called Marlin when doing CPU based rendering. JavaFX is normally hardware accelerated though, in which case all drawing is handled using shaders and its own graphics engine.


I am under the same impression as well.


>First of all, when I say "Java", I mean OpenJDK; things might be different in the Oracle side of the world.

OpenJDK is the Oracle implementation under a different license. When the Oracle Java team makes code changes, they do so to the OpenJDK code base.

There are very minor differences that are part of the packaging work Oracle does, such as slightly different wording in the copyright statement that's printed with the -v CLI option.


I know that they share code, and that the Oracle Java team commits to the OpenJDK code. If they're actually the same right now, idk, bit it's often been the case that they aren't. It's often been the case that the OpenJDK JRE and the Oracle JRE have different performance characteristics. Oracle JRE 8-10 bundled JavaFX, while there was no JavaFX for OpenJDK (in JRE 11 Oracle open-source JavaFX as OpenJFX).


Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System (via both Xlib and XCB), Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Experimental backends include OpenGL, BeOS, OS/2, and DirectFB.

https://www.cairographics.org




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: