vendor: 1,659 bytes, lines 1-39
1/******/ (() => { // webpackBootstrap 2/******/ // runtime can't be in strict mode because a global variable is assign and maybe created. 3/******/ // The require scope 4/******/ var __webpack_require__ = {}; 5/******/ 6/************************************************************************/ 7/******/ /* webpack/runtime/define property getters */ 8/******/ (() => { 9/******/ // define getter functions for harmony exports 10/******/ __webpack_require__.d = (exports, definition) => { 11/******/ for(var key in definition) { 12/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 13/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 14/******/ } 15/******/ } 16/******/ }; 17/******/ })(); 18/******/ 19/******/ /* webpack/runtime/hasOwnProperty shorthand */ 20/******/ (() => { 21/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 22/******/ })(); 23/******/ 24/******/ /* webpack/runtime/make namespace object */ 25/******/ (() => { 26/******/ // define __esModule on exports 27/******/ __webpack_require__.r = (exports) => { 28/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 29/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 30/******/ } 31/******/ Object.defineProperty(exports, '__esModule', { value: true }); 32/******/ }; 33/******/ })(); 34/******/ 35/************************************************************************/ 36var __webpack_exports__ = {}; 37// This entry need to be wrapped in an IIFE because it need to be in strict mode. 38(() => { 39"use strict";
40// ESM COMPAT FLAG 41__webpack_require__.r(__webpack_exports__); 42 43// EXPORTS 44__webpack_require__.d(__webpack_exports__, { 45 PixelReader: () => (/* binding */ PixelReader) 46}); 47 48;// CONCATENATED MODULE: external "CABLES.SHARED" 49const external_CABLES_SHARED_namespaceObject = CABLES.SHARED; 50;// CONCATENATED MODULE: ./src/corelibs/cgl_pixelreader/cgl_pixelreader.js 51 52 53class PixelReader 54{ 55 constructor() 56 { 57 this._log = new external_CABLES_SHARED_namespaceObject.Logger("LoadingStatus"); 58 59 this.pixelData = null; 60 this._finishedFence = true; 61 this._size = 0; 62 this._pbo = null; 63 } 64 65 _fence(cgl) 66 { 67 const gl = cgl.gl; 68 this._finishedFence = false; 69 return new Promise(function (resolve, reject) 70 { 71 if (cgl.aborted) return; 72 let sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0); 73 if (!sync) return; 74 gl.flush(); // Ensure the fence is submitted. 75 76 function check() 77 { 78 if (cgl.aborted) return; 79 const status = gl.clientWaitSync(sync, 0, 0); 80 81 if (status == gl.WAIT_FAILED) 82 { 83 console.error("fence wait failed"); 84 if (reject) reject(); 85 } 86 else 87 if (status == gl.TIMEOUT_EXPIRED) 88 { 89 // this._log.log("TIMEOUT_EXPIRED"); 90 return setTimeout(check, 0); 91 } 92 else 93 if (status == gl.CONDITION_SATISFIED) 94 { 95 // this._log.log("CONDITION_SATISFIED"); 96 resolve(); 97 gl.deleteSync(sync); 98 } 99 else if (status == gl.ALREADY_SIGNALED) 100 { 101 // this._log.log("already signaled"); 102 resolve(); 103 gl.deleteSync(sync); 104 } 105 else 106 { 107 this._log.log("unknown fence status", status); 108 } 109 } 110 111 // setTimeout(check, 3); 112 check(); 113 }); 114 } 115 116 read(cgl, fb, pixelFormat, x, y, w, h, finishedcb) 117 { 118 if (CABLES.UI) 119 if (!CABLES.UI.loaded || performance.now() - CABLES.UI.loadedTime < 1000) return; 120 121 if (!this._finishedFence) return; 122 123 const gl = cgl.gl; 124 let bytesPerItem = 1; 125 126 if (cgl.aborted) return; 127 if (!fb) return; 128 129 if (pixelFormat === CGL.Texture.TYPE_FLOAT) pixelFormat = CGL.Texture.PFORMATSTR_RGBA32F; 130 // let isFloatingPoint = pixelFormat == CGL.Texture.TYPE_FLOAT; // old parameter was "textureType", now it is pixelformat, keeping this for compatibility... 131 132 let isFloatingPoint = CGL.Texture.isPixelFormatFloat(pixelFormat); 133 134 if (isFloatingPoint)bytesPerItem = 4; 135 if (CGL.Texture.isPixelFormatHalfFloat(pixelFormat)) bytesPerItem = 2; 136 137 const pixelInfo = CGL.Texture.setUpGlPixelFormat(cgl, pixelFormat); 138 const numItems = pixelInfo.numColorChannels * w * h; 139 140 if (w == 0 || h == 0 || numItems == 0) return; 141 142 if (!this._pixelData || this._size != numItems * bytesPerItem) 143 { 144 if (bytesPerItem > 1) this._pixelData = new Float32Array(numItems); 145 else this._pixelData = new Uint8Array(numItems); 146 147 this._size = numItems * bytesPerItem; 148 } 149 150 let channelType = gl.UNSIGNED_BYTE; 151 if (bytesPerItem > 1)channelType = gl.FLOAT; 152 153 if (this._size == 0 || !this._pixelData) 154 { 155 this._log.error("readpixel size 0", this._size, w, h); 156 return; 157 } 158 159 if (this._finishedFence) 160 { 161 this._pbo = gl.createBuffer(); 162 gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._pbo); 163 gl.bufferData(gl.PIXEL_PACK_BUFFER, this._pixelData.byteLength, gl.DYNAMIC_READ); 164 gl.bindFramebuffer(gl.FRAMEBUFFER, fb); 165 gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._pbo); 166 cgl.profileData.profileFencedPixelRead++; 167 168 if (this._size != numItems * bytesPerItem) 169 this._log.error("buffer size invalid", numItems, w, h, bytesPerItem); 170 171 let dataType = pixelInfo.glDataType; 172 if (bytesPerItem > 1)dataType = cgl.gl.FLOAT; 173 174 let format = pixelInfo.glDataFormat; 175 gl.readPixels(x, y, w, h, format, dataType, 0); 176 177 gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null); 178 gl.bindFramebuffer(gl.FRAMEBUFFER, null); 179 } 180 let startLength = this._pixelData.byteLength; 181 182 if (this._finishedFence && this._pbo) 183 this._fence(cgl).then((error) => 184 { 185 this._wasTriggered = false;
186 this._finishedFence = true; 187 188 if (!error && this._pixelData && this._pixelData.byteLength == startLength) 189 { 190 gl.bindBuffer(gl.PIXEL_PACK_BUFFER, this._pbo); 191 gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, this._pixelData); 192 gl.bindBuffer(gl.PIXEL_PACK_BUFFER, null); 193 194 if (finishedcb) finishedcb(this._pixelData); 195 } 196 gl.deleteBuffer(this._pbo); 197 this._pbo = null; 198 }); 199 200 return true; 201 } 202} 203 204})(); 205 206var __webpack_export_target__ = (CGL = typeof CGL === "undefined" ? {} : CGL); 207for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i]; 208if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true }); 209/******/ })() 210;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.