Chameleon

View gui.diff

1diff -rupN trunk/i386/boot2/gui.c trunk_guerrero/i386/boot2/gui.c
2--- trunk/i386/boot2/gui.c2011-09-02 05:32:56.000000000 +0200
3+++ trunk_guerrero/i386/boot2/gui.c2011-09-07 16:29:02.000000000 +0200
4@@ -166,6 +166,7 @@ menuitem_t infoMenuItems[] =
5 };
6
7 int initFont(font_t *font, image_t *image);
8+int destroyFont(font_t *font);
9 void colorFont(font_t *font, uint32_t color);
10 void makeRoundedCorners(pixmap_t *p);
11
12@@ -364,6 +365,25 @@ static int loadGraphics(void)
13 return 0;
14 }
15
16+static int unloadGraphics(void)
17+{
18+ int i;
19+
20+ destroyFont(&font_console);
21+ destroyFont(&font_small);
22+
23+for (i = 0; i < sizeof(images) / sizeof(images[0]); i++)
24+{
25+ if (images[i].image)
26+ {
27+ if (images[i].image->pixels) free(images[i].image->pixels);
28+ free (images[i].image);
29+ images[i].image = 0;
30+ }
31+}
32+return 0;
33+}
34+
35 pixmap_t *getCroppedPixmapAtPosition( pixmap_t *from, position_t pos, uint16_t width, uint16_t height )
36 {
37
38@@ -410,6 +430,19 @@ int createBackBuffer( window_t *window )
39 return 0;
40 }
41
42+int freeBackBuffer( window_t *window )
43+{
44+if (gui.backbuffer && gui.backbuffer->pixels)
45+ {
46+free(gui.backbuffer->pixels);
47+free(gui.backbuffer);
48+gui.backbuffer = 0;
49+return 0;
50+}
51+
52+return 1;
53+}
54+
55 int createWindowBuffer( window_t *window )
56 {
57 window->pixmap = malloc(sizeof(pixmap_t));
58@@ -758,6 +791,14 @@ int initGUI(void)
59 }
60 }
61 }
62+// not available memory, freeing resources
63+freeWindowBuffer(&gui.menu);
64+freeWindowBuffer(&gui.infobox);
65+freeWindowBuffer(&gui.bootprompt);
66+freeWindowBuffer(&gui.devicelist);
67+freeWindowBuffer(&gui.screen);
68+freeBackBuffer(&gui.screen);
69+unloadGraphics();
70 return 1;
71 }
72
73@@ -1428,6 +1469,21 @@ int initFont(font_t *font, image_t *data
74 return 0;
75 }
76
77+int destroyFont(font_t *font)
78+{
79+int i;
80+ for (i = 0; i < CHARACTERS_COUNT; i++)
81+ {
82+if (font->chars[i])
83+{
84+if (font->chars[i]->pixels) free (font->chars[i]->pixels);
85+free (font->chars[i]);
86+font->chars[i] = 0;
87+}
88+ }
89+ return 0;
90+}
91+
92 void colorFont(font_t *font, uint32_t color)
93 {
94 if( !color )
95

Archive Download this file

Attachment to issue 178

Created: 8 years 3 months ago by J Guerrero