MCPcopy
hub / github.com/tensorflow/tfjs / resizeProgram

Function resizeProgram

tfjs-react-native/src/camera/camera_webgl_util.ts:333–365  ·  view source on GitHub ↗
(
    gl: WebGL2RenderingContext, sourceDims: Dimensions, targetDims: Dimensions,
    alignCorners: boolean,
    interpolation: 'nearest_neighbor'|'bilinear')

Source from the content-addressed store, hash-verified

331}
332
333function 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
367function createProgramObjects(
368 gl: WebGL2RenderingContext, vertexShaderSource: string,

Callers 1

runResizeProgramFunction · 0.85

Calls 4

createProgramObjectsFunction · 0.85
hasMethod · 0.80
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…