Input and authoring¶
Module: byteink-compose. Conventions. Signatures and defaults follow the current source.
InkPointerSample¶
InkPointerSample¶
Coordinates must be finite and uptime nonnegative. Optional axes must satisfy their documented ranges; availability/tool type is frozen at begin and later missing axes hold their last measured values.
public data class InkPointerSample( public val x: Float, public val y: Float, public val uptimeMillis: Long, public val toolType: InputToolType = InputToolType.MOUSE, public val pressure: Float? = null, public val tiltRadians: Float? = null, public val orientationRadians: Float? = null, public val strokeUnitLengthCm: Float? = null, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
x |
Float |
Required |
Horizontal coordinate; input-surface units for pointer samples, page dp for InkPoint. |
y |
Float |
Required |
Vertical coordinate; input-surface units for pointer samples, page dp for InkPoint. |
uptimeMillis |
Long |
Required |
Nonnegative monotonic event/frame milliseconds, using one clock per gesture. |
toolType |
InputToolType |
InputToolType.MOUSE |
Device tool type; keep it constant within a gesture. |
pressure |
Float? |
null |
Measured finite pressure in [0, 1], or null when unavailable; Int brush levels use 0–5. |
tiltRadians |
Float? |
null |
Measured finite shaft tilt in [0, pi/2], or null when unavailable; zero is perpendicular to the surface. |
orientationRadians |
Float? |
null |
Measured finite shaft azimuth in [0, 2*pi), from local +x toward +y, or null when unavailable; not barrel rotation. |
strokeUnitLengthCm |
Float? |
null |
Calibrated finite positive centimeters per input-surface unit, or null when unavailable; do not infer from logical DPI. |
InkInputEvent¶
Pointer-addressed variants: Begin, Move, Batch, Predict, Finish and CancelPointer; Cancel discards all pointers. Batch preserves real history and optionally replaces predictions. Default pointerId is 0L where declared.
InkInputEvent.Begin¶
public data class Begin(public val sample: InkPointerSample, public val pointerId: Long = 0L) : InkInputEvent
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample |
Required |
Real pointer observation; a nullable finishing sample may be omitted. |
pointerId |
Long |
0L |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
InkInputEvent.Move¶
public data class Move(public val sample: InkPointerSample, public val pointerId: Long = 0L) : InkInputEvent
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample |
Required |
Real pointer observation; a nullable finishing sample may be omitted. |
pointerId |
Long |
0L |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
InkInputEvent.Batch¶
public data class Batch( public val samples: List<InkPointerSample>, public val predictedSamples: List<InkPointerSample>? = null, public val pointerId: Long = 0L, ) : InkInputEvent
| Parameter | Type | Default | Meaning |
|---|---|---|---|
samples |
List<InkPointerSample> |
Required |
Ordered real observations; all accepted history is submitted before updating the speculative tail. |
predictedSamples |
List<InkPointerSample>? |
null |
Replaceable speculative observations; empty clears predictions. Null requests automatic session prediction; the regular surface only forwards explicit predictions. |
pointerId |
Long |
0L |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
InkInputEvent.Predict¶
public data class Predict(public val samples: List<InkPointerSample>, public val pointerId: Long = 0L) : InkInputEvent
| Parameter | Type | Default | Meaning |
|---|---|---|---|
samples |
List<InkPointerSample> |
Required |
Replaceable speculative observations in input-surface units; an empty list clears the tail. Never added to saved real inputs. |
pointerId |
Long |
0L |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
InkInputEvent.Finish¶
public data class Finish(public val sample: InkPointerSample? = null, public val pointerId: Long = 0L) : InkInputEvent
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample? |
null |
Real pointer observation; a nullable finishing sample may be omitted. |
pointerId |
Long |
0L |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
InkInputEvent.CancelPointer¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
pointerId |
Long |
Required |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
InkInputEvent.Cancel¶
InkHoverEvent¶
A tablet tool above the surface without contact, for cursors and hover states. Exit follows when the tool leaves proximity or the component, or is removed; a contact ends hover without Exit and Move resumes after the lift. Hover never starts, extends or ends a stroke.
InkHoverEvent.Move¶
public data class Move(public val sample: InkPointerSample, public val pointerId: Long = 0L) : InkHoverEvent
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample |
Required |
Hover position in component-local units with tool, time and reported tilt; pressure is always null. |
pointerId |
Long |
0L |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
InkHoverEvent.Exit¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
pointerId |
Long |
0L |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
InkInputSource¶
subscribe returns an AutoCloseable subscription. Deliver original device observations serially on the UI thread; native subscriptions and closing run on the AWT EDT.
InkInputSource.subscribe¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
listener |
(InkInputEvent) -> Unit |
Required |
Serial UI-thread event callback; closing the subscription stops callbacks. |
InkInputPredictor¶
InkInputPredictor¶
Records real observations and returns replaceable predictions on the same input clock. Use one predictor per gesture; predictions never become saved inputs.
InkInputPredictor.record¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample |
Required |
Real pointer observation; a nullable finishing sample may be omitted. |
InkInputPredictor.predict¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
targetUptimeMillis |
Long |
Required |
Nonnegative target time on the same monotonic millisecond clock as recorded observations. |
InkInputPredictor.reset¶
InkLinearPredictor¶
Bounded linear position prediction from recent real observations; retains measured optional axes. Reversals, stationary input, tool changes and long gaps reset motion prediction.
public class InkLinearPredictor( public val maxPredictionMillis: Long = 24L, public val maxPredictionDistance: Float = 32f, ) : InkInputPredictor
| Parameter | Type | Default | Meaning |
|---|---|---|---|
maxPredictionMillis |
Long |
24L |
Maximum forecast horizon in milliseconds, within 1–100. |
maxPredictionDistance |
Float |
32f |
Finite positive forecast-distance ceiling in the same units as pointer coordinates. |
InkLinearPredictor.record¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample |
Required |
Real pointer observation; a nullable finishing sample may be omitted. |
InkLinearPredictor.predict¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
targetUptimeMillis |
Long |
Required |
Nonnegative target time on the same monotonic millisecond clock as recorded observations. |
InkLinearPredictor.reset¶
InkAuthoringController¶
InkAuthoringController¶
Single-pointer authoring. begin draws the first dot; append buffers; advance processes geometry; finish clears predictions and returns canonical real-input geometry or null when idle. close is terminal.
InkAuthoringController.revision¶
Compose snapshot state, initially 0; changes after processed geometry/lifecycle updates. Private setter.
InkAuthoringController.isDrawing¶
Compose snapshot state, initially false; whether a gesture is active. Private setter.
InkAuthoringController.hasPendingInputs¶
Compose snapshot scheduling state, initially false; append can set it before geometry changes. Private setter.
InkAuthoringController.liveStroke¶
Active engine stroke, or null while idle. Read on the controller's authoring thread.
InkAuthoringController.strokeToView¶
Captured stroke-to-surface transform; initially identity. Private setter.
InkAuthoringController.begin¶
public fun begin( brush: Brush, sample: InkPointerSample, strokeToView: AffineTransform = AffineTransform.IDENTITY, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
brush |
Brush |
Required |
Native brush captured at gesture start; keep stored metadata consistent with it. |
sample |
InkPointerSample |
Required |
Real pointer observation; a nullable finishing sample may be omitted. |
strokeToView |
AffineTransform |
AffineTransform.IDENTITY |
Finite invertible stroke/page-to-input-surface transform, snapshotted at begin; regular Compose uses pixels, direct panels use AWT logical units. |
InkAuthoringController.append¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample |
Required |
Real pointer observation; a nullable finishing sample may be omitted. |
InkAuthoringController.setPredictedInputs¶
Replaces the speculative tail; an empty list retracts it. Real input also retracts old forecasts. The caller schedules advance and forecast expiration.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
samples |
List<InkPointerSample> |
Required |
Replaceable speculative observations in input-surface units; an empty list clears the tail. Never added to saved real inputs. |
InkAuthoringController.isUpdateNeeded¶
InkAuthoringController.advance¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
uptimeMillis |
Long |
Required |
Nonnegative monotonic event/frame milliseconds, using one clock per gesture. |
InkAuthoringController.finish¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
sample |
InkPointerSample? |
null |
Real pointer observation; a nullable finishing sample may be omitted. |
InkAuthoringController.cancel¶
InkAuthoringController.close¶
InkAuthoringSession¶
InkLiveStroke¶
Borrowed active engine stroke and its captured transform. Read on the session's authoring thread; do not mutate it or retain it across retirement/reuse.
public data class InkLiveStroke( public val pointerId: Long, public val stroke: InProgressStroke, public val strokeToView: AffineTransform, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
pointerId |
Long |
Required |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
stroke |
InProgressStroke |
Required |
Native finished or live stroke, as specified by the type. |
strokeToView |
AffineTransform |
Required |
Finite invertible stroke/page-to-input-surface transform, snapshotted at begin; regular Compose uses pixels, direct panels use AWT logical units. |
InkAuthoringSession¶
Concurrent-pointer authoring with an independent controller/predictor per gesture. Captures brush, transform and completion callback at Begin; completion returns only real-input canonical strokes. close is terminal.
public class InkAuthoringSession( private val predictorFactory: (() -> InkInputPredictor)? = { InkLinearPredictor() }, public val predictionMillis: Long = 12L, ) : AutoCloseable
| Parameter | Type | Default | Meaning |
|---|---|---|---|
predictorFactory |
(() -> InkInputPredictor)? |
{ InkLinearPredictor() } |
Factory for a separate predictor per gesture; null disables automatic forecasting while allowing explicit predictions. |
predictionMillis |
Long |
12L |
Session forecast horizon in milliseconds, within 0–100; zero disables automatic forecasting. |
InkAuthoringSession.revision¶
Compose snapshot state, initially 0; changes after processed geometry/lifecycle updates. Private setter.
InkAuthoringSession.activePointerIds¶
Snapshot of currently active pointer identifiers; read on the session's authoring thread.
InkAuthoringSession.liveStrokes¶
Snapshot list of borrowed active engines and captured transforms; engines may be recycled after retirement.
InkAuthoringSession.handle¶
Handles events serially; Begin replaces the same pointer's old gesture, inactive moves are ignored, CancelPointer discards one pointer, Cancel discards all. Completion runs synchronously using the callback captured at Begin.
public fun handle( event: InkInputEvent, brush: Brush, strokeToView: AffineTransform = AffineTransform.IDENTITY, onStrokeFinished: (Long, Stroke) -> Unit, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
event |
InkInputEvent |
Required |
Pointer event dispatched serially on the session's authoring thread. |
brush |
Brush |
Required |
Native brush captured at gesture start; keep stored metadata consistent with it. |
strokeToView |
AffineTransform |
AffineTransform.IDENTITY |
Finite invertible stroke/page-to-input-surface transform, snapshotted at begin; regular Compose uses pixels, direct panels use AWT logical units. |
onStrokeFinished |
(Long, Stroke) -> Unit |
Required |
Captured at Begin; synchronously receives pointerId and a canonical real-input Stroke on completion. |
InkAuthoringSession.advance¶
Advance with a time on the same input clock; retires expired forecasts and returns whether geometry changed.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
uptimeMillis |
Long |
Required |
Nonnegative monotonic event/frame milliseconds, using one clock per gesture. |
InkAuthoringSession.advanceNow¶
Maps a monotonic nanosecond clock to each gesture before advancing; convenient for native hosts.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
nanoTime |
Long |
System.nanoTime() |
Current monotonic nanoseconds, normally System.nanoTime(); the session maps this to each gesture's input clock. |
InkAuthoringSession.isUpdateNeeded¶
InkAuthoringSession.needsAnimationTick¶
Check alongside isUpdateNeeded when scheduling; includes forecast expiry even when current geometry needs no update.
InkAuthoringSession.cancel¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
pointerId |
Long |
Required |
Stable pointer identifier within the event stream; default 0 preserves single-pointer callers. |
InkAuthoringSession.cancelAll¶
InkAuthoringSession.close¶
InkDrawingSurface¶
rememberInkAuthoringController¶
Composable: call within a Compose composition.
InkDrawingSurface¶
Single-controller Compose frame loop; keeps the first active pointer and forwards explicit predictions without generating or expiring them automatically. Captures brush/transform/callback at Begin. Disabling/removal cancels; the owner closes the controller and renderer.
Composable: call within a Compose composition.
public fun InkDrawingSurface( controller: InkAuthoringController, brush: Brush, modifier: Modifier = Modifier, strokeToView: AffineTransform = AffineTransform.IDENTITY, renderer: InkPathRenderer = remember { InkPathRenderer() }, enabled: Boolean = true, inputSource: InkInputSource? = null, onStrokeFinished: (Stroke) -> Unit, drawContent: DrawScope.() -> Unit = {}, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
controller |
InkAuthoringController |
Required |
UI-thread authoring controller; attach to one surface at a time. |
brush |
Brush |
Required |
Native brush captured at gesture start; keep stored metadata consistent with it. |
modifier |
Modifier |
Modifier |
Compose layout, sizing and drawing modifiers. |
strokeToView |
AffineTransform |
AffineTransform.IDENTITY |
Finite invertible stroke/page-to-local-Compose-pixel transform, captured at Begin; include device density, zoom and scroll. |
renderer |
InkPathRenderer |
remember { InkPathRenderer() } |
Reusable drawing-thread renderer; clear path caches or close owned mesh renderers on disposal. |
enabled |
Boolean |
true |
Whether to accept input; false cancels the active gesture. |
inputSource |
InkInputSource? |
null |
Optional native adapter; null uses Compose primary-pointer gestures. |
onStrokeFinished |
(Stroke) -> Unit |
Required |
Completion callback captured at pointer down; retain/store the returned stroke. |
drawContent |
DrawScope.() -> Unit |
{} |
DrawScope block drawn before live ink, usually for finished ink and paper. |
InkDrawingSurface¶
Single-controller Compose frame loop; keeps the first active pointer and forwards explicit predictions without generating or expiring them automatically. Captures brush/transform/callback at Begin. Disabling/removal cancels; the owner closes the controller and renderer.
Composable: call within a Compose composition.
public fun InkDrawingSurface( controller: InkAuthoringController, brush: Brush, modifier: Modifier = Modifier, strokeToView: AffineTransform = AffineTransform.IDENTITY, renderer: InkRenderer, enabled: Boolean = true, inputSource: InkInputSource? = null, onStrokeFinished: (Stroke) -> Unit, drawContent: DrawScope.() -> Unit = {}, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
controller |
InkAuthoringController |
Required |
UI-thread authoring controller; attach to one surface at a time. |
brush |
Brush |
Required |
Native brush captured at gesture start; keep stored metadata consistent with it. |
modifier |
Modifier |
Modifier |
Compose layout, sizing and drawing modifiers. |
strokeToView |
AffineTransform |
AffineTransform.IDENTITY |
Finite invertible stroke/page-to-local-Compose-pixel transform, captured at Begin; include device density, zoom and scroll. |
renderer |
InkRenderer |
Required |
Reusable drawing-thread renderer; clear path caches or close owned mesh renderers on disposal. |
enabled |
Boolean |
true |
Whether to accept input; false cancels the active gesture. |
inputSource |
InkInputSource? |
null |
Optional native adapter; null uses Compose primary-pointer gestures. |
onStrokeFinished |
(Stroke) -> Unit |
Required |
Completion callback captured at pointer down; retain/store the returned stroke. |
drawContent |
DrawScope.() -> Unit |
{} |
DrawScope block drawn before live ink, usually for finished ink and paper. |
NativeInkInputSource¶
InkNativeBackend¶
Values: WINDOWS_POINTER (WM_POINTER), LINUX_XINPUT2 (X11/XWayland), LINUX_WAYLAND_TABLET (JBR WLToolkit). Selection follows the actual AWT toolkit, not only session environment variables.
NativeInkInputSource¶
Java 25+ native pen/history adapter for Windows and Linux on x86_64 or arm64. Native Wayland requires JBR 25 WLToolkit, native access, and opening java.desktop/sun.awt.wl. Uses the matching configured top-level surface; no raw reads from JBR's borrowed display socket. On native Wayland each tool over the window shows the AWT cursor of the component under it: cursor-shape-v1 when offered, else a themed cursor surface (XCURSOR_THEME/XCURSOR_SIZE); -Dbyteink.wayland.cursorShape=false forces surfaces.
public class NativeInkInputSource( private val component: Component, private val windowHandle: Long, private val pixelsPerLocalUnit: () -> Float = { 1f }, private val centimetersPerNativePixel: Float? = null, private val onFailure: (Throwable) -> Unit = { throw IllegalStateException("Native ink capture failed", it) }, ) : InkInputSource
| Parameter | Type | Default | Meaning |
|---|---|---|---|
component |
Component |
Required |
Displayable AWT input component; construct and manage the adapter on the event dispatch thread. |
windowHandle |
Long |
Required |
Nonzero matching native HWND, XID, or configured JBR Wayland top-level wl_surface handle; not an AWT object identity. |
pixelsPerLocalUnit |
() -> Float |
{ 1f } |
Callback returning finite positive native pixels per component-local logical unit; native points are divided by this scale. |
centimetersPerNativePixel |
Float? |
null |
Optional calibrated finite positive centimeters per native pixel; logical display DPI is not physical calibration. |
onFailure |
(Throwable) -> Unit |
{ throw IllegalStateException("Native ink capture failed", it) } |
EDT callback after delivery is stopped and gestures cancelled, including asynchronous Wayland setup failures; native cleanup can finish on its reader. The default throws an IllegalStateException. |
NativeInkInputSource.backend¶
Native capture backend selected from the operating system and actual AWT toolkit.
NativeInkInputSource.isReady¶
Read on EDT. True after the current subscription initializes; false before subscription and immediately after close/failure. Native Wayland publishes readiness asynchronously after registry/device discovery. Does not imply tablet hardware/protocol availability. Private setter.
NativeInkInputSource.onHover¶
Writable EDT callback for native Wayland tablet hover over the component, ordered with subscribe's events while a ready subscription is open; never called on X11/Windows, where the pen moves the system pointer. Nothing arrives after close.
NativeInkInputSource.subscribe¶
EDT-only; component must be displayable, with one subscription per source. Recreate after a Wayland hide/show. Wayland setup returns asynchronously, publishes isReady on EDT after both discovery sync replies, and ignores contacts beginning earlier. Close clears readiness/delivery immediately and signals off-EDT cleanup. Generation checks discard old packets after resubscription. Wayland setup/runtime errors deliver Cancel, close capture, then invoke onFailure on EDT. Windows/X11 acquisition stays synchronous. Listener exceptions close capture and are rethrown.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
listener |
(InkInputEvent) -> Unit |
Required |
Serial UI-thread event callback; closing the subscription stops callbacks. |
InkLowLatencyPanel¶
InkLowLatencyPanel¶
EDT-owned direct Skia authoring panel; native input and simultaneous-pointer prediction bypass Compose's frame clock. Uses AWT local logical coordinates. Default renderer is an owned InkMeshRenderer; supplied renderers are borrowed. Native Wayland retains finished/composed physical rasters with dirty wet redraw and software Swing presentation. The panel owns its session's engine mutation and updated-region reset.
public class InkLowLatencyPanel( public var brush: Brush, public var onStrokeFinished: (Long, Stroke) -> Unit, public var strokeToView: AffineTransform = AffineTransform.IDENTITY, renderer: InkRenderer? = null, private val inputSource: InkInputSource? = null, predictorFactory: (() -> InkInputPredictor)? = { InkLinearPredictor() }, drawContent: (Canvas, Int, Int) -> Unit = { _, _, _ -> }, private val centimetersPerNativePixel: Float? = null, ) : JPanel(BorderLayout()), AutoCloseable
| Parameter | Type | Default | Meaning |
|---|---|---|---|
brush |
Brush |
Required |
Native brush captured at gesture start; keep stored metadata consistent with it. |
onStrokeFinished |
(Long, Stroke) -> Unit |
Required |
Captured (pointerId, canonical real-input Stroke) callback; update finished content synchronously and enqueue persistence. |
strokeToView |
AffineTransform |
AffineTransform.IDENTITY |
Finite invertible stroke/page-to-AWT-local-logical-unit transform, captured per pointer at Begin; the panel applies device scale itself. |
renderer |
InkRenderer? |
null |
Borrowed caller-owned renderer, or null for an owned InkMeshRenderer; the panel closes only its own default renderer. |
inputSource |
InkInputSource? |
null |
Optional caller-supplied serial input source; null acquires built-in native input, with explicit acquisition failures. |
predictorFactory |
(() -> InkInputPredictor)? |
{ InkLinearPredictor() } |
Factory for a separate predictor per gesture; null disables automatic forecasting while allowing explicit predictions. |
drawContent |
(Canvas, Int, Int) -> Unit |
{ _, _, _ -> } |
Compose Canvas callback drawn before wet ink; width/height and canvas coordinates use AWT component-local logical units. |
centimetersPerNativePixel |
Float? |
null |
Optional calibrated finite positive centimeters per native pixel; logical display DPI is not physical calibration. |
InkLowLatencyPanel.session¶
Panel-owned simultaneous-pointer session; mutate/read only on the AWT EDT.
InkLowLatencyPanel.renderer¶
Actual drawing renderer; owned when constructed by the panel, borrowed when supplied by the caller.
InkLowLatencyPanel.drawContent¶
InkLowLatencyPanel.clearColorArgb¶
Writable EDT panel clear color, initially opaque white; call requestInkRender after changing it.
InkLowLatencyPanel.retainedPixelBudgetBytes¶
Writable EDT combined background/frame N32 pixel budget on native Wayland, initially 64 MiB. Zero disables retention. Oversized views and custom renderers use full redraw; changing the budget releases existing rasters.
InkLowLatencyPanel.retainedPixelBytes¶
Retained N32 raster bytes, bounded by pixelBudgetBytes; zero after clear/close.
InkLowLatencyPanel.retainedBackgroundBuildCount¶
Cumulative finished-background raster builds, including full-redraw fallback; zero on Windows/X11.
InkLowLatencyPanel.retainedFullRedrawCount¶
Cumulative full-frame raster rebuilds, including fallback; zero on Windows/X11.
InkLowLatencyPanel.retainedDirtyRedrawCount¶
Cumulative dirty-region raster redraws that reuse finished content; zero on Windows/X11.
InkLowLatencyPanel.retainedLastRedrawnPixelCount¶
Physical pixels restored/rasterized in the most recent paint; zero for unchanged re-presentation. Excludes full-window presentation copies; zero on Windows/X11.
InkLowLatencyPanel.lastInputToRenderNanos¶
Last processed-handler-to-Skia-recording interval in nanoseconds; excludes device latency and presentation completion. Private setter.
InkLowLatencyPanel.renderedFrameCount¶
Cumulative recorded authoring frames; useful for checking idle rendering. Private setter.
InkLowLatencyPanel.processedPacketCount¶
Cumulative input event packets delivered to the session; a Batch may contain many observations. Private setter.
InkLowLatencyPanel.latencyDiagnostics¶
Writable EDT opt-in software collector, null by default. Replacing/disabling it invalidates pending attribution; use a distinct collector per panel. Snapshot and export after the workload.
InkLowLatencyPanel.isInputReady¶
Read on EDT. True when the panel has a ready subscription. Native Wayland waits for asynchronous discovery; supplied custom sources are assumed ready after subscribe returns. False on detach, disable, close or native failure.
InkLowLatencyPanel.nativeWindowHandle¶
Matching HWND/XID or configured top-level Wayland wl_surface; query on the EDT only after attachment.
InkLowLatencyPanel.authoringEnabled¶
Writable EDT input switch; disabling cancels active gestures and closes capture, enabling reacquires it.
InkLowLatencyPanel.addNotify¶
InkLowLatencyPanel.removeNotify¶
InkLowLatencyPanel.requestInkRender¶
Invalidates retained finished content and coalesces an EDT render request. Scene, view, erasure/exclusion, texture and animation changes outside completion must request this redraw, even with the same drawContent callback.
InkLowLatencyPanel.close¶
Terminal EDT cleanup: cancels input, retires wet caches, releases retained rasters, closes session/presentation and only the panel-owned default renderer.
InkLowLatencySurface¶
Compose wrapper around InkLowLatencyPanel. Uses native input by default, AWT logical coordinates, an owned mesh renderer when omitted, and automatic panel disposal. A caller-supplied renderer remains caller-owned. Native Wayland needs a compatible SwingGraphics ComposePanel host.
Composable: call within a Compose composition.
public fun InkLowLatencySurface( brush: Brush, modifier: Modifier = Modifier, strokeToView: AffineTransform = AffineTransform.IDENTITY, renderer: InkRenderer? = null, enabled: Boolean = true, inputSource: InkInputSource? = null, centimetersPerNativePixel: Float? = null, onStrokeFinished: (Long, Stroke) -> Unit, drawContent: (Canvas, Int, Int) -> Unit = { _, _, _ -> }, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
brush |
Brush |
Required |
Native brush captured at gesture start; keep stored metadata consistent with it. |
modifier |
Modifier |
Modifier |
Compose layout, sizing and drawing modifiers. |
strokeToView |
AffineTransform |
AffineTransform.IDENTITY |
Finite invertible stroke/page-to-AWT-local-logical-unit transform, captured per pointer at Begin; the panel applies device scale itself. |
renderer |
InkRenderer? |
null |
Borrowed caller-owned renderer, or null for an owned InkMeshRenderer; the panel closes only its own default renderer. |
enabled |
Boolean |
true |
Whether to acquire input; false cancels all active pointers and closes capture. |
inputSource |
InkInputSource? |
null |
Optional caller-supplied serial input source; null acquires built-in native input, with explicit acquisition failures. |
centimetersPerNativePixel |
Float? |
null |
Optional calibrated finite positive centimeters per native pixel; logical display DPI is not physical calibration. |
onStrokeFinished |
(Long, Stroke) -> Unit |
Required |
Captured (pointerId, canonical real-input Stroke) callback; update finished content synchronously and enqueue persistence. |
drawContent |
(Canvas, Int, Int) -> Unit |
{ _, _, _ -> } |
Compose Canvas callback drawn before wet ink; width/height and canvas coordinates use AWT component-local logical units. |
InkLowLatencySurface¶
Compose wrapper around InkLowLatencyPanel. Uses native input by default, AWT logical coordinates, an owned mesh renderer when omitted, and automatic panel disposal. A caller-supplied renderer remains caller-owned. Native Wayland needs a compatible SwingGraphics ComposePanel host.
Composable: call within a Compose composition.
public fun InkLowLatencySurface( brush: Brush, modifier: Modifier = Modifier, strokeToView: AffineTransform = AffineTransform.IDENTITY, renderer: InkRenderer? = null, enabled: Boolean = true, inputSource: InkInputSource? = null, centimetersPerNativePixel: Float? = null, latencyDiagnostics: InkLatencyDiagnostics?, onStrokeFinished: (Long, Stroke) -> Unit, drawContent: (Canvas, Int, Int) -> Unit = { _, _, _ -> }, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
brush |
Brush |
Required |
Native brush captured at gesture start; keep stored metadata consistent with it. |
modifier |
Modifier |
Modifier |
Compose layout, sizing and drawing modifiers. |
strokeToView |
AffineTransform |
AffineTransform.IDENTITY |
Finite invertible stroke/page-to-AWT-local-logical-unit transform, captured per pointer at Begin; the panel applies device scale itself. |
renderer |
InkRenderer? |
null |
Borrowed caller-owned renderer, or null for an owned InkMeshRenderer; the panel closes only its own default renderer. |
enabled |
Boolean |
true |
Whether to acquire input; false cancels all active pointers and closes capture. |
inputSource |
InkInputSource? |
null |
Optional caller-supplied serial input source; null acquires built-in native input, with explicit acquisition failures. |
centimetersPerNativePixel |
Float? |
null |
Optional calibrated finite positive centimeters per native pixel; logical display DPI is not physical calibration. |
latencyDiagnostics |
InkLatencyDiagnostics? |
Required |
Optional bounded software-timing collector; null disables instrumentation. Construct, attach and snapshot on AWT EDT; use a distinct collector per panel. |
onStrokeFinished |
(Long, Stroke) -> Unit |
Required |
Captured (pointerId, canonical real-input Stroke) callback; update finished content synchronously and enqueue persistence. |
drawContent |
(Canvas, Int, Int) -> Unit |
{ _, _, _ -> } |
Compose Canvas callback drawn before wet ink; width/height and canvas coordinates use AWT component-local logical units. |
InkLatencyDiagnostics¶
InkLatencyRenderPath¶
SWING_SOFTWARE measures delegate raster work; SKIA_LAYER measures delegate recording on the heavyweight backend. GPU execution and physical display timing are not inferred from recording duration.
InkLatencyInputOrigin¶
NATIVE_QUEUE starts at our native enqueue; LISTENER starts at delivered input; MIXED marks a frame combining different start boundaries. Device-event clocks are not used for these elapsed times.
InkLatencyInput¶
public data class InkLatencyInput( public val id: Long, public val origin: InkLatencyInputOrigin, public val packetCount: Int, public val eventCount: Int, public val realSampleCount: Int, public val oldestQueueWaitNanos: Long?, public val newestQueueWaitNanos: Long?, public val normalizationNanos: Long?, public val handlingNanos: Long, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
id |
Long |
Required |
Increasing input/frame record number within the collector epoch; overwritten records are not renumbered. |
origin |
InkLatencyInputOrigin |
Required |
Input age starts at our native queue enqueue boundary, or custom/listener delivery; device sampling is excluded. |
packetCount |
Int |
Required |
Original queue packets merged into this delivery; one for a custom listener callback. |
eventCount |
Int |
Required |
Normalized events delivered together; a native begin/finish with history can produce several events. |
realSampleCount |
Int |
Required |
Supplied real observations, excluding predictions; this is not an accepted-engine-input count. |
oldestQueueWaitNanos |
Long? |
Required |
Oldest original packet enqueue to merged consumer entry; null when queue arrival is unavailable. |
newestQueueWaitNanos |
Long? |
Required |
Newest original packet enqueue to merged consumer entry; null when queue arrival is unavailable. |
normalizationNanos |
Long? |
Required |
EDT coordinate/axis/time mapping before delivery; null for custom listener sources or control callbacks. |
handlingNanos |
Long |
Required |
Grouped listener handling, including session work, completion callbacks and scheduling the redraw. |
InkLatencyFrame¶
public data class InkLatencyFrame( public val id: Long, public val path: InkLatencyRenderPath, public val inputEventCount: Int, public val realSampleCount: Int, public val inputOrigin: InkLatencyInputOrigin?, public val renderQueueNanos: Long?, public val engineAdvanceNanos: Long, public val drawNanos: Long, public val swingTransferAndDrawNanos: Long?, public val frameRequestNanos: Long?, public val oldestInputToDrawNanos: Long?, public val newestInputToDrawNanos: Long?, public val oldestInputToRequestReturnNanos: Long?, public val newestInputToRequestReturnNanos: Long?, public val completed: Boolean, )
| Parameter | Type | Default | Meaning |
|---|---|---|---|
id |
Long |
Required |
Increasing input/frame record number within the collector epoch; overwritten records are not renumbered. |
path |
InkLatencyRenderPath |
Required |
SWING_SOFTWARE means delegate raster work; SKIA_LAYER means delegate recording on the selected heavyweight backend. |
inputEventCount |
Int |
Required |
Supplied events since the previous delegate invocation, including events the session ignores. |
realSampleCount |
Int |
Required |
Supplied real observations, excluding predictions; this is not an accepted-engine-input count. |
inputOrigin |
InkLatencyInputOrigin? |
Required |
Common start boundary for the frame's input ages, MIXED for different origins, or null for an input-free frame. |
renderQueueNanos |
Long? |
Required |
First coalesced render request enqueue to delegate entry; null for incidental or invalidated requests. |
engineAdvanceNanos |
Long |
Required |
Scheduled session advances since the previous delegate, including timer advances; begin/finish modeling is in input handling. |
drawNanos |
Long |
Required |
Delegate drawing duration: software raster on Wayland, recording on SkiaLayer; includes renderer preparation and background drawing. |
swingTransferAndDrawNanos |
Long? |
Required |
Delegate return to SkiaSwingLayer.paint return, including Skiko pixel copies, Java2D drawing and cleanup; null on SkiaLayer. |
frameRequestNanos |
Long? |
Required |
Complete synchronous renderImmediately/paintImmediately request duration, including caller-side work after delegate return; null for incidental paints. |
oldestInputToDrawNanos |
Long? |
Required |
Oldest supplied input arrival/delivery to delegate drawing completion; null when no new input is attributed. |
newestInputToDrawNanos |
Long? |
Required |
Newest supplied input arrival/delivery to delegate drawing completion; null when no new input is attributed. |
oldestInputToRequestReturnNanos |
Long? |
Required |
Oldest supplied input arrival/delivery to immediate request return; excludes deferred submission, compositor and physical display timing. |
newestInputToRequestReturnNanos |
Long? |
Required |
Newest supplied input arrival/delivery to immediate request return; null when that boundary is unavailable. |
completed |
Boolean |
Required |
Observed drawing and enclosing synchronous scopes returned normally; does not establish presentation success/completion. False frames are excluded from JSON statistics. |
InkLatencyDiagnostics¶
Opt-in software collector for one panel. Construct, attach, clear and snapshot on AWT EDT. Independent input/frame rings retain at most capacity records; no coordinates, pressures, strokes or handles are retained. Null panel diagnostics disables instrumentation.
| Property | Type | Default | Meaning |
|---|---|---|---|
capacity |
Int |
Returned value |
Maximum records in each independent input/frame ring, within 1..65,536; default 512. |
InkLatencyDiagnostics.constructor¶
| Parameter | Type | Default | Meaning |
|---|---|---|---|
capacity |
Int |
512 |
Maximum records in each independent input/frame ring, within 1..65,536; default 512. |
InkLatencyDiagnostics.snapshot¶
Copies immutable chronological records and overwrite counts. Serialize/export the result off EDT; capture excludes device sampling, deferred presentation and physical screen response.
InkLatencyDiagnostics.clear¶
Clears both rings/counters and increments the epoch, invalidating pending queue/frame attribution. Input itself is still delivered; unavailable arrival timing becomes null.
InkLatencySnapshot¶
| Property | Type | Default | Meaning |
|---|---|---|---|
capacity |
Int |
Returned value |
Maximum records in each independent input/frame ring, within 1..65,536; default 512. |
epoch |
Long |
Returned value |
Collector generation incremented by clear; invalidates previously captured queue/frame timestamps. |
inputs |
List<InkLatencyInput> |
Returned value |
Immutable chronological copy of retained input observations, at most capacity entries. |
frames |
List<InkLatencyFrame> |
Returned value |
Immutable chronological copy of retained frame observations, at most capacity entries. |
overwrittenInputs |
Long |
Returned value |
Input observations evicted by capacity since the last clear; exported statistics cover retained observations only. |
overwrittenFrames |
Long |
Returned value |
Frame observations evicted by capacity since the last clear; exported statistics cover retained observations only. |
InkLatencySnapshot.toJson¶
Schema 1 raw observations and unweighted retained-record median/P95/P99 statistics, in nanoseconds. Nearest-rank percentiles; even medians round down. Failed frames and absent values are excluded. Presentation completion and physical pen-to-photon fields are null. Runs off EDT after capture without file I/O.