@jbrowse/render-core 5.0.0-beta.1 → 5.0.0-beta.10

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.
Files changed (352) hide show
  1. package/esm/RenderCanvas.d.ts +2 -2
  2. package/esm/RenderLifecycleMixin.d.ts +52 -20
  3. package/esm/RenderLifecycleMixin.js +89 -23
  4. package/esm/canvas2dUtils.d.ts +90 -23
  5. package/esm/canvas2dUtils.js +119 -36
  6. package/esm/colorRampLut.d.ts +5 -5
  7. package/esm/colorRampLut.js +6 -6
  8. package/esm/computePipeline.d.ts +14 -0
  9. package/esm/computePipeline.js +62 -0
  10. package/esm/contractReports.d.ts +54 -0
  11. package/esm/contractReports.js +112 -0
  12. package/esm/coverageBand.d.ts +13 -8
  13. package/esm/coverageBand.js +15 -5
  14. package/esm/coverageBandBuffers.d.ts +2 -9
  15. package/esm/coverageBandBuffers.js +1 -13
  16. package/esm/createRenderingBackend.d.ts +14 -18
  17. package/esm/createRenderingBackend.js +4 -2
  18. package/esm/displayPhase.d.ts +83 -104
  19. package/esm/displayPhase.js +42 -82
  20. package/esm/encodeMemo.d.ts +14 -0
  21. package/esm/encodeMemo.js +48 -0
  22. package/esm/gpuContextLostError.d.ts +30 -0
  23. package/esm/gpuContextLostError.js +40 -0
  24. package/esm/gpuDevice.d.ts +29 -10
  25. package/esm/gpuDevice.js +35 -16
  26. package/esm/graphicsCapabilities.d.ts +27 -19
  27. package/esm/graphicsCapabilities.js +40 -18
  28. package/esm/hal/createHal.d.ts +4 -5
  29. package/esm/hal/createHal.js +14 -4
  30. package/esm/hal/deviceGpuCache.d.ts +25 -30
  31. package/esm/hal/deviceGpuCache.js +88 -97
  32. package/esm/hal/gpuHalBase.d.ts +5 -4
  33. package/esm/hal/gpuHalBase.js +25 -14
  34. package/esm/hal/index.d.ts +2 -2
  35. package/esm/hal/index.js +1 -1
  36. package/esm/hal/mockHal.d.ts +15 -10
  37. package/esm/hal/mockHal.js +31 -18
  38. package/esm/hal/oomReporter.d.ts +7 -0
  39. package/esm/hal/oomReporter.js +10 -0
  40. package/esm/hal/passIds.d.ts +8 -7
  41. package/esm/hal/passIds.js +11 -10
  42. package/esm/hal/regionRegistry.d.ts +0 -1
  43. package/esm/hal/regionRegistry.js +3 -15
  44. package/esm/hal/types.d.ts +55 -18
  45. package/esm/hal/webgl2Hal.d.ts +23 -6
  46. package/esm/hal/webgl2Hal.js +161 -155
  47. package/esm/hal/webgpuHal.d.ts +29 -13
  48. package/esm/hal/webgpuHal.js +221 -153
  49. package/esm/installUpload.d.ts +16 -3
  50. package/esm/installUpload.js +13 -41
  51. package/esm/instanceCache.d.ts +10 -7
  52. package/esm/instanceCache.js +14 -15
  53. package/esm/instancePass.d.ts +2 -1
  54. package/esm/mapUploadSync.d.ts +2 -10
  55. package/esm/mapUploadSync.js +2 -3
  56. package/esm/marks/barMark.d.ts +30 -0
  57. package/esm/marks/barMark.js +149 -0
  58. package/esm/marks/colorFill.d.ts +17 -0
  59. package/esm/marks/colorFill.js +26 -0
  60. package/esm/marks/drawAgainstHit.d.ts +113 -0
  61. package/esm/marks/drawAgainstHit.js +407 -0
  62. package/esm/marks/ellipseDistance.d.ts +10 -0
  63. package/esm/marks/ellipseDistance.js +136 -0
  64. package/esm/marks/glyphPaint.d.ts +36 -0
  65. package/esm/marks/glyphPaint.js +77 -0
  66. package/esm/marks/index.d.ts +33 -0
  67. package/esm/marks/index.js +20 -0
  68. package/esm/marks/lineMark.d.ts +37 -0
  69. package/esm/marks/lineMark.js +416 -0
  70. package/esm/marks/linkMark.d.ts +76 -0
  71. package/esm/marks/linkMark.js +585 -0
  72. package/esm/marks/markBackend.d.ts +118 -0
  73. package/esm/marks/markBackend.js +196 -0
  74. package/esm/marks/markHit.d.ts +32 -0
  75. package/esm/marks/markHit.js +61 -0
  76. package/esm/marks/markInk.d.ts +18 -0
  77. package/esm/marks/markInk.js +71 -0
  78. package/esm/marks/markPaint.d.ts +14 -0
  79. package/esm/marks/markPaint.js +32 -0
  80. package/esm/marks/markPlan.d.ts +25 -0
  81. package/esm/marks/markPlan.js +20 -0
  82. package/esm/marks/markRamp.d.ts +72 -0
  83. package/esm/marks/markRamp.js +197 -0
  84. package/esm/marks/nearestMarkHit.d.ts +55 -0
  85. package/esm/marks/nearestMarkHit.js +158 -0
  86. package/esm/marks/pathRecorder.d.ts +14 -0
  87. package/esm/marks/pathRecorder.js +80 -0
  88. package/esm/marks/pointMark.d.ts +42 -0
  89. package/esm/marks/pointMark.js +125 -0
  90. package/esm/marks/rowLane.d.ts +39 -0
  91. package/esm/marks/rowLane.js +41 -0
  92. package/esm/marks/rowSpanIndex.d.ts +29 -0
  93. package/esm/marks/rowSpanIndex.js +141 -0
  94. package/esm/marks/rowTable.d.ts +41 -0
  95. package/esm/marks/rowTable.js +75 -0
  96. package/esm/marks/ruleMark.d.ts +21 -0
  97. package/esm/marks/ruleMark.js +91 -0
  98. package/esm/marks/spanMark.d.ts +42 -0
  99. package/esm/marks/spanMark.js +81 -0
  100. package/esm/marks/types.d.ts +261 -0
  101. package/esm/marks/types.js +175 -0
  102. package/esm/marks/valueScale.d.ts +23 -0
  103. package/esm/marks/valueScale.js +11 -0
  104. package/esm/namedReactions.d.ts +3 -4
  105. package/esm/namedReactions.js +3 -4
  106. package/esm/perRegionRenderingBackend.d.ts +21 -3
  107. package/esm/perRegionRenderingBackend.js +37 -3
  108. package/esm/regionDataMap.d.ts +2 -2
  109. package/esm/regionDataMap.js +25 -23
  110. package/esm/renderBlock.d.ts +14 -0
  111. package/esm/renderBlock.js +25 -0
  112. package/esm/renderingBackendBase.d.ts +20 -14
  113. package/esm/renderingBackendBase.js +12 -7
  114. package/esm/scoreScale.d.ts +27 -0
  115. package/esm/scoreScale.js +88 -0
  116. package/esm/shaders/barMark.generated.d.ts +3 -0
  117. package/esm/shaders/barMark.generated.js +7 -0
  118. package/esm/shaders/barMark.glsl.generated.d.ts +2 -0
  119. package/esm/shaders/barMark.glsl.generated.js +4 -0
  120. package/esm/shaders/barMark.iface.generated.d.ts +90 -0
  121. package/esm/shaders/barMark.iface.generated.js +205 -0
  122. package/esm/shaders/barMark.wgsl.generated.d.ts +1 -0
  123. package/esm/shaders/barMark.wgsl.generated.js +3 -0
  124. package/esm/shaders/capsule.js.generated.d.ts +1 -0
  125. package/esm/shaders/capsule.js.generated.js +11 -0
  126. package/esm/shaders/clipStrip.generated.d.ts +2 -0
  127. package/esm/shaders/clipStrip.generated.js +4 -0
  128. package/esm/shaders/clipStrip.js.generated.d.ts +1 -0
  129. package/esm/shaders/clipStrip.js.generated.js +21 -0
  130. package/esm/shaders/colorRampLut.js.generated.d.ts +1 -0
  131. package/esm/shaders/colorRampLut.js.generated.js +17 -0
  132. package/esm/shaders/coverageBar.generated.d.ts +2 -3
  133. package/esm/shaders/coverageBar.generated.js +4 -3
  134. package/esm/shaders/coverageBar.glsl.generated.d.ts +2 -0
  135. package/esm/shaders/coverageBar.glsl.generated.js +4 -0
  136. package/esm/shaders/coverageBar.iface.generated.js +1 -1
  137. package/esm/shaders/coverageBar.wgsl.generated.d.ts +1 -0
  138. package/esm/shaders/coverageBar.wgsl.generated.js +3 -0
  139. package/esm/shaders/coverageClip.generated.d.ts +3 -0
  140. package/esm/shaders/coverageClip.generated.js +7 -0
  141. package/esm/shaders/coverageClip.glsl.generated.d.ts +2 -0
  142. package/esm/shaders/coverageClip.glsl.generated.js +4 -0
  143. package/esm/shaders/coverageClip.iface.generated.d.ts +85 -0
  144. package/esm/shaders/coverageClip.iface.generated.js +114 -0
  145. package/esm/shaders/coverageClip.wgsl.generated.d.ts +1 -0
  146. package/esm/shaders/coverageClip.wgsl.generated.js +3 -0
  147. package/esm/shaders/coverageIndicator.generated.d.ts +2 -3
  148. package/esm/shaders/coverageIndicator.generated.js +4 -3
  149. package/esm/shaders/coverageIndicator.glsl.generated.d.ts +2 -0
  150. package/esm/shaders/coverageIndicator.glsl.generated.js +4 -0
  151. package/esm/shaders/coverageIndicator.iface.generated.js +1 -1
  152. package/esm/shaders/coverageIndicator.wgsl.generated.d.ts +1 -0
  153. package/esm/shaders/coverageIndicator.wgsl.generated.js +3 -0
  154. package/esm/shaders/coverageInterbase.generated.d.ts +2 -3
  155. package/esm/shaders/coverageInterbase.generated.js +4 -3
  156. package/esm/shaders/coverageInterbase.glsl.generated.d.ts +2 -0
  157. package/esm/shaders/coverageInterbase.glsl.generated.js +4 -0
  158. package/esm/shaders/coverageInterbase.iface.generated.js +1 -1
  159. package/esm/shaders/coverageInterbase.wgsl.generated.d.ts +1 -0
  160. package/esm/shaders/coverageInterbase.wgsl.generated.js +3 -0
  161. package/esm/shaders/coverageMod.generated.d.ts +2 -3
  162. package/esm/shaders/coverageMod.generated.js +4 -3
  163. package/esm/shaders/coverageMod.glsl.generated.d.ts +2 -0
  164. package/esm/shaders/coverageMod.glsl.generated.js +4 -0
  165. package/esm/shaders/coverageMod.iface.generated.js +1 -1
  166. package/esm/shaders/coverageMod.wgsl.generated.d.ts +1 -0
  167. package/esm/shaders/coverageMod.wgsl.generated.js +3 -0
  168. package/esm/shaders/coverageSnp.generated.d.ts +2 -3
  169. package/esm/shaders/coverageSnp.generated.js +4 -3
  170. package/esm/shaders/coverageSnp.glsl.generated.d.ts +2 -0
  171. package/esm/shaders/coverageSnp.glsl.generated.js +4 -0
  172. package/esm/shaders/coverageSnp.iface.generated.js +1 -1
  173. package/esm/shaders/coverageSnp.wgsl.generated.d.ts +1 -0
  174. package/esm/shaders/coverageSnp.wgsl.generated.js +3 -0
  175. package/esm/shaders/curveDistance.js.generated.d.ts +5 -0
  176. package/esm/shaders/curveDistance.js.generated.js +87 -0
  177. package/esm/shaders/hpmath.js.generated.d.ts +2 -1
  178. package/esm/shaders/hpmath.js.generated.js +5 -2
  179. package/esm/shaders/lineCenterMark.generated.d.ts +3 -0
  180. package/esm/shaders/lineCenterMark.generated.js +7 -0
  181. package/esm/shaders/lineCenterMark.glsl.generated.d.ts +2 -0
  182. package/esm/shaders/lineCenterMark.glsl.generated.js +4 -0
  183. package/esm/shaders/lineCenterMark.iface.generated.d.ts +104 -0
  184. package/esm/shaders/lineCenterMark.iface.generated.js +237 -0
  185. package/esm/shaders/lineCenterMark.wgsl.generated.d.ts +1 -0
  186. package/esm/shaders/lineCenterMark.wgsl.generated.js +3 -0
  187. package/esm/shaders/lineCommon.generated.d.ts +2 -0
  188. package/esm/shaders/lineCommon.generated.js +4 -0
  189. package/esm/shaders/lineStepMark.generated.d.ts +3 -0
  190. package/esm/shaders/lineStepMark.generated.js +7 -0
  191. package/esm/shaders/lineStepMark.glsl.generated.d.ts +2 -0
  192. package/esm/shaders/lineStepMark.glsl.generated.js +4 -0
  193. package/esm/shaders/lineStepMark.iface.generated.d.ts +98 -0
  194. package/esm/shaders/lineStepMark.iface.generated.js +225 -0
  195. package/esm/shaders/lineStepMark.wgsl.generated.d.ts +1 -0
  196. package/esm/shaders/lineStepMark.wgsl.generated.js +3 -0
  197. package/esm/shaders/linkMark.consts.generated.d.ts +14 -0
  198. package/esm/shaders/linkMark.consts.generated.js +16 -0
  199. package/esm/shaders/linkMark.generated.d.ts +4 -0
  200. package/esm/shaders/linkMark.generated.js +8 -0
  201. package/esm/shaders/linkMark.glsl.generated.d.ts +2 -0
  202. package/esm/shaders/linkMark.glsl.generated.js +4 -0
  203. package/esm/shaders/linkMark.iface.generated.d.ts +142 -0
  204. package/esm/shaders/linkMark.iface.generated.js +1829 -0
  205. package/esm/shaders/linkMark.js.generated.d.ts +7 -0
  206. package/esm/shaders/linkMark.js.generated.js +159 -0
  207. package/esm/shaders/linkMark.wgsl.generated.d.ts +1 -0
  208. package/esm/shaders/linkMark.wgsl.generated.js +3 -0
  209. package/esm/shaders/markColor.generated.d.ts +9 -0
  210. package/esm/shaders/markColor.generated.js +11 -0
  211. package/esm/shaders/pointGlyph.js.generated.d.ts +2 -0
  212. package/esm/shaders/pointGlyph.js.generated.js +15 -0
  213. package/esm/shaders/pointMark.consts.generated.d.ts +7 -0
  214. package/esm/shaders/pointMark.consts.generated.js +9 -0
  215. package/esm/shaders/pointMark.generated.d.ts +4 -0
  216. package/esm/shaders/pointMark.generated.js +8 -0
  217. package/esm/shaders/pointMark.glsl.generated.d.ts +2 -0
  218. package/esm/shaders/pointMark.glsl.generated.js +4 -0
  219. package/esm/shaders/pointMark.iface.generated.d.ts +98 -0
  220. package/esm/shaders/pointMark.iface.generated.js +219 -0
  221. package/esm/shaders/pointMark.js.generated.d.ts +3 -0
  222. package/esm/shaders/pointMark.js.generated.js +93 -0
  223. package/esm/shaders/pointMark.wgsl.generated.d.ts +1 -0
  224. package/esm/shaders/pointMark.wgsl.generated.js +3 -0
  225. package/esm/shaders/rowRect.generated.d.ts +0 -1
  226. package/esm/shaders/rowRect.generated.js +0 -1
  227. package/esm/shaders/rowTable.generated.d.ts +1 -0
  228. package/esm/shaders/rowTable.generated.js +3 -0
  229. package/esm/shaders/rowTable.js.generated.d.ts +5 -0
  230. package/esm/shaders/rowTable.js.generated.js +29 -0
  231. package/esm/shaders/scoreScale.generated.d.ts +2 -0
  232. package/esm/shaders/scoreScale.generated.js +4 -0
  233. package/esm/shaders/scoreScale.js.generated.d.ts +1 -0
  234. package/esm/shaders/scoreScale.js.generated.js +50 -23
  235. package/esm/shaders/spanMark.generated.d.ts +3 -0
  236. package/esm/shaders/spanMark.generated.js +7 -0
  237. package/esm/shaders/spanMark.glsl.generated.d.ts +2 -0
  238. package/esm/shaders/spanMark.glsl.generated.js +4 -0
  239. package/esm/shaders/spanMark.iface.generated.d.ts +81 -0
  240. package/esm/shaders/spanMark.iface.generated.js +215 -0
  241. package/esm/shaders/spanMark.wgsl.generated.d.ts +1 -0
  242. package/esm/shaders/spanMark.wgsl.generated.js +3 -0
  243. package/esm/sharedBackendKey.d.ts +18 -0
  244. package/esm/{keyedRenderingBackend.js → sharedBackendKey.js} +5 -0
  245. package/esm/slangPass.d.ts +18 -11
  246. package/esm/slangPass.js +12 -4
  247. package/esm/useGraphicsCapabilities.d.ts +1 -1
  248. package/esm/useGraphicsCapabilities.js +1 -1
  249. package/esm/useRenderingBackend.d.ts +13 -13
  250. package/esm/useRenderingBackend.js +58 -20
  251. package/esm/webgpuUtils.d.ts +3 -11
  252. package/esm/webgpuUtils.js +12 -33
  253. package/package.json +32 -7
  254. package/src/shaders/antialias.slang +46 -0
  255. package/src/shaders/arcHull.test.ts +267 -0
  256. package/src/shaders/barMark.generated.ts +11 -0
  257. package/src/shaders/barMark.glsl.generated.ts +6 -0
  258. package/src/shaders/barMark.iface.generated.ts +285 -0
  259. package/src/shaders/barMark.slang +167 -0
  260. package/src/shaders/barMark.wgsl.generated.ts +4 -0
  261. package/src/shaders/capsule.js.generated.ts +14 -0
  262. package/src/shaders/capsule.slang +12 -4
  263. package/src/shaders/clipStrip.generated.ts +6 -0
  264. package/src/shaders/clipStrip.js.generated.ts +22 -0
  265. package/src/shaders/clipStrip.slang +34 -0
  266. package/src/shaders/clipStrip.test.ts +39 -0
  267. package/src/shaders/colorPack.slang +5 -1
  268. package/src/shaders/colorRampLut.js.generated.ts +22 -0
  269. package/src/shaders/colorRampLut.slang +15 -1
  270. package/src/shaders/coverageBand.slang +64 -32
  271. package/src/shaders/coverageBar.generated.ts +6 -5
  272. package/src/shaders/coverageBar.glsl.generated.ts +6 -0
  273. package/src/shaders/coverageBar.iface.generated.ts +1 -1
  274. package/src/shaders/coverageBar.slang +10 -10
  275. package/src/shaders/coverageBar.wgsl.generated.ts +4 -0
  276. package/src/shaders/coverageClip.generated.ts +11 -0
  277. package/src/shaders/coverageClip.glsl.generated.ts +6 -0
  278. package/src/shaders/coverageClip.iface.generated.ts +172 -0
  279. package/src/shaders/coverageClip.slang +38 -0
  280. package/src/shaders/coverageClip.wgsl.generated.ts +4 -0
  281. package/src/shaders/coverageIndicator.generated.ts +6 -5
  282. package/src/shaders/coverageIndicator.glsl.generated.ts +6 -0
  283. package/src/shaders/coverageIndicator.iface.generated.ts +1 -1
  284. package/src/shaders/coverageIndicator.wgsl.generated.ts +4 -0
  285. package/src/shaders/coverageInterbase.generated.ts +6 -5
  286. package/src/shaders/coverageInterbase.glsl.generated.ts +6 -0
  287. package/src/shaders/coverageInterbase.iface.generated.ts +1 -1
  288. package/src/shaders/coverageInterbase.wgsl.generated.ts +4 -0
  289. package/src/shaders/coverageMod.generated.ts +6 -5
  290. package/src/shaders/coverageMod.glsl.generated.ts +6 -0
  291. package/src/shaders/coverageMod.iface.generated.ts +1 -1
  292. package/src/shaders/coverageMod.wgsl.generated.ts +4 -0
  293. package/src/shaders/coverageSnp.generated.ts +6 -5
  294. package/src/shaders/coverageSnp.glsl.generated.ts +6 -0
  295. package/src/shaders/coverageSnp.iface.generated.ts +1 -1
  296. package/src/shaders/coverageSnp.wgsl.generated.ts +4 -0
  297. package/src/shaders/curveDistance.js.generated.ts +91 -0
  298. package/src/shaders/curveDistance.slang +265 -0
  299. package/src/shaders/hpClampFloor.test.ts +87 -0
  300. package/src/shaders/hpmath.js.generated.ts +6 -2
  301. package/src/shaders/hpmath.slang +100 -48
  302. package/src/shaders/insetValueScale.test.ts +67 -0
  303. package/src/shaders/lineCenterMark.generated.ts +11 -0
  304. package/src/shaders/lineCenterMark.glsl.generated.ts +6 -0
  305. package/src/shaders/lineCenterMark.iface.generated.ts +328 -0
  306. package/src/shaders/lineCenterMark.slang +127 -0
  307. package/src/shaders/lineCenterMark.wgsl.generated.ts +4 -0
  308. package/src/shaders/lineCommon.generated.ts +6 -0
  309. package/src/shaders/lineCommon.slang +102 -0
  310. package/src/shaders/lineStepMark.generated.ts +11 -0
  311. package/src/shaders/lineStepMark.glsl.generated.ts +6 -0
  312. package/src/shaders/lineStepMark.iface.generated.ts +311 -0
  313. package/src/shaders/lineStepMark.slang +125 -0
  314. package/src/shaders/lineStepMark.wgsl.generated.ts +4 -0
  315. package/src/shaders/linkMark.consts.generated.ts +30 -0
  316. package/src/shaders/linkMark.generated.ts +12 -0
  317. package/src/shaders/linkMark.glsl.generated.ts +6 -0
  318. package/src/shaders/linkMark.iface.generated.ts +1954 -0
  319. package/src/shaders/linkMark.js.generated.ts +167 -0
  320. package/src/shaders/linkMark.slang +439 -0
  321. package/src/shaders/linkMark.wgsl.generated.ts +4 -0
  322. package/src/shaders/markColor.generated.ts +20 -0
  323. package/src/shaders/markColor.slang +128 -0
  324. package/src/shaders/pointGlyph.js.generated.ts +20 -0
  325. package/src/shaders/pointGlyph.slang +23 -7
  326. package/src/shaders/pointGlyphPad.test.ts +242 -0
  327. package/src/shaders/pointMark.consts.generated.ts +16 -0
  328. package/src/shaders/pointMark.generated.ts +12 -0
  329. package/src/shaders/pointMark.glsl.generated.ts +6 -0
  330. package/src/shaders/pointMark.iface.generated.ts +304 -0
  331. package/src/shaders/pointMark.js.generated.ts +99 -0
  332. package/src/shaders/pointMark.slang +227 -0
  333. package/src/shaders/pointMark.wgsl.generated.ts +4 -0
  334. package/src/shaders/rowRect.generated.ts +0 -2
  335. package/src/shaders/rowRect.slang +39 -58
  336. package/src/shaders/rowTable.generated.ts +4 -0
  337. package/src/shaders/rowTable.js.generated.ts +37 -0
  338. package/src/shaders/rowTable.slang +98 -0
  339. package/src/shaders/scoreScale.generated.ts +6 -0
  340. package/src/shaders/scoreScale.js.generated.ts +48 -23
  341. package/src/shaders/scoreScale.slang +49 -55
  342. package/src/shaders/sdEllipse.test.ts +211 -0
  343. package/src/shaders/spanMark.generated.ts +11 -0
  344. package/src/shaders/spanMark.glsl.generated.ts +6 -0
  345. package/src/shaders/spanMark.iface.generated.ts +289 -0
  346. package/src/shaders/spanMark.slang +77 -0
  347. package/src/shaders/spanMark.wgsl.generated.ts +4 -0
  348. package/src/shaders/valueScale.slang +26 -0
  349. package/src/shaders/wideCircleLeg.test.ts +85 -0
  350. package/esm/globalRenderingBackend.d.ts +0 -90
  351. package/esm/globalRenderingBackend.js +0 -53
  352. package/esm/keyedRenderingBackend.d.ts +0 -41
@@ -0,0 +1,39 @@
1
+ import type { RowTable } from './rowTable.ts';
2
+ /**
3
+ * The `row` lane a value shape may carry: which band an instance stands in,
4
+ * `rowHeight` px each, the value scale ruling every band on its own. A caller
5
+ * that declares no rows is on row 0 with the whole canvas for a band, which is
6
+ * the same arithmetic, so the shaders take the lane unconditionally.
7
+ */
8
+ export interface RowChannel {
9
+ row?: Uint32Array;
10
+ }
11
+ export interface RowParams {
12
+ /** CSS px per row band; the canvas height when absent. */
13
+ rowHeight?: number;
14
+ /** CSS px every row's band starts below the canvas top, less a scroll; 0 when absent. */
15
+ rowOffsetPx?: number;
16
+ /**
17
+ * The table `row` is read through as a key: its drawn slot, hidden, or a
18
+ * colour override. Absent, `row` is the slot.
19
+ */
20
+ rowTable?: RowTable;
21
+ }
22
+ /** The lane the instance buffer packs: zeros where the caller sent none. */
23
+ export declare function rowLane(row: Uint32Array | undefined, count: number): Uint32Array<ArrayBufferLike>;
24
+ /**
25
+ * The `rowTableKeys` uniform: the table's key count, or -1 with none bound,
26
+ * which a shader reads as each `row` being its own slot.
27
+ */
28
+ export declare function rowTableKeys({ rowTable }: Pick<RowParams, 'rowTable'>): number;
29
+ /** What a pass reading the table binds. */
30
+ export declare function rowTableTextures({ rowTable }: Pick<RowParams, 'rowTable'>): {
31
+ rowTable: import("./types.ts").MarkTexels | undefined;
32
+ };
33
+ export declare function bandHeightPx(params: RowParams, canvasHeight: number): number;
34
+ /** The slot `key` is drawn on, undefined where the table hides it. */
35
+ export declare function keySlot(key: number, table: RowTable | undefined): number | undefined;
36
+ /** The slot instance `i` is drawn on, undefined where the table hides its key. */
37
+ export declare function rowSlot(row: Uint32Array | undefined, i: number, table: RowTable | undefined): number | undefined;
38
+ /** The colour instance `i` is drawn in: its key's override, else `color`. */
39
+ export declare function rowColor(color: number, row: Uint32Array | undefined, i: number, table: RowTable | undefined): number;
@@ -0,0 +1,41 @@
1
+ import { HIDDEN_ROW, NO_ROW_COLOR } from './rowTable.js';
2
+ const NO_ROWS = new Uint32Array(0);
3
+ /** The lane the instance buffer packs: zeros where the caller sent none. */
4
+ export function rowLane(row, count) {
5
+ return row ?? (count === 0 ? NO_ROWS : new Uint32Array(count));
6
+ }
7
+ /**
8
+ * The `rowTableKeys` uniform: the table's key count, or -1 with none bound,
9
+ * which a shader reads as each `row` being its own slot.
10
+ */
11
+ export function rowTableKeys({ rowTable }) {
12
+ return rowTable ? rowTable.keys : -1;
13
+ }
14
+ /** What a pass reading the table binds. */
15
+ export function rowTableTextures({ rowTable }) {
16
+ return { rowTable: rowTable?.texture };
17
+ }
18
+ export function bandHeightPx(params, canvasHeight) {
19
+ return params.rowHeight ?? canvasHeight;
20
+ }
21
+ function rowKey(row, i) {
22
+ return row === undefined ? 0 : row[i];
23
+ }
24
+ /** The slot `key` is drawn on, undefined where the table hides it. */
25
+ export function keySlot(key, table) {
26
+ if (!table) {
27
+ return key;
28
+ }
29
+ const slot = key < table.keys ? table.slot[key] : HIDDEN_ROW;
30
+ return slot === HIDDEN_ROW ? undefined : slot;
31
+ }
32
+ /** The slot instance `i` is drawn on, undefined where the table hides its key. */
33
+ export function rowSlot(row, i, table) {
34
+ return keySlot(rowKey(row, i), table);
35
+ }
36
+ /** The colour instance `i` is drawn in: its key's override, else `color`. */
37
+ export function rowColor(color, row, i, table) {
38
+ const key = rowKey(row, i);
39
+ const override = table && key < table.keys ? table.color[key] : NO_ROW_COLOR;
40
+ return override >>> 24 === 0 ? color : override;
41
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Instances from `x` to `x2` grouped by the row they stand in, each row's in
3
+ * start order, with the furthest end any instance of the row has reached so
4
+ * far: what answers which of a row's spans, bars, rules or line steps overlap
5
+ * a stretch of bp, in place of a spatial index over every instance. Each
6
+ * stands in its own row only, so the question a hover asks is one row's, and
7
+ * the answer is a binary search and a short walk.
8
+ */
9
+ export interface RowSpanIndex {
10
+ /** Each row key's first position in `order`, and the end, at `key + 1`. */
11
+ readonly rowStart: Uint32Array;
12
+ /** The instance at each position: a row's together, in start order. */
13
+ readonly order: Uint32Array;
14
+ /** The furthest end among the row's instances up to each position. */
15
+ readonly reach: Uint32Array;
16
+ }
17
+ /**
18
+ * The index over `count` spans from `x` to `x2`, each in the row `row` names
19
+ * (row 0 where there is no lane). A counting sort by row, a sort of each row
20
+ * the input left out of start order, and one pass for the reach.
21
+ */
22
+ export declare function rowSpanIndex(x: Uint32Array, x2: Uint32Array, row: Uint32Array | undefined, count?: number): RowSpanIndex;
23
+ /**
24
+ * The instances of row `key` whose span meets `[bpMin, bpMax]`, the ends
25
+ * included, as a spatial index over the spans would answer them. The last
26
+ * span starting at or before `bpMax` is a binary search away; walking back,
27
+ * the reach says when no earlier span of the row can reach `bpMin`.
28
+ */
29
+ export declare function spansInRow(index: RowSpanIndex, x: Uint32Array, x2: Uint32Array, key: number, bpMin: number, bpMax: number, out: number[]): void;
@@ -0,0 +1,141 @@
1
+ const lowEnd = (x, x2, i) => Math.min(x[i], x2[i]);
2
+ const highEnd = (x, x2, i) => Math.max(x[i], x2[i]);
3
+ // A row that arrived nearly in start order, as `cells` writes one (an
4
+ // insertion lands just ahead of the run it interrupts), put in order by
5
+ // insertion, which costs one move per piece out of place; a row further out of
6
+ // order than that answers false and is left for `sortRow`.
7
+ function nudgeRow(order, from, to, x, x2) {
8
+ let moves = 0;
9
+ const budget = 4 * (to - from);
10
+ for (let p = from + 1; p < to; p++) {
11
+ const i = order[p];
12
+ const start = lowEnd(x, x2, i);
13
+ let q = p - 1;
14
+ while (q >= from && lowEnd(x, x2, order[q]) > start) {
15
+ order[q + 1] = order[q];
16
+ q--;
17
+ if (++moves > budget) {
18
+ order[q + 1] = i;
19
+ return false;
20
+ }
21
+ }
22
+ order[q + 1] = i;
23
+ }
24
+ return true;
25
+ }
26
+ // One row's instances into start order, ties in the order they came: the
27
+ // start and the position packed into one double where that is exact, which
28
+ // keeps the typed sort off a comparator.
29
+ function sortRow(order, from, to, x, x2) {
30
+ const n = to - from;
31
+ const slice = order.subarray(from, to);
32
+ let lo = Infinity;
33
+ let hi = -Infinity;
34
+ for (const i of slice) {
35
+ const s = lowEnd(x, x2, i);
36
+ lo = Math.min(lo, s);
37
+ hi = Math.max(hi, s);
38
+ }
39
+ if ((hi - lo + 1) * n < Number.MAX_SAFE_INTEGER) {
40
+ const keys = new Float64Array(n);
41
+ for (let k = 0; k < n; k++) {
42
+ keys[k] = (lowEnd(x, x2, slice[k]) - lo) * n + k;
43
+ }
44
+ keys.sort();
45
+ const placed = Uint32Array.from(slice);
46
+ for (let k = 0; k < n; k++) {
47
+ slice[k] = placed[keys[k] % n];
48
+ }
49
+ }
50
+ else {
51
+ slice.sort((a, b) => lowEnd(x, x2, a) - lowEnd(x, x2, b) || a - b);
52
+ }
53
+ }
54
+ /**
55
+ * The index over `count` spans from `x` to `x2`, each in the row `row` names
56
+ * (row 0 where there is no lane). A counting sort by row, a sort of each row
57
+ * the input left out of start order, and one pass for the reach.
58
+ */
59
+ export function rowSpanIndex(x, x2, row, count = x.length) {
60
+ let rows = 1;
61
+ if (row) {
62
+ for (let i = 0; i < count; i++) {
63
+ if (row[i] + 1 > rows) {
64
+ rows = row[i] + 1;
65
+ }
66
+ }
67
+ }
68
+ const rowStart = new Uint32Array(rows + 1);
69
+ if (row) {
70
+ for (let i = 0; i < count; i++) {
71
+ rowStart[row[i] + 1]++;
72
+ }
73
+ for (let r = 0; r < rows; r++) {
74
+ rowStart[r + 1] = rowStart[r + 1] + rowStart[r];
75
+ }
76
+ }
77
+ else {
78
+ rowStart[1] = count;
79
+ }
80
+ const order = new Uint32Array(count);
81
+ if (row) {
82
+ const next = rowStart.slice(0, rows);
83
+ for (let i = 0; i < count; i++) {
84
+ order[next[row[i]]++] = i;
85
+ }
86
+ }
87
+ else {
88
+ for (let i = 0; i < count; i++) {
89
+ order[i] = i;
90
+ }
91
+ }
92
+ const reach = new Uint32Array(count);
93
+ for (let r = 0; r < rows; r++) {
94
+ const from = rowStart[r];
95
+ const to = rowStart[r + 1];
96
+ for (let p = from + 1; p < to; p++) {
97
+ if (lowEnd(x, x2, order[p]) < lowEnd(x, x2, order[p - 1])) {
98
+ if (!nudgeRow(order, from, to, x, x2)) {
99
+ sortRow(order, from, to, x, x2);
100
+ }
101
+ break;
102
+ }
103
+ }
104
+ let furthest = 0;
105
+ for (let p = from; p < to; p++) {
106
+ furthest = Math.max(furthest, highEnd(x, x2, order[p]));
107
+ reach[p] = furthest;
108
+ }
109
+ }
110
+ return { rowStart, order, reach };
111
+ }
112
+ /**
113
+ * The instances of row `key` whose span meets `[bpMin, bpMax]`, the ends
114
+ * included, as a spatial index over the spans would answer them. The last
115
+ * span starting at or before `bpMax` is a binary search away; walking back,
116
+ * the reach says when no earlier span of the row can reach `bpMin`.
117
+ */
118
+ export function spansInRow(index, x, x2, key, bpMin, bpMax, out) {
119
+ const { rowStart, order, reach } = index;
120
+ if (key + 1 >= rowStart.length) {
121
+ return;
122
+ }
123
+ const from = rowStart[key];
124
+ let lo = from;
125
+ let hi = rowStart[key + 1];
126
+ while (lo < hi) {
127
+ const mid = (lo + hi) >>> 1;
128
+ if (lowEnd(x, x2, order[mid]) <= bpMax) {
129
+ lo = mid + 1;
130
+ }
131
+ else {
132
+ hi = mid;
133
+ }
134
+ }
135
+ for (let p = lo - 1; p >= from && reach[p] >= bpMin; p--) {
136
+ const i = order[p];
137
+ if (highEnd(x, x2, i) >= bpMin) {
138
+ out.push(i);
139
+ }
140
+ }
141
+ }
@@ -0,0 +1,41 @@
1
+ import type { MarkTexels } from './types.ts';
2
+ /** The `slot` a hidden key holds. */
3
+ export declare const HIDDEN_ROW = 4294967295;
4
+ /** The `color` a key with no override holds: alpha 0, the instance's own colour. */
5
+ export declare const NO_ROW_COLOR = 0;
6
+ /**
7
+ * The row axis as a pass reads it: each key's drawn slot or `HIDDEN_ROW`, its
8
+ * packed ABGR colour override or `NO_ROW_COLOR`, and the RGBA8 texture the
9
+ * vertex stage samples for the same answers (`shaders/rowTable.slang` has the
10
+ * layout). One object, so the shader, the painter, the ink and the hit test
11
+ * cannot place a key differently. Immutable: a reorder, focus, hide or
12
+ * recolour builds a new one, and the backend uploads on identity.
13
+ */
14
+ export interface RowTable {
15
+ readonly keys: number;
16
+ readonly slot: Uint32Array;
17
+ readonly color: Uint32Array;
18
+ readonly texture: MarkTexels;
19
+ }
20
+ /**
21
+ * The table for `slot[key]` and `color[key]`, both indexed by key: `slot` is
22
+ * `HIDDEN_ROW` where the key draws nothing, `color` is `NO_ROW_COLOR` where the
23
+ * instance keeps its own colour, an override alpha 0 being none. Both arrays
24
+ * are held, not copied. Each key's texel sits where the shader's own twins
25
+ * put it.
26
+ */
27
+ export declare function buildRowTable(slot: Uint32Array, color?: Uint32Array): RowTable;
28
+ /**
29
+ * The keys a display's rows carry across every region: a name's key is
30
+ * assigned the first time it is asked for and never moves, so a region encoded
31
+ * against the registry stays valid as later regions add names and the table
32
+ * alone follows the reader's order, focus and colours. Grows only.
33
+ */
34
+ export declare class RowKeys {
35
+ private readonly index;
36
+ readonly names: string[];
37
+ keyOf(name: string): number;
38
+ /** The key a name holds, undefined where none was ever assigned. */
39
+ lookup(name: string): number | undefined;
40
+ get size(): number;
41
+ }
@@ -0,0 +1,75 @@
1
+ import { rowTablePlaneHeight, rowTableTexelX, rowTableTexelY, rowTableWidth, } from '../shaders/rowTable.js.generated.js';
2
+ /** The `slot` a hidden key holds. */
3
+ export const HIDDEN_ROW = 0xffffffff;
4
+ /** The `color` a key with no override holds: alpha 0, the instance's own colour. */
5
+ export const NO_ROW_COLOR = 0;
6
+ const MAX_SLOT = 0xffffff;
7
+ /**
8
+ * The table for `slot[key]` and `color[key]`, both indexed by key: `slot` is
9
+ * `HIDDEN_ROW` where the key draws nothing, `color` is `NO_ROW_COLOR` where the
10
+ * instance keeps its own colour, an override alpha 0 being none. Both arrays
11
+ * are held, not copied. Each key's texel sits where the shader's own twins
12
+ * put it.
13
+ */
14
+ export function buildRowTable(slot, color = new Uint32Array(slot.length)) {
15
+ const keys = slot.length;
16
+ if (color.length !== keys) {
17
+ throw new Error(`buildRowTable: ${keys} slots but ${color.length} colours; both are per key`);
18
+ }
19
+ const width = rowTableWidth(keys);
20
+ const plane = rowTablePlaneHeight(keys);
21
+ const bytes = new Uint8Array(width * plane * 2 * 4);
22
+ for (let key = 0; key < keys; key++) {
23
+ const s = slot[key];
24
+ const x = rowTableTexelX(key, keys);
25
+ const y = rowTableTexelY(key, keys);
26
+ const o = (y * width + x) * 4;
27
+ if (s !== HIDDEN_ROW) {
28
+ if (s > MAX_SLOT) {
29
+ throw new Error(`buildRowTable: slot ${s} of key ${key} exceeds the ${MAX_SLOT} the table holds`);
30
+ }
31
+ bytes[o] = s & 0xff;
32
+ bytes[o + 1] = (s >>> 8) & 0xff;
33
+ bytes[o + 2] = (s >>> 16) & 0xff;
34
+ bytes[o + 3] = 0xff;
35
+ }
36
+ const c = color[key];
37
+ const p = ((y + plane) * width + x) * 4;
38
+ bytes[p] = c & 0xff;
39
+ bytes[p + 1] = (c >>> 8) & 0xff;
40
+ bytes[p + 2] = (c >>> 16) & 0xff;
41
+ bytes[p + 3] = c >>> 24;
42
+ }
43
+ return {
44
+ keys,
45
+ slot,
46
+ color,
47
+ texture: { bytes, width, height: plane * 2 },
48
+ };
49
+ }
50
+ /**
51
+ * The keys a display's rows carry across every region: a name's key is
52
+ * assigned the first time it is asked for and never moves, so a region encoded
53
+ * against the registry stays valid as later regions add names and the table
54
+ * alone follows the reader's order, focus and colours. Grows only.
55
+ */
56
+ export class RowKeys {
57
+ index = new Map();
58
+ names = [];
59
+ keyOf(name) {
60
+ let key = this.index.get(name);
61
+ if (key === undefined) {
62
+ key = this.names.length;
63
+ this.names.push(name);
64
+ this.index.set(name, key);
65
+ }
66
+ return key;
67
+ }
68
+ /** The key a name holds, undefined where none was ever assigned. */
69
+ lookup(name) {
70
+ return this.index.get(name);
71
+ }
72
+ get size() {
73
+ return this.names.length;
74
+ }
75
+ }
@@ -0,0 +1,21 @@
1
+ import type { ColorChannel } from './markRamp.ts';
2
+ import type { ValuedMarkParams } from './pointMark.ts';
3
+ import type { RowChannel } from './rowLane.ts';
4
+ import type { MarkShape } from './types.ts';
5
+ /**
6
+ * The `rule` shape's channels: a segment across `x`..`x2` at `y`, Vega-Lite's
7
+ * `rule` with `x`, `x2` and `y`.
8
+ */
9
+ export interface RuleChannels extends ColorChannel, RowChannel {
10
+ x: Uint32Array;
11
+ x2: Uint32Array;
12
+ y: Float32Array;
13
+ count: number;
14
+ }
15
+ export interface RuleParams extends ValuedMarkParams {
16
+ /** Thickness in CSS px. */
17
+ sizePx: number;
18
+ /** Narrowest a rule is painted, in CSS px, grown from its `x` end. */
19
+ minWidthPx: number;
20
+ }
21
+ export declare const ruleMark: MarkShape<RuleChannels, RuleParams>;
@@ -0,0 +1,91 @@
1
+ import { bpProjection, projectBp, spanLeft } from '../canvas2dUtils.js';
2
+ import * as shader from '../shaders/pointMark.generated.js';
3
+ import { pointRowYPx, pointYPx } from '../shaders/pointMark.js.generated.js';
4
+ import { rowBandTopPx } from '../shaders/rowTable.js.generated.js';
5
+ import { slangPass } from '../slangPass.js';
6
+ import { makeAbgrFill } from './colorFill.js';
7
+ import { colorBits, paintColors } from './markRamp.js';
8
+ import { valueWindow } from './nearestMarkHit.js';
9
+ import { writePointUniforms } from './pointMark.js';
10
+ import { bandHeightPx, rowColor, rowLane, rowSlot, rowTableTextures, } from './rowLane.js';
11
+ import { valueScaleUniforms } from './valueScale.js';
12
+ function ruleFrame(block, frame, params) {
13
+ const { valueScaleType, valueSymlogConstant } = valueScaleUniforms(params);
14
+ return {
15
+ ...bpProjection(block),
16
+ band: bandHeightPx(params, frame.canvasHeight),
17
+ rowOffsetPx: params.rowOffsetPx ?? 0,
18
+ reverse: params.reverse ? 1 : 0,
19
+ domainMin: params.domain[0],
20
+ domainMax: params.domain[1],
21
+ scaleType: valueScaleType,
22
+ symlogConstant: valueSymlogConstant,
23
+ insetPx: params.insetPx ?? 0,
24
+ sizePx: params.sizePx,
25
+ minWidthPx: params.minWidthPx,
26
+ table: params.rowTable,
27
+ left: 0,
28
+ top: 0,
29
+ width: 0,
30
+ };
31
+ }
32
+ function placeRule(c, g, i) {
33
+ const slot = rowSlot(c.row, i, g.table);
34
+ if (slot === undefined) {
35
+ return false;
36
+ }
37
+ const xa = projectBp(g, c.x[i]);
38
+ const xb = projectBp(g, c.x2[i]);
39
+ const width = Math.max(g.minWidthPx, Math.abs(xb - xa));
40
+ const valueY = pointYPx(c.y[i], g.domainMin, g.domainMax, g.band, g.scaleType, g.insetPx, g.symlogConstant);
41
+ g.left = spanLeft(xa, xb, width);
42
+ g.width = width;
43
+ g.top =
44
+ pointRowYPx(rowBandTopPx(g.rowOffsetPx, g.band, slot), g.band, g.reverse, valueY) -
45
+ g.sizePx / 2;
46
+ return true;
47
+ }
48
+ export const ruleMark = {
49
+ id: 'rule',
50
+ pass: {
51
+ ...slangPass({ id: 'rule', mod: shader }),
52
+ pack: c => shader.packInstances({
53
+ ...c,
54
+ color: colorBits(c, c.count),
55
+ glyph: new Uint8Array(c.count),
56
+ row: rowLane(c.row, c.count),
57
+ }, c.count),
58
+ },
59
+ writeUniforms(scratch, clip, block, frame, params) {
60
+ writePointUniforms(scratch, clip, block, frame, params, {
61
+ radiusPx: params.sizePx / 2,
62
+ rule: true,
63
+ minWidthPx: params.minWidthPx,
64
+ });
65
+ },
66
+ textures: rowTableTextures,
67
+ paintBlock(ctx, channels, block, frame, params) {
68
+ const { count, row } = channels;
69
+ if (count === 0) {
70
+ return;
71
+ }
72
+ const color = paintColors(channels, count, params.colorScale);
73
+ const g = ruleFrame(block, frame, params);
74
+ const setFill = makeAbgrFill(ctx);
75
+ for (let i = 0; i < count; i++) {
76
+ if (placeRule(channels, g, i)) {
77
+ setFill(rowColor(color[i], row, i, g.table));
78
+ ctx.fillRect(g.left, g.top, g.width, g.sizePx);
79
+ }
80
+ }
81
+ },
82
+ ink(channels, block, frame, params, i) {
83
+ const g = ruleFrame(block, frame, params);
84
+ return placeRule(channels, g, i)
85
+ ? { left: g.left, top: g.top, width: g.width, height: g.sizePx }
86
+ : undefined;
87
+ },
88
+ valueWindow(yPx, radiusPx, frame, params) {
89
+ return valueWindow(yPx, radiusPx + params.sizePx / 2, frame, params);
90
+ },
91
+ };
@@ -0,0 +1,42 @@
1
+ import type { ColorChannel } from './markRamp.ts';
2
+ import type { RowTable } from './rowTable.ts';
3
+ import type { MarkColorScale, MarkShape } from './types.ts';
4
+ /**
5
+ * The `span` shape's channels: a coloured rectangle from `x` to `x2` on the
6
+ * band belonging to `row`, its colour packed or, under a colour scale, the
7
+ * value it resolves from.
8
+ */
9
+ export interface SpanChannels extends ColorChannel {
10
+ x: Uint32Array;
11
+ x2: Uint32Array;
12
+ /** The band's slot, or its key where the params bind a `rowTable`. */
13
+ row: Uint32Array;
14
+ count: number;
15
+ }
16
+ export interface SpanParams {
17
+ /** The quantitative colour scale, for a span whose colour is a ramp or a threshold. */
18
+ colorScale?: MarkColorScale;
19
+ /** CSS px per row. */
20
+ rowHeight: number;
21
+ /** Fraction of the row the rect fills, leaving inter-row gaps. */
22
+ rowProportion: number;
23
+ /**
24
+ * Narrowest a span is painted, in CSS px. A caller whose marks tile writes
25
+ * zero; one whose marks are sparse intervals floors them.
26
+ */
27
+ minWidthPx: number;
28
+ /**
29
+ * CSS px the **painter alone** adds to each span's right edge, closing the
30
+ * hairline two antialiased `fillRect`s leave where tiling runs meet on a
31
+ * fractional pixel. The GPU pass needs none, and the ink excludes it.
32
+ */
33
+ seamPx: number;
34
+ /** Rows-area scroll offset in CSS px; 0 for a canvas sized to its content. */
35
+ scrollTop: number;
36
+ /**
37
+ * The table `row` is read through as a key: its drawn slot, hidden, or a
38
+ * colour override. Absent, `row` is the slot.
39
+ */
40
+ rowTable?: RowTable;
41
+ }
42
+ export declare const spanMark: MarkShape<SpanChannels, SpanParams>;
@@ -0,0 +1,81 @@
1
+ import { bpRangeXTuple } from '../blockClipUtils.js';
2
+ import { bpProjection, projectBp, spanLeft } from '../canvas2dUtils.js';
3
+ import { drawnRowHeightPx, rowBandOffsetPx, } from '../shaders/rowRect.js.generated.js';
4
+ import * as shader from '../shaders/spanMark.generated.js';
5
+ import { slangPass } from '../slangPass.js';
6
+ import { makeAbgrFill } from './colorFill.js';
7
+ import { colorBits, paintColors, rampUniforms } from './markRamp.js';
8
+ import { rowColor, rowSlot, rowTableKeys, rowTableTextures } from './rowLane.js';
9
+ function spanFrame(block, params) {
10
+ const { rowHeight, rowProportion } = params;
11
+ const { originPx, startBp, spanBp, signedSpanPx } = bpProjection(block);
12
+ return {
13
+ originPx,
14
+ startBp,
15
+ spanBp,
16
+ signedSpanPx,
17
+ rowHeight,
18
+ scrollTop: params.scrollTop,
19
+ bandOffsetPx: rowBandOffsetPx(rowHeight, rowProportion),
20
+ minWidthPx: params.minWidthPx,
21
+ table: params.rowTable,
22
+ left: 0,
23
+ top: 0,
24
+ width: 0,
25
+ height: drawnRowHeightPx(rowHeight, rowProportion),
26
+ };
27
+ }
28
+ function placeSpan(c, g, i) {
29
+ const slot = rowSlot(c.row, i, g.table);
30
+ if (slot === undefined) {
31
+ return false;
32
+ }
33
+ const xa = projectBp(g, c.x[i]);
34
+ const xb = projectBp(g, c.x2[i]);
35
+ const width = Math.max(g.minWidthPx, Math.abs(xb - xa));
36
+ g.left = spanLeft(xa, xb, width);
37
+ g.top = g.bandOffsetPx + g.rowHeight * slot - g.scrollTop;
38
+ g.width = width;
39
+ return true;
40
+ }
41
+ export const spanMark = {
42
+ id: 'span',
43
+ pass: {
44
+ ...slangPass({ id: 'span', mod: shader }),
45
+ pack: c => shader.packInstances({ ...c, color: colorBits(c, c.count) }, c.count),
46
+ },
47
+ writeUniforms(scratch, clip, block, frame, params) {
48
+ shader.writeUniforms(scratch, {
49
+ bpRangeX: bpRangeXTuple(clip, block.reversed),
50
+ canvasHeight: frame.canvasHeight,
51
+ minCellDenomPx: clip.scissorW,
52
+ minCellPx: params.minWidthPx,
53
+ zero: 0,
54
+ rowHeight: params.rowHeight,
55
+ rowProportion: params.rowProportion,
56
+ scrollTop: params.scrollTop,
57
+ rowTableKeys: rowTableKeys(params),
58
+ ...rampUniforms(params.colorScale),
59
+ });
60
+ },
61
+ textures: rowTableTextures,
62
+ paintBlock(ctx, channels, block, _frame, params) {
63
+ const { count, row } = channels;
64
+ const { seamPx } = params;
65
+ const color = paintColors(channels, count, params.colorScale);
66
+ const g = spanFrame(block, params);
67
+ const setFill = makeAbgrFill(ctx);
68
+ for (let i = 0; i < count; i++) {
69
+ if (placeSpan(channels, g, i)) {
70
+ setFill(rowColor(color[i], row, i, g.table));
71
+ ctx.fillRect(g.left, g.top, g.width + seamPx, g.height);
72
+ }
73
+ }
74
+ },
75
+ ink(channels, block, _frame, params, i) {
76
+ const g = spanFrame(block, params);
77
+ return placeSpan(channels, g, i)
78
+ ? { left: g.left, top: g.top, width: g.width, height: g.height }
79
+ : undefined;
80
+ },
81
+ };