thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
12e206
From 83143be104bdf9d750078d4331c53c66581f7b26 Mon Sep 17 00:00:00 2001
12e206
From: Gerd Hoffmann <kraxel@redhat.com>
12e206
Date: Thu, 5 Oct 2017 14:51:16 +0200
12e206
Subject: [PATCH 04/11] vga: Remove remainder of old conversion cruft
12e206
12e206
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
12e206
Message-id: <20171005145119.15277-5-kraxel@redhat.com>
12e206
Patchwork-id: 76826
12e206
O-Subject: [RHEL-7.5 qemu-kvm PATCH 4/7] vga: Remove remainder of old conversion cruft
12e206
Bugzilla: 1501294
12e206
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
12e206
RH-Acked-by: Thomas Huth <thuth@redhat.com>
12e206
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
12e206
12e206
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12e206
12e206
All the macros used to generate different versions of vga_template.h
12e206
are now unnecessary, take them all out and remove the _32 suffix from
12e206
most functions.
12e206
12e206
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
12e206
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
12e206
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
12e206
(cherry picked from commit d2e043a804141ec0a896270d25d6ae370c473ddd)
12e206
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
12e206
---
12e206
 hw/display/vga.c          |  46 +++++-----
12e206
 hw/display/vga_template.h | 227 +++++++++++++++-------------------------------
12e206
 2 files changed, 95 insertions(+), 178 deletions(-)
12e206
12e206
diff --git a/hw/display/vga.c b/hw/display/vga.c
12e206
index dab75a3..1a292a9 100644
12e206
--- a/hw/display/vga.c
12e206
+++ b/hw/display/vga.c
12e206
@@ -1047,10 +1047,8 @@ void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val)
12e206
 typedef void vga_draw_line_func(VGACommonState *s1, uint8_t *d,
12e206
                                 const uint8_t *s, int width);
12e206
 
12e206
-#define DEPTH 32
12e206
 #include "vga_template.h"
12e206
 
12e206
-
12e206
 static unsigned int rgb_to_pixel32_dup(unsigned int r, unsigned int g, unsigned b)
12e206
 {
12e206
     unsigned int col;
12e206
@@ -1349,19 +1347,19 @@ static void vga_draw_text(VGACommonState *s, int full_update)
12e206
                 bgcol = palette[cattr >> 4];
12e206
                 fgcol = palette[cattr & 0x0f];
12e206
                 if (cw == 16) {
12e206
-                    vga_draw_glyph16_32(d1, linesize,
12e206
-                                        font_ptr, cheight, fgcol, bgcol);
12e206
+                    vga_draw_glyph16(d1, linesize,
12e206
+                                     font_ptr, cheight, fgcol, bgcol);
12e206
                 } else if (cw != 9) {
12e206
-                    vga_draw_glyph8_32(d1, linesize,
12e206
-                                       font_ptr, cheight, fgcol, bgcol);
12e206
+                    vga_draw_glyph8(d1, linesize,
12e206
+                                    font_ptr, cheight, fgcol, bgcol);
12e206
                 } else {
12e206
                     dup9 = 0;
12e206
                     if (ch >= 0xb0 && ch <= 0xdf &&
12e206
                         (s->ar[VGA_ATC_MODE] & 0x04)) {
12e206
                         dup9 = 1;
12e206
                     }
12e206
-                    vga_draw_glyph9_32(d1, linesize,
12e206
-                                       font_ptr, cheight, fgcol, bgcol, dup9);
12e206
+                    vga_draw_glyph9(d1, linesize,
12e206
+                                    font_ptr, cheight, fgcol, bgcol, dup9);
12e206
                 }
12e206
                 if (src == cursor_ptr &&
12e206
                     !(s->cr[VGA_CRTC_CURSOR_START] & 0x20) &&
12e206
@@ -1377,14 +1375,14 @@ static void vga_draw_text(VGACommonState *s, int full_update)
12e206
                         h = line_last - line_start + 1;
12e206
                         d = d1 + linesize * line_start;
12e206
                         if (cw == 16) {
12e206
-                            vga_draw_glyph16_32(d, linesize,
12e206
-                                               cursor_glyph, h, fgcol, bgcol);
12e206
+                            vga_draw_glyph16(d, linesize,
12e206
+                                             cursor_glyph, h, fgcol, bgcol);
12e206
                         } else if (cw != 9) {
12e206
-                            vga_draw_glyph8_32(d, linesize,
12e206
-                                              cursor_glyph, h, fgcol, bgcol);
12e206
+                            vga_draw_glyph8(d, linesize,
12e206
+                                            cursor_glyph, h, fgcol, bgcol);
12e206
                         } else {
12e206
-                            vga_draw_glyph9_32(d, linesize,
12e206
-                                              cursor_glyph, h, fgcol, bgcol, 1);
12e206
+                            vga_draw_glyph9(d, linesize,
12e206
+                                            cursor_glyph, h, fgcol, bgcol, 1);
12e206
                         }
12e206
                     }
12e206
                 }
12e206
@@ -1422,16 +1420,16 @@ enum {
12e206
 };
12e206
 
12e206
 static vga_draw_line_func * const vga_draw_line_table[VGA_DRAW_LINE_NB] = {
12e206
-    vga_draw_line2_32,
12e206
-    vga_draw_line2d2_32,
12e206
-    vga_draw_line4_32,
12e206
-    vga_draw_line4d2_32,
12e206
-    vga_draw_line8d2_32,
12e206
-    vga_draw_line8_32,
12e206
-    vga_draw_line15_32,
12e206
-    vga_draw_line16_32,
12e206
-    vga_draw_line24_32,
12e206
-    vga_draw_line32_32,
12e206
+    vga_draw_line2,
12e206
+    vga_draw_line2d2,
12e206
+    vga_draw_line4,
12e206
+    vga_draw_line4d2,
12e206
+    vga_draw_line8d2,
12e206
+    vga_draw_line8,
12e206
+    vga_draw_line15,
12e206
+    vga_draw_line16,
12e206
+    vga_draw_line24,
12e206
+    vga_draw_line32,
12e206
 };
12e206
 
12e206
 static int vga_get_bpp(VGACommonState *s)
12e206
diff --git a/hw/display/vga_template.h b/hw/display/vga_template.h
12e206
index 90ec9c2..0660b52 100644
12e206
--- a/hw/display/vga_template.h
12e206
+++ b/hw/display/vga_template.h
12e206
@@ -22,41 +22,9 @@
12e206
  * THE SOFTWARE.
12e206
  */
12e206
 
12e206
-#if DEPTH == 8
12e206
-#define BPP 1
12e206
-#define PIXEL_TYPE uint8_t
12e206
-#elif DEPTH == 15 || DEPTH == 16
12e206
-#define BPP 2
12e206
-#define PIXEL_TYPE uint16_t
12e206
-#elif DEPTH == 32
12e206
-#define BPP 4
12e206
-#define PIXEL_TYPE uint32_t
12e206
-#else
12e206
-#error unsupport depth
12e206
-#endif
12e206
-
12e206
-#ifdef BGR_FORMAT
12e206
-#define PIXEL_NAME glue(DEPTH, bgr)
12e206
-#else
12e206
-#define PIXEL_NAME DEPTH
12e206
-#endif /* BGR_FORMAT */
12e206
-
12e206
-#if DEPTH != 15 && !defined(BGR_FORMAT)
12e206
-
12e206
-static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d,
12e206
-                                                     uint32_t font_data,
12e206
-                                                     uint32_t xorcol,
12e206
-                                                     uint32_t bgcol)
12e206
+static inline void vga_draw_glyph_line(uint8_t *d, uint32_t font_data,
12e206
+                                       uint32_t xorcol, uint32_t bgcol)
12e206
 {
12e206
-#if BPP == 1
12e206
-        ((uint32_t *)d)[0] = (dmask16[(font_data >> 4)] & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[1] = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol;
12e206
-#elif BPP == 2
12e206
-        ((uint32_t *)d)[0] = (dmask4[(font_data >> 6)] & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[1] = (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[2] = (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol;
12e206
-        ((uint32_t *)d)[3] = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol;
12e206
-#else
12e206
         ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
12e206
         ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
12e206
         ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
12e206
@@ -65,25 +33,24 @@ static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d,
12e206
         ((uint32_t *)d)[5] = (-((font_data >> 2) & 1) & xorcol) ^ bgcol;
12e206
         ((uint32_t *)d)[6] = (-((font_data >> 1) & 1) & xorcol) ^ bgcol;
12e206
         ((uint32_t *)d)[7] = (-((font_data >> 0) & 1) & xorcol) ^ bgcol;
12e206
-#endif
12e206
 }
12e206
 
12e206
-static void glue(vga_draw_glyph8_, DEPTH)(uint8_t *d, int linesize,
12e206
-                                          const uint8_t *font_ptr, int h,
12e206
-                                          uint32_t fgcol, uint32_t bgcol)
12e206
+static void vga_draw_glyph8(uint8_t *d, int linesize,
12e206
+                            const uint8_t *font_ptr, int h,
12e206
+                            uint32_t fgcol, uint32_t bgcol)
12e206
 {
12e206
     uint32_t font_data, xorcol;
12e206
 
12e206
     xorcol = bgcol ^ fgcol;
12e206
     do {
12e206
         font_data = font_ptr[0];
12e206
-        glue(vga_draw_glyph_line_, DEPTH)(d, font_data, xorcol, bgcol);
12e206
+        vga_draw_glyph_line(d, font_data, xorcol, bgcol);
12e206
         font_ptr += 4;
12e206
         d += linesize;
12e206
     } while (--h);
12e206
 }
12e206
 
12e206
-static void glue(vga_draw_glyph16_, DEPTH)(uint8_t *d, int linesize,
12e206
+static void vga_draw_glyph16(uint8_t *d, int linesize,
12e206
                                           const uint8_t *font_ptr, int h,
12e206
                                           uint32_t fgcol, uint32_t bgcol)
12e206
 {
12e206
@@ -92,48 +59,24 @@ static void glue(vga_draw_glyph16_, DEPTH)(uint8_t *d, int linesize,
12e206
     xorcol = bgcol ^ fgcol;
12e206
     do {
12e206
         font_data = font_ptr[0];
12e206
-        glue(vga_draw_glyph_line_, DEPTH)(d,
12e206
-                                          expand4to8[font_data >> 4],
12e206
-                                          xorcol, bgcol);
12e206
-        glue(vga_draw_glyph_line_, DEPTH)(d + 8 * BPP,
12e206
-                                          expand4to8[font_data & 0x0f],
12e206
-                                          xorcol, bgcol);
12e206
+        vga_draw_glyph_line(d, expand4to8[font_data >> 4],
12e206
+                            xorcol, bgcol);
12e206
+        vga_draw_glyph_line(d + 32, expand4to8[font_data & 0x0f],
12e206
+                            xorcol, bgcol);
12e206
         font_ptr += 4;
12e206
         d += linesize;
12e206
     } while (--h);
12e206
 }
12e206
 
12e206
-static void glue(vga_draw_glyph9_, DEPTH)(uint8_t *d, int linesize,
12e206
-                                          const uint8_t *font_ptr, int h,
12e206
-                                          uint32_t fgcol, uint32_t bgcol, int dup9)
12e206
+static void vga_draw_glyph9(uint8_t *d, int linesize,
12e206
+                            const uint8_t *font_ptr, int h,
12e206
+                            uint32_t fgcol, uint32_t bgcol, int dup9)
12e206
 {
12e206
     uint32_t font_data, xorcol, v;
12e206
 
12e206
     xorcol = bgcol ^ fgcol;
12e206
     do {
12e206
         font_data = font_ptr[0];
12e206
-#if BPP == 1
12e206
-        stl_p((uint32_t *)d, (dmask16[(font_data >> 4)] & xorcol) ^ bgcol);
12e206
-        v = (dmask16[(font_data >> 0) & 0xf] & xorcol) ^ bgcol;
12e206
-        stl_p(((uint32_t *)d)+1, v);
12e206
-        if (dup9)
12e206
-            ((uint8_t *)d)[8] = v >> (24 * (1 - BIG));
12e206
-        else
12e206
-            ((uint8_t *)d)[8] = bgcol;
12e206
-
12e206
-#elif BPP == 2
12e206
-        stl_p(((uint32_t *)d)+0, (dmask4[(font_data >> 6)] & xorcol) ^ bgcol);
12e206
-        stl_p(((uint32_t *)d)+1,
12e206
-              (dmask4[(font_data >> 4) & 3] & xorcol) ^ bgcol);
12e206
-        stl_p(((uint32_t *)d)+2,
12e206
-              (dmask4[(font_data >> 2) & 3] & xorcol) ^ bgcol);
12e206
-        v = (dmask4[(font_data >> 0) & 3] & xorcol) ^ bgcol;
12e206
-        stl_p(((uint32_t *)d)+3, v);
12e206
-        if (dup9)
12e206
-            ((uint16_t *)d)[8] = v >> (16 * (1 - BIG));
12e206
-        else
12e206
-            ((uint16_t *)d)[8] = bgcol;
12e206
-#else
12e206
         ((uint32_t *)d)[0] = (-((font_data >> 7)) & xorcol) ^ bgcol;
12e206
         ((uint32_t *)d)[1] = (-((font_data >> 6) & 1) & xorcol) ^ bgcol;
12e206
         ((uint32_t *)d)[2] = (-((font_data >> 5) & 1) & xorcol) ^ bgcol;
12e206
@@ -147,7 +90,6 @@ static void glue(vga_draw_glyph9_, DEPTH)(uint8_t *d, int linesize,
12e206
             ((uint32_t *)d)[8] = v;
12e206
         else
12e206
             ((uint32_t *)d)[8] = bgcol;
12e206
-#endif
12e206
         font_ptr += 4;
12e206
         d += linesize;
12e206
     } while (--h);
12e206
@@ -156,8 +98,8 @@ static void glue(vga_draw_glyph9_, DEPTH)(uint8_t *d, int linesize,
12e206
 /*
12e206
  * 4 color mode
12e206
  */
12e206
-static void glue(vga_draw_line2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
-                                         const uint8_t *s, int width)
12e206
+static void vga_draw_line2(VGACommonState *s1, uint8_t *d,
12e206
+                           const uint8_t *s, int width)
12e206
 {
12e206
     uint32_t plane_mask, *palette, data, v;
12e206
     int x;
12e206
@@ -170,36 +112,30 @@ static void glue(vga_draw_line2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
         data &= plane_mask;
12e206
         v = expand2[GET_PLANE(data, 0)];
12e206
         v |= expand2[GET_PLANE(data, 2)] << 2;
12e206
-        ((PIXEL_TYPE *)d)[0] = palette[v >> 12];
12e206
-        ((PIXEL_TYPE *)d)[1] = palette[(v >> 8) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[2] = palette[(v >> 4) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[3] = palette[(v >> 0) & 0xf];
12e206
+        ((uint32_t *)d)[0] = palette[v >> 12];
12e206
+        ((uint32_t *)d)[1] = palette[(v >> 8) & 0xf];
12e206
+        ((uint32_t *)d)[2] = palette[(v >> 4) & 0xf];
12e206
+        ((uint32_t *)d)[3] = palette[(v >> 0) & 0xf];
12e206
 
12e206
         v = expand2[GET_PLANE(data, 1)];
12e206
         v |= expand2[GET_PLANE(data, 3)] << 2;
12e206
-        ((PIXEL_TYPE *)d)[4] = palette[v >> 12];
12e206
-        ((PIXEL_TYPE *)d)[5] = palette[(v >> 8) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[6] = palette[(v >> 4) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[7] = palette[(v >> 0) & 0xf];
12e206
-        d += BPP * 8;
12e206
+        ((uint32_t *)d)[4] = palette[v >> 12];
12e206
+        ((uint32_t *)d)[5] = palette[(v >> 8) & 0xf];
12e206
+        ((uint32_t *)d)[6] = palette[(v >> 4) & 0xf];
12e206
+        ((uint32_t *)d)[7] = palette[(v >> 0) & 0xf];
12e206
+        d += 32;
12e206
         s += 4;
12e206
     }
12e206
 }
12e206
 
12e206
-#if BPP == 1
12e206
-#define PUT_PIXEL2(d, n, v) ((uint16_t *)d)[(n)] = (v)
12e206
-#elif BPP == 2
12e206
-#define PUT_PIXEL2(d, n, v) ((uint32_t *)d)[(n)] = (v)
12e206
-#else
12e206
 #define PUT_PIXEL2(d, n, v) \
12e206
 ((uint32_t *)d)[2*(n)] = ((uint32_t *)d)[2*(n)+1] = (v)
12e206
-#endif
12e206
 
12e206
 /*
12e206
  * 4 color mode, dup2 horizontal
12e206
  */
12e206
-static void glue(vga_draw_line2d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
-                                           const uint8_t *s, int width)
12e206
+static void vga_draw_line2d2(VGACommonState *s1, uint8_t *d,
12e206
+                             const uint8_t *s, int width)
12e206
 {
12e206
     uint32_t plane_mask, *palette, data, v;
12e206
     int x;
12e206
@@ -223,7 +159,7 @@ static void glue(vga_draw_line2d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
         PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]);
12e206
         PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]);
12e206
         PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]);
12e206
-        d += BPP * 16;
12e206
+        d += 64;
12e206
         s += 4;
12e206
     }
12e206
 }
12e206
@@ -231,8 +167,8 @@ static void glue(vga_draw_line2d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
 /*
12e206
  * 16 color mode
12e206
  */
12e206
-static void glue(vga_draw_line4_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
-                                         const uint8_t *s, int width)
12e206
+static void vga_draw_line4(VGACommonState *s1, uint8_t *d,
12e206
+                           const uint8_t *s, int width)
12e206
 {
12e206
     uint32_t plane_mask, data, v, *palette;
12e206
     int x;
12e206
@@ -247,15 +183,15 @@ static void glue(vga_draw_line4_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
         v |= expand4[GET_PLANE(data, 1)] << 1;
12e206
         v |= expand4[GET_PLANE(data, 2)] << 2;
12e206
         v |= expand4[GET_PLANE(data, 3)] << 3;
12e206
-        ((PIXEL_TYPE *)d)[0] = palette[v >> 28];
12e206
-        ((PIXEL_TYPE *)d)[1] = palette[(v >> 24) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[2] = palette[(v >> 20) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[3] = palette[(v >> 16) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[4] = palette[(v >> 12) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[5] = palette[(v >> 8) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[6] = palette[(v >> 4) & 0xf];
12e206
-        ((PIXEL_TYPE *)d)[7] = palette[(v >> 0) & 0xf];
12e206
-        d += BPP * 8;
12e206
+        ((uint32_t *)d)[0] = palette[v >> 28];
12e206
+        ((uint32_t *)d)[1] = palette[(v >> 24) & 0xf];
12e206
+        ((uint32_t *)d)[2] = palette[(v >> 20) & 0xf];
12e206
+        ((uint32_t *)d)[3] = palette[(v >> 16) & 0xf];
12e206
+        ((uint32_t *)d)[4] = palette[(v >> 12) & 0xf];
12e206
+        ((uint32_t *)d)[5] = palette[(v >> 8) & 0xf];
12e206
+        ((uint32_t *)d)[6] = palette[(v >> 4) & 0xf];
12e206
+        ((uint32_t *)d)[7] = palette[(v >> 0) & 0xf];
12e206
+        d += 32;
12e206
         s += 4;
12e206
     }
12e206
 }
12e206
@@ -263,8 +199,8 @@ static void glue(vga_draw_line4_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
 /*
12e206
  * 16 color mode, dup2 horizontal
12e206
  */
12e206
-static void glue(vga_draw_line4d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
-                                           const uint8_t *s, int width)
12e206
+static void vga_draw_line4d2(VGACommonState *s1, uint8_t *d,
12e206
+                             const uint8_t *s, int width)
12e206
 {
12e206
     uint32_t plane_mask, data, v, *palette;
12e206
     int x;
12e206
@@ -287,7 +223,7 @@ static void glue(vga_draw_line4d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
         PUT_PIXEL2(d, 5, palette[(v >> 8) & 0xf]);
12e206
         PUT_PIXEL2(d, 6, palette[(v >> 4) & 0xf]);
12e206
         PUT_PIXEL2(d, 7, palette[(v >> 0) & 0xf]);
12e206
-        d += BPP * 16;
12e206
+        d += 64;
12e206
         s += 4;
12e206
     }
12e206
 }
12e206
@@ -297,8 +233,8 @@ static void glue(vga_draw_line4d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
  *
12e206
  * XXX: add plane_mask support (never used in standard VGA modes)
12e206
  */
12e206
-static void glue(vga_draw_line8d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
-                                           const uint8_t *s, int width)
12e206
+static void vga_draw_line8d2(VGACommonState *s1, uint8_t *d,
12e206
+                             const uint8_t *s, int width)
12e206
 {
12e206
     uint32_t *palette;
12e206
     int x;
12e206
@@ -310,7 +246,7 @@ static void glue(vga_draw_line8d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
         PUT_PIXEL2(d, 1, palette[s[1]]);
12e206
         PUT_PIXEL2(d, 2, palette[s[2]]);
12e206
         PUT_PIXEL2(d, 3, palette[s[3]]);
12e206
-        d += BPP * 8;
12e206
+        d += 32;
12e206
         s += 4;
12e206
     }
12e206
 }
12e206
@@ -320,8 +256,8 @@ static void glue(vga_draw_line8d2_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
  *
12e206
  * XXX: add plane_mask support (never used in standard VGA modes)
12e206
  */
12e206
-static void glue(vga_draw_line8_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
-                                         const uint8_t *s, int width)
12e206
+static void vga_draw_line8(VGACommonState *s1, uint8_t *d,
12e206
+                           const uint8_t *s, int width)
12e206
 {
12e206
     uint32_t *palette;
12e206
     int x;
12e206
@@ -329,33 +265,28 @@ static void glue(vga_draw_line8_, DEPTH)(VGACommonState *s1, uint8_t *d,
12e206
     palette = s1->last_palette;
12e206
     width >>= 3;
12e206
     for(x = 0; x < width; x++) {
12e206
-        ((PIXEL_TYPE *)d)[0] = palette[s[0]];
12e206
-        ((PIXEL_TYPE *)d)[1] = palette[s[1]];
12e206
-        ((PIXEL_TYPE *)d)[2] = palette[s[2]];
12e206
-        ((PIXEL_TYPE *)d)[3] = palette[s[3]];
12e206
-        ((PIXEL_TYPE *)d)[4] = palette[s[4]];
12e206
-        ((PIXEL_TYPE *)d)[5] = palette[s[5]];
12e206
-        ((PIXEL_TYPE *)d)[6] = palette[s[6]];
12e206
-        ((PIXEL_TYPE *)d)[7] = palette[s[7]];
12e206
-        d += BPP * 8;
12e206
+        ((uint32_t *)d)[0] = palette[s[0]];
12e206
+        ((uint32_t *)d)[1] = palette[s[1]];
12e206
+        ((uint32_t *)d)[2] = palette[s[2]];
12e206
+        ((uint32_t *)d)[3] = palette[s[3]];
12e206
+        ((uint32_t *)d)[4] = palette[s[4]];
12e206
+        ((uint32_t *)d)[5] = palette[s[5]];
12e206
+        ((uint32_t *)d)[6] = palette[s[6]];
12e206
+        ((uint32_t *)d)[7] = palette[s[7]];
12e206
+        d += 32;
12e206
         s += 8;
12e206
     }
12e206
 }
12e206
 
12e206
-#endif /* DEPTH != 15 */
12e206
-
12e206
 
12e206
 /* XXX: optimize */
12e206
 
12e206
 /*
12e206
  * 15 bit color
12e206
  */
12e206
-static void glue(vga_draw_line15_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
12e206
-                                          const uint8_t *s, int width)
12e206
+static void vga_draw_line15(VGACommonState *s1, uint8_t *d,
12e206
+                            const uint8_t *s, int width)
12e206
 {
12e206
-#if DEPTH == 15 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
12e206
-    memcpy(d, s, width * 2);
12e206
-#else
12e206
     int w;
12e206
     uint32_t v, r, g, b;
12e206
 
12e206
@@ -365,22 +296,18 @@ static void glue(vga_draw_line15_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
12e206
         r = (v >> 7) & 0xf8;
12e206
         g = (v >> 2) & 0xf8;
12e206
         b = (v << 3) & 0xf8;
12e206
-        ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
         s += 2;
12e206
-        d += BPP;
12e206
+        d += 4;
12e206
     } while (--w != 0);
12e206
-#endif
12e206
 }
12e206
 
12e206
 /*
12e206
  * 16 bit color
12e206
  */
12e206
-static void glue(vga_draw_line16_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
12e206
-                                          const uint8_t *s, int width)
12e206
+static void vga_draw_line16(VGACommonState *s1, uint8_t *d,
12e206
+                            const uint8_t *s, int width)
12e206
 {
12e206
-#if DEPTH == 16 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
12e206
-    memcpy(d, s, width * 2);
12e206
-#else
12e206
     int w;
12e206
     uint32_t v, r, g, b;
12e206
 
12e206
@@ -390,18 +317,17 @@ static void glue(vga_draw_line16_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
12e206
         r = (v >> 8) & 0xf8;
12e206
         g = (v >> 3) & 0xfc;
12e206
         b = (v << 3) & 0xf8;
12e206
-        ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
         s += 2;
12e206
-        d += BPP;
12e206
+        d += 4;
12e206
     } while (--w != 0);
12e206
-#endif
12e206
 }
12e206
 
12e206
 /*
12e206
  * 24 bit color
12e206
  */
12e206
-static void glue(vga_draw_line24_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
12e206
-                                          const uint8_t *s, int width)
12e206
+static void vga_draw_line24(VGACommonState *s1, uint8_t *d,
12e206
+                            const uint8_t *s, int width)
12e206
 {
12e206
     int w;
12e206
     uint32_t r, g, b;
12e206
@@ -417,19 +343,19 @@ static void glue(vga_draw_line24_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
12e206
         g = s[1];
12e206
         r = s[2];
12e206
 #endif
12e206
-        ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
         s += 3;
12e206
-        d += BPP;
12e206
+        d += 4;
12e206
     } while (--w != 0);
12e206
 }
12e206
 
12e206
 /*
12e206
  * 32 bit color
12e206
  */
12e206
-static void glue(vga_draw_line32_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
12e206
-                                          const uint8_t *s, int width)
12e206
+static void vga_draw_line32(VGACommonState *s1, uint8_t *d,
12e206
+                            const uint8_t *s, int width)
12e206
 {
12e206
-#if DEPTH == 32 && defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) && !defined(BGR_FORMAT)
12e206
+#if defined(HOST_WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
12e206
     memcpy(d, s, width * 4);
12e206
 #else
12e206
     int w;
12e206
@@ -446,16 +372,9 @@ static void glue(vga_draw_line32_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
12e206
         g = s[1];
12e206
         r = s[2];
12e206
 #endif
12e206
-        ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
12e206
+        ((uint32_t *)d)[0] = rgb_to_pixel32(r, g, b);
12e206
         s += 4;
12e206
-        d += BPP;
12e206
+        d += 4;
12e206
     } while (--w != 0);
12e206
 #endif
12e206
 }
12e206
-
12e206
-#undef PUT_PIXEL2
12e206
-#undef DEPTH
12e206
-#undef BPP
12e206
-#undef PIXEL_TYPE
12e206
-#undef PIXEL_NAME
12e206
-#undef BGR_FORMAT
12e206
-- 
12e206
1.8.3.1
12e206