@lightningjs/renderer 2.20.2 → 2.20.3

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 (202) hide show
  1. package/dist/src/core/CoreNode.d.ts +1 -1
  2. package/dist/src/core/lib/WebGlContextWrapper.d.ts +5 -5
  3. package/dist/src/main-api/Inspector.js +5 -6
  4. package/dist/src/main-api/Inspector.js.map +1 -1
  5. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  6. package/package.json +1 -1
  7. package/src/main-api/Inspector.ts +5 -6
  8. package/dist/exports/canvas-shaders.d.ts +0 -10
  9. package/dist/exports/canvas-shaders.js +0 -27
  10. package/dist/exports/canvas-shaders.js.map +0 -1
  11. package/dist/exports/webgl-shaders.d.ts +0 -11
  12. package/dist/exports/webgl-shaders.js +0 -28
  13. package/dist/exports/webgl-shaders.js.map +0 -1
  14. package/dist/src/core/AutosizeManager.d.ts +0 -30
  15. package/dist/src/core/AutosizeManager.js +0 -159
  16. package/dist/src/core/AutosizeManager.js.map +0 -1
  17. package/dist/src/core/Autosizer.d.ts +0 -29
  18. package/dist/src/core/Autosizer.js +0 -177
  19. package/dist/src/core/Autosizer.js.map +0 -1
  20. package/dist/src/core/animations/Animation.d.ts +0 -16
  21. package/dist/src/core/animations/Animation.js +0 -111
  22. package/dist/src/core/animations/Animation.js.map +0 -1
  23. package/dist/src/core/animations/CoreTransition.d.ts +0 -24
  24. package/dist/src/core/animations/CoreTransition.js +0 -63
  25. package/dist/src/core/animations/CoreTransition.js.map +0 -1
  26. package/dist/src/core/animations/Playback.d.ts +0 -62
  27. package/dist/src/core/animations/Playback.js +0 -155
  28. package/dist/src/core/animations/Playback.js.map +0 -1
  29. package/dist/src/core/animations/Transition.d.ts +0 -25
  30. package/dist/src/core/animations/Transition.js +0 -63
  31. package/dist/src/core/animations/Transition.js.map +0 -1
  32. package/dist/src/core/animations/utils.d.ts +0 -2
  33. package/dist/src/core/animations/utils.js +0 -137
  34. package/dist/src/core/animations/utils.js.map +0 -1
  35. package/dist/src/core/lib/collectionUtils.d.ts +0 -5
  36. package/dist/src/core/lib/collectionUtils.js +0 -100
  37. package/dist/src/core/lib/collectionUtils.js.map +0 -1
  38. package/dist/src/core/lib/colorCache.d.ts +0 -1
  39. package/dist/src/core/lib/colorCache.js +0 -19
  40. package/dist/src/core/lib/colorCache.js.map +0 -1
  41. package/dist/src/core/lib/colorParser.d.ts +0 -21
  42. package/dist/src/core/lib/colorParser.js +0 -72
  43. package/dist/src/core/lib/colorParser.js.map +0 -1
  44. package/dist/src/core/platforms/Platform.d.ts +0 -42
  45. package/dist/src/core/platforms/Platform.js +0 -22
  46. package/dist/src/core/platforms/Platform.js.map +0 -1
  47. package/dist/src/core/platforms/web/WebPlatform.d.ts +0 -10
  48. package/dist/src/core/platforms/web/WebPlatform.js +0 -87
  49. package/dist/src/core/platforms/web/WebPlatform.js.map +0 -1
  50. package/dist/src/core/renderers/CoreShaderNode.d.ts +0 -59
  51. package/dist/src/core/renderers/CoreShaderNode.js +0 -113
  52. package/dist/src/core/renderers/CoreShaderNode.js.map +0 -1
  53. package/dist/src/core/renderers/CoreShaderProgram.d.ts +0 -4
  54. package/dist/src/core/renderers/CoreShaderProgram.js +0 -20
  55. package/dist/src/core/renderers/CoreShaderProgram.js.map +0 -1
  56. package/dist/src/core/renderers/canvas/CanvasRenderer.d.ts +0 -35
  57. package/dist/src/core/renderers/canvas/CanvasRenderer.js +0 -201
  58. package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +0 -1
  59. package/dist/src/core/renderers/canvas/CanvasShaderNode.d.ts +0 -21
  60. package/dist/src/core/renderers/canvas/CanvasShaderNode.js +0 -58
  61. package/dist/src/core/renderers/canvas/CanvasShaderNode.js.map +0 -1
  62. package/dist/src/core/renderers/canvas/CanvasTexture.d.ts +0 -17
  63. package/dist/src/core/renderers/canvas/CanvasTexture.js +0 -128
  64. package/dist/src/core/renderers/canvas/CanvasTexture.js.map +0 -1
  65. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.d.ts +0 -14
  66. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js +0 -63
  67. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js.map +0 -1
  68. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.d.ts +0 -22
  69. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js +0 -67
  70. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js.map +0 -1
  71. package/dist/src/core/renderers/webgl/WebGlCtxTexture.d.ts +0 -67
  72. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +0 -273
  73. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +0 -1
  74. package/dist/src/core/renderers/webgl/WebGlRenderOp.d.ts +0 -44
  75. package/dist/src/core/renderers/webgl/WebGlRenderOp.js +0 -125
  76. package/dist/src/core/renderers/webgl/WebGlRenderOp.js.map +0 -1
  77. package/dist/src/core/renderers/webgl/WebGlRenderer.d.ts +0 -136
  78. package/dist/src/core/renderers/webgl/WebGlRenderer.js +0 -569
  79. package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +0 -1
  80. package/dist/src/core/renderers/webgl/WebGlShaderNode.d.ts +0 -222
  81. package/dist/src/core/renderers/webgl/WebGlShaderNode.js +0 -331
  82. package/dist/src/core/renderers/webgl/WebGlShaderNode.js.map +0 -1
  83. package/dist/src/core/renderers/webgl/WebGlShaderProgram.d.ts +0 -37
  84. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +0 -218
  85. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +0 -1
  86. package/dist/src/core/shaders/canvas/Border.d.ts +0 -9
  87. package/dist/src/core/shaders/canvas/Border.js +0 -57
  88. package/dist/src/core/shaders/canvas/Border.js.map +0 -1
  89. package/dist/src/core/shaders/canvas/HolePunch.d.ts +0 -7
  90. package/dist/src/core/shaders/canvas/HolePunch.js +0 -38
  91. package/dist/src/core/shaders/canvas/HolePunch.js.map +0 -1
  92. package/dist/src/core/shaders/canvas/LinearGradient.d.ts +0 -10
  93. package/dist/src/core/shaders/canvas/LinearGradient.js +0 -48
  94. package/dist/src/core/shaders/canvas/LinearGradient.js.map +0 -1
  95. package/dist/src/core/shaders/canvas/RadialGradient.d.ts +0 -11
  96. package/dist/src/core/shaders/canvas/RadialGradient.js +0 -70
  97. package/dist/src/core/shaders/canvas/RadialGradient.js.map +0 -1
  98. package/dist/src/core/shaders/canvas/Rounded.d.ts +0 -7
  99. package/dist/src/core/shaders/canvas/Rounded.js +0 -33
  100. package/dist/src/core/shaders/canvas/Rounded.js.map +0 -1
  101. package/dist/src/core/shaders/canvas/RoundedWithBorder.d.ts +0 -7
  102. package/dist/src/core/shaders/canvas/RoundedWithBorder.js +0 -43
  103. package/dist/src/core/shaders/canvas/RoundedWithBorder.js.map +0 -1
  104. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.d.ts +0 -8
  105. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js +0 -41
  106. package/dist/src/core/shaders/canvas/RoundedWithBorderAndShadow.js.map +0 -1
  107. package/dist/src/core/shaders/canvas/RoundedWithShadow.d.ts +0 -7
  108. package/dist/src/core/shaders/canvas/RoundedWithShadow.js +0 -40
  109. package/dist/src/core/shaders/canvas/RoundedWithShadow.js.map +0 -1
  110. package/dist/src/core/shaders/canvas/Shadow.d.ts +0 -8
  111. package/dist/src/core/shaders/canvas/Shadow.js +0 -31
  112. package/dist/src/core/shaders/canvas/Shadow.js.map +0 -1
  113. package/dist/src/core/shaders/canvas/utils/render.d.ts +0 -5
  114. package/dist/src/core/shaders/canvas/utils/render.js +0 -84
  115. package/dist/src/core/shaders/canvas/utils/render.js.map +0 -1
  116. package/dist/src/core/shaders/templates/BorderTemplate.d.ts +0 -37
  117. package/dist/src/core/shaders/templates/BorderTemplate.js +0 -73
  118. package/dist/src/core/shaders/templates/BorderTemplate.js.map +0 -1
  119. package/dist/src/core/shaders/templates/HolePunchTemplate.d.ts +0 -46
  120. package/dist/src/core/shaders/templates/HolePunchTemplate.js +0 -35
  121. package/dist/src/core/shaders/templates/HolePunchTemplate.js.map +0 -1
  122. package/dist/src/core/shaders/templates/LinearGradientTemplate.d.ts +0 -23
  123. package/dist/src/core/shaders/templates/LinearGradientTemplate.js +0 -47
  124. package/dist/src/core/shaders/templates/LinearGradientTemplate.js.map +0 -1
  125. package/dist/src/core/shaders/templates/RadialGradientTemplate.d.ts +0 -33
  126. package/dist/src/core/shaders/templates/RadialGradientTemplate.js +0 -49
  127. package/dist/src/core/shaders/templates/RadialGradientTemplate.js.map +0 -1
  128. package/dist/src/core/shaders/templates/RoundedTemplate.d.ts +0 -29
  129. package/dist/src/core/shaders/templates/RoundedTemplate.js +0 -67
  130. package/dist/src/core/shaders/templates/RoundedTemplate.js.map +0 -1
  131. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.d.ts +0 -7
  132. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.js +0 -24
  133. package/dist/src/core/shaders/templates/RoundedWithBorderAndShadowTemplate.js.map +0 -1
  134. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.d.ts +0 -6
  135. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.js +0 -23
  136. package/dist/src/core/shaders/templates/RoundedWithBorderTemplate.js.map +0 -1
  137. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.d.ts +0 -6
  138. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.js +0 -23
  139. package/dist/src/core/shaders/templates/RoundedWithShadowTemplate.js.map +0 -1
  140. package/dist/src/core/shaders/templates/ShadowTemplate.d.ts +0 -34
  141. package/dist/src/core/shaders/templates/ShadowTemplate.js +0 -66
  142. package/dist/src/core/shaders/templates/ShadowTemplate.js.map +0 -1
  143. package/dist/src/core/shaders/utils.d.ts +0 -5
  144. package/dist/src/core/shaders/utils.js +0 -41
  145. package/dist/src/core/shaders/utils.js.map +0 -1
  146. package/dist/src/core/shaders/webgl/Border.d.ts +0 -3
  147. package/dist/src/core/shaders/webgl/Border.js +0 -110
  148. package/dist/src/core/shaders/webgl/Border.js.map +0 -1
  149. package/dist/src/core/shaders/webgl/Default.d.ts +0 -2
  150. package/dist/src/core/shaders/webgl/Default.js +0 -86
  151. package/dist/src/core/shaders/webgl/Default.js.map +0 -1
  152. package/dist/src/core/shaders/webgl/DefaultBatched.d.ts +0 -2
  153. package/dist/src/core/shaders/webgl/DefaultBatched.js +0 -104
  154. package/dist/src/core/shaders/webgl/DefaultBatched.js.map +0 -1
  155. package/dist/src/core/shaders/webgl/HolePunch.d.ts +0 -3
  156. package/dist/src/core/shaders/webgl/HolePunch.js +0 -65
  157. package/dist/src/core/shaders/webgl/HolePunch.js.map +0 -1
  158. package/dist/src/core/shaders/webgl/LinearGradient.d.ts +0 -3
  159. package/dist/src/core/shaders/webgl/LinearGradient.js +0 -100
  160. package/dist/src/core/shaders/webgl/LinearGradient.js.map +0 -1
  161. package/dist/src/core/shaders/webgl/RadialGradient.d.ts +0 -3
  162. package/dist/src/core/shaders/webgl/RadialGradient.js +0 -97
  163. package/dist/src/core/shaders/webgl/RadialGradient.js.map +0 -1
  164. package/dist/src/core/shaders/webgl/Rounded.d.ts +0 -7
  165. package/dist/src/core/shaders/webgl/Rounded.js +0 -88
  166. package/dist/src/core/shaders/webgl/Rounded.js.map +0 -1
  167. package/dist/src/core/shaders/webgl/RoundedWithBorder.d.ts +0 -3
  168. package/dist/src/core/shaders/webgl/RoundedWithBorder.js +0 -141
  169. package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +0 -1
  170. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.d.ts +0 -3
  171. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +0 -163
  172. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +0 -1
  173. package/dist/src/core/shaders/webgl/RoundedWithShadow.d.ts +0 -3
  174. package/dist/src/core/shaders/webgl/RoundedWithShadow.js +0 -85
  175. package/dist/src/core/shaders/webgl/RoundedWithShadow.js.map +0 -1
  176. package/dist/src/core/shaders/webgl/SdfShader.d.ts +0 -30
  177. package/dist/src/core/shaders/webgl/SdfShader.js +0 -107
  178. package/dist/src/core/shaders/webgl/SdfShader.js.map +0 -1
  179. package/dist/src/core/shaders/webgl/Shadow.d.ts +0 -3
  180. package/dist/src/core/shaders/webgl/Shadow.js +0 -110
  181. package/dist/src/core/shaders/webgl/Shadow.js.map +0 -1
  182. package/dist/src/core/text-rendering/CanvasFontHandler.d.ts +0 -59
  183. package/dist/src/core/text-rendering/CanvasFontHandler.js +0 -224
  184. package/dist/src/core/text-rendering/CanvasFontHandler.js.map +0 -1
  185. package/dist/src/core/text-rendering/CanvasTextRenderer.d.ts +0 -17
  186. package/dist/src/core/text-rendering/CanvasTextRenderer.js +0 -157
  187. package/dist/src/core/text-rendering/CanvasTextRenderer.js.map +0 -1
  188. package/dist/src/core/text-rendering/SdfFontHandler.d.ts +0 -182
  189. package/dist/src/core/text-rendering/SdfFontHandler.js +0 -391
  190. package/dist/src/core/text-rendering/SdfFontHandler.js.map +0 -1
  191. package/dist/src/core/text-rendering/SdfTextRenderer.d.ts +0 -17
  192. package/dist/src/core/text-rendering/SdfTextRenderer.js +0 -311
  193. package/dist/src/core/text-rendering/SdfTextRenderer.js.map +0 -1
  194. package/dist/src/core/text-rendering/TextLayoutEngine.d.ts +0 -18
  195. package/dist/src/core/text-rendering/TextLayoutEngine.js +0 -380
  196. package/dist/src/core/text-rendering/TextLayoutEngine.js.map +0 -1
  197. package/dist/src/core/text-rendering/TextRenderer.d.ts +0 -383
  198. package/dist/src/core/text-rendering/TextRenderer.js +0 -20
  199. package/dist/src/core/text-rendering/TextRenderer.js.map +0 -1
  200. package/dist/src/core/text-rendering/Utils.d.ts +0 -30
  201. package/dist/src/core/text-rendering/Utils.js +0 -84
  202. package/dist/src/core/text-rendering/Utils.js.map +0 -1
@@ -1,67 +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
- import type { Bound } from '../../lib/utils.js';
7
- /**
8
- * A wrapper around a WebGLTexture that handles loading the texture data
9
- * from a Texture source and uploading it to the GPU as well as freeing
10
- * the uploaded texture.
11
- *
12
- * @remarks
13
- * When accessing the ctxTexture property, the texture will be loaded if
14
- * it hasn't been already. ctxTexture will always return a valid WebGLTexture
15
- * and trigger the loading/uploading of the texture's data if it hasn't been
16
- * loaded yet.
17
- */
18
- export declare class WebGlCtxTexture extends CoreContextTexture {
19
- protected glw: WebGlContextWrapper;
20
- protected _nativeCtxTexture: WebGLTexture | null;
21
- private _w;
22
- private _h;
23
- txCoords: Bound;
24
- constructor(glw: WebGlContextWrapper, memManager: TextureMemoryManager, textureSource: Texture);
25
- /**
26
- * GL error check with direct state marking
27
- * Uses cached error result to minimize function calls
28
- */
29
- private checkGLError;
30
- get ctxTexture(): WebGLTexture | null;
31
- get w(): number;
32
- get h(): number;
33
- /**
34
- * Load the texture data from the Texture source and upload it to the GPU
35
- *
36
- * @remarks
37
- * This method is called automatically when accessing the ctxTexture property
38
- * if the texture hasn't been loaded yet. But it can also be called manually
39
- * to force the texture to be pre-loaded prior to accessing the ctxTexture
40
- * property.
41
- */
42
- load(): Promise<void>;
43
- /**
44
- * Called when the texture data needs to be loaded and uploaded to a texture
45
- */
46
- onLoadRequest(): Promise<Dimensions>;
47
- /**
48
- * Free the WebGLTexture from the GPU
49
- *
50
- * @returns
51
- */
52
- free(): void;
53
- /**
54
- * Release the WebGLTexture from the GPU without changing state
55
- */
56
- release(): void;
57
- /**
58
- * Create native context texture asynchronously
59
- *
60
- * @remarks
61
- * When this method resolves, the returned texture will be bound to the GL context state
62
- * and fully ready for use. This ensures proper GPU resource allocation timing.
63
- *
64
- * @returns Promise that resolves to the native WebGL texture or null on failure
65
- */
66
- protected createNativeCtxTexture(): WebGLTexture | null;
67
- }
@@ -1,273 +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 { uploadCompressedTexture } from '../../lib/textureCompression.js';
20
- import { CoreContextTexture } from '../CoreContextTexture.js';
21
- import { isHTMLImageElement } from './internal/RendererUtils.js';
22
- const TRANSPARENT_TEXTURE_DATA = new Uint8Array([0, 0, 0, 0]);
23
- /**
24
- * A wrapper around a WebGLTexture that handles loading the texture data
25
- * from a Texture source and uploading it to the GPU as well as freeing
26
- * the uploaded texture.
27
- *
28
- * @remarks
29
- * When accessing the ctxTexture property, the texture will be loaded if
30
- * it hasn't been already. ctxTexture will always return a valid WebGLTexture
31
- * and trigger the loading/uploading of the texture's data if it hasn't been
32
- * loaded yet.
33
- */
34
- export class WebGlCtxTexture extends CoreContextTexture {
35
- glw;
36
- _nativeCtxTexture = null;
37
- _w = 0;
38
- _h = 0;
39
- txCoords = {
40
- x1: 0,
41
- y1: 0,
42
- x2: 1,
43
- y2: 1,
44
- };
45
- constructor(glw, memManager, textureSource) {
46
- super(memManager, textureSource);
47
- this.glw = glw;
48
- }
49
- /**
50
- * GL error check with direct state marking
51
- * Uses cached error result to minimize function calls
52
- */
53
- checkGLError() {
54
- // Skip if already failed to prevent double-processing
55
- if (this.state === 'failed') {
56
- return true;
57
- }
58
- const error = this.glw.getError();
59
- if (error !== 0) {
60
- this.state = 'failed';
61
- this.textureSource.setState('failed', new Error(`WebGL Error: ${error}`));
62
- return true;
63
- }
64
- return false;
65
- }
66
- get ctxTexture() {
67
- if (this.state === 'freed') {
68
- this.load();
69
- return null;
70
- }
71
- return this._nativeCtxTexture;
72
- }
73
- get w() {
74
- return this._w;
75
- }
76
- get h() {
77
- return this._h;
78
- }
79
- /**
80
- * Load the texture data from the Texture source and upload it to the GPU
81
- *
82
- * @remarks
83
- * This method is called automatically when accessing the ctxTexture property
84
- * if the texture hasn't been loaded yet. But it can also be called manually
85
- * to force the texture to be pre-loaded prior to accessing the ctxTexture
86
- * property.
87
- */
88
- async load() {
89
- // If the texture is already loading or loaded, return resolved promise
90
- if (this.state === 'loading' || this.state === 'loaded') {
91
- return Promise.resolve();
92
- }
93
- this.state = 'loading';
94
- this.textureSource.setState('loading');
95
- // Await the native texture creation to ensure GPU buffer is fully allocated
96
- this._nativeCtxTexture = this.createNativeCtxTexture();
97
- if (this._nativeCtxTexture === null) {
98
- this.state = 'failed';
99
- const error = new Error('Could not create WebGL Texture');
100
- this.textureSource.setState('failed', error);
101
- console.error('Could not create WebGL Texture');
102
- throw error;
103
- }
104
- try {
105
- const { w, h } = await this.onLoadRequest();
106
- // If the texture has been freed while loading, return early.
107
- // Type assertion needed because state could change during async operations
108
- if (this.state === 'freed') {
109
- return;
110
- }
111
- this.state = 'loaded';
112
- this._w = w;
113
- this._h = h;
114
- // Update the texture source's width and height so that it can be used
115
- // for rendering.
116
- this.textureSource.setState('loaded', { w, h });
117
- // cleanup source texture data next tick
118
- // This is done using queueMicrotask to ensure it runs after the current
119
- // event loop tick, allowing the texture to be fully loaded and bound
120
- // to the GL context before freeing the source data.
121
- // This is important to avoid issues with the texture data being
122
- // freed while the texture is still being loaded or used.
123
- this.textureSource.freeTextureData();
124
- }
125
- catch (err) {
126
- // If the texture has been freed while loading, return early.
127
- // Type assertion needed because state could change during async operations
128
- if (this.state === 'freed') {
129
- return;
130
- }
131
- this.state = 'failed';
132
- const error = err instanceof Error ? err : new Error(String(err));
133
- this.textureSource.setState('failed', error);
134
- this.textureSource.freeTextureData();
135
- console.error(err);
136
- throw error; // Re-throw to propagate the error
137
- }
138
- }
139
- /**
140
- * Called when the texture data needs to be loaded and uploaded to a texture
141
- */
142
- async onLoadRequest() {
143
- const { glw } = this;
144
- const textureData = this.textureSource.textureData;
145
- if (textureData === null || this._nativeCtxTexture === null) {
146
- throw new Error('Texture data or native texture is null ' + this.textureSource.type);
147
- }
148
- // Set to a 1x1 transparent texture
149
- glw.texImage2D(0, glw.RGBA, 1, 1, 0, glw.RGBA, glw.UNSIGNED_BYTE, null);
150
- this.setTextureMemUse(TRANSPARENT_TEXTURE_DATA.byteLength);
151
- let w = 0;
152
- let h = 0;
153
- glw.activeTexture(0);
154
- const tdata = textureData.data;
155
- const format = glw.RGBA;
156
- const formatBytes = 4;
157
- const memoryPadding = 1.1; // Add padding to account for GPU Padding
158
- // If textureData is null, the texture is empty (0, 0) and we don't need to
159
- // upload any data to the GPU.
160
- if ((typeof ImageBitmap !== 'undefined' && tdata instanceof ImageBitmap) ||
161
- tdata instanceof ImageData ||
162
- // not using typeof HTMLI mageElement due to web worker
163
- isHTMLImageElement(tdata) === true) {
164
- w = tdata.width;
165
- h = tdata.height;
166
- glw.bindTexture(this._nativeCtxTexture);
167
- glw.pixelStorei(glw.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !!textureData.premultiplyAlpha);
168
- glw.texImage2D(0, format, format, glw.UNSIGNED_BYTE, tdata);
169
- // Check for errors after compressed texture operations
170
- if (this.checkGLError() === true) {
171
- return { w: 0, h: 0 };
172
- }
173
- this.setTextureMemUse(h * w * formatBytes * memoryPadding);
174
- }
175
- else if (tdata === null) {
176
- w = 0;
177
- h = 0;
178
- // Reset to a 1x1 transparent texture
179
- glw.bindTexture(this._nativeCtxTexture);
180
- glw.texImage2D(0, format, 1, 1, 0, format, glw.UNSIGNED_BYTE, TRANSPARENT_TEXTURE_DATA);
181
- this.setTextureMemUse(TRANSPARENT_TEXTURE_DATA.byteLength);
182
- }
183
- else if ('mipmaps' in tdata && tdata.mipmaps) {
184
- const { mipmaps, type, blockInfo } = tdata;
185
- uploadCompressedTexture[type](glw, this._nativeCtxTexture, tdata);
186
- // Check for errors after compressed texture operations
187
- if (this.checkGLError() === true) {
188
- return { w: 0, h: 0 };
189
- }
190
- w = tdata.w;
191
- h = tdata.h;
192
- this.txCoords.x2 = w / (Math.ceil(w / blockInfo.width) * blockInfo.width);
193
- this.txCoords.y2 =
194
- h / (Math.ceil(h / blockInfo.height) * blockInfo.height);
195
- this.setTextureMemUse(mipmaps[0]?.byteLength ?? 0);
196
- }
197
- else if (tdata && tdata instanceof Uint8Array) {
198
- // Color Texture
199
- w = 1;
200
- h = 1;
201
- glw.bindTexture(this._nativeCtxTexture);
202
- glw.pixelStorei(glw.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !!textureData.premultiplyAlpha);
203
- glw.texImage2D(0, format, w, h, 0, format, glw.UNSIGNED_BYTE, tdata);
204
- // Check for errors after compressed texture operations
205
- if (this.checkGLError() === true) {
206
- return { w: 0, h: 0 };
207
- }
208
- this.setTextureMemUse(w * h * formatBytes);
209
- }
210
- else {
211
- console.error(`WebGlCoreCtxTexture.onLoadRequest: Unexpected textureData returned`, textureData);
212
- }
213
- return {
214
- w,
215
- h,
216
- };
217
- }
218
- /**
219
- * Free the WebGLTexture from the GPU
220
- *
221
- * @returns
222
- */
223
- free() {
224
- if (this.state === 'freed') {
225
- return;
226
- }
227
- this.state = 'freed';
228
- this.textureSource.setState('freed');
229
- this.release();
230
- }
231
- /**
232
- * Release the WebGLTexture from the GPU without changing state
233
- */
234
- release() {
235
- this._w = 0;
236
- this._h = 0;
237
- if (this._nativeCtxTexture !== null) {
238
- this.glw.deleteTexture(this._nativeCtxTexture);
239
- this.setTextureMemUse(0);
240
- this._nativeCtxTexture = null;
241
- }
242
- // if the texture still has source data, free it
243
- this.textureSource.freeTextureData();
244
- }
245
- /**
246
- * Create native context texture asynchronously
247
- *
248
- * @remarks
249
- * When this method resolves, the returned texture will be bound to the GL context state
250
- * and fully ready for use. This ensures proper GPU resource allocation timing.
251
- *
252
- * @returns Promise that resolves to the native WebGL texture or null on failure
253
- */
254
- createNativeCtxTexture() {
255
- const { glw } = this;
256
- const nativeTexture = glw.createTexture();
257
- if (!nativeTexture) {
258
- return null;
259
- }
260
- // On initial load request, create a 1x1 transparent texture to use until
261
- // the texture data is finally loaded.
262
- glw.activeTexture(0);
263
- glw.bindTexture(nativeTexture);
264
- // linear texture filtering
265
- glw.texParameteri(glw.TEXTURE_MAG_FILTER, glw.LINEAR);
266
- glw.texParameteri(glw.TEXTURE_MIN_FILTER, glw.LINEAR);
267
- // texture wrapping method
268
- glw.texParameteri(glw.TEXTURE_WRAP_S, glw.CLAMP_TO_EDGE);
269
- glw.texParameteri(glw.TEXTURE_WRAP_T, glw.CLAMP_TO_EDGE);
270
- return nativeTexture;
271
- }
272
- }
273
- //# sourceMappingURL=WebGlCtxTexture.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebGlCtxTexture.js","sourceRoot":"","sources":["../../../../../src/core/renderers/webgl/WebGlCtxTexture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,MAAM,wBAAwB,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,eAAgB,SAAQ,kBAAkB;IAazC;IAZF,iBAAiB,GAAwB,IAAI,CAAC;IAChD,EAAE,GAAG,CAAC,CAAC;IACP,EAAE,GAAG,CAAC,CAAC;IAEf,QAAQ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C;IAED;;;;;;;;OAQG;IACO,sBAAsB;QAC9B,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAErB,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,EAAE,CAAC;QAC1C,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,yEAAyE;QACzE,sCAAsC;QACtC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QACrB,GAAG,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QAE/B,2BAA2B;QAC3B,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QACtD,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAEtD,0BAA0B;QAC1B,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;QACzD,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;QAEzD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
@@ -1,44 +0,0 @@
1
- import { CoreRenderOp } from '../CoreRenderOp.js';
2
- import type { WebGlCtxTexture } from './WebGlCtxTexture.js';
3
- import type { WebGlRenderer } from './WebGlRenderer.js';
4
- import type { BufferCollection } from './internal/BufferCollection.js';
5
- import type { WebGlShaderNode } from './WebGlShaderNode.js';
6
- import type { QuadOptions } from '../CoreRenderer.js';
7
- import type { CoreTextNode } from '../../CoreTextNode.js';
8
- import type { RectWithValid } from '../../lib/utils.js';
9
- import type { Dimensions } from '../../../common/CommonTypes.js';
10
- type ReqQuad = 'alpha' | 'shader' | 'parentHasRenderTexture' | 'rtt' | 'clippingRect' | 'height' | 'width';
11
- type RenderOpQuadOptions = Pick<QuadOptions, ReqQuad> & Partial<Omit<QuadOptions, ReqQuad>> & {
12
- sdfShaderProps?: Record<string, unknown>;
13
- sdfBuffers?: BufferCollection;
14
- };
15
- /**
16
- * Can render multiple quads with multiple textures (up to vertex shader texture limit)
17
- *
18
- */
19
- export declare class WebGlRenderOp extends CoreRenderOp {
20
- readonly renderer: WebGlRenderer;
21
- readonly bufferIdx: number;
22
- numQuads: number;
23
- textures: WebGlCtxTexture[];
24
- /**
25
- * need to improve this when TextRenderers are refactored
26
- */
27
- readonly sdfShaderProps: Record<string, unknown> | undefined;
28
- readonly sdfNode: CoreTextNode | undefined;
29
- readonly maxTextures: number;
30
- readonly buffers: BufferCollection;
31
- readonly shader: WebGlShaderNode;
32
- readonly width: number;
33
- readonly height: number;
34
- readonly clippingRect: RectWithValid;
35
- readonly rtt: boolean;
36
- readonly parentHasRenderTexture: boolean;
37
- readonly framebufferDimensions?: Dimensions | null;
38
- readonly alpha: number;
39
- readonly pixelRatio: number;
40
- constructor(renderer: WebGlRenderer, quad: RenderOpQuadOptions, bufferIdx: number);
41
- addTexture(texture: WebGlCtxTexture): number;
42
- draw(): void;
43
- }
44
- export {};
@@ -1,125 +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 { CoreRenderOp } from '../CoreRenderOp.js';
20
- /**
21
- * Can render multiple quads with multiple textures (up to vertex shader texture limit)
22
- *
23
- */
24
- export class WebGlRenderOp extends CoreRenderOp {
25
- renderer;
26
- bufferIdx;
27
- numQuads = 0;
28
- textures = [];
29
- /**
30
- * need to improve this when TextRenderers are refactored
31
- */
32
- sdfShaderProps;
33
- sdfNode;
34
- maxTextures;
35
- buffers;
36
- shader;
37
- width;
38
- height;
39
- clippingRect;
40
- rtt;
41
- parentHasRenderTexture;
42
- framebufferDimensions;
43
- alpha;
44
- pixelRatio;
45
- constructor(renderer, quad, bufferIdx) {
46
- super();
47
- this.renderer = renderer;
48
- this.bufferIdx = bufferIdx;
49
- this.buffers = quad.sdfBuffers || renderer.quadBufferCollection;
50
- this.shader = quad.shader;
51
- this.width = quad.width;
52
- this.height = quad.height;
53
- this.clippingRect = quad.clippingRect;
54
- this.parentHasRenderTexture = quad.parentHasRenderTexture;
55
- this.framebufferDimensions = quad.framebufferDimensions;
56
- this.rtt = quad.rtt;
57
- this.alpha = quad.alpha;
58
- this.pixelRatio =
59
- this.parentHasRenderTexture === true ? 1 : renderer.stage.pixelRatio;
60
- /**
61
- * related to line 51
62
- */
63
- this.sdfShaderProps = quad.sdfShaderProps;
64
- this.maxTextures = this.shader.program.supportsIndexedTextures
65
- ? renderer.glw.getParameter(renderer.glw.MAX_VERTEX_TEXTURE_IMAGE_UNITS)
66
- : 1;
67
- }
68
- addTexture(texture) {
69
- const { textures, maxTextures } = this;
70
- let existingIdx = -1;
71
- const texturesLength = textures.length;
72
- for (let i = 0; i < texturesLength; i++) {
73
- const t = textures[i];
74
- if (t === texture) {
75
- existingIdx = i;
76
- break;
77
- }
78
- }
79
- if (existingIdx !== -1) {
80
- return existingIdx;
81
- }
82
- if (texturesLength >= maxTextures) {
83
- return 0xffffffff;
84
- }
85
- this.textures.push(texture);
86
- return texturesLength;
87
- }
88
- draw() {
89
- const { glw, options, stage } = this.renderer;
90
- stage.shManager.useShader(this.shader.program);
91
- this.shader.program.bindRenderOp(this);
92
- // Clipping
93
- if (this.clippingRect.valid === true) {
94
- const clipX = Math.round(this.clippingRect.x * this.pixelRatio);
95
- const clipWidth = Math.round(this.clippingRect.width * this.pixelRatio);
96
- const clipHeight = Math.round(this.clippingRect.height * this.pixelRatio);
97
- let clipY = Math.round(options.canvas.height -
98
- clipHeight -
99
- this.clippingRect.y * this.pixelRatio);
100
- // if parent has render texture, we need to adjust the scissor rect
101
- // to be relative to the parent's framebuffer
102
- if (this.parentHasRenderTexture) {
103
- clipY = this.framebufferDimensions
104
- ? this.framebufferDimensions.h - this.height
105
- : 0;
106
- }
107
- glw.setScissorTest(true);
108
- glw.scissor(clipX, clipY, clipWidth, clipHeight);
109
- }
110
- else {
111
- glw.setScissorTest(false);
112
- }
113
- // Check if this is SDF rendering (has sdfBuffers)
114
- if (this.sdfShaderProps !== undefined) {
115
- // SDF rendering uses drawArrays with explicit triangle vertices (6 vertices per quad)
116
- glw.drawArrays(glw.TRIANGLES, 0, 6 * this.numQuads);
117
- }
118
- else {
119
- // Regular rendering uses drawElements with index buffer (4 vertices per quad)
120
- const quadIdx = (this.bufferIdx / 32) * 6 * 2;
121
- glw.drawElements(glw.TRIANGLES, 6 * this.numQuads, glw.UNSIGNED_SHORT, quadIdx);
122
- }
123
- }
124
- }
125
- //# sourceMappingURL=WebGlRenderOp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebGlRenderOp.js","sourceRoot":"","sources":["../../../../../src/core/renderers/webgl/WebGlRenderOp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAwBlD;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAsBlC;IAEA;IAvBX,QAAQ,GAAG,CAAC,CAAC;IACb,QAAQ,GAAsB,EAAE,CAAC;IAEjC;;OAEG;IACM,cAAc,CAAsC;IACpD,OAAO,CAA2B;IAClC,WAAW,CAAS;IACpB,OAAO,CAAmB;IAC1B,MAAM,CAAkB;IACxB,KAAK,CAAS;IACd,MAAM,CAAS;IACf,YAAY,CAAgB;IAC5B,GAAG,CAAU;IACb,sBAAsB,CAAU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import { WebGlRenderOp } from './WebGlRenderOp.js';
3
- import type { CoreContextTexture } from '../CoreContextTexture.js';
4
- import { type CoreWebGlParameters, type CoreWebGlExtensions, type WebGlColor } from './internal/RendererUtils.js';
5
- import { Texture, type TextureCoords } from '../../textures/Texture.js';
6
- import { BufferCollection } from './internal/BufferCollection.js';
7
- import { WebGlShaderProgram } from './WebGlShaderProgram.js';
8
- import { WebGlContextWrapper } from '../../lib/WebGlContextWrapper.js';
9
- import { type CoreNode } from '../../CoreNode.js';
10
- import type { WebGlShaderType } from './WebGlShaderNode.js';
11
- import { WebGlShaderNode } from './WebGlShaderNode.js';
12
- export type WebGlRendererOptions = CoreRendererOptions;
13
- interface CoreWebGlSystem {
14
- parameters: CoreWebGlParameters;
15
- extensions: CoreWebGlExtensions;
16
- }
17
- export declare class WebGlRenderer extends CoreRenderer {
18
- glw: WebGlContextWrapper;
19
- system: CoreWebGlSystem;
20
- quadBuffer: ArrayBuffer;
21
- fQuadBuffer: Float32Array;
22
- uiQuadBuffer: Uint32Array;
23
- renderOps: WebGlRenderOp[];
24
- curBufferIdx: number;
25
- curRenderOp: WebGlRenderOp | null;
26
- rttNodes: CoreNode[];
27
- activeRttNode: CoreNode | null;
28
- defaultTextureCoords: TextureCoords;
29
- defaultShaderNode: WebGlShaderNode | null;
30
- quadBufferCollection: BufferCollection;
31
- clearColor: WebGlColor;
32
- /**
33
- * White pixel texture used by default when no texture is specified.
34
- */
35
- quadBufferUsage: number;
36
- numQuadsRendered: number;
37
- /**
38
- * Whether the renderer is currently rendering to a texture.
39
- */
40
- renderToTextureActive: boolean;
41
- constructor(options: WebGlRendererOptions);
42
- reset(): void;
43
- createShaderProgram(shaderType: WebGlShaderType, props: Record<string, unknown>): WebGlShaderProgram;
44
- createShaderNode(shaderKey: string, shaderType: WebGlShaderType, props?: Record<string, unknown>, program?: WebGlShaderProgram): WebGlShaderNode<Record<string, unknown>>;
45
- supportsShaderType(shaderType: Readonly<WebGlShaderType>): boolean;
46
- createCtxTexture(textureSource: Texture): CoreContextTexture;
47
- /**
48
- * This function adds a quad (a rectangle composed of two triangles) to the WebGL rendering pipeline.
49
- *
50
- * It takes a set of options that define the quad's properties, such as its dimensions, colors, texture, shader, and transformation matrix.
51
- * The function first updates the shader properties with the current dimensions if necessary, then sets the default texture if none is provided.
52
- * It then checks if a new render operation is needed, based on the current shader and clipping rectangle.
53
- * If a new render operation is needed, it creates one and updates the current render operation.
54
- * The function then adjusts the texture coordinates based on the texture options and adds the texture to the texture manager.
55
- *
56
- * Finally, it calculates the vertices for the quad, taking into account any transformations, and adds them to the quad buffer.
57
- * The function updates the length and number of quads in the current render operation, and updates the current buffer index.
58
- */
59
- addQuad(params: QuadOptions): void;
60
- /**
61
- * Replace the existing RenderOp with a new one that uses the specified Shader
62
- * and starts at the specified buffer index.
63
- *
64
- * @param shader
65
- * @param bufferIdx
66
- */
67
- private newRenderOp;
68
- /**
69
- * Add a texture to the current RenderOp. If the texture cannot be added to the
70
- * current RenderOp, a new RenderOp will be created and the texture will be added
71
- * to that one.
72
- *
73
- * If the texture cannot be added to the new RenderOp, an error will be thrown.
74
- *
75
- * @param texture
76
- * @param bufferIdx
77
- * @param recursive
78
- * @returns Assigned Texture Index of the texture in the render op
79
- */
80
- private addTexture;
81
- /**
82
- * Test if the current Render operation can be reused for the specified parameters.
83
- * @param params
84
- * @returns
85
- */
86
- reuseRenderOp(params: QuadOptions): boolean;
87
- /**
88
- * add RenderOp to the render pipeline
89
- */
90
- addRenderOp(renderable: WebGlRenderOp): void;
91
- /**
92
- * Render the current set of RenderOps to render to the specified surface.
93
- *
94
- * TODO: 'screen' is the only supported surface at the moment.
95
- *
96
- * @param surface
97
- */
98
- render(surface?: 'screen' | CoreContextTexture): void;
99
- getQuadCount(): number;
100
- renderToTexture(node: CoreNode): void;
101
- /**
102
- * Inserts an RTT node into `this.rttNodes` while maintaining the correct rendering order based on hierarchy.
103
- *
104
- * Rendering order for RTT nodes is critical when nested RTT nodes exist in a parent-child relationship.
105
- * Specifically:
106
- * - Child RTT nodes must be rendered before their RTT-enabled parents to ensure proper texture composition.
107
- * - If an RTT node is added and it has existing RTT children, it should be rendered after those children.
108
- *
109
- * This function addresses both cases by:
110
- * 1. **Checking Upwards**: It traverses the node's hierarchy upwards to identify any RTT parent
111
- * already in `rttNodes`. If an RTT parent is found, the new node is placed before this parent.
112
- * 2. **Checking Downwards**: It traverses the node’s children recursively to find any RTT-enabled
113
- * children that are already in `rttNodes`. If such children are found, the new node is inserted
114
- * after the last (highest index) RTT child node.
115
- *
116
- * The final calculated insertion index ensures the new node is positioned in `rttNodes` to respect
117
- * both parent-before-child and child-before-parent rendering rules, preserving the correct order
118
- * for the WebGL renderer.
119
- *
120
- * @param node - The RTT-enabled CoreNode to be added to `rttNodes` in the appropriate hierarchical position.
121
- */
122
- private insertRTTNodeInOrder;
123
- private findMaxChildRTTIndex;
124
- renderRTTNodes(): void;
125
- updateViewport(): void;
126
- removeRTTNode(node: CoreNode): void;
127
- getBufferInfo(): BufferInfo | null;
128
- getDefaultShaderNode(): WebGlShaderNode;
129
- getTextureCoords(node: CoreNode): TextureCoords | undefined;
130
- /**
131
- * Sets the glClearColor to the specified color. *
132
- * @param color - The color to set as the clear color, represented as a 32-bit integer.
133
- */
134
- updateClearColor(color: number): void;
135
- }
136
- export {};