@glissade/backend-canvas2d 0.16.0 → 0.17.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/dist/index.js +15 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10,6 +10,20 @@ let shaderRunner = null;
|
|
|
10
10
|
function setShaderRunner(runner) {
|
|
11
11
|
shaderRunner = runner;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Allocate an offscreen layer (hit only by group opacity<1 / blend / filter /
|
|
15
|
+
* mesh). Prefer `OffscreenCanvas`, but fall back to a detached `<canvas>` where
|
|
16
|
+
* it's unavailable — so the single-file `@glissade/browser` bundle survives
|
|
17
|
+
* environments without `OffscreenCanvas`. Inert where `OffscreenCanvas` exists
|
|
18
|
+
* (every test + the Skia twin, which never reaches this), so it moves no golden.
|
|
19
|
+
*/
|
|
20
|
+
function createLayerCanvas(w, h) {
|
|
21
|
+
if (typeof OffscreenCanvas !== "undefined") return new OffscreenCanvas(w, h);
|
|
22
|
+
const canvas = document.createElement("canvas");
|
|
23
|
+
canvas.width = w;
|
|
24
|
+
canvas.height = h;
|
|
25
|
+
return canvas;
|
|
26
|
+
}
|
|
13
27
|
/** Largest canvas dimension browsers reliably allocate. */
|
|
14
28
|
const MAX_TEXTURE = 16384;
|
|
15
29
|
var Canvas2DBackend = class {
|
|
@@ -27,7 +41,7 @@ var Canvas2DBackend = class {
|
|
|
27
41
|
this.target = target;
|
|
28
42
|
this.raster = new Raster2D({
|
|
29
43
|
context: (c) => this.context(c),
|
|
30
|
-
createCanvas: (w, h) =>
|
|
44
|
+
createCanvas: (w, h) => createLayerCanvas(w, h),
|
|
31
45
|
newPath: () => new Path2D(),
|
|
32
46
|
applyShader: (layer, shader, w, h) => shaderRunner?.apply(layer, shader, w, h) ?? null
|
|
33
47
|
}, opts.shaderCaps ?? "warn");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glissade/backend-canvas2d",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "glissade Canvas 2D render backend: DisplayList -> CanvasRenderingContext2D/OffscreenCanvas.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"engines": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@glissade/core": "0.
|
|
22
|
-
"@glissade/scene": "0.
|
|
21
|
+
"@glissade/core": "0.17.0",
|
|
22
|
+
"@glissade/scene": "0.17.0"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|