chunk-TWB5CT7V.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import {
  2. a
  3. } from "./chunk-YJKEIUMW.js";
  4. import {
  5. u
  6. } from "./chunk-546QCRS4.js";
  7. import {
  8. D,
  9. G,
  10. M,
  11. P
  12. } from "./chunk-MI7HWWFL.js";
  13. import {
  14. e
  15. } from "./chunk-ZHRMTKME.js";
  16. import {
  17. t as t2
  18. } from "./chunk-MFFE4I2S.js";
  19. import {
  20. M as M2,
  21. b,
  22. h,
  23. i,
  24. r as r2
  25. } from "./chunk-CRGVDJI6.js";
  26. import {
  27. r,
  28. t
  29. } from "./chunk-GZT4BVFP.js";
  30. // node_modules/@arcgis/core/views/2d/engine/ImageryBitmapSource.js
  31. var i2 = class {
  32. constructor(e2, t3, i3) {
  33. this.pixelBlock = e2, this.extent = t3, this.originalPixelBlock = i3;
  34. }
  35. get width() {
  36. return r(this.pixelBlock) ? this.pixelBlock.width : 0;
  37. }
  38. get height() {
  39. return r(this.pixelBlock) ? this.pixelBlock.height : 0;
  40. }
  41. render(e2) {
  42. const i3 = this.pixelBlock;
  43. if (t(i3))
  44. return;
  45. const l = this.filter({ pixelBlock: i3 });
  46. if (t(l.pixelBlock))
  47. return;
  48. const r3 = l.pixelBlock.getAsRGBA(), o = e2.createImageData(l.pixelBlock.width, l.pixelBlock.height);
  49. o.data.set(r3), e2.putImageData(o, 0, 0);
  50. }
  51. getRenderedRasterPixels() {
  52. const e2 = this.filter({ pixelBlock: this.pixelBlock });
  53. return t(e2.pixelBlock) ? null : { width: e2.pixelBlock.width, height: e2.pixelBlock.height, renderedRasterPixels: new Uint8Array(e2.pixelBlock.getAsRGBA().buffer) };
  54. }
  55. };
  56. // node_modules/@arcgis/core/views/2d/engine/Bitmap.js
  57. function m(t3) {
  58. return t3 && "render" in t3;
  59. }
  60. function g(t3) {
  61. return t3 && !("render" in t3);
  62. }
  63. function p(t3) {
  64. const e2 = document.createElement("canvas");
  65. return e2.width = t3.width, e2.height = t3.height, t3.render(e2.getContext("2d")), e2;
  66. }
  67. function f(t3, e2, i3) {
  68. const s = { target: M.TEXTURE_2D, pixelFormat: P.RGBA, internalFormat: P.RGBA, dataType: G.UNSIGNED_BYTE, wrapMode: D.CLAMP_TO_EDGE };
  69. return e2 && i3 && (s.width = e2, s.height = i3), new u(t3, s);
  70. }
  71. var v = class extends a {
  72. constructor(t3 = null, e2, i3 = true) {
  73. super(), this.requestRenderOnSourceChangedEnabled = i3, this._textureInvalidated = true, this.stencilRef = 0, this.coordScale = [1, 1], this._height = void 0, this.pixelRatio = 1, this.resolution = 0, this.rotation = 0, this._source = null, this._width = void 0, this.x = 0, this.y = 0, this.blendFunction = e2, this.source = t3, this.requestRender = this.requestRender.bind(this);
  74. }
  75. destroy() {
  76. this._texture && (this._texture.dispose(), this._texture = null);
  77. }
  78. get isSourceScaled() {
  79. return this.width !== this.sourceWidth || this.height !== this.sourceHeight;
  80. }
  81. get height() {
  82. return this._height !== void 0 ? this._height : this.sourceHeight;
  83. }
  84. set height(t3) {
  85. this._height = t3;
  86. }
  87. get source() {
  88. return this._source;
  89. }
  90. set source(t3) {
  91. this._source = t3, this.invalidateTexture();
  92. }
  93. get sourceHeight() {
  94. return this._source instanceof HTMLImageElement ? this._source.naturalHeight : this._source.height;
  95. }
  96. get sourceWidth() {
  97. return this._source instanceof HTMLImageElement ? this._source.naturalWidth : this._source.width;
  98. }
  99. get width() {
  100. return this._width !== void 0 ? this._width : this.sourceWidth;
  101. }
  102. set width(t3) {
  103. this._width = t3;
  104. }
  105. beforeRender(t3) {
  106. super.beforeRender(t3), this.updateTexture(t3.context);
  107. }
  108. invalidateTexture() {
  109. this._textureInvalidated || (this._textureInvalidated = true, this.requestRenderOnSourceChangedEnabled && this.requestRender());
  110. }
  111. _createTransforms() {
  112. return { dvs: e() };
  113. }
  114. setTransform(t3) {
  115. const n = r2(this.transforms.dvs), [u2, a2] = t3.toScreenNoRotation([0, 0], [this.x, this.y]), d = this.resolution / this.pixelRatio / t3.resolution, c = d * this.width, l = d * this.height, _ = Math.PI * this.rotation / 180;
  116. M2(n, n, t2(u2, a2)), M2(n, n, t2(c / 2, l / 2)), h(n, n, -_), M2(n, n, t2(-c / 2, -l / 2)), b(n, n, t2(c, l)), i(this.transforms.dvs, t3.displayViewMat3, n);
  117. }
  118. setSamplingProfile(t3) {
  119. this._texture && (t3.mips && !this._texture.descriptor.hasMipmap && this._texture.generateMipmap(), this._texture.setSamplingMode(t3.samplingMode));
  120. }
  121. bind(t3, e2) {
  122. this._texture && t3.bindTexture(this._texture, e2);
  123. }
  124. updateTexture(e2) {
  125. if (!this.stage)
  126. return this._texture?.dispose(), void (this._texture = null);
  127. if (!this._textureInvalidated)
  128. return;
  129. this._textureInvalidated = false, this._texture || (this.source ? this._texture = f(e2, this.sourceWidth, this.sourceHeight) : this._texture = f(e2));
  130. const i3 = this.source;
  131. if (i3) {
  132. if (this._texture.resize(this.sourceWidth, this.sourceHeight), m(i3))
  133. if (i3 instanceof i2) {
  134. const e3 = i3.getRenderedRasterPixels();
  135. this._texture.setData(r(e3) ? e3.renderedRasterPixels : null);
  136. } else
  137. this._texture.setData(p(i3));
  138. else
  139. g(i3) && this._texture.setData(i3);
  140. this.ready();
  141. } else
  142. this._texture.setData(null);
  143. }
  144. onAttach() {
  145. this.invalidateTexture();
  146. }
  147. onDetach() {
  148. this.invalidateTexture();
  149. }
  150. };
  151. export {
  152. i2 as i,
  153. v
  154. };
  155. //# sourceMappingURL=chunk-TWB5CT7V.js.map