Skip to content

Optimize GlowRenderer allocation and state overhead#122

Open
serzel wants to merge 9 commits into
mainfrom
codex/refactor-project-to-use-local-glow-system
Open

Optimize GlowRenderer allocation and state overhead#122
serzel wants to merge 9 commits into
mainfrom
codex/refactor-project-to-use-local-glow-system

Conversation

@serzel

@serzel serzel commented Feb 18, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Reduce per-frame allocations and redundant canvas state changes in glow rendering while preserving visual quality.
  • Provide a small, reusable API for circular and outline glows to replace shadow-based blurs that allocate and mutate context state.
  • Improve performance hotspots by caching color parsing and removing per-call layer arrays/objects.
  • Split entity drawing into base + glow phases so glow rendering can be batched/sequenced more predictably.

Description

  • Added src/rendering/GlowRenderer.js implementing drawCircularGlow and drawOutlineGlow using constants, minimized allocations, and a colorCache to reuse parsed color RGB strings.
  • Replaced use of shadowColor/shadowBlur and ad-hoc glow code across UI and entities with calls to the new glow API in Ship.js, Bullet.js, Asteroid.js, DebrisParticle.js, Explosion.js, Particle.js, HUD.js, UIRenderer.js, and neon.js.
  • Refactored entity renderers to separate drawBase and drawGlow (and combined draw to call both) and split the Game drawing pass into #drawWorldBase, #drawWorldGlow, and #drawUI to avoid interleaved state churn.
  • Eliminated per-call layer arrays/objects for outline glows and removed redundant composite resets while keeping save/restore to isolate context state.

Testing

  • Ran a project-wide grep for shadowBlur|shadowColor to ensure usages were removed, which returned no matches.
  • Performed a syntax check with node --check src/rendering/GlowRenderer.js, which completed without errors.
  • Verified the modified files parsed correctly in the runtime environment (no syntax/runtime parse errors detected by the checks above).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant