ExternalTexture API
Declared by <huxerui/external_texture.h>.
Shared ownership
Section titled “Shared ownership”ExternalTexture is an abstract, non-copyable object. Construct a supported platform subclass and share it as std::shared_ptr<ExternalTexture>. A null pointer represents absence; there is no default value handle or HasValue() method.
Image(texture) and the corresponding PaintContext::DrawImage/DrawImageRect overloads consume that shared pointer. Static ImageFill sources remain image/vector assets, not live textures.
Observation
Section titled “Observation”IntrinsicSize(): immutable finite, positive logical size in DIPs, independent of the published frame’s pixel dimensions.Revision(): monotonically increasing publication revision, not a GPU handle or a frame timestamp.IsActive(): whether a committed RenderScene currently displays this identity. It is a production hint, not ownership or guaranteed visibility.
A new frame schedules repaint without recomposing the View or rerecording its PaintSequence. Change ordinary State for playback/error controls, not for every frame.
Producers
Section titled “Producers”Platform subclasses own mailbox format, synchronization, and publication. Their Finish() stops further publication while retaining the last frame. Publication after finish is invalid. Choose a new texture identity when logical size changes.
Subclassing the shared class does not automatically teach a renderer a new GPU format; the renderer must explicitly support the concrete mailbox type. Prefer the provided platform types and follow their thread and ownership contracts.
Capture pixels
Section titled “Capture pixels”Call SnapshotAsync() on the owning UI thread and await the returned Task<std::optional<Bitmap>>. It retains the latest frame at the call site, so subsequent publication or producer shutdown cannot substitute a newer frame. The default absence result is std::nullopt before the first publication. Readback produces a bitmap at the frame’s pixel dimensions with scale 1. A producer or frame that cannot be read back reports a runtime error when awaited.
The built-in Windows PixelTexture and D3D11Texture, Apple PixelBufferTexture and MetalTexture, Linux GdkTexture, GlTexture and PixelTexture, Android BitmapTexture, GlTexture and SurfaceStreamTexture, and Web VideoFrameTexture provide readback implementations. A particular frame or GPU operation can still fail. Use snapshots for export, inspection, or occasional processing. Keep ordinary live presentation on the producer path.
Frame acquisition
Section titled “Frame acquisition”Concrete GPU and platform producers expose AcquireFrame(). Acquisition returns the latest completed publication using the platform’s retained resource type. A frame can outlive a later publication or the producer itself. Keep it alive through consumer work and release it under the owning API’s rules. See published frame ownership by platform.

