GTK Scene Graph Kit

{{Short description|Application programming interface}}

{{Infobox software

| title = GSK

| name = GTK Scene Graph Kit

| logo =

| screenshot =

| caption =

| collapsible =

| author = Emmanuele Bassi et al.

| developer = The GNOME Project

| released = {{Start date and age|2017|03|24}}

| programming language = C

| operating system = Part of GTK

| platform =

| size =

| language =

| genre = Software library

| license = LGPL

| website = {{URL|https://docs.gtk.org/gsk4}}

}}

File:GTK+ software architecture.svg.]]

File:CSS3 taxonomy and status by Sergey Mavrody.svg taxonomy.]]

GTK Scene Graph Kit (GSK) is the rendering and scene graph API for GTK introduced with version 3.90. GSK lies between the graphical control elements (widgets) and the rendering.

Like GDK, GSK is part of GTK and licensed under the GNU Lesser General Public License (LGPL).

Rationale

GSK is part of GTK. GSK is meant to be used by GTK itself and by GTK-based applications that wish to replace Clutter for their UI. Applications that made use of Clutter instead of using only GTK are e.g. GNOME Shell, GNOME Videos, GNOME Boxes and Cheese.

Any application which makes use of GTK's graphical control elements (widgets), as opposed to those applications getting a GTK window and then drawing themselves on it, benefit from GSK.

=Performance=

Drawing graphical control elements (widgets) without a scenegraph leads to rendering things that don't show up on the screen, things that do not need to be rendered; hence it leads to avoidable performance and battery life losses. The scenegraph is used to do hidden surface determination.

=Simplicity=

The way widgets were drawn in GTK (when not using Clutter), was, that a draw function (part of GDK hence the name (GIMP "Drawing" Kit)) drew everything. There was no way to know, what has just been drawn. To know where the mouse pointer was currently hovering over, the current position had to be computed. With GSK, it should be fairly easy to write complex graphical control elements (widgets) and still track easily the whereabout of the mouse pointer.

=CSS=

It was decided for GTK to move to a Cascading Style Sheet (CSS)-based model for how graphical control elements (widgets) are styled (i.e. themed/skinned) and rendered. In CSS, shadows, borders, padding and style properties have well-defined semantics. Some of those semantics are difficult to implement with the old GTK drawing model.

GSK makes use of graphene,{{cite web |url=https://blogs.gnome.org/ebassi/2014/05/02/graphene/ |title=Graphene |last=Bassi |first=Emmanuele |date=2014-05-02}} an external library which houses a collection of geometry types — points, sizes, rectangles, vectors, quads, quaternions, matrices. [https://github.com/ebassi/graphene graphene] has been ported to the Meson build system.

GSK rendering pipeline

GSK uses a dual-layer approach:{{cite web |url=https://gitlab.gnome.org/GNOME/gtk/commit/7afdd3fdb5c5fda9da87555b40a61e6a321c2414 |title=Initial implementation of GSK rendering pipeline |first=Emmanuele |last=Bassi |date=2016-10-18}}

  1. The lower layer is a simple rendering tree of operations; it can be transformed into appropriate rendering commands with minimal state changes, so it gets transformed into the rendering pipeline. The tree of rendering operations is represented by GskRenderNode instances; an instance of GskRenderer takes the render nodes and submits them (after potentially reordering and transforming them to a more appropriate representation) to the underlying graphic system.
  2. higher layer: a complex set of logical layers; it adds a high level convenience API for application developers.

=Rendering APIs=

As of GTK 3.90, which is the development version number of what will become GTK 4, GSK supports rendering using these back-ends:

History

{{Expand section|date=March 2017}}

=Clutter=

Clutter was released to the public on June 22, 2006. The integration library "clutter-gtk" has been available since 2006-11-29.{{cite web |url=https://git.gnome.org/browse/clutter-gtk/commit/?id=9c9377198f7467b6fd30d080e5af84092eff4496 |title=add clutter-gtk |last=Bassi |first=Emmanuele |date=2006-11-29}}

At the 2nd Desktop Summit in August 2011 in Berlin there was quite some talk regarding "GTK+ 4.0 and Clutter 2.0".{{cite web |url=https://mail.gnome.org/archives/gtk-devel-list/2011-August/msg00058.html |title=GTK+ 4.0 and Clutter 2.0: rainbows and unicorns |last=Bassi |first=Emmanuele |date=2011-08-31}}

=Idea to introduce a scene graph to GTK=

In 2008 developers such as Havoc Pennington were considering to add a scene canvas to GTK, as people outside of GTK were making use of things like Clutter, Pigment, [https://wiki.gnome.org/Projects/HippoCanvas HippoCanvas] or [https://wiki.gnome.org/Projects/GooCanvas GooCanvas].{{cite web |url=https://mail.gnome.org/archives/gtk-devel-list/2008-March/msg00017.html |title=Havoc Pennington's scene graph proposal |last=Pennington |first=Havoc |date=2008-03-07}} It was proposed to make graphical control elements (widgets) one kind of object in a more flexible scene graph.

=GSK=

Before GSK, drawing used to be done by GDK - handling basic rendering such as drawing primitives, raster graphics (bitmaps), cursors, fonts, as well as window events and drag-and-drop functionality.{{cite web |url=https://www.bassi.io/articles/2014/07/29/guadec-2014-gsk/ |title=The GTK+ Scene Graph Kit |last=Bassi |first=Emmanuele |date=2014-07-29}}

In June 2006 Clutter, an OpenGL-based 'interactive canvas' library, was released. Clutter has its own scene graph, and GNOME developers preferred to use Clutter's scene graph with GTK, facilitated by a library called clutter-gtk.{{cite web |url=https://git.gnome.org/browse/clutter-gtk/tree/ |title=clutter-gtk on git.gnome}} Clutter can be embedded into every GNOME application by using the clutter-gtk library. The clutter-gtk library provides a GtkClutterEmbed GTK widget which can be used to display a ClutterStage.

Some thought went into how to merge Clutter and GTK in a better way than the clutter-gtk library.

In 2011, Firefox introduced "Azure" and Joe Drew and Bas Schouten bothered with some explanations.{{cite web |url=https://blog.mozilla.org/joe/2011/04/26/introducing-the-azure-project/ |title=Introducing the Azure project |date=2011-04-26 |access-date=2017-03-17 |archive-url=https://web.archive.org/web/20160908220007/https://blog.mozilla.org/joe/2011/04/26/introducing-the-azure-project/ |archive-date=2016-09-08 |url-status=dead }}{{cite web |url=https://www.basschouten.com/blog1.php/comparing-performance-azure-vs-cairo |title=Comparing Performance: Azure vs Cairo |date=2011-06-06}}{{cite web |url=https://www.basschouten.com/blog1.php/releasing-azure |title=Releasing Azure |date=2011-08-16}}

  • At GUADEC2013 in Brno Emmanuele shared his idea on implementing a scene graph and an animation framework inside the GNOME platform (after working for the past 6 years on Clutter).{{cite web |url=http://videos.guadec.org/2013/Future%20in%20the%20past%20GTK%20scene-graph/ |title=Future in the past GTK scene-graph |last=Bassi |first=Emmanuele |date=2013-08-12}}
  • GTK Scene Graph Kit (GSK) is the forthcoming scene graph for GTK in the process of being written by Emmanuele Bassi.{{cite web |url=https://www.bassi.io/articles/2014/07/29/guadec-2014-gsk/ |title=The GTK+ Scene Graph Kit |last=Bassi |first=Emmanuele |date=2014-07-29}}
  • On 30 July 2014, Emanuelle stated that he thought there shouldn't be a stand-alone Clutter 2.0.{{cite web |url=https://www.bassi.io/articles/2014/07/30/guadec-2013-scene-graph/ |title=Halting Problem – Future in the Past |last=Bassi |first=Emmanuele |date=2014-07-30}}

There was a presentation at the 2014 Developer Experience Hackfest regarding a new scene graph for GTK aimed at being merged into GTK+ 3.16.{{cite web |url=https://wiki.gnome.org/Hackfests/DeveloperExperience2014/GtkRoadmap#A4._A_scene_graph |title=2014 Developer Experience Hackfest: A scene graph for GTK+ 3.16}} Then GSK was planned to be ready and fully integrated into GTK+ version 3.20, to be released in March 2016. This was postponed to 3.22,{{cite web |url=https://wiki.gnome.org/Projects/GTK+/Roadmap |title=GNOME Wiki: roadmap for GTK+}} and then finally merged into 3.90.

Having OpenGL (or OpenGL ES) support in GDK facilitates a slightly better control of the graphics pipeline; OpenGL is well suited for compositing textured data but totally unsuited for drawing.{{citation needed|date=February 2017}}

The latest information about the status of GSK is from GUADEC 2016.{{cite web |url=https://www.youtube.com/watch?v=QzJHEpKdefA |title=GTK: are we in the future, yet? |last=Bassi |first=Emmanuele |website=YouTube |date=2016-08-16}}

=Other projects=

  • Enlightenment Foundation Libraries has been using a scene graph since 2000, implemented in the Evas library.{{cite web |url=https://docs.enlightenment.org/auto/evas_main.html |title=Evas}}
  • Qt has been redesigned, and starting with version 5, it features Qt Quick 2 with scenegraph based rendering.{{cite web |url=https://doc.qt.io/qt-5/topics-graphics.html#qt-quick-scene-graph |title=Qt Quick Scene Graph}}

See also

{{Portal|Free and open-source software}}

  • Clutter

References

{{Reflist}}