Skip to content

Commit 33ab23c

Browse files
committed
perf(timeline): remove masks and use BitmapText
1 parent b4a9ec4 commit 33ab23c

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

packages/app-frontend/src/features/timeline/TimelineView.vue

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ import { Queue } from '@front/util/queue'
3434
import { nonReactive } from '@front/util/reactivity'
3535
3636
PIXI.settings.ROUND_PIXELS = true
37+
PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST
38+
39+
PIXI.BitmapFont.from('Roboto Mono', {
40+
fontFamily: 'Roboto Mono',
41+
fontSize: 9,
42+
})
3743
3844
const LAYER_SIZE = 16
3945
const GROUP_SIZE = 6
@@ -495,6 +501,16 @@ export default defineComponent({
495501
writable: true,
496502
configurable: false,
497503
})
504+
Object.defineProperty(event, 'groupT', {
505+
value: null,
506+
writable: true,
507+
configurable: false,
508+
})
509+
Object.defineProperty(event, 'groupText', {
510+
value: null,
511+
writable: true,
512+
configurable: false,
513+
})
498514
eventContainer.addChild(groupG)
499515
event.group.oldSize = null
500516
event.group.oldSelected = null
@@ -898,29 +914,21 @@ export default defineComponent({
898914
// Title
899915
if (event.layer.groupsOnly && event.title && size > 32) {
900916
let t = event.groupT
917+
let text = event.groupText
901918
if (!t) {
902-
t = event.groupT = new PIXI.Text(`${SharedData.debugInfo ? `${event.id} ` : ''}${event.title} ${event.subtitle}`, {
903-
fontSize: 10,
904-
fill: darkMode.value ? 0xffffff : 0,
919+
text = `${SharedData.debugInfo ? `${event.id} ` : ''}${event.title} ${event.subtitle}`
920+
t = event.groupT = new PIXI.BitmapText('', {
921+
fontName: 'Roboto Mono',
922+
tint: darkMode.value ? 0xffffff : 0,
905923
})
924+
t.x = 1
906925
t.y = Math.round(-t.height / 2)
926+
t.dirty = false
927+
event.groupText = text
907928
event.container.addChild(t)
908-
909-
// Mask
910-
const mask = new PIXI.Graphics()
911-
event.container.addChild(mask)
912-
t.mask = mask
913-
}
914-
915-
const mask = t.mask as PIXI.Graphics
916-
if (size !== event.group.oldSize) {
917-
mask.clear()
918-
mask.beginFill(0)
919-
mask.drawRect(0, -LAYER_SIZE / 2, size - 1, LAYER_SIZE - 1)
920929
}
930+
t.text = text.slice(0, Math.floor((size - 1) / 6))
921931
} else if (event.groupT) {
922-
const mask = event.groupT.mask as PIXI.Graphics
923-
mask?.destroy()
924932
event.groupT.destroy()
925933
event.groupT = null
926934
}

packages/app-frontend/src/features/timeline/composable/store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export interface TimelineEvent extends TimelineEventFromBackend {
3737
container: PIXI.Container
3838
g: PIXI.Graphics
3939
groupG: PIXI.Graphics
40-
groupT: PIXI.Text
40+
groupT: PIXI.BitmapText
41+
groupText: string
4142
forcePositionUpdate?: boolean
4243
}
4344

0 commit comments

Comments
 (0)