diff options
author | Tomer Shalev <shalev.tomer@gmail.com> | 2009-11-28 17:07:57 +0000 |
---|---|---|
committer | Tomer Shalev <shalev.tomer@gmail.com> | 2009-11-28 17:07:57 +0000 |
commit | c2617dc4ed76eceaefd4ca39c0159498eb5e9762 (patch) | |
tree | 72ba77525fae0b356e6976175ddfe114d5a12c02 /firmware/drivers/lcd-bitmap-common.c | |
parent | c074c76211621ab15518649a4a835aeb5798bf29 (diff) | |
download | rockbox-c2617dc4ed76eceaefd4ca39c0159498eb5e9762.tar.gz rockbox-c2617dc4ed76eceaefd4ca39c0159498eb5e9762.zip |
Diacritic display enhancements
- Use the fact that unicode code currently does not support chars above 0xffff
(see utf8decode()), and change diacritic database's char code type to
unsigned short from int. Also comment out database entries above unsupported
range.
- Use const when possible.
- Iterate over buffer using the buffer's pointer, thus avoiding usage of some
variables, and avoiding multiple access to the same array item.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23776 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd-bitmap-common.c')
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 4a711d5378..78ceb848d5 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c | |||
@@ -83,11 +83,10 @@ static void lcd_gradient_rect(int x1, int x2, int y, unsigned h, | |||
83 | /* put a string at a given pixel position, skipping first ofs pixel columns */ | 83 | /* put a string at a given pixel position, skipping first ofs pixel columns */ |
84 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | 84 | static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) |
85 | { | 85 | { |
86 | unsigned short ch, *ucs; | 86 | unsigned short *ucs; |
87 | struct font* pf = font_get(current_vp->font); | 87 | struct font* pf = font_get(current_vp->font); |
88 | int vp_flags = current_vp->flags; | 88 | int vp_flags = current_vp->flags; |
89 | unsigned i; | 89 | int rtl_next_non_diac_width, last_non_diacritic_width; |
90 | static int rtl_next_non_diacritic_width, last_non_diacritic_width; | ||
91 | 90 | ||
92 | if ((vp_flags & VP_FLAG_ALIGNMENT_MASK) != 0) | 91 | if ((vp_flags & VP_FLAG_ALIGNMENT_MASK) != 0) |
93 | { | 92 | { |
@@ -109,25 +108,23 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | |||
109 | } | 108 | } |
110 | } | 109 | } |
111 | 110 | ||
112 | ucs = bidi_l2v(str, 1); | 111 | rtl_next_non_diac_width = 0; |
113 | |||
114 | rtl_next_non_diacritic_width = 0; | ||
115 | last_non_diacritic_width = 0; | 112 | last_non_diacritic_width = 0; |
116 | /* Mark diacritic and rtl flags for each character */ | 113 | /* Mark diacritic and rtl flags for each character */ |
117 | for (i = 0; i < SCROLL_LINE_SIZE && (ch = ucs[i]); i++) | 114 | for (ucs = bidi_l2v(str, 1); *ucs; ucs++) |
118 | { | 115 | { |
119 | bool is_rtl, is_diac; | 116 | bool is_rtl, is_diac; |
120 | const unsigned char *bits; | 117 | const unsigned char *bits; |
121 | int width, base_width, drawmode = 0, base_ofs = 0; | 118 | int width, base_width, drawmode = 0, base_ofs = 0; |
122 | unsigned short next_ch = ucs[i + 1]; | 119 | const unsigned short next_ch = ucs[1]; |
123 | 120 | ||
124 | if (x >= current_vp->width) | 121 | if (x >= current_vp->width) |
125 | break; | 122 | break; |
126 | 123 | ||
127 | is_diac = is_diacritic(ch, &is_rtl); | 124 | is_diac = is_diacritic(*ucs, &is_rtl); |
128 | 125 | ||
129 | /* Get proportional width and glyph bits */ | 126 | /* Get proportional width and glyph bits */ |
130 | width = font_get_width(pf, ch); | 127 | width = font_get_width(pf, *ucs); |
131 | 128 | ||
132 | /* Calculate base width */ | 129 | /* Calculate base width */ |
133 | if (is_rtl) | 130 | if (is_rtl) |
@@ -135,20 +132,20 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | |||
135 | /* Forward-seek the next non-diacritic character for base width */ | 132 | /* Forward-seek the next non-diacritic character for base width */ |
136 | if (is_diac) | 133 | if (is_diac) |
137 | { | 134 | { |
138 | if (!rtl_next_non_diacritic_width) | 135 | if (!rtl_next_non_diac_width) |
139 | { | 136 | { |
140 | unsigned j; | 137 | const unsigned short *u; |
141 | 138 | ||
142 | /* Jump to next non-diacritic char, and calc its width */ | 139 | /* Jump to next non-diacritic char, and calc its width */ |
143 | for (j = i + 1; ucs[j] && is_diacritic(ucs[j], NULL); j++); | 140 | for (u = &ucs[1]; *u && is_diacritic(*u, NULL); u++); |
144 | rtl_next_non_diacritic_width = ucs[j] ? | 141 | |
145 | font_get_width(pf, ucs[j]) : 0; | 142 | rtl_next_non_diac_width = *u ? font_get_width(pf, *u) : 0; |
146 | } | 143 | } |
147 | base_width = rtl_next_non_diacritic_width; | 144 | base_width = rtl_next_non_diac_width; |
148 | } | 145 | } |
149 | else | 146 | else |
150 | { | 147 | { |
151 | rtl_next_non_diacritic_width = 0; /* Mark */ | 148 | rtl_next_non_diac_width = 0; /* Mark */ |
152 | base_width = width; | 149 | base_width = width; |
153 | } | 150 | } |
154 | } | 151 | } |
@@ -188,7 +185,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) | |||
188 | base_ofs = (base_width - width) / 2; | 185 | base_ofs = (base_width - width) / 2; |
189 | } | 186 | } |
190 | 187 | ||
191 | bits = font_get_bits(pf, ch); | 188 | bits = font_get_bits(pf, *ucs); |
192 | LCDFN(mono_bitmap_part)(bits, ofs, 0, width, MAX(x + base_ofs, 0), y, | 189 | LCDFN(mono_bitmap_part)(bits, ofs, 0, width, MAX(x + base_ofs, 0), y, |
193 | width - ofs, pf->height); | 190 | width - ofs, pf->height); |
194 | 191 | ||