RenderNode

class RenderNode(*args, **kwargs)

Subclasses: BlendNode, BlurNode, BorderNode, CairoNode, ClipNode, ColorMatrixNode, ColorNode, ConicGradientNode, ContainerNode, CrossFadeNode, DebugNode, FillNode, GLShaderNode, InsetShadowNode, LinearGradientNode, MaskNode, OpacityNode, OutsetShadowNode, RadialGradientNode, RepeatNode, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RoundedClipNode, ShadowNode, StrokeNode, SubsurfaceNode, TextNode, TextureNode, TextureScaleNode, TransformNode

GskRenderNode is the basic block in a scene graph to be rendered using Renderer.

Each node has a parent, except the top-level node; each node may have children nodes.

Each node has an associated drawing surface, which has the size of the rectangle set when creating it.

Render nodes are meant to be transient; once they have been associated to a Renderer it’s safe to release any reference you have on them. All RenderNode’s are immutable, you can only specify their properties during construction.

Methods

class RenderNode
deserialize(bytes: Bytes, error_func: Callable[[...], None] | None = None, *user_data: Any) RenderNode | None

Loads data previously created via serialize.

For a discussion of the supported format, see that function.

Parameters:
  • bytes – the bytes containing the data

  • error_func – Callback on parsing errors

  • user_data – user_data for error_func

draw(cr: Context) None

Draw the contents of node to the given cairo context.

Typically, you’ll use this function to implement fallback rendering of GskRenderNode’s on an intermediate Cairo context, instead of using the drawing context associated to a Surface’s rendering buffer.

For advanced nodes that cannot be supported using Cairo, in particular for nodes doing 3D operations, this function may fail.

Parameters:

cr – cairo context to draw to

get_bounds() Rect

Retrieves the boundaries of the node.

The node will not draw outside of its boundaries.

get_node_type() RenderNodeType

Returns the type of the node.

serialize() Bytes

Serializes the node for later deserialization via deserialize(). No guarantees are made about the format used other than that the same version of GTK will be able to deserialize the result of a call to serialize() and deserialize() will correctly reject files it cannot open that were created with previous versions of GTK.

The intended use of this functions is testing, benchmarking and debugging. The format is not meant as a permanent storage format.

write_to_file(filename: str) bool

This function is equivalent to calling serialize followed by file_set_contents.

See those two functions for details on the arguments.

It is mostly intended for use inside a debugger to quickly dump a render node to a file for later inspection.

Parameters:

filename – the file to save it to.