chunk-267VUXDM.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import {
  2. has
  3. } from "./chunk-SPWQ3AWG.js";
  4. import {
  5. f,
  6. r,
  7. t
  8. } from "./chunk-YXWMMD76.js";
  9. // node_modules/@arcgis/core/views/2d/engine/webgl/cpuMapped/FreeList.js
  10. var a = class {
  11. constructor(t2) {
  12. if (this.next = null, !Array.isArray(t2))
  13. return void (this.data = t2);
  14. this.data = t2[0];
  15. let e2 = this;
  16. for (let n2 = 1; n2 < t2.length; n2++)
  17. e2.next = new a([t2[n2]]), e2 = e2.next;
  18. }
  19. *values() {
  20. let t2 = this;
  21. for (; t2; )
  22. yield t2.data, t2 = t2.next;
  23. }
  24. forEach(t2) {
  25. let a3 = this;
  26. for (; a3; )
  27. t2(a3.data), a3 = a3.next;
  28. }
  29. find(t2) {
  30. var _a;
  31. return t2(this.data) ? this : (_a = this.next) == null ? void 0 : _a.find(t2);
  32. }
  33. max(t2, a3 = this) {
  34. const e2 = t2(this.data) > t2(a3.data) ? this : a3;
  35. return this.next ? this.next.max(t2, e2) : e2;
  36. }
  37. remove(t2, a3 = null) {
  38. var _a, _b;
  39. 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;
  40. }
  41. get last() {
  42. return this.next ? this.next.last : this;
  43. }
  44. };
  45. var e = class {
  46. constructor(e2) {
  47. this._head = null, t(e2) || (this._head = new a(e2));
  48. }
  49. get head() {
  50. return this._head;
  51. }
  52. maxAvailableSpace() {
  53. if (t(this._head))
  54. return 0;
  55. const a3 = this._head.max((t2) => t2.end - t2.start);
  56. return a3.data.end - a3.data.start;
  57. }
  58. firstFit(a3) {
  59. if (t(this._head))
  60. return null;
  61. let e2 = null, n2 = this._head;
  62. for (; n2; ) {
  63. const t2 = n2.data.end - n2.data.start;
  64. if (t2 === a3)
  65. return e2 ? e2.next = n2.next : this._head = n2.next, n2.data.start;
  66. if (t2 > a3) {
  67. const t3 = n2.data.start;
  68. return n2.data.start += a3, t3;
  69. }
  70. e2 = n2, n2 = n2.next;
  71. }
  72. return null;
  73. }
  74. free(e2, n2) {
  75. const r2 = e2 + n2;
  76. if (t(this._head)) {
  77. const t2 = new a({ start: e2, end: r2 });
  78. return void (this._head = t2);
  79. }
  80. if (r2 <= this._head.data.start) {
  81. if (r2 === this._head.data.start)
  82. return void (this._head.data.start -= n2);
  83. const t2 = new a({ start: e2, end: r2 });
  84. return t2.next = this._head, void (this._head = t2);
  85. }
  86. let s = this._head, d = s.next;
  87. for (; d; ) {
  88. if (d.data.start >= r2) {
  89. if (s.data.end === e2) {
  90. if (s.data.end += n2, s.data.end === d.data.start) {
  91. const t3 = d.data.end - d.data.start;
  92. return s.data.end += t3, void (s.next = d.next);
  93. }
  94. return;
  95. }
  96. if (d.data.start === r2)
  97. return void (d.data.start -= n2);
  98. const t2 = new a({ start: e2, end: r2 });
  99. return t2.next = s.next, void (s.next = t2);
  100. }
  101. s = d, d = d.next;
  102. }
  103. if (e2 === s.data.end)
  104. return void (s.data.end += n2);
  105. const i2 = new a({ start: e2, end: r2 });
  106. s.next = i2;
  107. }
  108. };
  109. // node_modules/@arcgis/core/views/2d/engine/webgl/BufferPool.js
  110. var a2 = has("esri-2d-log-allocations");
  111. var i = class {
  112. constructor(t2, e2) {
  113. this._array = t2, this._pool = e2;
  114. }
  115. get array() {
  116. return this._array;
  117. }
  118. get length() {
  119. return this._array.length;
  120. }
  121. static create(t2, e2) {
  122. const s = e2.acquire(t2);
  123. return new i(s, e2);
  124. }
  125. expand(t2) {
  126. const e2 = this._pool.acquire(t2);
  127. e2.set(this._array), this._pool.release(this._array), this._array = e2;
  128. }
  129. destroy() {
  130. this._pool.release(this._array);
  131. }
  132. set(t2, e2) {
  133. this._array.set(t2._array, e2);
  134. }
  135. slice() {
  136. const t2 = this._pool.acquire(this._array.byteLength);
  137. return t2.set(this._array), new i(t2, this._pool);
  138. }
  139. };
  140. var o = class {
  141. constructor() {
  142. this._data = new ArrayBuffer(o.BYTE_LENGTH), this._freeList = new e({ start: 0, end: this._data.byteLength });
  143. }
  144. static get BYTE_LENGTH() {
  145. return 64e6;
  146. }
  147. get buffer() {
  148. return this._data;
  149. }
  150. allocate(t2) {
  151. const e2 = this._freeList.firstFit(t2);
  152. return t(e2) ? null : new Uint32Array(this._data, e2, t2 / Uint32Array.BYTES_PER_ELEMENT);
  153. }
  154. free(t2) {
  155. this._freeList.free(t2.byteOffset, t2.byteLength);
  156. }
  157. };
  158. var n = class {
  159. constructor() {
  160. this._bytesAllocated = 0, this._pages = [], this._pagesByBuffer = /* @__PURE__ */ new Map(), this._addPage();
  161. }
  162. destroy() {
  163. this._pages = [], this._pagesByBuffer = null;
  164. }
  165. get _bytesTotal() {
  166. return this._pages.length * o.BYTE_LENGTH;
  167. }
  168. acquire(s) {
  169. if (this._bytesAllocated += s, a2 && console.log(`Allocating ${s}, (${this._bytesAllocated} / ${this._bytesTotal})`), s > o.BYTE_LENGTH)
  170. return new Uint32Array(s / Uint32Array.BYTES_PER_ELEMENT);
  171. for (const e2 of this._pages) {
  172. const r2 = e2.allocate(s);
  173. if (r(r2))
  174. return r2;
  175. }
  176. return f(this._addPage().allocate(s), "Expected to allocate page");
  177. }
  178. release(t2) {
  179. this._bytesAllocated -= t2.byteLength, a2 && console.log(`Freeing ${t2.byteLength}, (${this._bytesAllocated} / ${this._bytesTotal})`);
  180. const e2 = this._pagesByBuffer.get(t2.buffer);
  181. e2 && e2.free(t2);
  182. }
  183. _addPage() {
  184. const t2 = new o();
  185. return this._pages.push(t2), this._pagesByBuffer.set(t2.buffer, t2), t2;
  186. }
  187. };
  188. export {
  189. a,
  190. e,
  191. i,
  192. n
  193. };
  194. //# sourceMappingURL=chunk-267VUXDM.js.map