diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-10-25 12:18:21 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-10-25 12:18:21 +0000 |
commit | 0952848368e403f81541e222f941ec46b0e583a4 (patch) | |
tree | 366bb0b3a471f403049a224ea8222fa4f040ad5e | |
parent | 462f012d179baa382e7983b479c08b9ad73659af (diff) | |
download | rockbox-0952848368e403f81541e222f941ec46b0e583a4.tar.gz rockbox-0952848368e403f81541e222f941ec46b0e583a4.zip |
reduce ramusage slightly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28355 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/icon.c | 63 |
1 files changed, 27 insertions, 36 deletions
diff --git a/apps/gui/icon.c b/apps/gui/icon.c index b0e1ba9ce0..d12447b79a 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c | |||
@@ -52,25 +52,19 @@ | |||
52 | /* We dont actually do anything with these pointers, | 52 | /* We dont actually do anything with these pointers, |
53 | but they need to be grouped like this to save code | 53 | but they need to be grouped like this to save code |
54 | so storing them as void* is ok. (stops compile warning) */ | 54 | so storing them as void* is ok. (stops compile warning) */ |
55 | static const void * inbuilt_icons[NB_SCREENS] = { | 55 | static const struct bitmap inbuilt_iconset[NB_SCREENS] = |
56 | (void*)default_icons | 56 | { |
57 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) | 57 | { |
58 | , (void*)remote_default_icons | 58 | .width = BMPWIDTH_default_icons, |
59 | #endif | 59 | .height = BMPHEIGHT_default_icons, |
60 | }; | 60 | .data = (unsigned char*)default_icons, |
61 | 61 | }, | |
62 | static const int default_width[NB_SCREENS] = { | ||
63 | BMPWIDTH_default_icons | ||
64 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) | ||
65 | , BMPWIDTH_remote_default_icons | ||
66 | #endif | ||
67 | }; | ||
68 | |||
69 | /* height of whole file */ | ||
70 | static const int default_height[NB_SCREENS] = { | ||
71 | BMPHEIGHT_default_icons | ||
72 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) | 62 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) |
73 | , BMPHEIGHT_remote_default_icons | 63 | { |
64 | .width = BMPWIDTH_remote_default_icons, | ||
65 | .height = BMPHEIGHT_remote_default_icons, | ||
66 | .data = (unsigned char*)remote_default_icons, | ||
67 | }, | ||
74 | #endif | 68 | #endif |
75 | }; | 69 | }; |
76 | 70 | ||
@@ -86,14 +80,12 @@ static struct bitmap viewer_iconset[NB_SCREENS]; | |||
86 | 80 | ||
87 | 81 | ||
88 | #define ICON_HEIGHT(screen) (!custom_icons_loaded[screen]? \ | 82 | #define ICON_HEIGHT(screen) (!custom_icons_loaded[screen]? \ |
89 | default_height[screen] : \ | 83 | inbuilt_iconset : user_iconset)[screen].height \ |
90 | user_iconset[screen].height) \ | ||
91 | / Icon_Last_Themeable | 84 | / Icon_Last_Themeable |
92 | 85 | ||
93 | #define ICON_WIDTH(screen) (!custom_icons_loaded[screen]? \ | 86 | #define ICON_WIDTH(screen) (!custom_icons_loaded[screen]? \ |
94 | default_width[screen] : \ | 87 | inbuilt_iconset : user_iconset)[screen].width |
95 | user_iconset[screen].width) | 88 | |
96 | |||
97 | /* x,y in letters, not pixles */ | 89 | /* x,y in letters, not pixles */ |
98 | void screen_put_icon(struct screen * display, | 90 | void screen_put_icon(struct screen * display, |
99 | int x, int y, enum themable_icons icon) | 91 | int x, int y, enum themable_icons icon) |
@@ -105,15 +97,17 @@ void screen_put_icon_with_offset(struct screen * display, | |||
105 | int x, int y, int off_x, int off_y, | 97 | int x, int y, int off_x, int off_y, |
106 | enum themable_icons icon) | 98 | enum themable_icons icon) |
107 | { | 99 | { |
100 | const int screen = display->screen_type; | ||
101 | const int icon_width = ICON_WIDTH(screen); | ||
102 | const int icon_height = ICON_HEIGHT(screen); | ||
108 | int xpos, ypos; | 103 | int xpos, ypos; |
109 | int width, height; | 104 | int width, height; |
110 | int screen = display->screen_type; | ||
111 | display->getstringsize((unsigned char *)"M", &width, &height); | 105 | display->getstringsize((unsigned char *)"M", &width, &height); |
112 | xpos = x*ICON_WIDTH(screen) + off_x; | 106 | xpos = x*icon_width + off_x; |
113 | ypos = y*height + off_y; | 107 | ypos = y*height + off_y; |
114 | 108 | ||
115 | if ( height > ICON_HEIGHT(screen) )/* center the cursor */ | 109 | if ( height > icon_height )/* center the cursor */ |
116 | ypos += (height - ICON_HEIGHT(screen)) / 2; | 110 | ypos += (height - icon_height) / 2; |
117 | screen_put_iconxy(display, xpos, ypos, icon); | 111 | screen_put_iconxy(display, xpos, ypos, icon); |
118 | } | 112 | } |
119 | 113 | ||
@@ -148,21 +142,18 @@ void screen_put_iconxy(struct screen * display, | |||
148 | screen_put_iconxy(display, xpos, ypos, Icon_Questionmark); | 142 | screen_put_iconxy(display, xpos, ypos, Icon_Questionmark); |
149 | return; | 143 | return; |
150 | } | 144 | } |
151 | data = iconset->data; | ||
152 | stride = STRIDE(display->screen_type, iconset->width, iconset->height); | ||
153 | } | 145 | } |
154 | else if (custom_icons_loaded[screen]) | 146 | else if (custom_icons_loaded[screen]) |
155 | { | 147 | { |
156 | iconset = &user_iconset[screen]; | 148 | iconset = &user_iconset[screen]; |
157 | data = iconset->data; | ||
158 | stride = STRIDE(display->screen_type, iconset->width, iconset->height); | ||
159 | } | 149 | } |
160 | else | 150 | else |
161 | { | 151 | { |
162 | data = inbuilt_icons[screen]; | 152 | iconset = &inbuilt_iconset[screen]; |
163 | stride = STRIDE( display->screen_type, BMPWIDTH_default_icons, | ||
164 | BMPHEIGHT_default_icons); | ||
165 | } | 153 | } |
154 | data = iconset->data; | ||
155 | stride = STRIDE(display->screen_type, iconset->width, iconset->height); | ||
156 | |||
166 | /* add some left padding to the icons if they are on the edge */ | 157 | /* add some left padding to the icons if they are on the edge */ |
167 | if (xpos == 0) | 158 | if (xpos == 0) |
168 | xpos++; | 159 | xpos++; |
@@ -187,8 +178,8 @@ void screen_put_cursorxy(struct screen * display, int x, int y, bool on) | |||
187 | #else | 178 | #else |
188 | screen_put_icon(display, x, y, on?CURSOR_CHAR:-1); | 179 | screen_put_icon(display, x, y, on?CURSOR_CHAR:-1); |
189 | #endif | 180 | #endif |
190 | |||
191 | } | 181 | } |
182 | |||
192 | enum Iconset { | 183 | enum Iconset { |
193 | Iconset_Mainscreen, | 184 | Iconset_Mainscreen, |
194 | Iconset_Mainscreen_viewers, | 185 | Iconset_Mainscreen_viewers, |