ref: 84351ae4cb50857fe62e0938198db0c7ea33d05c
parent: 2fdd83c82779fa108ae435bee1cae6d68243c75b
author: qwx <devnull@localhost>
date: Sat Mar 31 07:37:25 EDT 2018
blit,c64,gb*: fix phaser coolant leak during resize
--- a/sys/src/games/blit/blit.c
+++ b/sys/src/games/blit/blit.c
@@ -38,12 +38,8 @@
picr.max.y += screen->r.min.y - picr.min.y;
picr.min.y = screen->r.min.y;
}
- if(tmp != nil) freeimage(tmp);
+ freeimage(tmp);
tmp = allocimage(display, Rect(0, 0, scale * SX, scale > 1 ? 1 : scale * SY), CHAN1(CMap, 1), scale > 1, 0);
- if(bg != nil) freeimage(bg);
- bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
- colbg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, colbgv);
- colfg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, colfgv);
draw(screen, screen->r, bg, nil, ZP);
updated = Rect(0, 0, SX, SY);
}
@@ -207,7 +203,10 @@
meminit();
if(initdraw(nil, nil, nil) < 0)
sysfatal("initdraw: %r");
-
+
+ bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
+ colbg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, colbgv);
+ colfg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, colfgv);
screeninit();
proccreate(keyproc, nil, mainstacksize);
mc = initmouse(nil, screen);
--- a/sys/src/games/c64/c64.c
+++ b/sys/src/games/c64/c64.c
@@ -221,9 +221,8 @@
p.y += pich*scale*3/4;
q = Pt(Dx(screen->r) * 2/5, 8);
progr = (Rectangle){subpt(p, q), addpt(p, q)};
+ freeimage(tmp);
tmp = allocimage(display, Rect(0, 0, picw*scale, scale > 1 ? 1 : pich), XRGB32, 1, 0);
- bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
- red = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xFF0000FF);
draw(screen, screen->r, bg, nil, ZP);
}
@@ -279,6 +278,8 @@
mc = initmouse(nil, screen);
if(mc == nil)
sysfatal("initmouse: %r");
+ bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
+ red = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xFF0000FF);
screeninit();
proccreate(keyproc, nil, mainstacksize);
--- a/sys/src/games/gb/gb.c
+++ b/sys/src/games/gb/gb.c
@@ -210,8 +210,8 @@
p = divpt(addpt(screen->r.min, screen->r.max), 2);
picr = (Rectangle){subpt(p, Pt(scale * PICW/2, scale * PICH/2)), addpt(p, Pt(scale * PICW/2, scale * PICH/2))};
+ freeimage(tmp);
tmp = allocimage(display, Rect(0, 0, scale * PICW, scale > 1 ? 1 : scale * PICH), XRGB32, scale > 1, 0);
- bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
draw(screen, screen->r, bg, nil, ZP);
}
@@ -467,6 +467,7 @@
if(mc == nil)
sysfatal("initmouse: %r");
proccreate(keyproc, nil, mainstacksize);
+ bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
screeninit();
eventinit();
--- a/sys/src/games/gba/gba.c
+++ b/sys/src/games/gba/gba.c
@@ -218,8 +218,8 @@
p = divpt(addpt(screen->r.min, screen->r.max), 2);
picr = (Rectangle){subpt(p, Pt(scale * 120, scale * 80)), addpt(p, Pt(scale * 120, scale * 80))};
+ freeimage(tmp);
tmp = allocimage(display, Rect(0, 0, scale * 240, scale > 1 ? 1 : scale * 160), CHAN4(CIgnore, 1, CBlue, 5, CGreen, 5, CRed, 5), scale > 1, 0);
- bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
draw(screen, screen->r, bg, nil, ZP);
}
@@ -443,6 +443,7 @@
if(mc == nil)
sysfatal("initmouse: %r");
proccreate(keyproc, nil, mainstacksize);
+ bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
screeninit();
eventinit();