@genome-spy/app 0.83.1 → 0.84.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.
@@ -0,0 +1,147 @@
1
+ import { a as e, n as t, o as n, u as r } from "./clipOptions-Dqco1p8b.js";
2
+ import { y as i } from "./twgl-full.module-BNEMlXRV.js";
3
+ import { t as a } from "./viewRenderingContext-HtpqwS_x.js";
4
+ //#region ../core/src/view/renderingContext/bufferedViewRenderingContext.js
5
+ var o = class extends a {
6
+ #e = [
7
+ 0,
8
+ 0,
9
+ 0,
10
+ 0
11
+ ];
12
+ #t;
13
+ #n = [];
14
+ #r;
15
+ #i;
16
+ #a = /* @__PURE__ */ new Set();
17
+ #o;
18
+ #s = void 0;
19
+ #c = 1;
20
+ #l = {
21
+ width: 0,
22
+ height: 0
23
+ };
24
+ #u;
25
+ constructor(e, t) {
26
+ if (super(e), this.#i = t.webGLHelper, this.#r = t.framebufferInfo, this.#c = t.devicePixelRatio, this.#l = t.canvasSize, this.#o = t.markPredicate ?? (() => !0), this.#u = t.pixelOffset, t.clearColor) {
27
+ let e = r(t.clearColor).rgb();
28
+ this.#e = [
29
+ e.r / 255,
30
+ e.g / 255,
31
+ e.b / 255,
32
+ e.opacity
33
+ ];
34
+ }
35
+ }
36
+ getDevicePixelRatio() {
37
+ return this.#c;
38
+ }
39
+ pushView(e, t) {
40
+ this.#a.add(e), this.#s = t;
41
+ }
42
+ renderMark(t, r) {
43
+ if (!this.#o(t) || this.globalOptions.picking && !t.isPickingParticipant()) return;
44
+ let i = t.render(r);
45
+ if (i) {
46
+ let a = e(r);
47
+ this.#n.push({
48
+ mark: t,
49
+ callback: i,
50
+ coords: this.#s,
51
+ clip: n(a, t.properties.clip, this.#s),
52
+ cullClip: a
53
+ });
54
+ }
55
+ }
56
+ render() {
57
+ if (this.#t || this.#d(), this.#t.length == 0) return;
58
+ let e = this.#i.gl, t = this.#r;
59
+ t ? (e.bindFramebuffer(e.FRAMEBUFFER, t.framebuffer), e.viewport(0, 0, t.width, t.height)) : e.viewport(0, 0, e.drawingBufferWidth, e.drawingBufferHeight), e.disable(e.SCISSOR_TEST), e.clearColor(...this.#e), e.clear(e.COLOR_BUFFER_BIT);
60
+ for (let e of this.#a) e.onBeforeRender();
61
+ for (let e of this.#t) e();
62
+ this.#r && e.bindFramebuffer(e.FRAMEBUFFER, null);
63
+ }
64
+ #d() {
65
+ this.#t = [];
66
+ let e = !0, n = !0, r = (t) => () => {
67
+ e && t();
68
+ }, a = (t) => () => {
69
+ e && n && t();
70
+ }, o = i(this.#n.reverse(), (e) => e.mark);
71
+ for (let [i, s] of [...o.entries()].reverse()) {
72
+ if (!i.isReady()) continue;
73
+ this.#t.push(() => {
74
+ e = i.unitView.getEffectiveOpacity() > 0;
75
+ }), this.#t.push(...i.prepareRender(this.globalOptions).map((e) => r(e)));
76
+ let o, c, l;
77
+ for (let e of s) {
78
+ let s = e.coords;
79
+ (!s.equals(o) || !t(e.clip, c) || !t(e.cullClip, l)) && this.#t.push(r(() => {
80
+ n = i.setViewport(this.#l, this.#c, s, e.clip, e.cullClip, this.#u);
81
+ })), this.#t.push(a(e.callback)), o = e.coords, c = e.clip, l = e.cullClip;
82
+ }
83
+ }
84
+ }
85
+ };
86
+ //#endregion
87
+ //#region ../core/src/gl/framebufferReadback.js
88
+ function s(e, t, n = {}) {
89
+ let r = n.x ?? 0, i = n.y ?? 0, a = n.width ?? t.width, o = n.height ?? t.height;
90
+ f(t, r, i, a, o);
91
+ let s = new Uint8Array(a * o * 4);
92
+ e.bindFramebuffer(e.FRAMEBUFFER, t.framebuffer);
93
+ try {
94
+ e.readPixels(r, t.height - i - o, a, o, e.RGBA, e.UNSIGNED_BYTE, s);
95
+ } finally {
96
+ e.bindFramebuffer(e.FRAMEBUFFER, null);
97
+ }
98
+ return {
99
+ pixels: d(s, a, o, n.unpremultiplyAlpha ?? !1),
100
+ width: a,
101
+ height: o
102
+ };
103
+ }
104
+ function c(e, t, n = "image/png", r = {}) {
105
+ return u(e, t, r).toDataURL(n);
106
+ }
107
+ function l(e, t, n = "image/png", r = {}) {
108
+ let i = u(e, t, r);
109
+ return new Promise((e, t) => {
110
+ i.toBlob((r) => {
111
+ r ? e(r) : t(/* @__PURE__ */ Error(`Could not encode framebuffer as ${n}.`));
112
+ }, n);
113
+ });
114
+ }
115
+ function u(e, t, n) {
116
+ let { pixels: r, width: i, height: a } = s(e, t, n), o = document.createElement("canvas");
117
+ o.width = i, o.height = a;
118
+ let c = o.getContext("2d"), l = c.createImageData(i, a);
119
+ return l.data.set(r), c.putImageData(l, 0, 0), o;
120
+ }
121
+ function d(e, t, n, r) {
122
+ let i = new Uint8ClampedArray(e.length), a = t * 4;
123
+ for (let t = 0; t < n; t++) {
124
+ let r = (n - t - 1) * a, o = t * a;
125
+ i.set(e.subarray(r, r + a), o);
126
+ }
127
+ if (r) for (let e = 0; e < i.length; e += 4) {
128
+ let t = i[e + 3];
129
+ if (t == 0) i[e] = 0, i[e + 1] = 0, i[e + 2] = 0;
130
+ else if (t < 255) {
131
+ let n = 255 / t;
132
+ i[e] = Math.round(i[e] * n), i[e + 1] = Math.round(i[e + 1] * n), i[e + 2] = Math.round(i[e + 2] * n);
133
+ }
134
+ }
135
+ return i;
136
+ }
137
+ function f(e, t, n, r, i) {
138
+ if (![
139
+ t,
140
+ n,
141
+ r,
142
+ i
143
+ ].every(Number.isInteger)) throw RangeError("Framebuffer readback bounds must be integers.");
144
+ if (t < 0 || n < 0 || r <= 0 || i <= 0 || t + r > e.width || n + i > e.height) throw RangeError("Framebuffer readback bounds are out of range.");
145
+ }
146
+ //#endregion
147
+ export { c as n, o as r, l as t };