@lightningjs/renderer 3.0.0-beta7 → 3.0.0-beta9

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 (240) hide show
  1. package/dist/exports/utils.d.ts +2 -1
  2. package/dist/exports/utils.js +2 -1
  3. package/dist/exports/utils.js.map +1 -1
  4. package/dist/src/core/CoreNode.d.ts +24 -49
  5. package/dist/src/core/CoreNode.js +257 -255
  6. package/dist/src/core/CoreNode.js.map +1 -1
  7. package/dist/src/core/CoreTextNode.d.ts +1 -1
  8. package/dist/src/core/CoreTextNode.js +14 -15
  9. package/dist/src/core/CoreTextNode.js.map +1 -1
  10. package/dist/src/core/CoreTextureManager.d.ts +4 -9
  11. package/dist/src/core/CoreTextureManager.js +41 -78
  12. package/dist/src/core/CoreTextureManager.js.map +1 -1
  13. package/dist/src/core/Stage.d.ts +12 -27
  14. package/dist/src/core/Stage.js +50 -37
  15. package/dist/src/core/Stage.js.map +1 -1
  16. package/dist/src/core/TextureMemoryManager.d.ts +10 -1
  17. package/dist/src/core/TextureMemoryManager.js +103 -50
  18. package/dist/src/core/TextureMemoryManager.js.map +1 -1
  19. package/dist/src/core/animations/CoreAnimation.js +5 -0
  20. package/dist/src/core/animations/CoreAnimation.js.map +1 -1
  21. package/dist/src/core/animations/CoreAnimationController.d.ts +1 -0
  22. package/dist/src/core/animations/CoreAnimationController.js +11 -4
  23. package/dist/src/core/animations/CoreAnimationController.js.map +1 -1
  24. package/dist/src/core/lib/WebGlContextWrapper.d.ts +19 -2
  25. package/dist/src/core/lib/WebGlContextWrapper.js +56 -25
  26. package/dist/src/core/lib/WebGlContextWrapper.js.map +1 -1
  27. package/dist/src/core/renderers/CoreRenderer.d.ts +1 -0
  28. package/dist/src/core/renderers/CoreRenderer.js.map +1 -1
  29. package/dist/src/core/renderers/CoreShaderNode.d.ts +1 -0
  30. package/dist/src/core/renderers/CoreShaderNode.js +9 -0
  31. package/dist/src/core/renderers/CoreShaderNode.js.map +1 -1
  32. package/dist/src/core/renderers/canvas/CanvasRenderer.d.ts +1 -0
  33. package/dist/src/core/renderers/canvas/CanvasRenderer.js +3 -0
  34. package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
  35. package/dist/src/core/renderers/canvas/CanvasShaderNode.js +1 -4
  36. package/dist/src/core/renderers/canvas/CanvasShaderNode.js.map +1 -1
  37. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +0 -3
  38. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -1
  39. package/dist/src/core/renderers/webgl/WebGlRenderer.d.ts +1 -0
  40. package/dist/src/core/renderers/webgl/WebGlRenderer.js +56 -54
  41. package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
  42. package/dist/src/core/renderers/webgl/WebGlShaderNode.js +1 -4
  43. package/dist/src/core/renderers/webgl/WebGlShaderNode.js.map +1 -1
  44. package/dist/src/core/renderers/webgl/WebGlShaderProgram.d.ts +4 -2
  45. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +31 -13
  46. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -1
  47. package/dist/src/core/shaders/canvas/LinearGradient.js +5 -3
  48. package/dist/src/core/shaders/canvas/LinearGradient.js.map +1 -1
  49. package/dist/src/core/shaders/canvas/RadialGradient.js +13 -11
  50. package/dist/src/core/shaders/canvas/RadialGradient.js.map +1 -1
  51. package/dist/src/core/shaders/canvas/RoundedWithBorder.js +7 -5
  52. package/dist/src/core/shaders/canvas/RoundedWithBorder.js.map +1 -1
  53. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js +10 -8
  54. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +1 -1
  55. package/dist/src/core/shaders/canvas/RoundedWithShadow.js +7 -5
  56. package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +1 -1
  57. package/dist/src/core/shaders/templates/BorderTemplate.d.ts +1 -1
  58. package/dist/src/core/shaders/templates/BorderTemplate.js +1 -1
  59. package/dist/src/core/shaders/templates/BorderTemplate.js.map +1 -1
  60. package/dist/src/core/shaders/templates/HolePunchTemplate.js +1 -1
  61. package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +1 -1
  62. package/dist/src/core/shaders/templates/RoundedTemplate.js +1 -1
  63. package/dist/src/core/shaders/templates/RoundedTemplate.js.map +1 -1
  64. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.d.ts +1 -1
  65. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.d.ts +1 -1
  66. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.d.ts +1 -1
  67. package/dist/src/core/shaders/templates/ShadowTemplate.d.ts +1 -1
  68. package/dist/src/core/shaders/{templates/shaderUtils.d.ts → utils.d.ts} +1 -1
  69. package/dist/src/core/shaders/{templates/shaderUtils.js → utils.js} +2 -2
  70. package/dist/src/core/shaders/utils.js.map +1 -0
  71. package/dist/src/core/shaders/webgl/HolePunch.js +4 -3
  72. package/dist/src/core/shaders/webgl/HolePunch.js.map +1 -1
  73. package/dist/src/core/shaders/webgl/LinearGradient.js +5 -4
  74. package/dist/src/core/shaders/webgl/LinearGradient.js.map +1 -1
  75. package/dist/src/core/shaders/webgl/RadialGradient.js +6 -5
  76. package/dist/src/core/shaders/webgl/RadialGradient.js.map +1 -1
  77. package/dist/src/core/shaders/webgl/RoundedWithBorder.js +18 -7
  78. package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -1
  79. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +30 -17
  80. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -1
  81. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js +0 -50
  82. package/dist/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.js.map +1 -1
  83. package/dist/src/core/textures/ImageTexture.d.ts +1 -1
  84. package/dist/src/core/textures/ImageTexture.js +1 -1
  85. package/dist/src/core/textures/ImageTexture.js.map +1 -1
  86. package/dist/src/core/textures/Texture.d.ts +12 -0
  87. package/dist/src/core/textures/Texture.js +19 -0
  88. package/dist/src/core/textures/Texture.js.map +1 -1
  89. package/dist/src/core/utils.d.ts +1 -1
  90. package/dist/src/main-api/Inspector.d.ts +6 -1
  91. package/dist/src/main-api/Inspector.js +42 -4
  92. package/dist/src/main-api/Inspector.js.map +1 -1
  93. package/dist/src/main-api/Renderer.d.ts +62 -43
  94. package/dist/src/main-api/Renderer.js +119 -31
  95. package/dist/src/main-api/Renderer.js.map +1 -1
  96. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  97. package/exports/utils.ts +7 -1
  98. package/package.json +1 -1
  99. package/src/core/CoreNode.ts +307 -313
  100. package/src/core/CoreTextNode.ts +23 -20
  101. package/src/core/CoreTextureManager.ts +40 -99
  102. package/src/core/Stage.ts +68 -65
  103. package/src/core/TextureMemoryManager.ts +135 -67
  104. package/src/core/animations/CoreAnimation.ts +7 -0
  105. package/src/core/animations/CoreAnimationController.ts +13 -4
  106. package/src/core/lib/WebGlContextWrapper.ts +69 -75
  107. package/src/core/renderers/CoreRenderer.ts +1 -0
  108. package/src/core/renderers/CoreShaderNode.ts +10 -0
  109. package/src/core/renderers/canvas/CanvasRenderer.ts +4 -0
  110. package/src/core/renderers/canvas/CanvasShaderNode.ts +1 -4
  111. package/src/core/renderers/webgl/WebGlCtxTexture.ts +0 -3
  112. package/src/core/renderers/webgl/WebGlRenderer.ts +64 -65
  113. package/src/core/renderers/webgl/WebGlShaderNode.ts +2 -4
  114. package/src/core/renderers/webgl/WebGlShaderProgram.ts +37 -14
  115. package/src/core/shaders/canvas/LinearGradient.ts +8 -6
  116. package/src/core/shaders/canvas/RadialGradient.ts +22 -36
  117. package/src/core/shaders/canvas/RoundedWithBorder.ts +10 -8
  118. package/src/core/shaders/canvas/RoundedWithBorderAndShadow.ts +14 -12
  119. package/src/core/shaders/canvas/RoundedWithShadow.ts +8 -7
  120. package/src/core/shaders/templates/BorderTemplate.ts +1 -1
  121. package/src/core/shaders/templates/HolePunchTemplate.ts +1 -1
  122. package/src/core/shaders/templates/RoundedTemplate.ts +1 -1
  123. package/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.ts +1 -1
  124. package/src/core/shaders/templates/RoundedWithBorderTemplate.ts +1 -1
  125. package/src/core/shaders/templates/RoundedWithShadowTemplate.ts +1 -1
  126. package/src/core/shaders/templates/ShadowTemplate.ts +1 -1
  127. package/src/core/shaders/{templates/shaderUtils.ts → utils.ts} +2 -3
  128. package/src/core/shaders/webgl/HolePunch.ts +4 -7
  129. package/src/core/shaders/webgl/LinearGradient.ts +5 -4
  130. package/src/core/shaders/webgl/RadialGradient.ts +7 -6
  131. package/src/core/shaders/webgl/RoundedWithBorder.ts +18 -7
  132. package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +30 -21
  133. package/src/core/text-rendering/renderers/SdfTextRenderer/SdfTextRenderer.ts +2 -58
  134. package/src/core/textures/ImageTexture.ts +17 -16
  135. package/src/core/textures/Texture.ts +23 -0
  136. package/src/main-api/Inspector.ts +52 -5
  137. package/src/main-api/Renderer.ts +222 -77
  138. package/dist/src/core/platform.d.ts +0 -10
  139. package/dist/src/core/platform.js +0 -56
  140. package/dist/src/core/platform.js.map +0 -1
  141. package/dist/src/core/renderers/CoreShader.d.ts +0 -9
  142. package/dist/src/core/renderers/CoreShader.js +0 -28
  143. package/dist/src/core/renderers/CoreShader.js.map +0 -1
  144. package/dist/src/core/renderers/canvas/CanvasCoreRenderer.d.ts +0 -33
  145. package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js +0 -250
  146. package/dist/src/core/renderers/canvas/CanvasCoreRenderer.js.map +0 -1
  147. package/dist/src/core/renderers/canvas/CanvasCoreTexture.d.ts +0 -16
  148. package/dist/src/core/renderers/canvas/CanvasCoreTexture.js +0 -123
  149. package/dist/src/core/renderers/canvas/CanvasCoreTexture.js.map +0 -1
  150. package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.d.ts +0 -10
  151. package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js +0 -43
  152. package/dist/src/core/renderers/canvas/shaders/UnsupportedShader.js.map +0 -1
  153. package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.d.ts +0 -12
  154. package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js +0 -55
  155. package/dist/src/core/renderers/webgl/WebGlCoreCtxRenderTexture.js.map +0 -1
  156. package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.d.ts +0 -9
  157. package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js +0 -38
  158. package/dist/src/core/renderers/webgl/WebGlCoreCtxSubTexture.js.map +0 -1
  159. package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.d.ts +0 -57
  160. package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js +0 -227
  161. package/dist/src/core/renderers/webgl/WebGlCoreCtxTexture.js.map +0 -1
  162. package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.d.ts +0 -34
  163. package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js +0 -114
  164. package/dist/src/core/renderers/webgl/WebGlCoreRenderOp.js.map +0 -1
  165. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.d.ts +0 -133
  166. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js +0 -613
  167. package/dist/src/core/renderers/webgl/WebGlCoreRenderer.js.map +0 -1
  168. package/dist/src/core/renderers/webgl/WebGlCoreShader.d.ts +0 -83
  169. package/dist/src/core/renderers/webgl/WebGlCoreShader.js +0 -231
  170. package/dist/src/core/renderers/webgl/WebGlCoreShader.js.map +0 -1
  171. package/dist/src/core/renderers/webgl/shaders/DefaultShader.d.ts +0 -9
  172. package/dist/src/core/renderers/webgl/shaders/DefaultShader.js +0 -87
  173. package/dist/src/core/renderers/webgl/shaders/DefaultShader.js.map +0 -1
  174. package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.d.ts +0 -10
  175. package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js +0 -119
  176. package/dist/src/core/renderers/webgl/shaders/DefaultShaderBatched.js.map +0 -1
  177. package/dist/src/core/renderers/webgl/shaders/DynamicShader.d.ts +0 -29
  178. package/dist/src/core/renderers/webgl/shaders/DynamicShader.js +0 -413
  179. package/dist/src/core/renderers/webgl/shaders/DynamicShader.js.map +0 -1
  180. package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.d.ts +0 -28
  181. package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js +0 -131
  182. package/dist/src/core/renderers/webgl/shaders/RoundedRectangle.js.map +0 -1
  183. package/dist/src/core/renderers/webgl/shaders/SdfShader.d.ts +0 -47
  184. package/dist/src/core/renderers/webgl/shaders/SdfShader.js +0 -160
  185. package/dist/src/core/renderers/webgl/shaders/SdfShader.js.map +0 -1
  186. package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.d.ts +0 -31
  187. package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js +0 -71
  188. package/dist/src/core/renderers/webgl/shaders/effects/BorderBottomEffect.js.map +0 -1
  189. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.d.ts +0 -30
  190. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js +0 -58
  191. package/dist/src/core/renderers/webgl/shaders/effects/BorderEffect.js.map +0 -1
  192. package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.d.ts +0 -31
  193. package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js +0 -71
  194. package/dist/src/core/renderers/webgl/shaders/effects/BorderLeftEffect.js.map +0 -1
  195. package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.d.ts +0 -31
  196. package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js +0 -71
  197. package/dist/src/core/renderers/webgl/shaders/effects/BorderRightEffect.js.map +0 -1
  198. package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.d.ts +0 -31
  199. package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js +0 -71
  200. package/dist/src/core/renderers/webgl/shaders/effects/BorderTopEffect.js.map +0 -1
  201. package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.d.ts +0 -9
  202. package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js +0 -136
  203. package/dist/src/core/renderers/webgl/shaders/effects/EffectUtils.js.map +0 -1
  204. package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.d.ts +0 -36
  205. package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js +0 -85
  206. package/dist/src/core/renderers/webgl/shaders/effects/FadeOutEffect.js.map +0 -1
  207. package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.d.ts +0 -45
  208. package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js +0 -104
  209. package/dist/src/core/renderers/webgl/shaders/effects/GlitchEffect.js.map +0 -1
  210. package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.d.ts +0 -22
  211. package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js +0 -45
  212. package/dist/src/core/renderers/webgl/shaders/effects/GrayscaleEffect.js.map +0 -1
  213. package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.d.ts +0 -58
  214. package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js +0 -80
  215. package/dist/src/core/renderers/webgl/shaders/effects/HolePunchEffect.js.map +0 -1
  216. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.d.ts +0 -35
  217. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +0 -129
  218. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js.map +0 -1
  219. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.d.ts +0 -39
  220. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +0 -116
  221. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js.map +0 -1
  222. package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.d.ts +0 -61
  223. package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js +0 -127
  224. package/dist/src/core/renderers/webgl/shaders/effects/RadialProgressEffect.js.map +0 -1
  225. package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.d.ts +0 -40
  226. package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js +0 -71
  227. package/dist/src/core/renderers/webgl/shaders/effects/RadiusEffect.js.map +0 -1
  228. package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.d.ts +0 -115
  229. package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js +0 -61
  230. package/dist/src/core/renderers/webgl/shaders/effects/ShaderEffect.js.map +0 -1
  231. package/dist/src/core/shaders/templates/shaderUtils.js.map +0 -1
  232. package/dist/src/core/temp.d.ts +0 -1
  233. package/dist/src/core/temp.js +0 -77
  234. package/dist/src/core/temp.js.map +0 -1
  235. package/dist/src/main-api/DynamicShaderController.d.ts +0 -29
  236. package/dist/src/main-api/DynamicShaderController.js +0 -58
  237. package/dist/src/main-api/DynamicShaderController.js.map +0 -1
  238. package/dist/src/main-api/ShaderController.d.ts +0 -31
  239. package/dist/src/main-api/ShaderController.js +0 -37
  240. package/dist/src/main-api/ShaderController.js.map +0 -1
@@ -1,250 +0,0 @@
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 Cable Communications Management, LLC.
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 { getRgbaComponents } from '../../lib/utils.js';
20
- import { SubTexture } from '../../textures/SubTexture.js';
21
- import { TextureType } from '../../textures/Texture.js';
22
- import { CoreRenderer, } from '../CoreRenderer.js';
23
- import { CanvasCoreTexture } from './CanvasCoreTexture.js';
24
- import { getBorder, getRadius, roundRect, strokeLine, } from './internal/C2DShaderUtils.js';
25
- import { formatRgba, parseColorRgba, parseColor, } from './internal/ColorUtils.js';
26
- import { UnsupportedShader } from './shaders/UnsupportedShader.js';
27
- import { assertTruthy } from '../../../utils.js';
28
- export class CanvasCoreRenderer extends CoreRenderer {
29
- context;
30
- canvas;
31
- pixelRatio;
32
- clearColor;
33
- renderToTextureActive = false;
34
- activeRttNode = null;
35
- defShaderCtr;
36
- constructor(options) {
37
- super(options);
38
- this.mode = 'canvas';
39
- this.shManager.renderer = this;
40
- const { canvas, pixelRatio, clearColor } = options;
41
- this.canvas = canvas;
42
- this.context = canvas.getContext('2d');
43
- this.pixelRatio = pixelRatio;
44
- this.clearColor = clearColor ? getRgbaComponents(clearColor) : undefined;
45
- // Stub for default shader controller since the canvas renderer does not
46
- // (really) support the concept of a shader (yet)
47
- this.defShaderCtr = {
48
- type: 'DefaultShader',
49
- props: {},
50
- shader: new UnsupportedShader('DefaultShader'),
51
- getResolvedProps: () => () => {
52
- return {};
53
- },
54
- };
55
- }
56
- reset() {
57
- this.canvas.width = this.canvas.width; // quick reset canvas
58
- const ctx = this.context;
59
- if (this.clearColor) {
60
- const [r, g, b, a] = this.clearColor;
61
- ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${a / 255})`;
62
- ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
63
- }
64
- ctx.scale(this.pixelRatio, this.pixelRatio);
65
- }
66
- render() {
67
- // noop
68
- }
69
- addQuad(quad) {
70
- const ctx = this.context;
71
- const { tx, ty, width, height, alpha, colorTl, colorTr, colorBr, ta, tb, tc, td, clippingRect, } = quad;
72
- let texture = quad.texture;
73
- let ctxTexture = undefined;
74
- let frame;
75
- const textureType = texture?.type;
76
- assertTruthy(textureType, 'Texture type is not defined');
77
- // The Canvas2D renderer only supports image and color textures and subTexture images
78
- if (textureType !== TextureType.image &&
79
- textureType !== TextureType.color &&
80
- textureType !== TextureType.subTexture &&
81
- textureType !== TextureType.noise) {
82
- return;
83
- }
84
- if (texture) {
85
- if (texture instanceof SubTexture) {
86
- frame = texture.props;
87
- texture = texture.parentTexture;
88
- }
89
- ctxTexture = texture.ctxTexture;
90
- if (texture.state === 'freed') {
91
- return;
92
- }
93
- if (texture.state !== 'loaded') {
94
- return;
95
- }
96
- }
97
- const color = parseColor(colorTl);
98
- const hasTransform = ta !== 1;
99
- const hasClipping = clippingRect.width !== 0 && clippingRect.height !== 0;
100
- const hasGradient = colorTl !== colorTr || colorTl !== colorBr;
101
- const hasQuadShader = Boolean(quad.shader);
102
- const radius = hasQuadShader ? getRadius(quad) : 0;
103
- const border = hasQuadShader ? getBorder(quad) : undefined;
104
- if (hasTransform || hasClipping || radius) {
105
- ctx.save();
106
- }
107
- if (hasClipping) {
108
- const path = new Path2D();
109
- const { x, y, width, height } = clippingRect;
110
- path.rect(x, y, width, height);
111
- ctx.clip(path);
112
- }
113
- if (hasTransform) {
114
- // Quad transform:
115
- // | ta tb tx |
116
- // | tc td ty |
117
- // | 0 0 1 |
118
- // C2D transform:
119
- // | a c e |
120
- // | b d f |
121
- // | 0 0 1 |
122
- const scale = this.pixelRatio;
123
- ctx.setTransform(ta, tc, tb, td, tx * scale, ty * scale);
124
- ctx.scale(scale, scale);
125
- ctx.translate(-tx, -ty);
126
- }
127
- if (radius) {
128
- const path = new Path2D();
129
- roundRect.call(path, tx, ty, width, height, radius);
130
- ctx.clip(path);
131
- }
132
- if ((textureType === TextureType.image ||
133
- textureType === TextureType.subTexture ||
134
- textureType === TextureType.noise) &&
135
- ctxTexture) {
136
- const image = ctxTexture.getImage(color);
137
- ctx.globalAlpha = color.a ?? alpha;
138
- if (frame) {
139
- ctx.drawImage(image, frame.x, frame.y, frame.width, frame.height, tx, ty, width, height);
140
- }
141
- else {
142
- try {
143
- ctx.drawImage(image, tx, ty, width, height);
144
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
145
- }
146
- catch (error) {
147
- // noop
148
- }
149
- }
150
- ctx.globalAlpha = 1;
151
- }
152
- else if (textureType === TextureType.color && hasGradient) {
153
- let endX = tx;
154
- let endY = ty;
155
- let endColor;
156
- if (colorTl === colorTr) {
157
- // vertical
158
- endX = tx;
159
- endY = ty + height;
160
- endColor = parseColor(colorBr);
161
- }
162
- else {
163
- // horizontal
164
- endX = tx + width;
165
- endY = ty;
166
- endColor = parseColor(colorTr);
167
- }
168
- const gradient = ctx.createLinearGradient(tx, ty, endX, endY);
169
- gradient.addColorStop(0, formatRgba(color));
170
- gradient.addColorStop(1, formatRgba(endColor));
171
- ctx.fillStyle = gradient;
172
- ctx.fillRect(tx, ty, width, height);
173
- }
174
- else if (textureType === TextureType.color) {
175
- ctx.fillStyle = formatRgba(color);
176
- ctx.fillRect(tx, ty, width, height);
177
- }
178
- if (border && border.width) {
179
- const borderWidth = border.width;
180
- const borderInnerWidth = border.width / 2;
181
- const borderColor = formatRgba(parseColorRgba(border.color ?? 0));
182
- ctx.beginPath();
183
- ctx.lineWidth = borderWidth;
184
- ctx.strokeStyle = borderColor;
185
- ctx.globalAlpha = alpha;
186
- if (radius) {
187
- roundRect.call(ctx, tx + borderInnerWidth, ty + borderInnerWidth, width - borderWidth, height - borderWidth, radius);
188
- ctx.stroke();
189
- }
190
- else {
191
- ctx.strokeRect(tx + borderInnerWidth, ty + borderInnerWidth, width - borderWidth, height - borderWidth);
192
- }
193
- ctx.globalAlpha = 1;
194
- }
195
- else if (hasQuadShader) {
196
- const borderTop = getBorder(quad, 'Top');
197
- const borderRight = getBorder(quad, 'Right');
198
- const borderBottom = getBorder(quad, 'Bottom');
199
- const borderLeft = getBorder(quad, 'Left');
200
- if (borderTop) {
201
- strokeLine(ctx, tx, ty, width, height, borderTop.width, borderTop.color, 'Top');
202
- }
203
- if (borderRight) {
204
- strokeLine(ctx, tx, ty, width, height, borderRight.width, borderRight.color, 'Right');
205
- }
206
- if (borderBottom) {
207
- strokeLine(ctx, tx, ty, width, height, borderBottom.width, borderBottom.color, 'Bottom');
208
- }
209
- if (borderLeft) {
210
- strokeLine(ctx, tx, ty, width, height, borderLeft.width, borderLeft.color, 'Left');
211
- }
212
- }
213
- if (hasTransform || hasClipping || radius) {
214
- ctx.restore();
215
- }
216
- }
217
- createCtxTexture(textureSource) {
218
- return new CanvasCoreTexture(this.txMemManager, textureSource);
219
- }
220
- getShaderManager() {
221
- return this.shManager;
222
- }
223
- getDefShaderCtr() {
224
- return this.defShaderCtr;
225
- }
226
- renderRTTNodes() {
227
- // noop
228
- }
229
- removeRTTNode(node) {
230
- // noop
231
- }
232
- renderToTexture(node) {
233
- // noop
234
- }
235
- getBufferInfo() {
236
- return null;
237
- }
238
- getQuadCount() {
239
- return null;
240
- }
241
- /**
242
- * Updates the clear color of the canvas renderer.
243
- *
244
- * @param color - The color to set as the clear color.
245
- */
246
- updateClearColor(color) {
247
- this.clearColor = color ? getRgbaComponents(color) : undefined;
248
- }
249
- }
250
- //# sourceMappingURL=CanvasCoreRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CanvasCoreRenderer.js","sourceRoot":"","sources":["../../../../../src/core/renderers/canvas/CanvasCoreRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,EAAE,iBAAiB,EAAa,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAgB,MAAM,2BAA2B,CAAC;AAEtE,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,GACX,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IACxB,CAAC;IAEQ,eAAe;QACtB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,cAAc;QACZ,OAAO;IACT,CAAC;IAED,aAAa,CAAC,IAAc;QAC1B,OAAO;IACT,CAAC;IAED,eAAe,CAAC,IAAc;QAC5B,OAAO;IACT,CAAC;IACD,aAAa;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,KAAa;QAC5B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,CAAC;CACF"}
@@ -1,16 +0,0 @@
1
- import { CoreContextTexture } from '../CoreContextTexture.js';
2
- import { type IParsedColor } from './internal/ColorUtils.js';
3
- export declare class CanvasCoreTexture extends CoreContextTexture {
4
- protected image: ImageBitmap | HTMLCanvasElement | HTMLImageElement | undefined;
5
- protected tintCache: {
6
- key: string;
7
- image: HTMLCanvasElement;
8
- } | undefined;
9
- load(): void;
10
- free(): void;
11
- updateMemSize(): void;
12
- hasImage(): boolean;
13
- getImage(color: IParsedColor): ImageBitmap | HTMLCanvasElement | HTMLImageElement;
14
- protected tintTexture(source: ImageBitmap | HTMLCanvasElement | HTMLImageElement, color: string): HTMLCanvasElement;
15
- private onLoadRequest;
16
- }
@@ -1,123 +0,0 @@
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 Cable Communications Management, LLC.
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 { CoreContextTexture } from '../CoreContextTexture.js';
21
- import { formatRgba } from './internal/ColorUtils.js';
22
- export class CanvasCoreTexture extends CoreContextTexture {
23
- image;
24
- tintCache;
25
- load() {
26
- this.textureSource.setState('loading');
27
- this.onLoadRequest()
28
- .then((size) => {
29
- this.textureSource.setState('loaded', size);
30
- this.textureSource.freeTextureData();
31
- this.updateMemSize();
32
- })
33
- .catch((err) => {
34
- this.textureSource.setState('failed', err);
35
- this.textureSource.freeTextureData();
36
- });
37
- }
38
- free() {
39
- this.image = undefined;
40
- this.tintCache = undefined;
41
- this.textureSource.setState('freed');
42
- this.setTextureMemUse(0);
43
- this.textureSource.freeTextureData();
44
- }
45
- updateMemSize() {
46
- // Counting memory usage for:
47
- // - main image
48
- // - tinted image
49
- const mult = this.tintCache ? 8 : 4;
50
- if (this.textureSource.dimensions) {
51
- const { width, height } = this.textureSource.dimensions;
52
- this.setTextureMemUse(width * height * mult);
53
- }
54
- }
55
- hasImage() {
56
- return this.image !== undefined;
57
- }
58
- getImage(color) {
59
- const image = this.image;
60
- assertTruthy(image, 'Attempt to get unloaded image texture');
61
- if (color.isWhite) {
62
- if (this.tintCache) {
63
- this.tintCache = undefined;
64
- this.updateMemSize();
65
- }
66
- return image;
67
- }
68
- const key = formatRgba(color);
69
- if (this.tintCache?.key === key) {
70
- return this.tintCache.image;
71
- }
72
- const tintedImage = this.tintTexture(image, key);
73
- this.tintCache = {
74
- key,
75
- image: tintedImage,
76
- };
77
- this.updateMemSize();
78
- return tintedImage;
79
- }
80
- tintTexture(source, color) {
81
- const { width, height } = source;
82
- const canvas = document.createElement('canvas');
83
- canvas.width = width;
84
- canvas.height = height;
85
- const ctx = canvas.getContext('2d');
86
- if (ctx) {
87
- // fill with target color
88
- ctx.fillStyle = color;
89
- ctx.globalCompositeOperation = 'copy';
90
- ctx.fillRect(0, 0, width, height);
91
- // multiply with image, resulting in non-transparent tinted image
92
- ctx.globalCompositeOperation = 'multiply';
93
- ctx.drawImage(source, 0, 0, width, height, 0, 0, width, height);
94
- // apply original image alpha
95
- ctx.globalCompositeOperation = 'destination-in';
96
- ctx.drawImage(source, 0, 0, width, height, 0, 0, width, height);
97
- }
98
- return canvas;
99
- }
100
- async onLoadRequest() {
101
- assertTruthy(this.textureSource?.textureData?.data, 'Texture data is null');
102
- const { data } = this.textureSource.textureData;
103
- // TODO: canvas from text renderer should be able to provide the canvas directly
104
- // instead of having to re-draw it into a new canvas...
105
- if (data instanceof ImageData) {
106
- const canvas = document.createElement('canvas');
107
- canvas.width = data.width;
108
- canvas.height = data.height;
109
- const ctx = canvas.getContext('2d');
110
- if (ctx)
111
- ctx.putImageData(data, 0, 0);
112
- this.image = canvas;
113
- return { width: data.width, height: data.height };
114
- }
115
- else if ((typeof ImageBitmap !== 'undefined' && data instanceof ImageBitmap) ||
116
- data instanceof HTMLImageElement) {
117
- this.image = data;
118
- return { width: data.width, height: data.height };
119
- }
120
- return { width: 0, height: 0 };
121
- }
122
- }
123
- //# sourceMappingURL=CanvasCoreTexture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CanvasCoreTexture.js","sourceRoot":"","sources":["../../../../../src/core/renderers/canvas/CanvasCoreTexture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAqB,MAAM,0BAA0B,CAAC;AAEzE,MAAM,OAAO,iBAAkB,SAAQ,kBAAkB;IAC7C,KAAK,CAID;IACJ,SAAS,CAKL;IAEd,IAAI;QACF,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAEvC,IAAI,CAAC,aAAa,EAAE;aACjB,IAAI,CAAC,C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AChC,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACpD,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACjC,CAAC;CACF"}
@@ -1,10 +0,0 @@
1
- import { CoreShader } from '../../CoreShader.js';
2
- export declare const ROUNDED_RECTANGLE_SHADER_TYPE = "RoundedRectangle";
3
- export declare class UnsupportedShader extends CoreShader {
4
- shType: string;
5
- constructor(shType: string);
6
- bindRenderOp(): void;
7
- protected bindProps(): void;
8
- attach(): void;
9
- detach(): void;
10
- }
@@ -1,43 +0,0 @@
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 Cable Communications Management, LLC.
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 { CoreShader } from '../../CoreShader.js';
20
- export const ROUNDED_RECTANGLE_SHADER_TYPE = 'RoundedRectangle';
21
- export class UnsupportedShader extends CoreShader {
22
- shType;
23
- constructor(shType) {
24
- super();
25
- this.shType = shType;
26
- // if (shType !== ROUNDED_RECTANGLE_SHADER_TYPE) {
27
- // console.warn('Unsupported shader:', shType);
28
- // }
29
- }
30
- bindRenderOp() {
31
- // noop
32
- }
33
- bindProps() {
34
- // noop
35
- }
36
- attach() {
37
- // noop
38
- }
39
- detach() {
40
- // noop
41
- }
42
- }
43
- //# sourceMappingURL=UnsupportedShader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UnsupportedShader.js","sourceRoot":"","sources":["../../../../../../src/core/renderers/canvas/shaders/UnsupportedShader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,CAAC,MAAM,6BAA6B,GAAG,kBAAkB,CAAC;AAEhE,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IACxC,MAAM,CAAS;IAEtB,YAAY,MAAc;QACxB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,kDAAkD;QAClD,iDAAiD;QACjD,IAAI;IACN,CAAC;IAED,YAAY;QACV,OAAO;IACT,CAAC;IACS,SAAS;QACjB,OAAO;IACT,CAAC;IAED,MAAM;QACJ,OAAO;IACT,CAAC;IACD,MAAM;QACJ,OAAO;IACT,CAAC;CACF"}
@@ -1,12 +0,0 @@
1
- import type { Dimensions } from '../../../common/CommonTypes.js';
2
- import type { TextureMemoryManager } from '../../TextureMemoryManager.js';
3
- import type { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js';
4
- import type { RenderTexture } from '../../textures/RenderTexture.js';
5
- import { WebGlCoreCtxTexture } from './WebGlCoreCtxTexture.js';
6
- export declare class WebGlCoreCtxRenderTexture extends WebGlCoreCtxTexture {
7
- textureSource: RenderTexture;
8
- framebuffer: WebGLFramebuffer | null;
9
- constructor(glw: WebGlContextWrapper, memManager: TextureMemoryManager, textureSource: RenderTexture);
10
- onLoadRequest(): Promise<Dimensions>;
11
- free(): void;
12
- }
@@ -1,55 +0,0 @@
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 2024 Comcast Cable Communications Management, LLC.
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 { WebGlCoreCtxTexture } from './WebGlCoreCtxTexture.js';
21
- export class WebGlCoreCtxRenderTexture extends WebGlCoreCtxTexture {
22
- framebuffer = null;
23
- constructor(glw, memManager, textureSource) {
24
- super(glw, memManager, textureSource);
25
- }
26
- async onLoadRequest() {
27
- const { glw } = this;
28
- const nativeTexture = (this._nativeCtxTexture =
29
- this.createNativeCtxTexture());
30
- const { width, height } = this.textureSource;
31
- // Create Framebuffer object
32
- this.framebuffer = glw.createFramebuffer();
33
- // Set the dimensions of the render texture
34
- glw.texImage2D(0, glw.RGBA, width, height, 0, glw.RGBA, glw.UNSIGNED_BYTE, null);
35
- // Update the texture memory manager
36
- this.setTextureMemUse(width * height * 4);
37
- // Bind the framebuffer
38
- glw.bindFramebuffer(this.framebuffer);
39
- // Attach the texture to the framebuffer
40
- glw.framebufferTexture2D(glw.COLOR_ATTACHMENT0, nativeTexture, 0);
41
- // Unbind the framebuffer
42
- glw.bindFramebuffer(null);
43
- return {
44
- width,
45
- height,
46
- };
47
- }
48
- free() {
49
- super.free();
50
- // Delete the framebuffer
51
- this.glw.deleteFramebuffer(this.framebuffer);
52
- this.framebuffer = null;
53
- }
54
- }
55
- //# sourceMappingURL=WebGlCoreCtxRenderTexture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebGlCoreCtxRenderTexture.js","sourceRoot":"","sources":["../../../../../src/core/renderers/webgl/WebGlCoreCtxRenderTexture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EAAE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,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF"}
@@ -1,9 +0,0 @@
1
- import type { Dimensions } from '../../../common/CommonTypes.js';
2
- import type { TextureMemoryManager } from '../../TextureMemoryManager.js';
3
- import type { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js';
4
- import type { SubTexture } from '../../textures/SubTexture.js';
5
- import { WebGlCoreCtxTexture } from './WebGlCoreCtxTexture.js';
6
- export declare class WebGlCoreCtxSubTexture extends WebGlCoreCtxTexture {
7
- constructor(glw: WebGlContextWrapper, memManager: TextureMemoryManager, textureSource: SubTexture);
8
- onLoadRequest(): Promise<Dimensions>;
9
- }
@@ -1,38 +0,0 @@
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 Cable Communications Management, LLC.
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 { WebGlCoreCtxTexture } from './WebGlCoreCtxTexture.js';
21
- export class WebGlCoreCtxSubTexture extends WebGlCoreCtxTexture {
22
- constructor(glw, memManager, textureSource) {
23
- super(glw, memManager, textureSource);
24
- }
25
- async onLoadRequest() {
26
- const props = this.textureSource.textureData;
27
- assertTruthy(props, 'SubTexture must have texture data');
28
- if (props.data instanceof Uint8Array) {
29
- // its a 1x1 Color Texture
30
- return { width: 1, height: 1 };
31
- }
32
- return {
33
- width: props.data?.width || 0,
34
- height: props.data?.height || 0,
35
- };
36
- }
37
- }
38
- //# sourceMappingURL=WebGlCoreCtxSubTexture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebGlCoreCtxSubTexture.js","sourceRoot":"","sources":["../../../../../src/core/renderers/webgl/WebGlCoreCtxSubTexture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,OAAO,sBAAuB,SAAQ,mBAAmB;IAC7D,YACE,GAAwB,EACxB,UAAgC,EAChC,aAAyB;QAEzB,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACxC,CAAC;IAEQ,KAAK,CAAC,aAAa;QAC1B,MAAM,KAAK,GAAI,IAAI,CAAC,aAA4B,CAAC,WAAW,CAAC;QAC7D,YAAY,CAAC,KAAK,EAAE,mCAAmC,CAAC,CAAC;QAEzD,IAAI,KAAK,CAAC,IAAI,YAAY,UAAU,EAAE,CAAC;YACrC,0BAA0B;YAC1B,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACjC,CAAC;QAED,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC;YAC7B,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;SAChC,CAAC;IACJ,CAAC;CACF"}
@@ -1,57 +0,0 @@
1
- import type { Dimensions } from '../../../common/CommonTypes.js';
2
- import type { TextureMemoryManager } from '../../TextureMemoryManager.js';
3
- import type { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js';
4
- import type { Texture } from '../../textures/Texture.js';
5
- import { CoreContextTexture } from '../CoreContextTexture.js';
6
- /**
7
- * A wrapper around a WebGLTexture that handles loading the texture data
8
- * from a Texture source and uploading it to the GPU as well as freeing
9
- * the uploaded texture.
10
- *
11
- * @remarks
12
- * When accessing the ctxTexture property, the texture will be loaded if
13
- * it hasn't been already. ctxTexture will always return a valid WebGLTexture
14
- * and trigger the loading/uploading of the texture's data if it hasn't been
15
- * loaded yet.
16
- */
17
- export declare class WebGlCoreCtxTexture extends CoreContextTexture {
18
- protected glw: WebGlContextWrapper;
19
- protected _nativeCtxTexture: WebGLTexture | null;
20
- private _w;
21
- private _h;
22
- constructor(glw: WebGlContextWrapper, memManager: TextureMemoryManager, textureSource: Texture);
23
- get ctxTexture(): WebGLTexture | null;
24
- get w(): number;
25
- get h(): number;
26
- /**
27
- * Load the texture data from the Texture source and upload it to the GPU
28
- *
29
- * @remarks
30
- * This method is called automatically when accessing the ctxTexture property
31
- * if the texture hasn't been loaded yet. But it can also be called manually
32
- * to force the texture to be pre-loaded prior to accessing the ctxTexture
33
- * property.
34
- */
35
- load(): void;
36
- /**
37
- * Called when the texture data needs to be loaded and uploaded to a texture
38
- */
39
- onLoadRequest(): Promise<Dimensions>;
40
- /**
41
- * Free the WebGLTexture from the GPU
42
- *
43
- * @returns
44
- */
45
- free(): void;
46
- /**
47
- * Create native context texture
48
- *
49
- * @remarks
50
- * When this method returns the returned texture will be bound to the GL context state.
51
- *
52
- * @param width
53
- * @param height
54
- * @returns
55
- */
56
- protected createNativeCtxTexture(): WebGLTexture | null;
57
- }