Skip to content

Commit b1e52e2

Browse files
committed
Revert "perf: draw simplified nodes on the canvas instead of the DOM"
This reverts commit 93f7e4d. Drawing the simplified nodes through litegraph's own node pass means the Vue renderer cannot render a zoomed-out graph without litegraph present, which is the opposite of the direction this renderer is heading. Links already have the right shape - a Vue-owned canvas element with the drawing itself living renderer-side in CanvasPathRenderer - so the simplified node pass should follow that pattern instead.
1 parent cb17d3c commit b1e52e2

3 files changed

Lines changed: 38 additions & 12 deletions

File tree

src/components/graph/GraphCanvas.vue

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,10 @@
7272
@pointermove.capture="forwardPointerMovePanEvent"
7373
>
7474
<!-- Vue nodes rendered based on graph nodes -->
75-
<!--
76-
Nothing is mounted while zoomed out past legibility: the canvas renderer
77-
draws each node as a plain rectangle instead, which is what a node looks
78-
like at that zoom anyway and costs no elements.
79-
-->
80-
<template v-if="!isLowQuality">
75+
<template v-for="nodeData in allNodes" :key="nodeData.id">
76+
<LGraphNodeLOD v-if="isLowQuality" :node-data="nodeData" />
8177
<LGraphNode
82-
v-for="nodeData in allNodes"
83-
:key="nodeData.id"
78+
v-else
8479
:node-data="nodeData"
8580
:error="
8681
executionErrorStore.lastExecutionErrorNodeId === nodeData.id
@@ -192,6 +187,7 @@ import type { StartupOutcome } from '@/platform/workflow/persistence/base/draftT
192187
import { useFirstRunEntry } from '@/renderer/extensions/firstRunTour/gettingStarted/firstRunEntry'
193188
import MiniMap from '@/renderer/extensions/minimap/MiniMap.vue'
194189
import LGraphNode from '@/renderer/extensions/vueNodes/components/LGraphNode.vue'
190+
import LGraphNodeLOD from '@/renderer/extensions/vueNodes/components/LGraphNodeLOD.vue'
195191
import { useLowQualityRendering } from '@/renderer/extensions/vueNodes/composables/useLowQualityRendering'
196192
import { requestSlotLayoutSyncForAllNodes } from '@/renderer/extensions/vueNodes/composables/useSlotElementTracking'
197193
import { UnauthorizedError } from '@/scripts/api'

src/lib/litegraph/src/LGraphCanvas.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5670,10 +5670,7 @@ export class LGraphCanvas implements CustomEventDispatcher<LGraphCanvasEventMap>
56705670
node.arrange()
56715671
}
56725672
// Skip all node body/widget/title rendering. Vue overlay handles visuals.
5673-
// Except when zoomed out past the point of legibility: a node is then
5674-
// just a filled rectangle, which is far cheaper to draw here than to
5675-
// mount an element per node, so fall through and draw it as normal.
5676-
if (!this.low_quality) return
5673+
return
56775674
}
56785675

56795676
const color = node.renderingColor
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script setup lang="ts">
2+
import { computed } from 'vue'
3+
4+
import type { VueNodeData } from '@/composables/graph/useGraphNodeManager'
5+
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
6+
import { useNodeLayout } from '@/renderer/extensions/vueNodes/layout/useNodeLayout'
7+
8+
const { nodeData } = defineProps<{ nodeData: VueNodeData }>()
9+
10+
const { position, size } = useNodeLayout(() => nodeData.id)
11+
12+
const style = computed(() => ({
13+
transform: `translate(${position.value.x ?? 0}px, ${(position.value.y ?? 0) - LiteGraph.NODE_TITLE_HEIGHT}px)`,
14+
width: `${size.value.width ?? 0}px`,
15+
height: `${(size.value.height ?? 0) + LiteGraph.NODE_TITLE_HEIGHT}px`,
16+
backgroundColor: nodeData.bgcolor || undefined
17+
}))
18+
</script>
19+
20+
<template>
21+
<!--
22+
Stand-in for a full node while zoomed too far out to read its text, matching
23+
litegraph's own low-quality pass, which draws a plain filled rect and skips
24+
text, badges and shadows. Deliberately childless and non-interactive: the
25+
whole point is that one node costs one element instead of a component tree.
26+
-->
27+
<div
28+
:data-node-id="nodeData.id"
29+
data-node-lod
30+
class="lg-node-lod pointer-events-none absolute bg-node-component-surface"
31+
:style="style"
32+
/>
33+
</template>

0 commit comments

Comments
 (0)