Skip to content

Commit f9bed6c

Browse files
committed
update get size
1 parent 4d80ade commit f9bed6c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cocos/rendering/custom/framework.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ export function defaultWindowResize (ppl: BasicPipeline, window: RenderWindow, w
6666
ppl.addDepthStencil(`ShadowDepth${id}`, Format.DEPTH_STENCIL, shadowSize.x, shadowSize.y);
6767
}
6868

69+
function getRenderWindowSize (window: RenderWindow): [number, number] {
70+
return [Math.max(Math.floor(window.width), 1), Math.max(Math.floor(window.height), 1)];
71+
}
72+
6973
// Map to store throttle timers by cameraId
7074
const throttleTimers = new Map();
7175
// Map to store last resize time by cameraId
@@ -103,18 +107,16 @@ export function dispatchResizeEvents (cameras: Camera[], builder: PipelineBuilde
103107
if (isFrequentResizing && throttleTimers.has(cameraId)) {
104108
continue;
105109
}
106-
107-
const width = Math.max(Math.floor(camera.window.width), 1);
108-
const height = Math.max(Math.floor(camera.window.height), 1);
109-
110110
if (isFrequentResizing) {
111111
// Apply throttle only when frequent resizing is detected
112112
throttleTimers.set(cameraId, setTimeout(() => {
113+
const [width, height] = getRenderWindowSize(camera.window);
113114
builder.windowResize!(ppl, camera.window, camera, width, height);
114115
camera.window.setRenderWindowResizeHandled();
115116
throttleTimers.delete(cameraId);
116117
}, THROTTLE_DELAY));
117118
} else {
119+
const [width, height] = getRenderWindowSize(camera.window);
118120
// Normal resize - execute immediately
119121
builder.windowResize(ppl, camera.window, camera, width, height);
120122
camera.window.setRenderWindowResizeHandled();

0 commit comments

Comments
 (0)