@samitouri / QOSamiQemu / commits / 1c0f729127

ati-vga: Simplify hw cursor drawing

Avoid calculating index at every step when we can just count the position. Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Reviewed-by: Chad Jablonski <chad@jablonski.xyz> Message-ID: <90b49357b6bf80bcf8962331575ffd16a96b706a.1773009887.git.balaton@eik.bme.hu> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

BALATON Zoltan committed Mar 8, 2026 at 23:49 UTC 1c0f729127f39dbcbdbc812b3c7465104c2a6fcf
1 file changed +5 -5
hw/display/ati.c
+5 -5
@@ -198,7 +198,7 @@ static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y)
198 ATIVGAState *s = container_of(vga, ATIVGAState, vga);
199 uint32_t srcoff;
200 uint32_t *dp = (uint32_t *)d;
201 - int i, j, h;
201 + int i, j, h, idx = 0;
202
203 if (!(s->regs.crtc_gen_cntl & CRTC2_CUR_EN) ||
204 scr_y < vga->hw_cursor_y || scr_y >= vga->hw_cursor_y + 64 ||
@@ -213,10 +213,10 @@ static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y)
213 uint32_t color;
214 uint8_t abits = vga_read_byte(vga, srcoff + i);
215 uint8_t xbits = vga_read_byte(vga, srcoff + i + 8);
216 - for (j = 0; j < 8; j++, abits <<= 1, xbits <<= 1) {
216 + for (j = 0; j < 8; j++, abits <<= 1, xbits <<= 1, idx++) {
217 if (abits & BIT(7)) {
218 if (xbits & BIT(7)) {
219 - color = dp[i * 8 + j] ^ 0xffffffff; /* complement */
219 + color = dp[idx] ^ 0xffffffff; /* complement */
220 } else {
221 continue; /* transparent, no change */
222 }
@@ -224,10 +224,10 @@ static void ati_cursor_draw_line(VGACommonState *vga, uint8_t *d, int scr_y)
224 color = (xbits & BIT(7) ? s->regs.cur_color1 :
225 s->regs.cur_color0) | 0xff000000;
226 }
227 - if (vga->hw_cursor_x + i * 8 + j >= h) {
227 + if (vga->hw_cursor_x + idx >= h) {
228 return; /* end of screen, don't span to next line */
229 }
230 - dp[i * 8 + j] = color;
230 + dp[idx] = color;
231 }
232 }
233 }