@lightningjs/renderer 0.0.1
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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +184 -0
- package/dist/exports/core-api.d.ts +73 -0
- package/dist/exports/core-api.js +95 -0
- package/dist/exports/core-api.js.map +1 -0
- package/dist/exports/main-api.d.ts +28 -0
- package/dist/exports/main-api.js +45 -0
- package/dist/exports/main-api.js.map +1 -0
- package/dist/exports/utils.d.ts +23 -0
- package/dist/exports/utils.js +42 -0
- package/dist/exports/utils.js.map +1 -0
- package/dist/src/common/CommonTypes.d.ts +38 -0
- package/dist/src/common/CommonTypes.js +20 -0
- package/dist/src/common/CommonTypes.js.map +1 -0
- package/dist/src/common/EventEmitter.d.ts +12 -0
- package/dist/src/common/EventEmitter.js +66 -0
- package/dist/src/common/EventEmitter.js.map +1 -0
- package/dist/src/common/IAnimationController.d.ts +9 -0
- package/dist/src/common/IAnimationController.js +20 -0
- package/dist/src/common/IAnimationController.js.map +1 -0
- package/dist/src/core/CoreExtension.d.ts +12 -0
- package/dist/src/core/CoreExtension.js +29 -0
- package/dist/src/core/CoreExtension.js.map +1 -0
- package/dist/src/core/CoreNode.d.ts +147 -0
- package/dist/src/core/CoreNode.js +498 -0
- package/dist/src/core/CoreNode.js.map +1 -0
- package/dist/src/core/CoreShaderManager.d.ts +29 -0
- package/dist/src/core/CoreShaderManager.js +58 -0
- package/dist/src/core/CoreShaderManager.js.map +1 -0
- package/dist/src/core/CoreTextNode.d.ts +64 -0
- package/dist/src/core/CoreTextNode.js +251 -0
- package/dist/src/core/CoreTextNode.js.map +1 -0
- package/dist/src/core/CoreTextureManager.d.ts +173 -0
- package/dist/src/core/CoreTextureManager.js +190 -0
- package/dist/src/core/CoreTextureManager.js.map +1 -0
- package/dist/src/core/Matrix2DContext.d.ts +15 -0
- package/dist/src/core/Matrix2DContext.js +45 -0
- package/dist/src/core/Matrix2DContext.js.map +1 -0
- package/dist/src/core/Stage.d.ts +53 -0
- package/dist/src/core/Stage.js +214 -0
- package/dist/src/core/Stage.js.map +1 -0
- package/dist/src/core/animations/AnimationManager.d.ts +7 -0
- package/dist/src/core/animations/AnimationManager.js +34 -0
- package/dist/src/core/animations/AnimationManager.js.map +1 -0
- package/dist/src/core/animations/CoreAnimation.d.ts +27 -0
- package/dist/src/core/animations/CoreAnimation.js +103 -0
- package/dist/src/core/animations/CoreAnimation.js.map +1 -0
- package/dist/src/core/animations/CoreAnimationController.d.ts +21 -0
- package/dist/src/core/animations/CoreAnimationController.js +96 -0
- package/dist/src/core/animations/CoreAnimationController.js.map +1 -0
- package/dist/src/core/lib/glm/common.d.ts +162 -0
- package/dist/src/core/lib/glm/common.js +81 -0
- package/dist/src/core/lib/glm/common.js.map +1 -0
- package/dist/src/core/lib/glm/index.d.ts +11 -0
- package/dist/src/core/lib/glm/index.js +30 -0
- package/dist/src/core/lib/glm/index.js.map +1 -0
- package/dist/src/core/lib/glm/mat2.d.ts +219 -0
- package/dist/src/core/lib/glm/mat2.js +396 -0
- package/dist/src/core/lib/glm/mat2.js.map +1 -0
- package/dist/src/core/lib/glm/mat2d.d.ts +237 -0
- package/dist/src/core/lib/glm/mat2d.js +442 -0
- package/dist/src/core/lib/glm/mat2d.js.map +1 -0
- package/dist/src/core/lib/glm/mat3.d.ts +283 -0
- package/dist/src/core/lib/glm/mat3.js +680 -0
- package/dist/src/core/lib/glm/mat3.js.map +1 -0
- package/dist/src/core/lib/glm/mat4.d.ts +550 -0
- package/dist/src/core/lib/glm/mat4.js +1802 -0
- package/dist/src/core/lib/glm/mat4.js.map +1 -0
- package/dist/src/core/lib/glm/quat.d.ts +363 -0
- package/dist/src/core/lib/glm/quat.js +693 -0
- package/dist/src/core/lib/glm/quat.js.map +1 -0
- package/dist/src/core/lib/glm/quat2.d.ts +356 -0
- package/dist/src/core/lib/glm/quat2.js +754 -0
- package/dist/src/core/lib/glm/quat2.js.map +1 -0
- package/dist/src/core/lib/glm/vec2.d.ts +365 -0
- package/dist/src/core/lib/glm/vec2.js +569 -0
- package/dist/src/core/lib/glm/vec2.js.map +1 -0
- package/dist/src/core/lib/glm/vec3.d.ts +406 -0
- package/dist/src/core/lib/glm/vec3.js +720 -0
- package/dist/src/core/lib/glm/vec3.js.map +1 -0
- package/dist/src/core/lib/glm/vec4.d.ts +330 -0
- package/dist/src/core/lib/glm/vec4.js +608 -0
- package/dist/src/core/lib/glm/vec4.js.map +1 -0
- package/dist/src/core/lib/utils.d.ts +27 -0
- package/dist/src/core/lib/utils.js +108 -0
- package/dist/src/core/lib/utils.js.map +1 -0
- package/dist/src/core/platform.d.ts +10 -0
- package/dist/src/core/platform.js +37 -0
- package/dist/src/core/platform.js.map +1 -0
- package/dist/src/core/renderers/CoreContextTexture.d.ts +6 -0
- package/dist/src/core/renderers/CoreContextTexture.js +25 -0
- package/dist/src/core/renderers/CoreContextTexture.js.map +1 -0
- package/dist/src/core/renderers/CoreRenderOp.d.ts +3 -0
- package/dist/src/core/renderers/CoreRenderOp.js +21 -0
- package/dist/src/core/renderers/CoreRenderOp.js.map +1 -0
- package/dist/src/core/renderers/CoreRenderer.d.ts +39 -0
- package/dist/src/core/renderers/CoreRenderer.js +26 -0
- package/dist/src/core/renderers/CoreRenderer.js.map +1 -0
- package/dist/src/core/renderers/CoreShader.d.ts +9 -0
- package/dist/src/core/renderers/CoreShader.js +28 -0
- package/dist/src/core/renderers/CoreShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.d.ts +7 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js +32 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.d.ts +46 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +163 -0
- package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.d.ts +27 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js +82 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.d.ts +100 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +372 -0
- package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +1 -0
- package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +39 -0
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js +187 -0
- package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/internal/BufferCollection.d.ts +27 -0
- package/dist/src/core/renderers/webgl/internal/BufferCollection.js +48 -0
- package/dist/src/core/renderers/webgl/internal/BufferCollection.js.map +1 -0
- package/dist/src/core/renderers/webgl/internal/RendererUtils.d.ts +39 -0
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js +92 -0
- package/dist/src/core/renderers/webgl/internal/RendererUtils.js.map +1 -0
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.d.ts +46 -0
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.js +50 -0
- package/dist/src/core/renderers/webgl/internal/ShaderUtils.js.map +1 -0
- package/dist/src/core/renderers/webgl/internal/WebGlUtils.d.ts +10 -0
- package/dist/src/core/renderers/webgl/internal/WebGlUtils.js +31 -0
- package/dist/src/core/renderers/webgl/internal/WebGlUtils.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.d.ts +9 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +89 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.d.ts +10 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +119 -0
- package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.d.ts +53 -0
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +299 -0
- package/dist/src/core/renderers/webgl/shaders/DynamicShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.d.ts +29 -0
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +135 -0
- package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/SdfShader.d.ts +45 -0
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js +137 -0
- package/dist/src/core/renderers/webgl/shaders/SdfShader.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.d.ts +15 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +68 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.d.ts +14 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js +54 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.d.ts +15 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +68 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.d.ts +15 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +68 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.d.ts +15 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +68 -0
- package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.d.ts +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js +33 -0
- package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.d.ts +17 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js +98 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.d.ts +6 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js +32 -0
- package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.d.ts +16 -0
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +140 -0
- package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.d.ts +14 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +82 -0
- package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js.map +1 -0
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.d.ts +44 -0
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js +61 -0
- package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js.map +1 -0
- package/dist/src/core/scene/Scene.d.ts +59 -0
- package/dist/src/core/scene/Scene.js +106 -0
- package/dist/src/core/scene/Scene.js.map +1 -0
- package/dist/src/core/text-rendering/TextTextureRendererUtils.d.ts +53 -0
- package/dist/src/core/text-rendering/TextTextureRendererUtils.js +156 -0
- package/dist/src/core/text-rendering/TextTextureRendererUtils.js.map +1 -0
- package/dist/src/core/text-rendering/TrFontManager.d.ts +25 -0
- package/dist/src/core/text-rendering/TrFontManager.js +75 -0
- package/dist/src/core/text-rendering/TrFontManager.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.d.ts +29 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js +88 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/SdfTrFontFace.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.d.ts +103 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.js +21 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/FontShaper.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.d.ts +59 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.js +86 -0
- package/dist/src/core/text-rendering/font-face-types/SdfTrFontFace/internal/SdfFontShaper.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.d.ts +48 -0
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.js +54 -0
- package/dist/src/core/text-rendering/font-face-types/TrFontFace.js.map +1 -0
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.d.ts +11 -0
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.js +54 -0
- package/dist/src/core/text-rendering/font-face-types/WebTrFontFace.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.d.ts +45 -0
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js +492 -0
- package/dist/src/core/text-rendering/renderers/CanvasTextRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.d.ts +115 -0
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js +493 -0
- package/dist/src/core/text-rendering/renderers/LightningTextTextureRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.d.ts +67 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +452 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.d.ts +12 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.js +61 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/PeekableGenerator.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.d.ts +33 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.js +52 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/SpecialCodepoints.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.d.ts +13 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.js +32 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.d.ts +21 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.js +53 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.d.ts +4 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js +34 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.d.ts +18 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js +294 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.d.ts +20 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js +55 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.d.ts +10 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.js +39 -0
- package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.js.map +1 -0
- package/dist/src/core/text-rendering/renderers/TextRenderer.d.ts +254 -0
- package/dist/src/core/text-rendering/renderers/TextRenderer.js +100 -0
- package/dist/src/core/text-rendering/renderers/TextRenderer.js.map +1 -0
- package/dist/src/core/textures/ColorTexture.d.ts +35 -0
- package/dist/src/core/textures/ColorTexture.js +62 -0
- package/dist/src/core/textures/ColorTexture.js.map +1 -0
- package/dist/src/core/textures/ImageTexture.d.ts +51 -0
- package/dist/src/core/textures/ImageTexture.js +76 -0
- package/dist/src/core/textures/ImageTexture.js.map +1 -0
- package/dist/src/core/textures/NoiseTexture.d.ts +42 -0
- package/dist/src/core/textures/NoiseTexture.js +63 -0
- package/dist/src/core/textures/NoiseTexture.js.map +1 -0
- package/dist/src/core/textures/SubTexture.d.ts +57 -0
- package/dist/src/core/textures/SubTexture.js +82 -0
- package/dist/src/core/textures/SubTexture.js.map +1 -0
- package/dist/src/core/textures/Texture.d.ts +92 -0
- package/dist/src/core/textures/Texture.js +105 -0
- package/dist/src/core/textures/Texture.js.map +1 -0
- package/dist/src/core/utils.d.ts +15 -0
- package/dist/src/core/utils.js +183 -0
- package/dist/src/core/utils.js.map +1 -0
- package/dist/src/main-api/INode.d.ts +390 -0
- package/dist/src/main-api/INode.js +20 -0
- package/dist/src/main-api/INode.js.map +1 -0
- package/dist/src/main-api/IRenderDriver.d.ts +20 -0
- package/dist/src/main-api/IRenderDriver.js +20 -0
- package/dist/src/main-api/IRenderDriver.js.map +1 -0
- package/dist/src/main-api/RendererMain.d.ts +232 -0
- package/dist/src/main-api/RendererMain.js +303 -0
- package/dist/src/main-api/RendererMain.js.map +1 -0
- package/dist/src/render-drivers/main/MainOnlyNode.d.ts +84 -0
- package/dist/src/render-drivers/main/MainOnlyNode.js +324 -0
- package/dist/src/render-drivers/main/MainOnlyNode.js.map +1 -0
- package/dist/src/render-drivers/main/MainOnlyTextNode.d.ts +39 -0
- package/dist/src/render-drivers/main/MainOnlyTextNode.js +165 -0
- package/dist/src/render-drivers/main/MainOnlyTextNode.js.map +1 -0
- package/dist/src/render-drivers/main/MainRenderDriver.d.ts +17 -0
- package/dist/src/render-drivers/main/MainRenderDriver.js +88 -0
- package/dist/src/render-drivers/main/MainRenderDriver.js.map +1 -0
- package/dist/src/render-drivers/threadx/NodeStruct.d.ts +81 -0
- package/dist/src/render-drivers/threadx/NodeStruct.js +254 -0
- package/dist/src/render-drivers/threadx/NodeStruct.js.map +1 -0
- package/dist/src/render-drivers/threadx/SharedNode.d.ts +36 -0
- package/dist/src/render-drivers/threadx/SharedNode.js +57 -0
- package/dist/src/render-drivers/threadx/SharedNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/TextNodeStruct.d.ts +34 -0
- package/dist/src/render-drivers/threadx/TextNodeStruct.js +156 -0
- package/dist/src/render-drivers/threadx/TextNodeStruct.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.d.ts +20 -0
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js +84 -0
- package/dist/src/render-drivers/threadx/ThreadXMainAnimationController.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXMainNode.d.ts +37 -0
- package/dist/src/render-drivers/threadx/ThreadXMainNode.js +121 -0
- package/dist/src/render-drivers/threadx/ThreadXMainNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.d.ts +23 -0
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js +50 -0
- package/dist/src/render-drivers/threadx/ThreadXMainTextNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.d.ts +21 -0
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js +194 -0
- package/dist/src/render-drivers/threadx/ThreadXRenderDriver.js.map +1 -0
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.d.ts +48 -0
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js +32 -0
- package/dist/src/render-drivers/threadx/ThreadXRendererMessage.js.map +1 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.d.ts +19 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js +172 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.d.ts +22 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js +101 -0
- package/dist/src/render-drivers/threadx/worker/ThreadXRendererTextNode.js.map +1 -0
- package/dist/src/render-drivers/threadx/worker/renderer.d.ts +1 -0
- package/dist/src/render-drivers/threadx/worker/renderer.js +130 -0
- package/dist/src/render-drivers/threadx/worker/renderer.js.map +1 -0
- package/dist/src/render-drivers/utils.d.ts +10 -0
- package/dist/src/render-drivers/utils.js +41 -0
- package/dist/src/render-drivers/utils.js.map +1 -0
- package/dist/src/utils.d.ts +79 -0
- package/dist/src/utils.js +162 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/tsconfig.dist.tsbuildinfo +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Number of floating point numbers that represent a single glyph in the SDF vertex buffer.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* The vertex buffer contains:
|
|
24
|
+
* - 6 vertex positions
|
|
25
|
+
* - 6 texture coordinates
|
|
26
|
+
* - = 12 positions/coordinates per glyph
|
|
27
|
+
*
|
|
28
|
+
* Each vertex position and texture coordinate consist of 2 floating point numbers (x/y).
|
|
29
|
+
* So there are 12 * 2 = 24 floating point numbers that make up a single glyph.
|
|
30
|
+
*/
|
|
31
|
+
export const FLOATS_PER_GLYPH = 24;
|
|
32
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../src/core/text-rendering/renderers/SdfTextRenderer/internal/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC"}
|
package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TrProps, TextRendererState } from '../../TextRenderer.js';
|
|
2
|
+
import type { SdfTextRendererState } from '../SdfTextRenderer.js';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the start conditions for the layout loop.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Returns `undefined` if the layout loop should not be run.
|
|
8
|
+
*
|
|
9
|
+
* @param fontSize
|
|
10
|
+
* @param fontSizeRatio
|
|
11
|
+
* @param sdfLineHeight
|
|
12
|
+
* @param renderWindow
|
|
13
|
+
* @param lineCache
|
|
14
|
+
* @param textH
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function getStartConditions(fontSize: TrProps['fontSize'], offsetY: TrProps['offsetY'], fontSizeRatio: number, sdfLineHeight: number, renderWindow: SdfTextRendererState['renderWindow'], lineCache: SdfTextRendererState['lineCache'], textH: TextRendererState['textH']): {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
lineIndex: number;
|
|
21
|
+
} | undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Gets the start conditions for the layout loop.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Returns `undefined` if the layout loop should not be run.
|
|
24
|
+
*
|
|
25
|
+
* @param fontSize
|
|
26
|
+
* @param fontSizeRatio
|
|
27
|
+
* @param sdfLineHeight
|
|
28
|
+
* @param renderWindow
|
|
29
|
+
* @param lineCache
|
|
30
|
+
* @param textH
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export function getStartConditions(fontSize, offsetY, fontSizeRatio, sdfLineHeight, renderWindow, lineCache, textH) {
|
|
34
|
+
// State variables
|
|
35
|
+
let startLineIndex = 0;
|
|
36
|
+
if (renderWindow) {
|
|
37
|
+
startLineIndex = Math.min(Math.max(Math.floor(renderWindow.y1 / fontSize), 0), lineCache.length);
|
|
38
|
+
}
|
|
39
|
+
// TODO: Possibly break out startX / startY into a separate function
|
|
40
|
+
// TODO: (fontSize / 6.4286 / fontSizeRatio) Adding this to the startY helps the text line up better with Canvas rendered text
|
|
41
|
+
const startX = 0;
|
|
42
|
+
const startY = offsetY / fontSizeRatio + startLineIndex * sdfLineHeight; // TODO: Figure out what determines the initial y offset of text.
|
|
43
|
+
// Don't attempt to render anything if we know we're starting past the established end of the text
|
|
44
|
+
if (textH && startY >= textH / fontSizeRatio) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
x: startX,
|
|
49
|
+
y: startY,
|
|
50
|
+
lineIndex: startLineIndex,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=getStartConditions.js.map
|
package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStartConditions.js","sourceRoot":"","sources":["../../../../../../../src/core/text-rendering/renderers/SdfTextRenderer/internal/getStartConditions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAA6B,EAC7B,OAA2B,EAC3B,aAAqB,EACrB,aAAqB,EACrB,YAAkD,EAClD,SAA4C,EAC5C,KAAiC;IAQjC,kBAAkB;IAClB,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,YAAY,EAAE;QAChB,cAAc,GAAG,IAAI,CAAC,GAAG,CACvB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,EACnD,SAAS,CAAC,MAAM,CACjB,CAAC;KACH;IAED,oEAAoE;IACpE,8HAA8H;IAC9H,MAAM,MAAM,GAAG,CAAC,CAAC;IACjB,MAAM,MAAM,GAAG,OAAO,GAAG,aAAa,GAAG,cAAc,GAAG,aAAa,CAAC,CAAC,iEAAiE;IAE1I,kGAAkG;IAClG,IAAI,KAAK,IAAI,MAAM,IAAI,KAAK,GAAG,aAAa,EAAE;QAC5C,OAAO;KACR;IAED,OAAO;QACL,CAAC,EAAE,MAAM;QACT,CAAC,EAAE,MAAM;QACT,SAAS,EAAE,cAAc;KAC1B,CAAC;AACJ,CAAC"}
|
package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
// Reversible Generator Wrapper Class
|
|
20
|
+
/**
|
|
21
|
+
* Generator function that yields each Unicode code point in the given string.
|
|
22
|
+
*/
|
|
23
|
+
export function* getUnicodeCodepoints(text, start = 0) {
|
|
24
|
+
let i = start;
|
|
25
|
+
while (i < text.length) {
|
|
26
|
+
const codePoint = text.codePointAt(i);
|
|
27
|
+
if (codePoint === undefined) {
|
|
28
|
+
throw new Error('Invalid Unicode code point');
|
|
29
|
+
}
|
|
30
|
+
yield codePoint;
|
|
31
|
+
i += codePoint <= 0xffff ? 1 : 2;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=getUnicodeCodepoints.js.map
|
package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUnicodeCodepoints.js","sourceRoot":"","sources":["../../../../../../../src/core/text-rendering/renderers/SdfTextRenderer/internal/getUnicodeCodepoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,qCAAqC;AAErC;;GAEG;AACH,MAAM,SAAS,CAAC,CAAC,oBAAoB,CACnC,IAAY,EACZ,KAAK,GAAG,CAAC;IAET,IAAI,CAAC,GAAG,KAAK,CAAC;IACd,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE;QACtB,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACtC,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC/C;QACD,MAAM,SAAS,CAAC;QAChB,CAAC,IAAI,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAClC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TrProps, TextRendererState } from '../../TextRenderer.js';
|
|
2
|
+
import type { SdfTextRendererState } from '../SdfTextRenderer.js';
|
|
3
|
+
export declare function layoutText(curLineIndex: number, startX: number, startY: number, text: TrProps['text'], textAlign: TrProps['textAlign'], width: TrProps['width'], height: TrProps['height'], fontSize: TrProps['fontSize'], letterSpacing: TrProps['letterSpacing'],
|
|
4
|
+
/**
|
|
5
|
+
* Mutated
|
|
6
|
+
*/
|
|
7
|
+
vertexBuffer: NonNullable<SdfTextRendererState['vertexBuffer']>, contain: TrProps['contain'],
|
|
8
|
+
/**
|
|
9
|
+
* Mutated
|
|
10
|
+
*/
|
|
11
|
+
lineCache: SdfTextRendererState['lineCache'], renderWindow: SdfTextRendererState['renderWindow'], trFontFace: SdfTextRendererState['trFontFace'], forceFullLayoutCalc: TextRendererState['forceFullLayoutCalc'], scrollable: TrProps['scrollable']): {
|
|
12
|
+
bufferNumFloats: number;
|
|
13
|
+
bufferNumQuads: number;
|
|
14
|
+
layoutNumCharacters: number;
|
|
15
|
+
fullyProcessed: boolean;
|
|
16
|
+
maxX: number;
|
|
17
|
+
maxY: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { assertTruthy } from '../../../../../utils.js';
|
|
20
|
+
import { PeekableIterator } from './PeekableGenerator.js';
|
|
21
|
+
import { FLOATS_PER_GLYPH } from './constants.js';
|
|
22
|
+
import { getUnicodeCodepoints } from './getUnicodeCodepoints.js';
|
|
23
|
+
import { measureText } from './measureText.js';
|
|
24
|
+
export function layoutText(curLineIndex, startX, startY, text, textAlign, width, height, fontSize, letterSpacing,
|
|
25
|
+
/**
|
|
26
|
+
* Mutated
|
|
27
|
+
*/
|
|
28
|
+
vertexBuffer, contain,
|
|
29
|
+
/**
|
|
30
|
+
* Mutated
|
|
31
|
+
*/
|
|
32
|
+
lineCache, renderWindow, trFontFace, forceFullLayoutCalc, scrollable) {
|
|
33
|
+
assertTruthy(trFontFace, 'Font face must be loaded');
|
|
34
|
+
assertTruthy(trFontFace.loaded, 'Font face must be loaded');
|
|
35
|
+
assertTruthy(trFontFace.data, 'Font face must be loaded');
|
|
36
|
+
assertTruthy(trFontFace.shaper, 'Font face must be loaded');
|
|
37
|
+
// Regardless of fontSize (or other scaling properties), we layout the vertices of each glyph
|
|
38
|
+
// using the fixed coordinate space determined by font size used to produce the atlas.
|
|
39
|
+
// Scaling for display is handled by shader uniforms inexpensively.
|
|
40
|
+
// So we have:
|
|
41
|
+
// - vertex space: the space in which the vertices of each glyph are laid out
|
|
42
|
+
// - screen space: the screen pixel space
|
|
43
|
+
// Input properties such as x, y, w, fontSize, letterSpacing, etc. are all expressed in screen space.
|
|
44
|
+
// We convert these to the vertex space by dividing them the `fontSizeRatio` factor.
|
|
45
|
+
/**
|
|
46
|
+
* `lineHeight` in vertex coordinates
|
|
47
|
+
*/
|
|
48
|
+
const vertexLineHeight = trFontFace.data.info.size;
|
|
49
|
+
/**
|
|
50
|
+
* See above
|
|
51
|
+
*/
|
|
52
|
+
const fontSizeRatio = fontSize / vertexLineHeight;
|
|
53
|
+
/**
|
|
54
|
+
* `w` in vertex coordinates
|
|
55
|
+
*/
|
|
56
|
+
const vertexW = width / fontSizeRatio;
|
|
57
|
+
/**
|
|
58
|
+
* `letterSpacing` in vertex coordinates
|
|
59
|
+
*/
|
|
60
|
+
const vertexLSpacing = letterSpacing / fontSizeRatio;
|
|
61
|
+
const startingLineCacheEntry = lineCache[curLineIndex];
|
|
62
|
+
const startingCodepointIndex = startingLineCacheEntry?.codepointIndex || 0;
|
|
63
|
+
const startingMaxX = startingLineCacheEntry?.maxX || 0;
|
|
64
|
+
const startingMaxY = startingLineCacheEntry?.maxY || 0;
|
|
65
|
+
let maxX = startingMaxX;
|
|
66
|
+
let maxY = startingMaxY;
|
|
67
|
+
let curX = startX;
|
|
68
|
+
let curY = startY;
|
|
69
|
+
let bufferOffset = 0;
|
|
70
|
+
/**
|
|
71
|
+
* Buffer offset to last word boundry. This is -1 when we aren't in a word boundry.
|
|
72
|
+
*/
|
|
73
|
+
const lastWord = {
|
|
74
|
+
codepointIndex: -1,
|
|
75
|
+
bufferOffset: -1,
|
|
76
|
+
xStart: -1,
|
|
77
|
+
};
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
79
|
+
const shaper = trFontFace.shaper;
|
|
80
|
+
const shaperProps = {
|
|
81
|
+
letterSpacing: vertexLSpacing,
|
|
82
|
+
};
|
|
83
|
+
// Get glyphs
|
|
84
|
+
let glyphs = shaper.shapeText(shaperProps, new PeekableIterator(getUnicodeCodepoints(text, startingCodepointIndex), startingCodepointIndex));
|
|
85
|
+
let glyphResult;
|
|
86
|
+
let curLineBufferStart = -1;
|
|
87
|
+
const bufferLineInfos = [];
|
|
88
|
+
const truncateSeq = '...';
|
|
89
|
+
const vertexTruncateHeight = height / fontSizeRatio;
|
|
90
|
+
const truncateSeqVertexWidth = measureText(truncateSeq, shaperProps, shaper);
|
|
91
|
+
// Line-by-line layout
|
|
92
|
+
let moreLines = true;
|
|
93
|
+
while (moreLines) {
|
|
94
|
+
const nextLineWillFit = contain !== 'both' ||
|
|
95
|
+
scrollable ||
|
|
96
|
+
curY + vertexLineHeight + vertexLineHeight <= vertexTruncateHeight;
|
|
97
|
+
const lineVertexW = nextLineWillFit
|
|
98
|
+
? vertexW
|
|
99
|
+
: vertexW - truncateSeqVertexWidth;
|
|
100
|
+
/**
|
|
101
|
+
* Vertex X position to the beginning of the last word boundary. This becomes -1 when we start traversing a word.
|
|
102
|
+
*/
|
|
103
|
+
let xStartLastWordBoundary = 0;
|
|
104
|
+
// Layout glyphs in this line
|
|
105
|
+
// Any break statements in this while loop will trigger a line break
|
|
106
|
+
while ((glyphResult = glyphs.next()) && !glyphResult.done) {
|
|
107
|
+
const glyph = glyphResult.value;
|
|
108
|
+
if (curLineIndex === lineCache.length) {
|
|
109
|
+
lineCache.push({
|
|
110
|
+
codepointIndex: glyph.cluster,
|
|
111
|
+
maxY,
|
|
112
|
+
maxX,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
else if (curLineIndex > lineCache.length) {
|
|
116
|
+
throw new Error('Unexpected lineCache length');
|
|
117
|
+
}
|
|
118
|
+
// If we encounter a word boundary (white space or newline) we invalidate
|
|
119
|
+
// the lastWord and set the xStartLastWordBoundary if we haven't already.
|
|
120
|
+
if (glyph.codepoint === 32 || glyph.codepoint === 10) {
|
|
121
|
+
if (lastWord.codepointIndex !== -1) {
|
|
122
|
+
lastWord.codepointIndex = -1;
|
|
123
|
+
xStartLastWordBoundary = curX;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (lastWord.codepointIndex === -1) {
|
|
127
|
+
lastWord.codepointIndex = glyph.cluster;
|
|
128
|
+
lastWord.bufferOffset = bufferOffset;
|
|
129
|
+
lastWord.xStart = xStartLastWordBoundary;
|
|
130
|
+
}
|
|
131
|
+
if (glyph.mapped) {
|
|
132
|
+
// Mapped glyph
|
|
133
|
+
const charEndX = curX + glyph.xOffset + glyph.width;
|
|
134
|
+
// Word wrap check
|
|
135
|
+
if (
|
|
136
|
+
// We are containing the text
|
|
137
|
+
contain !== 'none' &&
|
|
138
|
+
// The current glyph reaches outside the contained width
|
|
139
|
+
charEndX >= lineVertexW &&
|
|
140
|
+
// There is a last word that we can break to the next line
|
|
141
|
+
lastWord.codepointIndex !== -1 &&
|
|
142
|
+
// We have advanced at least one character since the last word started
|
|
143
|
+
lastWord.codepointIndex < glyph.cluster &&
|
|
144
|
+
// Prevents infinite loop when a single word is longer than the width
|
|
145
|
+
lastWord.xStart > 0) {
|
|
146
|
+
// The current word is about to go off the edge of the container width
|
|
147
|
+
// Reinitialize the iterator starting at the last word
|
|
148
|
+
// and proceeding to the next line
|
|
149
|
+
if (nextLineWillFit) {
|
|
150
|
+
glyphs = shaper.shapeText(shaperProps, new PeekableIterator(getUnicodeCodepoints(text, lastWord.codepointIndex), lastWord.codepointIndex));
|
|
151
|
+
bufferOffset = lastWord.bufferOffset;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
glyphs = shaper.shapeText(shaperProps, new PeekableIterator(getUnicodeCodepoints(truncateSeq, 0), 0));
|
|
156
|
+
curX = lastWord.xStart;
|
|
157
|
+
bufferOffset = lastWord.bufferOffset;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
// This glyph fits, so we can add it to the buffer
|
|
162
|
+
const quadX = curX + glyph.xOffset;
|
|
163
|
+
const quadY = curY + glyph.yOffset;
|
|
164
|
+
const lineIsBelowWindowTop = renderWindow
|
|
165
|
+
? curY + vertexLineHeight >= renderWindow.y1 / fontSizeRatio
|
|
166
|
+
: true;
|
|
167
|
+
const lineIsAboveWindowBottom = renderWindow
|
|
168
|
+
? curY <= renderWindow.y2 / fontSizeRatio
|
|
169
|
+
: true;
|
|
170
|
+
// Only add to buffer for rendering if the line is within the render window
|
|
171
|
+
if (lineIsBelowWindowTop && lineIsAboveWindowBottom) {
|
|
172
|
+
if (curLineBufferStart === -1) {
|
|
173
|
+
curLineBufferStart = bufferOffset;
|
|
174
|
+
}
|
|
175
|
+
const atlasEntry = trFontFace.getAtlasEntry(glyph.glyphId);
|
|
176
|
+
// Add texture coordinates
|
|
177
|
+
const u = atlasEntry.x / trFontFace.data.common.scaleW;
|
|
178
|
+
const v = atlasEntry.y / trFontFace.data.common.scaleH;
|
|
179
|
+
const uvWidth = atlasEntry.width / trFontFace.data.common.scaleW;
|
|
180
|
+
const uvHeight = atlasEntry.height / trFontFace.data.common.scaleH;
|
|
181
|
+
// TODO: (Performance) We can optimize this by using ELEMENT_ARRAY_BUFFER
|
|
182
|
+
// eliminating the need to duplicate vertices
|
|
183
|
+
// Top-left
|
|
184
|
+
vertexBuffer[bufferOffset++] = quadX;
|
|
185
|
+
vertexBuffer[bufferOffset++] = quadY;
|
|
186
|
+
vertexBuffer[bufferOffset++] = u;
|
|
187
|
+
vertexBuffer[bufferOffset++] = v;
|
|
188
|
+
// Top-right
|
|
189
|
+
vertexBuffer[bufferOffset++] = quadX + glyph.width;
|
|
190
|
+
vertexBuffer[bufferOffset++] = quadY;
|
|
191
|
+
vertexBuffer[bufferOffset++] = u + uvWidth;
|
|
192
|
+
vertexBuffer[bufferOffset++] = v;
|
|
193
|
+
// Bottom-left
|
|
194
|
+
vertexBuffer[bufferOffset++] = quadX;
|
|
195
|
+
vertexBuffer[bufferOffset++] = quadY + glyph.height;
|
|
196
|
+
vertexBuffer[bufferOffset++] = u;
|
|
197
|
+
vertexBuffer[bufferOffset++] = v + uvHeight;
|
|
198
|
+
// Bottom-right
|
|
199
|
+
vertexBuffer[bufferOffset++] = quadX + glyph.width;
|
|
200
|
+
vertexBuffer[bufferOffset++] = quadY + glyph.height;
|
|
201
|
+
vertexBuffer[bufferOffset++] = u + uvWidth;
|
|
202
|
+
vertexBuffer[bufferOffset++] = v + uvHeight;
|
|
203
|
+
}
|
|
204
|
+
maxY = Math.max(maxY, quadY + glyph.height);
|
|
205
|
+
curX += glyph.xAdvance;
|
|
206
|
+
maxX = Math.max(maxX, curX);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// Unmapped character
|
|
211
|
+
// Handle newlines
|
|
212
|
+
if (glyph.codepoint === 10) {
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Prepare for the next line...
|
|
218
|
+
if (curLineBufferStart !== -1) {
|
|
219
|
+
bufferLineInfos.push({
|
|
220
|
+
bufferStart: curLineBufferStart,
|
|
221
|
+
bufferEnd: bufferOffset,
|
|
222
|
+
});
|
|
223
|
+
curLineBufferStart = -1;
|
|
224
|
+
}
|
|
225
|
+
curX = 0;
|
|
226
|
+
curY += vertexLineHeight;
|
|
227
|
+
curLineIndex++;
|
|
228
|
+
lastWord.codepointIndex = -1;
|
|
229
|
+
xStartLastWordBoundary = 0;
|
|
230
|
+
// Figure out if there are any more lines to render...
|
|
231
|
+
if (!forceFullLayoutCalc &&
|
|
232
|
+
contain === 'both' &&
|
|
233
|
+
renderWindow &&
|
|
234
|
+
curY > renderWindow.y2 / fontSizeRatio) {
|
|
235
|
+
// Stop layout calculation early (for performance purposes) if:
|
|
236
|
+
// - We're not forcing a full layout calculation (for width/height calculation)
|
|
237
|
+
// - ...and we're containing the text vertically+horizontally (contain === 'both')
|
|
238
|
+
// - ...and we have a render window
|
|
239
|
+
// - ...and the next line is below the bottom of the render window
|
|
240
|
+
moreLines = false;
|
|
241
|
+
}
|
|
242
|
+
else if (glyphResult && glyphResult.done) {
|
|
243
|
+
// If we've reached the end of the text, we know we're done
|
|
244
|
+
moreLines = false;
|
|
245
|
+
}
|
|
246
|
+
else if (contain === 'both' && !scrollable && !nextLineWillFit) {
|
|
247
|
+
// If we're contained vertically+horizontally (contain === 'both')
|
|
248
|
+
// but not scrollable and the next line won't fit, we're done.
|
|
249
|
+
moreLines = false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// Use textAlign to determine if we need to adjust the x position of the text
|
|
253
|
+
// in the buffer line by line
|
|
254
|
+
if (textAlign === 'center') {
|
|
255
|
+
const vertexTextW = contain === 'none' ? maxX : vertexW;
|
|
256
|
+
for (let i = 0; i < bufferLineInfos.length; i++) {
|
|
257
|
+
const line = bufferLineInfos[i];
|
|
258
|
+
// - 4 = the x position of a rightmost vertex
|
|
259
|
+
const lineWidth =
|
|
260
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
261
|
+
vertexBuffer[line.bufferEnd - 4] - vertexBuffer[line.bufferStart];
|
|
262
|
+
const xOffset = (vertexTextW - lineWidth) / 2;
|
|
263
|
+
for (let j = line.bufferStart; j < line.bufferEnd; j += 4) {
|
|
264
|
+
vertexBuffer[j] += xOffset;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else if (textAlign === 'right') {
|
|
269
|
+
const vertexTextW = contain === 'none' ? maxX : vertexW;
|
|
270
|
+
for (let i = 0; i < bufferLineInfos.length; i++) {
|
|
271
|
+
const line = bufferLineInfos[i];
|
|
272
|
+
const lineWidth = line.bufferEnd === line.bufferStart
|
|
273
|
+
? 0
|
|
274
|
+
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
275
|
+
vertexBuffer[line.bufferEnd - 4] - vertexBuffer[line.bufferStart];
|
|
276
|
+
const xOffset = vertexTextW - lineWidth;
|
|
277
|
+
for (let j = line.bufferStart; j < line.bufferEnd; j += 4) {
|
|
278
|
+
vertexBuffer[j] += xOffset;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
assertTruthy(glyphResult);
|
|
283
|
+
return {
|
|
284
|
+
bufferNumFloats: bufferOffset,
|
|
285
|
+
bufferNumQuads: bufferOffset / 16,
|
|
286
|
+
layoutNumCharacters: glyphResult.done
|
|
287
|
+
? text.length - startingCodepointIndex
|
|
288
|
+
: glyphResult.value.cluster - startingCodepointIndex + 1,
|
|
289
|
+
fullyProcessed: !!glyphResult.done,
|
|
290
|
+
maxX,
|
|
291
|
+
maxY,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=layoutText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layoutText.js","sourceRoot":"","sources":["../../../../../../../src/core/text-rendering/renderers/SdfTextRenderer/internal/layoutText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAQvD,OAAO,EAAE,gBAAgB,EAAE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,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;QAExD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC/C,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAE,CAAC;YACjC,MAAM,SAAS,GACb,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,WAAW;gBACjC,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,oEAAoE;oBACpE,YAAY,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAE,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAE,CAAC;YAE1E,MAAM,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;YACxC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE;gBACzD,YAAY,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC;aAC5B;SACF;KACF;IAED,YAAY,CAAC,WAAW,CAAC,CAAC;IAE1B,OAAO;QACL,eAAe,EAAE,YAAY;QAC7B,cAAc,EAAE,YAAY,GAAG,EAAE;QACjC,mBAAmB,EAAE,WAAW,CAAC,IAAI;YACnC,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,sBAAsB;YACtC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,GAAG,sBAAsB,GAAG,CAAC;QAC1D,cAAc,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI;QAClC,IAAI;QACJ,IAAI;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Bound } from '../../../../lib/utils.js';
|
|
2
|
+
import type { TrProps } from '../../TextRenderer.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a render window from the given parameters.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* The render window is a rectangle that defines the area of the text that
|
|
8
|
+
* should be rendered. It is used to skip rendering parts of the text that
|
|
9
|
+
* are outside of the render window. The render window is relative to the
|
|
10
|
+
* text's top left corner of the overrall text.
|
|
11
|
+
*
|
|
12
|
+
* @param x The x coordinate of the text element's top left corner relative to the screen.
|
|
13
|
+
* @param y The y coordinate of the text element's top left corner relative to the screen.
|
|
14
|
+
* @param scrollY The amount of pixels to scroll the text vertically.
|
|
15
|
+
* @param lineHeight The height of a single line of text.
|
|
16
|
+
* @param numExtraLines The number of extra lines to render above and below the visible window.
|
|
17
|
+
* @param visibleWindow The visible window of the text element relative to the screen
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare function makeRenderWindow(x: TrProps['x'], y: TrProps['y'], scrollY: TrProps['scrollY'], lineHeight: number, numExtraLines: number, visibleWindow: Bound): Bound;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { isBoundPositive } from '../../../../lib/utils.js';
|
|
20
|
+
/**
|
|
21
|
+
* Create a render window from the given parameters.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* The render window is a rectangle that defines the area of the text that
|
|
25
|
+
* should be rendered. It is used to skip rendering parts of the text that
|
|
26
|
+
* are outside of the render window. The render window is relative to the
|
|
27
|
+
* text's top left corner of the overrall text.
|
|
28
|
+
*
|
|
29
|
+
* @param x The x coordinate of the text element's top left corner relative to the screen.
|
|
30
|
+
* @param y The y coordinate of the text element's top left corner relative to the screen.
|
|
31
|
+
* @param scrollY The amount of pixels to scroll the text vertically.
|
|
32
|
+
* @param lineHeight The height of a single line of text.
|
|
33
|
+
* @param numExtraLines The number of extra lines to render above and below the visible window.
|
|
34
|
+
* @param visibleWindow The visible window of the text element relative to the screen
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export function makeRenderWindow(x, y, scrollY, lineHeight, numExtraLines, visibleWindow) {
|
|
38
|
+
const bufferMargin = lineHeight * numExtraLines;
|
|
39
|
+
const x1 = visibleWindow.x1 - x;
|
|
40
|
+
const y1 = visibleWindow.y1 - y;
|
|
41
|
+
return isBoundPositive(visibleWindow)
|
|
42
|
+
? {
|
|
43
|
+
x1: x1,
|
|
44
|
+
y1: y1 + scrollY - bufferMargin,
|
|
45
|
+
x2: x1 + (visibleWindow.x2 - visibleWindow.x1),
|
|
46
|
+
y2: y1 + scrollY + (visibleWindow.y2 - visibleWindow.y1) + bufferMargin,
|
|
47
|
+
}
|
|
48
|
+
: {
|
|
49
|
+
x1: 0,
|
|
50
|
+
y1: 0,
|
|
51
|
+
x2: 0,
|
|
52
|
+
y2: 0,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=makeRenderWindow.js.map
|
package/dist/src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeRenderWindow.js","sourceRoot":"","sources":["../../../../../../../src/core/text-rendering/renderers/SdfTextRenderer/internal/makeRenderWindow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,eAAe,EAAc,MAAM,0BAA0B,CAAC;AAGvE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,CAAe,EACf,CAAe,EACf,OAA2B,EAC3B,UAAkB,EAClB,aAAqB,EACrB,aAAoB;IAEpB,MAAM,YAAY,GAAG,UAAU,GAAG,aAAa,CAAC;IAChD,MAAM,EAAE,GAAG,aAAa,CAAC,EAAE,GAAG,CAAC,CAAC;IAChC,MAAM,EAAE,GAAG,aAAa,CAAC,EAAE,GAAG,CAAC,CAAC;IAChC,OAAO,eAAe,CAAC,aAAa,CAAC;QACnC,CAAC,CAAC;YACE,EAAE,EAAE,EAAE;YACN,EAAE,EAAE,EAAE,GAAG,OAAO,GAAG,YAAY;YAC/B,EAAE,EAAE,EAAE,GAAG,CAAC,aAAa,CAAC,EAAE,GAAG,aAAa,CAAC,EAAE,CAAC;YAC9C,EAAE,EAAE,EAAE,GAAG,OAAO,GAAG,CAAC,aAAa,CAAC,EAAE,GAAG,aAAa,CAAC,EAAE,CAAC,GAAG,YAAY;SACxE;QACH,CAAC,CAAC;YACE,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;YACL,EAAE,EAAE,CAAC;SACN,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FontShaper, FontShaperProps } from '../../../font-face-types/SdfTrFontFace/internal/FontShaper.js';
|
|
2
|
+
/**
|
|
3
|
+
* Measures a single-line of text width ignoring any unmapped glyphs including line breaks
|
|
4
|
+
*
|
|
5
|
+
* @param text
|
|
6
|
+
* @param shaperProps
|
|
7
|
+
* @param shaper
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function measureText(text: string, shaperProps: FontShaperProps, shaper: FontShaper): number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* If not stated otherwise in this file or this component's LICENSE file the
|
|
3
|
+
* following copyright and licenses apply:
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2023 Comcast
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the License);
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { PeekableIterator } from './PeekableGenerator.js';
|
|
20
|
+
import { getUnicodeCodepoints } from './getUnicodeCodepoints.js';
|
|
21
|
+
/**
|
|
22
|
+
* Measures a single-line of text width ignoring any unmapped glyphs including line breaks
|
|
23
|
+
*
|
|
24
|
+
* @param text
|
|
25
|
+
* @param shaperProps
|
|
26
|
+
* @param shaper
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
export function measureText(text, shaperProps, shaper) {
|
|
30
|
+
const glyphs = shaper.shapeText(shaperProps, new PeekableIterator(getUnicodeCodepoints(text, 0), 0));
|
|
31
|
+
let width = 0;
|
|
32
|
+
for (const glyph of glyphs) {
|
|
33
|
+
if (glyph.mapped) {
|
|
34
|
+
width += glyph.xAdvance;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return width;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=measureText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measureText.js","sourceRoot":"","sources":["../../../../../../../src/core/text-rendering/renderers/SdfTextRenderer/internal/measureText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,IAAY,EACZ,WAA4B,EAC5B,MAAkB;IAElB,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAC7B,WAAW,EACX,IAAI,gBAAgB,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CACvD,CAAC;IACF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;QAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;YAChB,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC;SACzB;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|