perf: reduce unnecessary frame clippings (#8980)

* reduce unnecessary frame clippings

* further optim
This commit is contained in:
Ryan Di 2025-01-23 07:25:46 +08:00 committed by GitHub
parent ec06fbc1fc
commit dd1b45a25a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 152 additions and 46 deletions

View file

@ -4,7 +4,7 @@ import { getElementAbsoluteCoords } from "../element";
import {
elementOverlapsWithFrame,
getTargetFrame,
isElementInFrame,
shouldApplyFrameClip,
} from "../frame";
import {
isEmbeddableElement,
@ -273,6 +273,8 @@ const _renderStaticScene = ({
}
});
const inFrameGroupsMap = new Map<string, boolean>();
// Paint visible elements
visibleElements
.filter((el) => !isIframeLikeElement(el))
@ -297,9 +299,16 @@ const _renderStaticScene = ({
appState.frameRendering.clip
) {
const frame = getTargetFrame(element, elementsMap, appState);
// TODO do we need to check isElementInFrame here?
if (frame && isElementInFrame(element, elementsMap, appState)) {
if (
frame &&
shouldApplyFrameClip(
element,
frame,
appState,
elementsMap,
inFrameGroupsMap,
)
) {
frameClip(frame, context, renderConfig, appState);
}
renderElement(
@ -400,7 +409,16 @@ const _renderStaticScene = ({
const frame = getTargetFrame(element, elementsMap, appState);
if (frame && isElementInFrame(element, elementsMap, appState)) {
if (
frame &&
shouldApplyFrameClip(
element,
frame,
appState,
elementsMap,
inFrameGroupsMap,
)
) {
frameClip(frame, context, renderConfig, appState);
}
render();