Skip to content

Commit

Permalink
J2DScreen: Don't use static members to avoid leaking memory between s…
Browse files Browse the repository at this point in the history
…cenes
  • Loading branch information
themikelester committed Dec 17, 2024
1 parent 90ea8ae commit bb53e8c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Common/JSYSTEM/J2Dv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,21 +453,19 @@ export class J2DPicture extends J2DPane {
//#region J2DScreen
export class J2DScreen extends J2DPane {
public color: Color
private static defaultCtx: J2DGrafContext;
private defaultCtx: J2DGrafContext;

constructor(data: SCRN, cache: GfxRenderCache) {
super(data.panes[0], cache, null);
this.defaultCtx = new J2DGrafContext(cache.device, 0.0, 0.0, 640.0, 480.0, -1.0, 0.0);
this.color = data.inf1.color;
}

override draw(renderInstManager: GfxRenderInstManager, viewerRenderInput: ViewerRenderInput, ctx2D: J2DGrafContext | null, offsetX?: number, offsetY?: number): void {
if (ctx2D !== null) {
super.draw(renderInstManager, viewerRenderInput, ctx2D, offsetX, offsetY);
} else {
if(!J2DScreen.defaultCtx) {
J2DScreen.defaultCtx = new J2DGrafContext(renderInstManager.gfxRenderCache.device, 0.0, 0.0, 640.0, 480.0, -1.0, 0.0);
}
super.draw(renderInstManager, viewerRenderInput, J2DScreen.defaultCtx, offsetX, offsetY);
super.draw(renderInstManager, viewerRenderInput, this.defaultCtx, offsetX, offsetY);
}
}
}
Expand Down

0 comments on commit bb53e8c

Please sign in to comment.