MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / ensureOverlayTargets

Function ensureOverlayTargets

src/core/createRenderCoordinator.ts:1939–1976  ·  view source on GitHub ↗
(canvasWidthDevicePx: number, canvasHeightDevicePx: number)

Source from the content-addressed store, hash-verified

1937 };
1938
1939 const ensureOverlayTargets = (canvasWidthDevicePx: number, canvasHeightDevicePx: number): void => {
1940 const w = Number.isFinite(canvasWidthDevicePx) ? Math.max(1, Math.floor(canvasWidthDevicePx)) : 1;
1941 const h = Number.isFinite(canvasHeightDevicePx) ? Math.max(1, Math.floor(canvasHeightDevicePx)) : 1;
1942
1943 if (mainColorTexture && overlayMsaaTexture && overlayBlitBindGroup && overlayTargetsWidth === w && overlayTargetsHeight === h && overlayTargetsFormat === targetFormat) {
1944 return;
1945 }
1946
1947 destroyTexture(mainColorTexture);
1948 destroyTexture(overlayMsaaTexture);
1949
1950 mainColorTexture = device.createTexture({
1951 label: 'renderCoordinator/mainColorTexture',
1952 size: { width: w, height: h },
1953 format: targetFormat,
1954 usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
1955 });
1956 mainColorView = mainColorTexture.createView();
1957
1958 overlayMsaaTexture = device.createTexture({
1959 label: 'renderCoordinator/annotationOverlayMsaaTexture',
1960 size: { width: w, height: h },
1961 sampleCount: ANNOTATION_OVERLAY_MSAA_SAMPLE_COUNT,
1962 format: targetFormat,
1963 usage: GPUTextureUsage.RENDER_ATTACHMENT,
1964 });
1965 overlayMsaaView = overlayMsaaTexture.createView();
1966
1967 overlayBlitBindGroup = device.createBindGroup({
1968 label: 'renderCoordinator/overlayBlitBindGroup',
1969 layout: overlayBlitBindGroupLayout,
1970 entries: [{ binding: 0, resource: mainColorView }],
1971 });
1972
1973 overlayTargetsWidth = w;
1974 overlayTargetsHeight = h;
1975 overlayTargetsFormat = targetFormat;
1976 };
1977
1978 const initialGridArea = computeGridArea(gpuContext, currentOptions);
1979

Callers 1

renderFunction · 0.85

Calls 1

destroyTextureFunction · 0.85

Tested by

no test coverage detected