@weasel-js/renderer 1.10.0 → 1.11.0
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 -1
- package/dist/{chunk-LFD47OV2.js → chunk-CUJEWF5G.js} +102 -52
- package/dist/chunk-CUJEWF5G.js.map +1 -0
- package/dist/{imageCache-DYcWftY8.d.ts → imageCache-CDm3qgsg.d.ts} +24 -11
- package/dist/index.d.ts +122 -21
- package/dist/index.js +1036 -408
- package/dist/index.js.map +1 -1
- package/dist/patterns-builtin.d.ts +2 -0
- package/dist/patterns-builtin.js.map +1 -1
- package/dist/test-seams.d.ts +6 -8
- package/dist/test-seams.js +1 -1
- package/package.json +10 -7
- package/dist/chunk-LFD47OV2.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A WebGL2 renderer that turns a list of draw commands into pixels.
|
|
|
4
4
|
|
|
5
5
|
Part of [weasel](https://github.com/orochi235/weasel), a domain-agnostic 2D
|
|
6
6
|
scene-graph canvas kit for React. See the
|
|
7
|
-
[API reference](https://orochi235.github.io/weasel/
|
|
7
|
+
[API reference](https://orochi235.github.io/weasel/#pkg/renderer).
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
npm install @weasel-js/renderer
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ownTextureIds, rasterizeTile, drawTileShapes, tileGeometry, tileSize, registerTextureAs, textureRegistry, unregisterTexture } from './chunk-Q4SIHV7Q.js';
|
|
2
|
-
import { defaultOpenFill, pathFromD, boundsOfPath } from '@weasel-js/geom';
|
|
2
|
+
import { DEFAULT_FLATTEN_TOLERANCE, defaultOpenFill, pathFromD, boundsOfPath } from '@weasel-js/geom';
|
|
3
3
|
import { tessellate } from '@weasel-js/geom/tessellate';
|
|
4
|
-
import { createReflectable, createEmitter } from '@weasel-js/registry';
|
|
4
|
+
import { createReflectable, createEmitter, isDev } from '@weasel-js/registry';
|
|
5
5
|
import { resolveStrokeWidth, strokeInsets, tessellateStroke, markerGeneration, screenSpaceKey, markerHeads, metricKey, getMarker, markerKeyOf, markerReadsKey } from '@weasel-js/stroke';
|
|
6
6
|
import { isTileKind, isPatternPaint, tileSpecOf, isTilePaint, patternPlacementOf } from '@weasel-js/paint';
|
|
7
7
|
import { GLYPH_COVERAGE_GLSL } from '@weasel-js/font';
|
|
@@ -180,13 +180,17 @@ function wrapModes(gl, rep) {
|
|
|
180
180
|
return [gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE];
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
+
var FILL_TOLERANCES_PER_PATH = 4;
|
|
183
184
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
184
|
-
function getMesh(path) {
|
|
185
|
+
function getMesh(path, flattenTolerance = DEFAULT_FLATTEN_TOLERANCE) {
|
|
185
186
|
const openFill = defaultOpenFill();
|
|
186
|
-
|
|
187
|
+
let byTolerance = cache.get(path);
|
|
188
|
+
if (byTolerance === void 0) cache.set(path, byTolerance = /* @__PURE__ */ new Map());
|
|
189
|
+
const cached = byTolerance.get(flattenTolerance);
|
|
187
190
|
if (cached !== void 0 && cached.openFill === openFill) return cached.mesh;
|
|
188
|
-
const mesh = tessellate(path);
|
|
189
|
-
|
|
191
|
+
const mesh = tessellate(path, { flattenTolerance });
|
|
192
|
+
if (cached === void 0 && byTolerance.size >= FILL_TOLERANCES_PER_PATH) byTolerance.clear();
|
|
193
|
+
byTolerance.set(flattenTolerance, { mesh, openFill });
|
|
190
194
|
return mesh;
|
|
191
195
|
}
|
|
192
196
|
function _resetCacheForTests() {
|
|
@@ -200,7 +204,6 @@ function _resetProgramRegistryForTests() {
|
|
|
200
204
|
function getProgramSource(id) {
|
|
201
205
|
return registry.get(id) ?? null;
|
|
202
206
|
}
|
|
203
|
-
var isDev = () => typeof process !== "undefined" ? process.env.NODE_ENV !== "production" : true;
|
|
204
207
|
function registerProgram(id, vert, frag) {
|
|
205
208
|
if (registry.has(id) && !isDev()) {
|
|
206
209
|
throw new Error(`weasel registerProgram: duplicate program id "${id}". In production, re-registration is not allowed. Pass a unique id or call in dev mode.`);
|
|
@@ -298,6 +301,7 @@ function configKey(stroke, flattenTolerance, spaces) {
|
|
|
298
301
|
stroke.align ?? "center",
|
|
299
302
|
(stroke.dash ?? []).join(","),
|
|
300
303
|
stroke.varyingWidthJoinThreshold ?? "",
|
|
304
|
+
stroke.nib ? `${stroke.nib.angle}:${stroke.nib.ratio}` : "",
|
|
301
305
|
flattenTolerance ?? "",
|
|
302
306
|
insets.start,
|
|
303
307
|
insets.end,
|
|
@@ -617,8 +621,12 @@ vec3 straightRgb(vec4 premultiplied) {
|
|
|
617
621
|
);
|
|
618
622
|
|
|
619
623
|
// src/shaders/batchFill.ts
|
|
620
|
-
var BATCH_TEXTURE_SLOTS =
|
|
624
|
+
var BATCH_TEXTURE_SLOTS = 16;
|
|
621
625
|
var WHITE_SLOT = 0;
|
|
626
|
+
var RAMP_SLOT = BATCH_TEXTURE_SLOTS - 1;
|
|
627
|
+
var BATCH_MATRIX_SLOTS = 8;
|
|
628
|
+
var PAINT_MODES = 8;
|
|
629
|
+
var MATRIX_STRIDE = BATCH_TEXTURE_SLOTS * PAINT_MODES;
|
|
622
630
|
var PAINT_MODE_PLAIN = 0;
|
|
623
631
|
var PAINT_MODE_RADIAL = 3;
|
|
624
632
|
var PAINT_MODE_CONIC = 4;
|
|
@@ -627,6 +635,9 @@ var INV_TAU = (1 / (2 * Math.PI)).toFixed(10);
|
|
|
627
635
|
function packSlot(slot, mode) {
|
|
628
636
|
return slot + BATCH_TEXTURE_SLOTS * mode;
|
|
629
637
|
}
|
|
638
|
+
function withMatrix(slot, matrix) {
|
|
639
|
+
return slot + MATRIX_STRIDE * matrix;
|
|
640
|
+
}
|
|
630
641
|
var BATCH_ATTRIBUTE_LOCATIONS = {
|
|
631
642
|
a_position: 0,
|
|
632
643
|
a_vertexColor: 1,
|
|
@@ -635,12 +646,16 @@ var BATCH_ATTRIBUTE_LOCATIONS = {
|
|
|
635
646
|
a_texSlot: 4
|
|
636
647
|
};
|
|
637
648
|
var L = BATCH_ATTRIBUTE_LOCATIONS;
|
|
638
|
-
function
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
649
|
+
function sampleTree(lo, hi, indent = " ") {
|
|
650
|
+
if (lo === hi) return `${indent}return texture(u_samplers[${lo}], uv);`;
|
|
651
|
+
const mid = lo + hi + 1 >> 1;
|
|
652
|
+
return [
|
|
653
|
+
`${indent}if (slot < ${mid}) {`,
|
|
654
|
+
sampleTree(lo, mid - 1, `${indent} `),
|
|
655
|
+
`${indent}} else {`,
|
|
656
|
+
sampleTree(mid, hi, `${indent} `),
|
|
657
|
+
`${indent}}`
|
|
658
|
+
].join("\n");
|
|
644
659
|
}
|
|
645
660
|
var BATCH_VERT_SRC = (
|
|
646
661
|
/* glsl */
|
|
@@ -657,6 +672,7 @@ out vec2 v_uv;
|
|
|
657
672
|
out float v_post;
|
|
658
673
|
flat out int v_texSlot;
|
|
659
674
|
flat out float v_paintMode;
|
|
675
|
+
flat out int v_matrix;
|
|
660
676
|
void main() {
|
|
661
677
|
vec3 screen = u_model * vec3(a_position, 1.0);
|
|
662
678
|
vec3 clip = u_proj * vec3(screen.xy, 1.0);
|
|
@@ -664,34 +680,39 @@ void main() {
|
|
|
664
680
|
v_vertexColor = a_vertexColor;
|
|
665
681
|
v_uv = a_uv;
|
|
666
682
|
v_post = a_post;
|
|
667
|
-
// slot +
|
|
683
|
+
// slot + 16 * mode + 128 * matrix, unpacked \u2014 see the file header for why
|
|
684
|
+
// they share a float.
|
|
668
685
|
int packed = int(a_texSlot + 0.5);
|
|
669
686
|
v_texSlot = packed % ${BATCH_TEXTURE_SLOTS};
|
|
670
|
-
v_paintMode = float(packed / ${BATCH_TEXTURE_SLOTS});
|
|
687
|
+
v_paintMode = float((packed / ${BATCH_TEXTURE_SLOTS}) % ${PAINT_MODES});
|
|
688
|
+
v_matrix = packed / ${MATRIX_STRIDE};
|
|
671
689
|
}
|
|
672
690
|
`
|
|
673
691
|
);
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
692
|
+
function batchFragSrc(matrices) {
|
|
693
|
+
const m = matrices === 1 ? "0" : "v_matrix";
|
|
694
|
+
return (
|
|
695
|
+
/* glsl */
|
|
696
|
+
`#version 300 es
|
|
677
697
|
precision highp float;
|
|
678
698
|
in vec4 v_vertexColor;
|
|
679
699
|
in vec2 v_uv;
|
|
680
700
|
in float v_post;
|
|
681
701
|
flat in int v_texSlot;
|
|
682
702
|
flat in float v_paintMode;
|
|
703
|
+
flat in int v_matrix;
|
|
683
704
|
uniform sampler2D u_samplers[${BATCH_TEXTURE_SLOTS}];
|
|
684
705
|
uniform vec4 u_color;
|
|
685
|
-
uniform float u_alpha;
|
|
686
|
-
uniform float u_synthBold;
|
|
706
|
+
uniform float u_alpha[${matrices}];
|
|
687
707
|
uniform vec2 u_fieldScale[${BATCH_TEXTURE_SLOTS}];
|
|
688
|
-
uniform mat4 u_colorMatrix;
|
|
689
|
-
uniform vec4 u_colorBias;
|
|
708
|
+
uniform mat4 u_colorMatrix[${matrices}];
|
|
709
|
+
uniform vec4 u_colorBias[${matrices}];
|
|
690
710
|
out vec4 outColor;
|
|
691
711
|
|
|
692
712
|
vec4 sampleSlot(int slot, vec2 uv) {
|
|
693
|
-
${
|
|
694
|
-
|
|
713
|
+
${sampleTree(0, BATCH_TEXTURE_SLOTS - 1)}
|
|
714
|
+
// Never reached: every slot returns above.
|
|
715
|
+
return vec4(0.0);
|
|
695
716
|
}
|
|
696
717
|
${GLYPH_COVERAGE_GLSL}
|
|
697
718
|
${STRAIGHT_RGB_GLSL}
|
|
@@ -714,7 +735,7 @@ void main() {
|
|
|
714
735
|
float t = v_paintMode > ${PAINT_MODE_CONIC - 0.5}
|
|
715
736
|
? fract(atan(v_uv.y, v_uv.x) * ${INV_TAU})
|
|
716
737
|
: length(v_uv);
|
|
717
|
-
texel =
|
|
738
|
+
texel = texture(u_samplers[${RAMP_SLOT}], vec2(t, v_post));
|
|
718
739
|
} else {
|
|
719
740
|
texel = sampleSlot(v_texSlot, v_uv);
|
|
720
741
|
}
|
|
@@ -722,24 +743,26 @@ void main() {
|
|
|
722
743
|
texel.rgb = mix(texel.rgb, straightRgb(texel), step(${PAINT_MODE_IMAGE - 0.5}, v_paintMode));
|
|
723
744
|
float isGlyph = step(0.5, v_paintMode) * step(v_paintMode, 2.5);
|
|
724
745
|
// Unconditional, and multiplied out afterwards rather than branched around:
|
|
725
|
-
// see the file header.
|
|
726
|
-
float coverage = glyphCoverage(texel, v_paintMode,
|
|
746
|
+
// see the file header. A glyph's a_post is its synthetic-bold shift.
|
|
747
|
+
float coverage = glyphCoverage(texel, v_paintMode, v_post * isGlyph, v_uv, u_fieldScale[v_texSlot]);
|
|
727
748
|
// A glyph's texel is a distance field, so it takes no part in the color; a
|
|
728
749
|
// plain vertex multiplies its texel in as it always did.
|
|
729
750
|
vec4 src = mix(texel, vec4(1.0), isGlyph) * u_color * v_vertexColor;
|
|
730
|
-
vec4 mapped = clamp(u_colorMatrix * src + u_colorBias, 0.0, 1.0);
|
|
731
|
-
float a = mapped.a * u_alpha * mix(v_post, 1.0, isGrad) * mix(1.0, coverage, isGlyph);
|
|
751
|
+
vec4 mapped = clamp(u_colorMatrix[${m}] * src + u_colorBias[${m}], 0.0, 1.0);
|
|
752
|
+
float a = mapped.a * u_alpha[${m}] * mix(v_post, 1.0, max(isGrad, isGlyph)) * mix(1.0, coverage, isGlyph);
|
|
732
753
|
outColor = vec4(mapped.rgb * a, a);
|
|
733
754
|
}
|
|
734
755
|
`
|
|
735
|
-
);
|
|
756
|
+
);
|
|
757
|
+
}
|
|
758
|
+
var BATCH_FRAG_SRC = batchFragSrc(1);
|
|
759
|
+
var BATCH_MATRICES_FRAG_SRC = batchFragSrc(BATCH_MATRIX_SLOTS);
|
|
736
760
|
var BATCH_FILL_UNIFORMS = [
|
|
737
761
|
"u_proj",
|
|
738
762
|
"u_model",
|
|
739
763
|
"u_samplers",
|
|
740
764
|
"u_color",
|
|
741
765
|
"u_alpha",
|
|
742
|
-
"u_synthBold",
|
|
743
766
|
"u_fieldScale",
|
|
744
767
|
"u_colorMatrix",
|
|
745
768
|
"u_colorBias"
|
|
@@ -819,7 +842,6 @@ var INITIAL_VERTICES = 256;
|
|
|
819
842
|
var INITIAL_INDICES = 384;
|
|
820
843
|
var WHITE_U = 0.5;
|
|
821
844
|
var WHITE_V = 0.5;
|
|
822
|
-
var PLAIN_WHITE = packSlot(WHITE_SLOT, PAINT_MODE_PLAIN);
|
|
823
845
|
var SOLID_RING_SIZE = 64;
|
|
824
846
|
var BATCH_TIERS = [
|
|
825
847
|
{ vertices: 16, indices: 24 },
|
|
@@ -902,9 +924,9 @@ var DrawBatch = class {
|
|
|
902
924
|
}
|
|
903
925
|
/**
|
|
904
926
|
* Append one rect's four corners through `m`, all carrying `rgba` (straight
|
|
905
|
-
* alpha).
|
|
927
|
+
* alpha) and `P` in `a_texSlot`: the white texel, and the run's matrix.
|
|
906
928
|
*/
|
|
907
|
-
pushRect(x, y, w, h, m, r, g, b, a) {
|
|
929
|
+
pushRect(x, y, w, h, m, r, g, b, a, P) {
|
|
908
930
|
this.reserve(4, 6);
|
|
909
931
|
let i = this.nVerts * FLOATS_PER_VERTEX;
|
|
910
932
|
const ma = m[0], mb = m[1], mc = m[3], md = m[4], mtx = m[6], mty = m[7];
|
|
@@ -914,7 +936,6 @@ var DrawBatch = class {
|
|
|
914
936
|
const bx = ma * x1 + mc * y + mtx, by = mb * x1 + md * y + mty;
|
|
915
937
|
const cx = ma * x1 + mc * y1 + mtx, cy = mb * x1 + md * y1 + mty;
|
|
916
938
|
const dx = ma * x + mc * y1 + mtx, dy = mb * x + md * y1 + mty;
|
|
917
|
-
const P = PLAIN_WHITE;
|
|
918
939
|
i = this.writeVertex(i, ax, ay, r, g, b, a, WHITE_U, WHITE_V, 1, P);
|
|
919
940
|
i = this.writeVertex(i, bx, by, r, g, b, a, WHITE_U, WHITE_V, 1, P);
|
|
920
941
|
i = this.writeVertex(i, cx, cy, r, g, b, a, WHITE_U, WHITE_V, 1, P);
|
|
@@ -926,7 +947,8 @@ var DrawBatch = class {
|
|
|
926
947
|
* Append one image quad: the destination rect `(x, y, w, h)` mapped through
|
|
927
948
|
* `m`, sampling `(u0, v0)`-`(u1, v1)`, every corner carrying `post` as the
|
|
928
949
|
* after-the-color-matrix alpha factor and `rgb` as the scale on its texel.
|
|
929
|
-
* `slot` is the texture unit the corners sample
|
|
950
|
+
* `slot` is the texture unit the corners sample, and may carry the index of
|
|
951
|
+
* the run's matrix they are mapped by as well (`withMatrix`).
|
|
930
952
|
*
|
|
931
953
|
* Corners wind top-left, top-right, bottom-right, bottom-left — the same
|
|
932
954
|
* winding `pushRect` uses, which is what lets a run of mixed rects and quads
|
|
@@ -956,13 +978,13 @@ var DrawBatch = class {
|
|
|
956
978
|
* `rgba`.
|
|
957
979
|
*
|
|
958
980
|
* `mode` says which channels of that atlas carry the distance field, and
|
|
959
|
-
* rides the vertices packed into the slot.
|
|
960
|
-
*
|
|
981
|
+
* rides the vertices packed into the slot. `synthBold` is the shift on the
|
|
982
|
+
* field's threshold, in `a_post`: a glyph has no use for an alpha factor there.
|
|
961
983
|
*
|
|
962
984
|
* A synthetic oblique is sheared here, before `m`; `tanItalic` is 0 for an
|
|
963
985
|
* upright face. Corners wind as `pushQuad`'s do.
|
|
964
986
|
*/
|
|
965
|
-
pushGlyph(x0, y0, x1, y1, baselineY, tanItalic, m, u0, v0, u1, v1, r, g, b, a, slot, mode) {
|
|
987
|
+
pushGlyph(x0, y0, x1, y1, baselineY, tanItalic, m, u0, v0, u1, v1, r, g, b, a, slot, mode, synthBold) {
|
|
966
988
|
this.reserve(4, 6);
|
|
967
989
|
let i = this.nVerts * FLOATS_PER_VERTEX;
|
|
968
990
|
const ma = m[0], mb = m[1], mc = m[3], md = m[4], mtx = m[6], mty = m[7];
|
|
@@ -975,10 +997,10 @@ var DrawBatch = class {
|
|
|
975
997
|
const cx = ma * bx1 + mc * y1 + mtx, cy = mb * bx1 + md * y1 + mty;
|
|
976
998
|
const dx = ma * bx0 + mc * y1 + mtx, dy = mb * bx0 + md * y1 + mty;
|
|
977
999
|
const P = packSlot(slot, mode);
|
|
978
|
-
i = this.writeVertex(i, ax, ay, r, g, b, a, u0, v0,
|
|
979
|
-
i = this.writeVertex(i, bx, by, r, g, b, a, u1, v0,
|
|
980
|
-
i = this.writeVertex(i, cx, cy, r, g, b, a, u1, v1,
|
|
981
|
-
this.writeVertex(i, dx, dy, r, g, b, a, u0, v1,
|
|
1000
|
+
i = this.writeVertex(i, ax, ay, r, g, b, a, u0, v0, synthBold, P);
|
|
1001
|
+
i = this.writeVertex(i, bx, by, r, g, b, a, u1, v0, synthBold, P);
|
|
1002
|
+
i = this.writeVertex(i, cx, cy, r, g, b, a, u1, v1, synthBold, P);
|
|
1003
|
+
this.writeVertex(i, dx, dy, r, g, b, a, u0, v1, synthBold, P);
|
|
982
1004
|
this.pushQuadIndices();
|
|
983
1005
|
return this.clip === null || this.clipQuad(this.nVerts - 4, this.nIdx - 6, this.clip);
|
|
984
1006
|
}
|
|
@@ -1058,11 +1080,11 @@ var DrawBatch = class {
|
|
|
1058
1080
|
return this.clip === null || this.clipMesh(base, this.nIdx - srcIdx.length, this.clip);
|
|
1059
1081
|
}
|
|
1060
1082
|
/**
|
|
1061
|
-
* Append a tessellated mesh through `m`, all vertices carrying `rgba
|
|
1062
|
-
* mesh's own indices are rebased onto the staged
|
|
1063
|
-
* index buffer is uploaded per flush
|
|
1083
|
+
* Append a tessellated mesh through `m`, all vertices carrying `rgba` and
|
|
1084
|
+
* `P`, as `pushRect`'s do. The mesh's own indices are rebased onto the staged
|
|
1085
|
+
* vertices, which is why the index buffer is uploaded per flush.
|
|
1064
1086
|
*/
|
|
1065
|
-
pushMesh(mesh, m, r, g, b, a) {
|
|
1087
|
+
pushMesh(mesh, m, r, g, b, a, P) {
|
|
1066
1088
|
const src = mesh.vertices;
|
|
1067
1089
|
const srcIdx = mesh.indices;
|
|
1068
1090
|
const n = src.length >> 1;
|
|
@@ -1083,7 +1105,7 @@ var DrawBatch = class {
|
|
|
1083
1105
|
v[i++] = WHITE_U;
|
|
1084
1106
|
v[i++] = WHITE_V;
|
|
1085
1107
|
v[i++] = 1;
|
|
1086
|
-
v[i++] =
|
|
1108
|
+
v[i++] = P;
|
|
1087
1109
|
}
|
|
1088
1110
|
const base = this.nVerts;
|
|
1089
1111
|
const out = this.idx;
|
|
@@ -1443,6 +1465,7 @@ function maybeReraster(src, entry, v, drawnAt) {
|
|
|
1443
1465
|
);
|
|
1444
1466
|
}
|
|
1445
1467
|
function getImageBitmap(src, drawnAt) {
|
|
1468
|
+
if (src.startsWith(BITMAP_SCHEME)) return held.get(src)?.deref();
|
|
1446
1469
|
const entry = cache6.get(src);
|
|
1447
1470
|
if (!entry) {
|
|
1448
1471
|
startLoad2(src);
|
|
@@ -1452,10 +1475,35 @@ function getImageBitmap(src, drawnAt) {
|
|
|
1452
1475
|
if (drawnAt && entry.vector) maybeReraster(src, entry, entry.vector, drawnAt);
|
|
1453
1476
|
return entry.bitmap;
|
|
1454
1477
|
}
|
|
1478
|
+
var BITMAP_SCHEME = "weasel-bitmap:";
|
|
1479
|
+
var held = /* @__PURE__ */ new Map();
|
|
1480
|
+
var srcOfBitmap = /* @__PURE__ */ new WeakMap();
|
|
1481
|
+
var minted = 0;
|
|
1482
|
+
var forget = new FinalizationRegistry((src) => {
|
|
1483
|
+
if (held.get(src)?.deref() === void 0) held.delete(src);
|
|
1484
|
+
});
|
|
1485
|
+
function bitmapSrc(bitmap) {
|
|
1486
|
+
let src = srcOfBitmap.get(bitmap);
|
|
1487
|
+
if (src === void 0) {
|
|
1488
|
+
src = `${BITMAP_SCHEME}${++minted}`;
|
|
1489
|
+
srcOfBitmap.set(bitmap, src);
|
|
1490
|
+
held.set(src, new WeakRef(bitmap));
|
|
1491
|
+
forget.register(bitmap, src, bitmap);
|
|
1492
|
+
}
|
|
1493
|
+
return src;
|
|
1494
|
+
}
|
|
1455
1495
|
function imageStatus(src) {
|
|
1496
|
+
if (src.startsWith(BITMAP_SCHEME)) return getImageBitmap(src) === void 0 ? "idle" : "ready";
|
|
1456
1497
|
return cache6.get(src)?.status ?? "idle";
|
|
1457
1498
|
}
|
|
1458
1499
|
function releaseImage(src) {
|
|
1500
|
+
const bitmap = held.get(src)?.deref();
|
|
1501
|
+
held.delete(src);
|
|
1502
|
+
if (bitmap !== void 0) {
|
|
1503
|
+
srcOfBitmap.delete(bitmap);
|
|
1504
|
+
forget.unregister(bitmap);
|
|
1505
|
+
releaseImageSource(bitmap);
|
|
1506
|
+
}
|
|
1459
1507
|
const entry = cache6.get(src);
|
|
1460
1508
|
cache6.delete(src);
|
|
1461
1509
|
decodedVectors.delete(src);
|
|
@@ -1474,6 +1522,8 @@ function __setImageLoaderForTests(fn) {
|
|
|
1474
1522
|
}
|
|
1475
1523
|
function _resetImageCacheForTests() {
|
|
1476
1524
|
cache6.clear();
|
|
1525
|
+
held = /* @__PURE__ */ new Map();
|
|
1526
|
+
srcOfBitmap = /* @__PURE__ */ new WeakMap();
|
|
1477
1527
|
ready = createEmitter();
|
|
1478
1528
|
decodedVectors.clear();
|
|
1479
1529
|
loader = defaultLoader;
|
|
@@ -1482,6 +1532,6 @@ function _resetImageCacheForTests() {
|
|
|
1482
1532
|
readsAtLastPass = 0;
|
|
1483
1533
|
}
|
|
1484
1534
|
|
|
1485
|
-
export { BATCH_ATTRIBUTE_LOCATIONS, BATCH_FILL_ATTRIBUTES, BATCH_FILL_UNIFORMS, BATCH_FRAG_SRC, BATCH_TEXTURE_SLOTS, BATCH_VERT_SRC, DrawBatch, FLOATS_PER_VERTEX, GLImageCache, PAINT_MODE_CONIC, PAINT_MODE_PLAIN, PAINT_MODE_RADIAL, STRAIGHT_RGB_GLSL, __setImageLoaderForTests, _resetCacheForTests, _resetImageCacheForTests, _resetMarkerCommandCacheForTests, _resetOutlineMeshCacheForTests, _resetOutlineStrokeMeshCacheForTests, _resetPaintDrawKindsForTests, _resetPatternSpecCacheForTests, _resetProgramRegistryForTests, _resetStrokeMeshCacheForTests, axisAlignedClipRect, cachedMarkerCommands, commandFill, commandPaint, commandStroke, fillInPoseFrame, fillToBoundsFrame, getImageBitmap, getMesh, getPaintDrawKind, getProgramSource, imageStatus, intersectClipRects, isPaintKindKnown, isVectorImageSrc, outlineMesh, outlineStrokeMesh, paintDrawKindRegistry, programSourceRegistry, quantizeEmWidth, quantizeStrokeScale, registerPaintDrawKind, registerPaintDrawKindLoader, registerProgram, releaseImage, releaseImageSource, resolveFillPattern, resolvePatternSpec, retryImage, setImageCacheBudget, strokeMesh, subscribeImageReady, uploadPremultiplied, warmPaintKinds };
|
|
1486
|
-
//# sourceMappingURL=chunk-
|
|
1487
|
-
//# sourceMappingURL=chunk-
|
|
1535
|
+
export { BATCH_ATTRIBUTE_LOCATIONS, BATCH_FILL_ATTRIBUTES, BATCH_FILL_UNIFORMS, BATCH_FRAG_SRC, BATCH_MATRICES_FRAG_SRC, BATCH_MATRIX_SLOTS, BATCH_TEXTURE_SLOTS, BATCH_VERT_SRC, DrawBatch, FLOATS_PER_VERTEX, GLImageCache, PAINT_MODE_CONIC, PAINT_MODE_PLAIN, PAINT_MODE_RADIAL, RAMP_SLOT, STRAIGHT_RGB_GLSL, WHITE_SLOT, __setImageLoaderForTests, _resetCacheForTests, _resetImageCacheForTests, _resetMarkerCommandCacheForTests, _resetOutlineMeshCacheForTests, _resetOutlineStrokeMeshCacheForTests, _resetPaintDrawKindsForTests, _resetPatternSpecCacheForTests, _resetProgramRegistryForTests, _resetStrokeMeshCacheForTests, axisAlignedClipRect, bitmapSrc, cachedMarkerCommands, commandFill, commandPaint, commandStroke, fillInPoseFrame, fillToBoundsFrame, getImageBitmap, getMesh, getPaintDrawKind, getProgramSource, imageStatus, intersectClipRects, isPaintKindKnown, isVectorImageSrc, outlineMesh, outlineStrokeMesh, packSlot, paintDrawKindRegistry, programSourceRegistry, quantizeEmWidth, quantizeStrokeScale, registerPaintDrawKind, registerPaintDrawKindLoader, registerProgram, releaseImage, releaseImageSource, resolveFillPattern, resolvePatternSpec, retryImage, setImageCacheBudget, strokeMesh, subscribeImageReady, uploadPremultiplied, warmPaintKinds, withMatrix };
|
|
1536
|
+
//# sourceMappingURL=chunk-CUJEWF5G.js.map
|
|
1537
|
+
//# sourceMappingURL=chunk-CUJEWF5G.js.map
|