Skip to content

gegl, operations: add infrastructure to query older versions of an operation.

Jehan requested to merge wip/Jehan/set-op-version into master

This is a patch to allow GIMP to store the GEGL operation versions and for operation code to keep track of older implementations. This way, even when we'll enhance operations (adding or removing operation's arguments, or even changing argument semantic), GIMP will be able to reload the effect with the expected rendering (i.e. using the older operation interface).

The patch on GIMP side is gimp!1660, using the new API.

As an example of how an operation could be updated, here is a bogus example where I changed "center-x" and "center-y" arguments to be in [-1, 1] range instead of [0, 1]: 0001-operations-say-supernova-center-x-and-center-y-chang.patch

This operation has both the old and the new versions implemented, therefore can be called with old style arguments or new ones and you get the expected result. Note that this is an example where an argument still exist but its semantic change. The new obsolete() macro would also work for a removed argument for instance.


From now on, GIMP will store the "op-version" key of an operation's node in a XCF, which will allow to update operations without breaking rendering. The enhancement is composed of:

  • GeglOperation:
    • When updating an operation signature, additionally to bumping the "op-version" key, you should now set or update the "obsolete-op-versions" key which is an ordered comma-separated list of version strings.
    • Operation properties have a new "obsolete()" macro feature. Obsolete properties are invisible by default to gegl_operation_list_properties() or gegl_operation_find_property().
    • It is the responsibility of the operation's implementation to handle appropriately being called on an obsolete version. The new functions gegl_node_is_last_version() and gegl_node_get_op_version() in particular can be used within an operation's code to determine which code path to run.
    • The new utility functions gegl_operation_get_supported_versions(), gegl_operation_is_supported_version() and gegl_operation_find_property_for_version() allow to validate an operation description before creating a GeglNode.
    • Note: gegl_operation_get_op_version() was moved from gegl/graph/gegl-node.[ch] to gegl/operation/gegl-operation.c (and header in gegl/gegl-operations-util.h) where it belongs.
  • GeglNode:
    • the "op-version" can now be set on the node with gegl_node_set_op_version(). It must be one of the supported versions (i.e. either the "op-version" of the GeglOperation or one of its "obsolete-op-versions").
    • Alternatively, the varargs generic gegl_node_set*() functions will recognize "op-version" as a special property name (same as it could recognize "operation").
    • gegl_node_list_properties(), gegl_node_set_property(), gegl_node_get_property() (and variants gegl_node_set*() and gegl_node_get*()) are now version-aware. I.e. that if you set a specific op-version, it will set or get the correct values, correctly mapping from the old property name to an internal name (as defined through the obsolete() macro).

Merge request reports