(
gl: WebGL2RenderingContext, sourceDims: Dimensions, targetDims: Dimensions,
alignCorners: boolean,
interpolation: 'nearest_neighbor'|'bilinear')
| 331 | } |
| 332 | |
| 333 | function resizeProgram( |
| 334 | gl: WebGL2RenderingContext, sourceDims: Dimensions, targetDims: Dimensions, |
| 335 | alignCorners: boolean, |
| 336 | interpolation: 'nearest_neighbor'|'bilinear'): ProgramObjects { |
| 337 | if (!programCacheByContext.has(gl)) { |
| 338 | programCacheByContext.set(gl, new Map()); |
| 339 | } |
| 340 | const programCache = programCacheByContext.get(gl); |
| 341 | |
| 342 | const cacheKey = `resize_${sourceDims.width}_${sourceDims.height}_${ |
| 343 | sourceDims.depth}_${targetDims.width}_${targetDims.height}_${ |
| 344 | targetDims.depth}_${alignCorners}_${interpolation}`; |
| 345 | |
| 346 | if (!programCache.has(cacheKey)) { |
| 347 | const vertSource = resizeNNProgramInfo.vertexShaderSource(); |
| 348 | let fragSource: string; |
| 349 | if (interpolation === 'nearest_neighbor') { |
| 350 | fragSource = resizeNNProgramInfo.fragmentShaderSource( |
| 351 | sourceDims, targetDims, alignCorners); |
| 352 | } else { |
| 353 | fragSource = resizeBilinearProgramInfo.fragmentShaderSource( |
| 354 | sourceDims, targetDims, alignCorners); |
| 355 | } |
| 356 | |
| 357 | const vertices = resizeNNProgramInfo.vertices(); |
| 358 | const texCoords = resizeNNProgramInfo.texCoords(); |
| 359 | const programObjects = |
| 360 | createProgramObjects(gl, vertSource, fragSource, vertices, texCoords); |
| 361 | |
| 362 | programCache.set(cacheKey, programObjects); |
| 363 | } |
| 364 | return programCache.get(cacheKey); |
| 365 | } |
| 366 | |
| 367 | function createProgramObjects( |
| 368 | gl: WebGL2RenderingContext, vertexShaderSource: string, |
no test coverage detected
searching dependent graphs…