123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- import {
- has
- } from "./chunk-SPWQ3AWG.js";
- import {
- f,
- r,
- t
- } from "./chunk-YXWMMD76.js";
- // node_modules/@arcgis/core/views/2d/engine/webgl/cpuMapped/FreeList.js
- var a = class {
- constructor(t2) {
- if (this.next = null, !Array.isArray(t2))
- return void (this.data = t2);
- this.data = t2[0];
- let e2 = this;
- for (let n2 = 1; n2 < t2.length; n2++)
- e2.next = new a([t2[n2]]), e2 = e2.next;
- }
- *values() {
- let t2 = this;
- for (; t2; )
- yield t2.data, t2 = t2.next;
- }
- forEach(t2) {
- let a3 = this;
- for (; a3; )
- t2(a3.data), a3 = a3.next;
- }
- find(t2) {
- var _a;
- return t2(this.data) ? this : (_a = this.next) == null ? void 0 : _a.find(t2);
- }
- max(t2, a3 = this) {
- const e2 = t2(this.data) > t2(a3.data) ? this : a3;
- return this.next ? this.next.max(t2, e2) : e2;
- }
- remove(t2, a3 = null) {
- var _a, _b;
- return this === t2 ? a3 ? (a3.next = this.next, a3) : this.next : (_b = (_a = this.next) == null ? void 0 : _a.remove(t2, this)) != null ? _b : null;
- }
- get last() {
- return this.next ? this.next.last : this;
- }
- };
- var e = class {
- constructor(e2) {
- this._head = null, t(e2) || (this._head = new a(e2));
- }
- get head() {
- return this._head;
- }
- maxAvailableSpace() {
- if (t(this._head))
- return 0;
- const a3 = this._head.max((t2) => t2.end - t2.start);
- return a3.data.end - a3.data.start;
- }
- firstFit(a3) {
- if (t(this._head))
- return null;
- let e2 = null, n2 = this._head;
- for (; n2; ) {
- const t2 = n2.data.end - n2.data.start;
- if (t2 === a3)
- return e2 ? e2.next = n2.next : this._head = n2.next, n2.data.start;
- if (t2 > a3) {
- const t3 = n2.data.start;
- return n2.data.start += a3, t3;
- }
- e2 = n2, n2 = n2.next;
- }
- return null;
- }
- free(e2, n2) {
- const r2 = e2 + n2;
- if (t(this._head)) {
- const t2 = new a({ start: e2, end: r2 });
- return void (this._head = t2);
- }
- if (r2 <= this._head.data.start) {
- if (r2 === this._head.data.start)
- return void (this._head.data.start -= n2);
- const t2 = new a({ start: e2, end: r2 });
- return t2.next = this._head, void (this._head = t2);
- }
- let s = this._head, d = s.next;
- for (; d; ) {
- if (d.data.start >= r2) {
- if (s.data.end === e2) {
- if (s.data.end += n2, s.data.end === d.data.start) {
- const t3 = d.data.end - d.data.start;
- return s.data.end += t3, void (s.next = d.next);
- }
- return;
- }
- if (d.data.start === r2)
- return void (d.data.start -= n2);
- const t2 = new a({ start: e2, end: r2 });
- return t2.next = s.next, void (s.next = t2);
- }
- s = d, d = d.next;
- }
- if (e2 === s.data.end)
- return void (s.data.end += n2);
- const i2 = new a({ start: e2, end: r2 });
- s.next = i2;
- }
- };
- // node_modules/@arcgis/core/views/2d/engine/webgl/BufferPool.js
- var a2 = has("esri-2d-log-allocations");
- var i = class {
- constructor(t2, e2) {
- this._array = t2, this._pool = e2;
- }
- get array() {
- return this._array;
- }
- get length() {
- return this._array.length;
- }
- static create(t2, e2) {
- const s = e2.acquire(t2);
- return new i(s, e2);
- }
- expand(t2) {
- const e2 = this._pool.acquire(t2);
- e2.set(this._array), this._pool.release(this._array), this._array = e2;
- }
- destroy() {
- this._pool.release(this._array);
- }
- set(t2, e2) {
- this._array.set(t2._array, e2);
- }
- slice() {
- const t2 = this._pool.acquire(this._array.byteLength);
- return t2.set(this._array), new i(t2, this._pool);
- }
- };
- var o = class {
- constructor() {
- this._data = new ArrayBuffer(o.BYTE_LENGTH), this._freeList = new e({ start: 0, end: this._data.byteLength });
- }
- static get BYTE_LENGTH() {
- return 64e6;
- }
- get buffer() {
- return this._data;
- }
- allocate(t2) {
- const e2 = this._freeList.firstFit(t2);
- return t(e2) ? null : new Uint32Array(this._data, e2, t2 / Uint32Array.BYTES_PER_ELEMENT);
- }
- free(t2) {
- this._freeList.free(t2.byteOffset, t2.byteLength);
- }
- };
- var n = class {
- constructor() {
- this._bytesAllocated = 0, this._pages = [], this._pagesByBuffer = /* @__PURE__ */ new Map(), this._addPage();
- }
- destroy() {
- this._pages = [], this._pagesByBuffer = null;
- }
- get _bytesTotal() {
- return this._pages.length * o.BYTE_LENGTH;
- }
- acquire(s) {
- if (this._bytesAllocated += s, a2 && console.log(`Allocating ${s}, (${this._bytesAllocated} / ${this._bytesTotal})`), s > o.BYTE_LENGTH)
- return new Uint32Array(s / Uint32Array.BYTES_PER_ELEMENT);
- for (const e2 of this._pages) {
- const r2 = e2.allocate(s);
- if (r(r2))
- return r2;
- }
- return f(this._addPage().allocate(s), "Expected to allocate page");
- }
- release(t2) {
- this._bytesAllocated -= t2.byteLength, a2 && console.log(`Freeing ${t2.byteLength}, (${this._bytesAllocated} / ${this._bytesTotal})`);
- const e2 = this._pagesByBuffer.get(t2.buffer);
- e2 && e2.free(t2);
- }
- _addPage() {
- const t2 = new o();
- return this._pages.push(t2), this._pagesByBuffer.set(t2.buffer, t2), t2;
- }
- };
- export {
- a,
- e,
- i,
- n
- };
- //# sourceMappingURL=chunk-267VUXDM.js.map
|