@idetik/core 0.46.2 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1584,6 +1584,12 @@ declare abstract class Layer {
1584
1584
  getUniforms(): Record<string, unknown>;
1585
1585
  }
1586
1586
 
1587
+ type GpuTiming = {
1588
+ supported: boolean;
1589
+ samples: number;
1590
+ totalMs: number;
1591
+ lastSampleAt?: number;
1592
+ };
1587
1593
  declare abstract class Renderer {
1588
1594
  private readonly canvas_;
1589
1595
  private width_;
@@ -1593,7 +1599,10 @@ declare abstract class Renderer {
1593
1599
  protected abstract renderObject(layer: Layer, object: RenderableObject, camera: Camera): void;
1594
1600
  protected abstract clear(): void;
1595
1601
  constructor(canvas: HTMLCanvasElement);
1596
- beginFrame(): void;
1602
+ abstract beginFrame(): void;
1603
+ abstract endFrame(): void;
1604
+ abstract resetGpuTiming(): void;
1605
+ abstract get gpuTiming(): GpuTiming;
1597
1606
  abstract render(viewport: Viewport): void;
1598
1607
  updateSize(): void;
1599
1608
  private updateRendererSize;
@@ -1622,11 +1631,35 @@ type MemoryStats = {
1622
1631
  /** JS heap size limit in bytes, when the browser exposes it. */
1623
1632
  jsHeapLimitBytes?: number;
1624
1633
  };
1634
+ /**
1635
+ * A snapshot of drawing frequency and GPU draw cost.
1636
+ *
1637
+ * Values are averaged over sampling windows of at least one second. A frame
1638
+ * is one canvas draw pass across all viewports including draws during resize.
1639
+ * GPU timings are collected asynchronously and lag draw submission.
1640
+ */
1641
+ type RuntimeStats = {
1642
+ /** Whether GPU timer queries are supported by the current renderer context. */
1643
+ gpuTimingSupported: boolean;
1644
+ /**
1645
+ * Canvas draw passes per second in the latest sampling window.
1646
+ * This value diverges from frames per second when on-demand rendering
1647
+ * is enabled.
1648
+ */
1649
+ renderedFramesPerSecond: number;
1650
+ /**
1651
+ * Mean elapsed GPU timeline time per sampled canvas render pass, in ms.
1652
+ * The interval spans drawing across all viewports, excluding layer updates.
1653
+ * Undefined when no recent valid sample exists.
1654
+ */
1655
+ gpuMsPerFrame?: number;
1656
+ };
1625
1657
  /**
1626
1658
  * Statistics available through `idetik.stats`.
1627
1659
  *
1628
1660
  * Getters read the current state. Only `chunks` walks chunk states. Reading
1629
- * memory usage, queue counts, or rendered objects does not scan chunks.
1661
+ * runtime rates, memory usage, queue counts, or rendered objects does not
1662
+ * scan chunks.
1630
1663
  *
1631
1664
  * @group Core
1632
1665
  */
@@ -1634,8 +1667,19 @@ declare class Stats {
1634
1667
  private readonly renderer_;
1635
1668
  private readonly chunkManager_;
1636
1669
  private readonly viewports_;
1670
+ private readonly runtime_;
1671
+ private sampleStartedAt_;
1672
+ private draws_;
1673
+ private gpuSamples_;
1674
+ private gpuMsAtWindowStart_;
1637
1675
  /** @hidden */
1638
1676
  constructor(renderer: Renderer, chunkManager: ChunkManager, viewports: readonly Viewport[]);
1677
+ /**
1678
+ * Drawing frequency and GPU cost, recalculated on read when at least one
1679
+ * second has passed since the last calculation or reset. Values cover that
1680
+ * entire interval, so less frequent reads produce longer-term averages.
1681
+ */
1682
+ get runtime(): RuntimeStats;
1639
1683
  /**
1640
1684
  * CPU chunk memory shared across instances, this renderer's GPU texture
1641
1685
  * memory, and optional JS heap figures. Heap figures are not specific to
@@ -1652,6 +1696,13 @@ declare class Stats {
1652
1696
  get chunks(): ChunkStats;
1653
1697
  /** Objects reported by the renderer for the last viewport render. */
1654
1698
  get renderedObjects(): number;
1699
+ /** @hidden */
1700
+ recordDraw(): void;
1701
+ /** @hidden */
1702
+ private sample;
1703
+ /** @hidden */
1704
+ resetRates(): void;
1705
+ private resetSample;
1655
1706
  }
1656
1707
 
1657
1708
  /**
@@ -1743,7 +1794,7 @@ declare class Idetik {
1743
1794
  readonly canvas: HTMLCanvasElement;
1744
1795
  /** The registered overlays that update once per frame in order. */
1745
1796
  readonly overlays: Overlay[];
1746
- /** Memory, queue, chunk, and rendered-object statistics. */
1797
+ /** Runtime, memory, queue, chunk, and rendered-object statistics. */
1747
1798
  readonly stats: Stats;
1748
1799
  private readonly chunkManager_;
1749
1800
  private readonly context_;
@@ -3626,4 +3677,4 @@ declare class OrbitControls implements CameraControls {
3626
3677
  }
3627
3678
 
3628
3679
  export { AxesLayer, Box2, Box3, Camera, Color, Frustum, Idetik, ImageLayer, ImageRenderable, LabelImageRenderable, LabelLayer, Layer, OmeZarrImageSource, OrbitControls, OrthographicCamera, PanZoomControls, PerspectiveCamera, PointsRenderable, ProjectedLineRenderable, RenderableObject, Stats, TrsTransform, Viewport, VolumeLayer, VolumeRenderable, createExplorationPolicy, createImageSourcePolicy, createNoPrefetchPolicy, createPlaybackPolicy, loadOmeZarrPlate, loadOmeZarrWell, loadOmeroChannels, loadOmeroDefaults };
3629
- export type { AxesLayerProps, BlendMode, CameraControls, CameraType, ChannelProps, ChunkStats, ColorLike, FileSystemOmeZarrImageSourceProps, HttpOmeZarrImageSourceProps, IdetikProps, ImageLayerProps, ImageRenderableProps, ImageSourcePolicy, ImageSourcePolicyProps, LabelColorMap, LabelColorMapProps, LabelImageRenderableProps, LabelLayerProps, LayerProps, LayerState, MemoryStats, OrbitControlsProps, OrthographicCameraFrame, OrthographicCameraProps, Overlay, PanZoomControlsProps, PerspectiveCameraProps, PointPickingResult, PointProps, PriorityCategory, ProjectedLineRenderableProps, QueueStats, SliceCoordinates, SliceOrientation, SourceChunkStats, SourceDimension, SourceDimensionLod, SourceDimensionMap, StateChangeCallback, ViewportChunkStats, ViewportProps, VolumeLayerProps, VolumeRenderableProps };
3680
+ export type { AxesLayerProps, BlendMode, CameraControls, CameraType, ChannelProps, ChunkStats, ColorLike, FileSystemOmeZarrImageSourceProps, HttpOmeZarrImageSourceProps, IdetikProps, ImageLayerProps, ImageRenderableProps, ImageSourcePolicy, ImageSourcePolicyProps, LabelColorMap, LabelColorMapProps, LabelImageRenderableProps, LabelLayerProps, LayerProps, LayerState, MemoryStats, OrbitControlsProps, OrthographicCameraFrame, OrthographicCameraProps, Overlay, PanZoomControlsProps, PerspectiveCameraProps, PointPickingResult, PointProps, PriorityCategory, ProjectedLineRenderableProps, QueueStats, RuntimeStats, SliceCoordinates, SliceOrientation, SourceChunkStats, SourceDimension, SourceDimensionLod, SourceDimensionMap, StateChangeCallback, ViewportChunkStats, ViewportProps, VolumeLayerProps, VolumeRenderableProps };