콘텐츠로 이동

FilterResult class

이 콘텐츠는 아직 번역되지 않았습니다.

Output of Execute. Wraps a backend’s intermediate image with explicit ownership semantics so callers can using-dispose without worrying about whether the result aliases a borrowed source layer or a scratch surface from the pool.

public abstract class FilterResult : IDisposable
name description
abstract Bounds { get; } Bounds of this image in the executor’s source coordinate space. Initially equals SourceBounds; nodes that translate or extend the region (Offset, Blur halo) update this so downstream nodes know the spatial layout.
abstract IsPremultiplied { get; } true when the underlying pixels are in premultiplied alpha (Premultiplied). Mirrored on the result so CPU fallback paths know how to interpret ReadPixels bytes.
abstract PixelHeight { get; } Gets the height in device pixels.
abstract PixelWidth { get; } Gets the width in device pixels.
abstract UnderlyingSurface { get; } The underlying render surface if this result is backed by one (Borrowed/Scratch). Returns null for backend-specific results that wrap native handles only. Used by GPU executors to reach the backend resources behind the result.
abstract AsImage() Backend-native image handle for use in draw operations (DrawImage etc.).
abstract Dispose() Releases the result according to its ownership: a no-op for a borrowed source, a pool return for a scratch surface.
abstract ReadPixels(…) CPU-side pixel access (BGRA32). For GPU-backed results, the first call may incur a GPU→CPU readback. Returned span has stride strideBytes and length PixelHeight × strideBytes. The buffer is owned by the result and remains valid until Dispose.

Three concrete shapes:

  • BorrowedFilterResult - points at a layer the caller owns. Dispose is no-op.
  • ScratchFilterResult - backed by a rented render surface from the executor’s scratch pool; Dispose returns it.
  • Backend-specific subclasses - wrap native handles, optionally with lazy CPU readback for cross-backend chain-of-responsibility fallback.

All subclasses must support both AsImage (for backend-native draw operations) and ReadPixels (for CPU executor handoff). The latter may trigger a GPU→CPU readback, which is the unavoidable cost of mixing GPU and CPU nodes in one graph.