// Generated API outline. Implementation bodies omitted.
#nullable enable
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using System;
using nfloat = System.Runtime.InteropServices.NFloat;
using static Xui.Core.Math2D.Constants;
namespace Xui.Core.Canvas.Composition.Graphics
{
/// A backdrop material rather than a filter of the group's foreground drawing.
public enum BackdropMaterial
{
/// No backdrop material.
None,
/// Native system material blur where available.
Blur,
/// Native Liquid Glass on supported iOS versions; system blur on older iOS.
LiquidGlass
}
/// An allocation-free, stack-only lifetime for a canvas composition group.
///
/// Use with a using declaration or statement. Scopes must close in reverse opening order;
/// do not copy a live scope. Balance all Save/Restore calls inside the scope before closing it.
///
public ref struct CompositionGroup
{
/// Whether the caller must emit this group's content into the context.
public bool NeedsRedraw { get; }
/// Creates a scope for an already-opened group. Intended for context implementations.
public CompositionGroup(ICompositionContext owner, bool needsRedraw);
/// Closes the group and restores its enclosing drawing state.
public void Dispose();
}
///
/// Explicit immediate-mode implementation for backends without retained composition.
/// Groups isolate Save/Restore drawing state and apply presentation, but always redraw.
/// Surface effects use portable approximations; this does not create native views or retain pixels.
///
public sealed class ImmediateCompositionContext(IContext context) : ICompositionContext
{
///
/// Opens a group and applies its presentation properties. Draw through the same context
/// only when the returned scope's is true.
/// Dispose the scope before drawing subsequent siblings.
///
///
/// Keys identify siblings by reference, not value equality. Use a stable reference, not
/// a boxed value or a newly allocated key each frame. HasUpdates=false permits reuse;
/// it never guarantees it. Export and immediate contexts always request drawing.
/// A retained backend must also redraw when it lacks valid content. Reusing a group
/// reuses its entire subtree, so HasUpdates must include relevant descendant changes.
/// Presentation changes are processed even when content can be reused.
/// HasUpdates=true must request drawing; it is also used by capture middleware to
/// force both the display and export branches to accept the same drawing commands.
/// Groups inherit drawing state and restore it on disposal, with the same path and
/// state semantics as Save/Restore. Bounds do not change the coordinate origin.
/// In a view-backed group, issue direct drawing before declaring child surfaces.
/// To draw above those children, declare a separate overlay group. Retained backends
/// reject drawing that violates this ordering instead of silently changing its depth.
/// An inherited arbitrary canvas clip may require flattening a surface into its parent;
/// that fallback requests drawing on every frame. Prefer group bounds clipping when
/// native composition and content reuse are needed.
///
///
///
/// using var group = context.Group(new GroupOptions
/// {
/// Key = this,
/// HasUpdates = HasRenderUpdates,
/// Bounds = Frame
/// });
/// if (group.NeedsRedraw)
/// DrawContent(context);
///
///
public CompositionGroup Group(scoped in GroupOptions options);
///
/// Closes the innermost group. Called by ;
/// prefer disposing the returned scope over calling this directly.
///
public void EndGroup();
}
/// A solid border following the inside of a surface's rounded bounds.
public readonly record struct OutlineBorder(Color Color, nfloat Width)
{
/// Checks a finite, nonnegative width.
public void Validate();
}
}
namespace Xui.Core.Canvas.Composition.Graphics
{
using Xui.Core.Canvas.Composition.Commands;
/// A retained 2D drawing surface with recorded canvas commands and ordered composition children.
/// Command buffers and reconciliation caches belong here; shared presentation is provided by Node. Platforms may derive from this class to own their
/// native resources and release them in DisposeCore. Native backends replay Commands when needed.
public class GraphicsNode : Node
{
/// Inherited canvas state replayed before this surface's own commands.
public readonly CanvasCommandBuffer Inherited;
/// Recorded 2D drawing content owned by this surface.
public readonly CanvasCommandBuffer Commands;
/// Number of visible children in back-to-front order. Leaf nodes return zero.
public override int Count { get; }
/// Returns the visible child at the given index.
public override Node this[int index] { get; }
/// Cached, omitted children. Backends detach these surfaces until they are declared again.
public readonly List HiddenChildren;
/// Whether the command stream contains visible drawing operations.
public bool HasDrawing { get; }
/// Overrides release their owned content, children and platform resources, then call base.
protected override void DisposeCore();
}
}
namespace Xui.Core.Canvas.Composition.Graphics
{
using Xui.Core.Math2D;
/// Identity, content invalidation, and presentation of an explicit canvas group.
public readonly struct GroupOptions
{
/// A stable reference identifying this group among its siblings. Never serialized as an SVG ID.
public required object Key { get; init; }
///
/// Whether the group's graphics or descendants have changed. Defaults to true.
/// False permits a backend to reuse content, but callers must still check NeedsRedraw.
///
public bool HasUpdates { get; init; }
///
/// Optional content bounds in the group's coordinate system. Does not translate the
/// origin or clip implicitly. Retained backends may use these bounds for backing storage.
///
public Rect? Bounds { get; init; }
/// Local transform concatenated with the parent transform. Defaults to identity.
public AffineTransform Transform { get; init; }
/// Clips drawing to Bounds, after applying Transform. Requires Bounds.
public bool ClipToBounds { get; init; }
/// Requests a retained native surface. Requires Bounds. Draw its content before declaring child groups.
public bool ViewBacking { get; init; }
/// Uniform radius of the surface outline and optional bounds clip.
public nfloat CornerRadius { get; init; }
/// Optional surface color, updated independently of recorded drawing content.
public Color? Background { get; init; }
/// Native backdrop material, approximated by a translucent surface in portable renderers.
public BackdropMaterial Backdrop { get; init; }
/// Optional shadow of the bounds outline, independent of the drawn content's alpha.
public OutlineShadow? Shadow { get; init; }
/// Optional border drawn inside the rounded bounds.
public OutlineBorder? Border { get; init; }
///
/// Keep this keyed surface in a bounded cache when omitted by culling. A parent
/// retains at most eight hidden children; older entries release their native resources.
///
public bool CacheWhenHidden { get; init; }
/// Creates options that request drawing and preserve the parent transform.
public GroupOptions();
/// Checks required identity and bounds before a backend changes drawing state.
public void Validate();
}
/// A drop shadow cast by the group's rounded bounds, not by its glyphs or transparent pixels.
public readonly record struct OutlineShadow(Color Color, nfloat Radius, Vector Offset)
{
/// Checks finite, nonnegative blur and finite offsets.
public void Validate();
}
/// Portable surface approximation for contexts without native backdrop effects.
public static class SurfaceEffects
{
/// Draws an outline shadow and translucent material without filtering foreground text.
public static void Draw(IContext context, in GroupOptions options);
}
}