@solidtv/renderer 1.1.1 → 1.1.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.
- package/README.md +1 -4
- package/dist/src/core/CoreNode.d.ts +27 -0
- package/dist/src/core/CoreNode.js +164 -43
- package/dist/src/core/CoreNode.js.map +1 -1
- package/dist/src/core/CoreTextureManager.d.ts +0 -4
- package/dist/src/core/CoreTextureManager.js +70 -17
- package/dist/src/core/CoreTextureManager.js.map +1 -1
- package/dist/src/core/Stage.js +5 -4
- package/dist/src/core/Stage.js.map +1 -1
- package/dist/src/core/lib/Matrix3d.d.ts +9 -0
- package/dist/src/core/lib/Matrix3d.js +29 -3
- package/dist/src/core/lib/Matrix3d.js.map +1 -1
- package/dist/src/core/lib/WebGlContextWrapper.js +0 -4
- package/dist/src/core/lib/WebGlContextWrapper.js.map +1 -1
- package/dist/src/core/lib/collectionUtils.js +1 -1
- package/dist/src/core/lib/collectionUtils.js.map +1 -1
- package/dist/src/core/renderers/canvas/CanvasRenderer.d.ts +3 -3
- package/dist/src/core/renderers/canvas/CanvasRenderer.js +3 -3
- package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/CanvasFontHandler.d.ts +1 -1
- package/dist/src/core/text-rendering/CanvasFontHandler.js +3 -3
- package/dist/src/core/text-rendering/CanvasFontHandler.js.map +1 -1
- package/dist/src/core/text-rendering/CanvasTextRenderer.d.ts +2 -3
- package/dist/src/core/text-rendering/CanvasTextRenderer.js +2 -1
- package/dist/src/core/text-rendering/CanvasTextRenderer.js.map +1 -1
- package/dist/src/core/text-rendering/SdfFontHandler.js +3 -3
- package/dist/src/core/text-rendering/SdfFontHandler.js.map +1 -1
- package/dist/src/core/text-rendering/Utils.js.map +1 -1
- package/dist/src/core/textures/ImageTexture.js +1 -1
- package/dist/src/core/textures/ImageTexture.js.map +1 -1
- package/dist/src/core/textures/SubTexture.js.map +1 -1
- package/dist/src/core/textures/Texture.d.ts +6 -0
- package/dist/src/core/textures/Texture.js +6 -0
- package/dist/src/core/textures/Texture.js.map +1 -1
- package/dist/tsconfig.dist.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/core/CoreNode.test.ts +438 -0
- package/src/core/CoreNode.ts +176 -61
- package/src/core/CoreTextureManager.ts +77 -20
- package/src/core/Stage.ts +10 -7
- package/src/core/lib/Matrix3d.test.ts +72 -0
- package/src/core/lib/Matrix3d.ts +30 -3
- package/src/core/lib/WebGlContextWrapper.ts +0 -2
- package/src/core/lib/collectionUtils.ts +1 -1
- package/src/core/renderers/canvas/CanvasRenderer.ts +3 -3
- package/src/core/text-rendering/CanvasFontHandler.ts +4 -4
- package/src/core/text-rendering/CanvasTextRenderer.ts +7 -2
- package/src/core/text-rendering/SdfFontHandler.ts +4 -4
- package/src/core/text-rendering/Utils.ts +0 -2
- package/src/core/textures/ImageTexture.ts +1 -4
- package/src/core/textures/SubTexture.ts +0 -2
- package/src/core/textures/Texture.ts +7 -0
|
@@ -83,7 +83,7 @@ export const findChildIndexById = (
|
|
|
83
83
|
for (let i = 0; i < children.length; i++) {
|
|
84
84
|
const child = children[i]!;
|
|
85
85
|
|
|
86
|
-
// @ts-
|
|
86
|
+
// @ts-expect-error - accessing protected property
|
|
87
87
|
if (child._id === node._id) {
|
|
88
88
|
return i;
|
|
89
89
|
}
|
|
@@ -229,7 +229,7 @@ export class CanvasRenderer extends CoreRenderer {
|
|
|
229
229
|
return new CanvasShaderNode(shaderKey, shaderType, this.stage, props);
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
createShaderProgram(
|
|
232
|
+
createShaderProgram(_shaderConfig) {
|
|
233
233
|
return null;
|
|
234
234
|
}
|
|
235
235
|
|
|
@@ -245,11 +245,11 @@ export class CanvasRenderer extends CoreRenderer {
|
|
|
245
245
|
// noop
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
removeRTTNode(
|
|
248
|
+
removeRTTNode(_node: CoreNode): void {
|
|
249
249
|
// noop
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
renderToTexture(
|
|
252
|
+
renderToTexture(_node: CoreNode): void {
|
|
253
253
|
// noop
|
|
254
254
|
}
|
|
255
255
|
getBufferInfo(): null {
|
|
@@ -65,7 +65,7 @@ const processFontData = (
|
|
|
65
65
|
/**
|
|
66
66
|
* Load a font by providing fontFamily, fontUrl, and optional metrics
|
|
67
67
|
*/
|
|
68
|
-
export const loadFont =
|
|
68
|
+
export const loadFont = (
|
|
69
69
|
stage: Stage,
|
|
70
70
|
options: FontLoadOptions,
|
|
71
71
|
): Promise<void> => {
|
|
@@ -73,7 +73,7 @@ export const loadFont = async (
|
|
|
73
73
|
|
|
74
74
|
// If already loaded, return immediately
|
|
75
75
|
if (fontCache.has(fontFamily) === true) {
|
|
76
|
-
return;
|
|
76
|
+
return Promise.resolve();
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const existingPromise = fontLoadPromises.get(fontFamily);
|
|
@@ -117,7 +117,7 @@ export const getFontFamilies = (): FontFamilyMap => {
|
|
|
117
117
|
*/
|
|
118
118
|
export const init = (
|
|
119
119
|
c: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
|
|
120
|
-
mc
|
|
120
|
+
mc?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D,
|
|
121
121
|
): void => {
|
|
122
122
|
if (initialized === true) {
|
|
123
123
|
return;
|
|
@@ -130,7 +130,7 @@ export const init = (
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
context = c;
|
|
133
|
-
measureContext = mc;
|
|
133
|
+
measureContext = mc || c;
|
|
134
134
|
|
|
135
135
|
// Register the default 'sans-serif' font face
|
|
136
136
|
const defaultMetrics: FontMetrics = {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { assertTruthy } from '../../utils.js';
|
|
2
2
|
import type { Stage } from '../Stage.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
FontHandler,
|
|
5
|
+
TextLineStruct,
|
|
6
|
+
TextRenderInfo,
|
|
7
|
+
} from './TextRenderer.js';
|
|
4
8
|
import * as CanvasFontHandler from './CanvasFontHandler.js';
|
|
5
9
|
import type { CoreTextNodeProps } from '../CoreTextNode.js';
|
|
6
10
|
import { hasZeroWidthSpace } from './Utils.js';
|
|
@@ -9,6 +13,7 @@ import { mapTextLayout } from './TextLayoutEngine.js';
|
|
|
9
13
|
const MAX_TEXTURE_DIMENSION = 4096;
|
|
10
14
|
|
|
11
15
|
const type = 'canvas' as const;
|
|
16
|
+
const font: FontHandler = CanvasFontHandler;
|
|
12
17
|
|
|
13
18
|
let canvas: HTMLCanvasElement | OffscreenCanvas | null = null;
|
|
14
19
|
let context:
|
|
@@ -238,7 +243,7 @@ const renderQuads = (): void => {
|
|
|
238
243
|
*/
|
|
239
244
|
const CanvasTextRenderer = {
|
|
240
245
|
type,
|
|
241
|
-
font
|
|
246
|
+
font,
|
|
242
247
|
renderText,
|
|
243
248
|
addQuads,
|
|
244
249
|
renderQuads,
|
|
@@ -259,14 +259,14 @@ export const canRenderFont = (trProps: TrProps): boolean => {
|
|
|
259
259
|
* @param {string} options.atlasUrl - PNG atlas texture URL
|
|
260
260
|
* @param {FontMetrics} options.metrics - Optional font metrics
|
|
261
261
|
*/
|
|
262
|
-
export const loadFont =
|
|
262
|
+
export const loadFont = (
|
|
263
263
|
stage: Stage,
|
|
264
264
|
options: FontLoadOptions,
|
|
265
265
|
): Promise<void> => {
|
|
266
266
|
const { fontFamily, atlasUrl, atlasDataUrl, metrics } = options;
|
|
267
267
|
// Early return if already loaded
|
|
268
268
|
if (fontCache.get(fontFamily) !== undefined) {
|
|
269
|
-
return;
|
|
269
|
+
return Promise.resolve();
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
// Early return if already loading
|
|
@@ -276,8 +276,8 @@ export const loadFont = async (
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
if (atlasDataUrl === undefined) {
|
|
279
|
-
|
|
280
|
-
`Atlas data URL must be provided for SDF font: ${fontFamily}
|
|
279
|
+
return Promise.reject(
|
|
280
|
+
new Error(`Atlas data URL must be provided for SDF font: ${fontFamily}`),
|
|
281
281
|
);
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -12,10 +12,7 @@ import {
|
|
|
12
12
|
import { isSvgImage, loadSvg } from '../lib/textureSvg.js';
|
|
13
13
|
import { fetchJson } from '../lib/utils.js';
|
|
14
14
|
import type { Platform } from '../platforms/Platform.js';
|
|
15
|
-
import {
|
|
16
|
-
ENABLE_COMPRESSED_TEXTURES,
|
|
17
|
-
isProductionEnvironment,
|
|
18
|
-
} from '../../utils.js';
|
|
15
|
+
import { ENABLE_COMPRESSED_TEXTURES } from '../../utils.js';
|
|
19
16
|
|
|
20
17
|
/**
|
|
21
18
|
* Properties of the {@link ImageTexture}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Dimensions } from '../../common/CommonTypes.js';
|
|
2
1
|
import { assertTruthy } from '../../utils.js';
|
|
3
2
|
import type { CoreTextureManager } from '../CoreTextureManager.js';
|
|
4
3
|
import { ImageTexture } from './ImageTexture.js';
|
|
@@ -8,7 +7,6 @@ import {
|
|
|
8
7
|
type TextureData,
|
|
9
8
|
type TextureFailedEventHandler,
|
|
10
9
|
type TextureLoadedEventHandler,
|
|
11
|
-
type TextureState,
|
|
12
10
|
} from './Texture.js';
|
|
13
11
|
|
|
14
12
|
let subTextureId = 0;
|
|
@@ -153,6 +153,13 @@ export abstract class Texture extends EventEmitter {
|
|
|
153
153
|
|
|
154
154
|
public textureData: TextureData | null = null;
|
|
155
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Cache key under which this texture is registered in the
|
|
158
|
+
* {@link CoreTextureManager} keyCache, or `null` if the texture is
|
|
159
|
+
* not cached. Owned by the texture manager.
|
|
160
|
+
*/
|
|
161
|
+
public cacheKey: string | null = null;
|
|
162
|
+
|
|
156
163
|
public memUsed = 0;
|
|
157
164
|
|
|
158
165
|
/**
|