Skip to content

Commit 85d5acf

Browse files
committed
feat: Implement SpritePool for optimized rendering in timeline components
- Refactored AxisRenderer, EventBatchRenderer, SearchStyleRenderer, TimelineMarkerRenderer, and FlameChart to utilize SpritePool for efficient sprite management. - Enhanced performance by reducing garbage collection overhead and leveraging GPU batching with a shared 1x1 white texture. - Updated rendering logic to use sprites instead of graphics objects, improving rendering speed and reducing draw calls. - Added renderer type option in TimelineOptions to switch between 'sprite' and 'mesh' rendering approaches for flexibility in performance testing.
1 parent 48c438a commit 85d5acf

9 files changed

Lines changed: 685 additions & 752 deletions

File tree

log-viewer/src/features/timeline/__tests__/batching.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,19 @@ describe('EventBatchRenderer', () => {
122122
});
123123

124124
describe('initialization', () => {
125-
it('should create Graphics objects for each batch plus one for buckets', () => {
125+
it('should create a SpritePool container', () => {
126126
renderer = new EventBatchRenderer(container, batches);
127127

128-
// 3 category batches + 1 dedicated bucket Graphics = 4 total
129-
expect(container.children).toHaveLength(4);
130-
expect(container.children.every((child) => child instanceof PIXI.Graphics)).toBe(true);
128+
// SpritePool creates a container for sprites
129+
expect(container.children).toHaveLength(1);
130+
expect(container.children[0] instanceof PIXI.Container).toBe(true);
131131
});
132132

133-
it('should create only bucket Graphics with empty batches', () => {
133+
it('should create SpritePool container with empty batches', () => {
134134
const emptyBatches = new Map<string, RenderBatch>();
135135
renderer = new EventBatchRenderer(container, emptyBatches);
136136

137-
// No category batches but still 1 dedicated bucket Graphics
137+
// SpritePool container is still created
138138
expect(container.children).toHaveLength(1);
139139
});
140140
});
@@ -506,14 +506,14 @@ describe('EventBatchRenderer', () => {
506506
});
507507

508508
describe('cleanup', () => {
509-
it('should destroy all Graphics objects', () => {
509+
it('should destroy SpritePool and remove all children', () => {
510510
renderer = new EventBatchRenderer(container, batches);
511511

512512
const childrenCount = container.children.length;
513513
expect(childrenCount).toBeGreaterThan(0);
514514

515515
renderer.destroy();
516-
// After destruction, graphics are removed from their parent
516+
// After destruction, SpritePool container is removed
517517
// Container should have no children
518518
expect(container.children.length).toBe(0);
519519
});

0 commit comments

Comments
 (0)