(gpuResource?: GPGPUContext|HTMLCanvasElement|OffscreenCanvas)
| 142 | private warnedAboutMemory = false; |
| 143 | |
| 144 | constructor(gpuResource?: GPGPUContext|HTMLCanvasElement|OffscreenCanvas) { |
| 145 | super(); |
| 146 | if (!env().getBool('HAS_WEBGL')) { |
| 147 | throw new Error('WebGL is not supported on this device'); |
| 148 | } |
| 149 | |
| 150 | let newGPGPU; |
| 151 | if (gpuResource != null) { |
| 152 | if (gpuResource instanceof GPGPUContext) { |
| 153 | newGPGPU = gpuResource; |
| 154 | } else { |
| 155 | const gl = |
| 156 | getWebGLContext(env().getNumber('WEBGL_VERSION'), gpuResource); |
| 157 | newGPGPU = new GPGPUContext(gl); |
| 158 | } |
| 159 | this.binaryCache = {}; |
| 160 | this.gpgpuCreatedLocally = false; |
| 161 | } else { |
| 162 | const gl = getWebGLContext(env().getNumber('WEBGL_VERSION')); |
| 163 | newGPGPU = new GPGPUContext(gl); |
| 164 | this.binaryCache = getBinaryCache(env().getNumber('WEBGL_VERSION')); |
| 165 | this.gpgpuCreatedLocally = true; |
| 166 | } |
| 167 | |
| 168 | this.gpgpu = newGPGPU; |
| 169 | this.canvas = this.gpgpu.gl.canvas; |
| 170 | this.textureManager = new TextureManager(this.gpgpu); |
| 171 | this.numMBBeforeWarning = numMBBeforeWarning(); |
| 172 | this.texData = new DataStorage(this, engine()); |
| 173 | } |
| 174 | |
| 175 | override numDataIds() { |
| 176 | return this.texData.numDataIds() - this.pendingDeletes; |
nothing calls this directly
no test coverage detected