Geometry generator symbol layers are a feature that has been added in QGIS 2.14. They allow using the expression engine to modify geometries or even create new geometries while rendering.
Geometry generator symbol layers make it possible to use expression syntax to generate a geometry on the fly during the rendering process. The resulting geometry does not have to match with the original geometry type and we can add several differently modified symbol layers on top of each other.
The latest version of the QGIS user manual provides some example expressions, which served as a basis for the following examples:
Rendering the centroid of a feature
To add a geometry layer representing feature centroids, we need to set the geometry type to Point / Multipoint and enter the following expression:
centroid( $geometry )
It is worth noting that the correct geometry type has to be set manually. If a wrong type is set, the symbol layer can not be rendered.
Drawing buffers around features
Buffers are an example of a polygon geometry generator layer. The second parameter of the buffer function defines if the buffer is generated outside (for positive values) or inside (for negative values) of the feature. The value has to be provided in the layer’s CRS units, in this case, that means an inner buffer of 0.005 degrees:
buffer( $geometry, -0.005 )
Creating a line between features in different layers
The following expression creates lines from all district centroids (as shown in the first example) and a feature from the Citybike layer where the STATION attribute value is ‘Millennium Tower’:
make_line( centroid( $geometry ), geometry( get_feature( 'Citybike', 'STATION', 'Millennium Tower' ) ) )
More advanced examples
Using these basic examples as a starting point, geometry generators open a wide field of advanced symbology options. For example, this sector light style presented on GIS.Stackexchange or my recently introduced conveyor belt flow style: