/
githubmirror
/
pixijs
Обзор
Документация
Войти
/
githubmirror
/
pixijs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/rendering/renderers/shared/instructions/InstructionSet.ts
70 строк
2 KB
Zyie
fix: memory leaks in renderer systems (#11581)
02 сен 2025, 15:27
Не верифицирован
02 сен 2025, 15:27
6aeb34a
Код
Авторство
О чём код?
import { uid } from '../../../../utils/data/uid'; import type { Renderable } from '../Renderable'; import type { Instruction } from './Instruction'; /** * A set of instructions that can be executed by the renderer. * Basically wraps an array, but with some extra properties that help the renderer * to keep things nice and optimised. * * Note: * InstructionSet.instructions contains all the instructions, but does not resize (for performance). * So for the true length of the instructions you need to use InstructionSet.instructionSize * @category rendering * @advanced */ export class InstructionSet { /** a unique id for this instruction set used through the renderer */ public readonly uid: number = uid('instructionSet'); /** the array of instructions */ public readonly instructions: Instruction[] = []; /** the actual size of the array (any instructions passed this should be ignored) */ public instructionSize = 0; /** allows for access to the render pipes of the renderer */ public renderPipes: any; public renderables: Renderable[] = []; /** used by the garbage collector to track when the instruction set was last used */ public gcTick = 0; /** reset the instruction set so it can be reused set size back to 0 */ public reset() { this.instructionSize = 0; } /** * Destroy the instruction set, clearing the instructions and renderables. * @internal */ public destroy() { this.instructions.length = 0; this.renderables.length = 0; this.renderPipes = null; this.gcTick = 0; } /** * Add an instruction to the set * @param instruction - add an instruction to the set */ public add(instruction: Instruction) { this.instructions[this.instructionSize++] = instruction; } /** * Log the instructions to the console (for debugging) * @internal */ public log() { this.instructions.length = this.instructionSize; // eslint-disable-next-line no-console console.table(this.instructions, ['type', 'action']); } }