[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 36/67] ui/console: use QEMU_PIXMAN_COLOR helpers
From: |
marcandre . lureau |
Subject: |
[PATCH 36/67] ui/console: use QEMU_PIXMAN_COLOR helpers |
Date: |
Wed, 30 Aug 2023 13:38:10 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
QEMU_RGB macro is actually defining a pixman color. Make this explicit
in the macro name. Move it to qemu-pixman.h so it can be used elsewhere,
as done in the following patch. Finally, define
QEMU_PIXMAN_COLOR_{BLACK,GRAY}, to avoid need to look up the VGA color
table from the QemuConsole placeholder surface rendering.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
include/ui/qemu-pixman.h | 6 ++++++
ui/console.c | 39 ++++++++++++++++++---------------------
2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h
index ce4518e4de..51f8709327 100644
--- a/include/ui/qemu-pixman.h
+++ b/include/ui/qemu-pixman.h
@@ -47,6 +47,12 @@
# define PIXMAN_LE_x8r8g8b8 PIXMAN_x8r8g8b8
#endif
+#define QEMU_PIXMAN_COLOR(r, g, b)
\
+ { .red = r << 8, .green = g << 8, .blue = b << 8, .alpha = 0xffff }
+
+#define QEMU_PIXMAN_COLOR_BLACK QEMU_PIXMAN_COLOR(0x00, 0x00, 0x00)
+#define QEMU_PIXMAN_COLOR_GRAY QEMU_PIXMAN_COLOR(0xaa, 0xaa, 0xaa)
+
/* -------------------------------------------------------------------- */
typedef struct PixelFormat {
diff --git a/ui/console.c b/ui/console.c
index ed9e7137b8..88e37eaff3 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -363,29 +363,26 @@ static void vga_bitblt(QemuConsole *con,
#include "vgafont.h"
-#define QEMU_RGB(r, g, b) \
- { .red = r << 8, .green = g << 8, .blue = b << 8, .alpha = 0xffff }
-
static const pixman_color_t color_table_rgb[2][8] = {
{ /* dark */
- [QEMU_COLOR_BLACK] = QEMU_RGB(0x00, 0x00, 0x00), /* black */
- [QEMU_COLOR_BLUE] = QEMU_RGB(0x00, 0x00, 0xaa), /* blue */
- [QEMU_COLOR_GREEN] = QEMU_RGB(0x00, 0xaa, 0x00), /* green */
- [QEMU_COLOR_CYAN] = QEMU_RGB(0x00, 0xaa, 0xaa), /* cyan */
- [QEMU_COLOR_RED] = QEMU_RGB(0xaa, 0x00, 0x00), /* red */
- [QEMU_COLOR_MAGENTA] = QEMU_RGB(0xaa, 0x00, 0xaa), /* magenta */
- [QEMU_COLOR_YELLOW] = QEMU_RGB(0xaa, 0xaa, 0x00), /* yellow */
- [QEMU_COLOR_WHITE] = QEMU_RGB(0xaa, 0xaa, 0xaa), /* white */
+ [QEMU_COLOR_BLACK] = QEMU_PIXMAN_COLOR_BLACK,
+ [QEMU_COLOR_BLUE] = QEMU_PIXMAN_COLOR(0x00, 0x00, 0xaa), /* blue */
+ [QEMU_COLOR_GREEN] = QEMU_PIXMAN_COLOR(0x00, 0xaa, 0x00), /* green
*/
+ [QEMU_COLOR_CYAN] = QEMU_PIXMAN_COLOR(0x00, 0xaa, 0xaa), /* cyan */
+ [QEMU_COLOR_RED] = QEMU_PIXMAN_COLOR(0xaa, 0x00, 0x00), /* red */
+ [QEMU_COLOR_MAGENTA] = QEMU_PIXMAN_COLOR(0xaa, 0x00, 0xaa), /*
magenta */
+ [QEMU_COLOR_YELLOW] = QEMU_PIXMAN_COLOR(0xaa, 0xaa, 0x00), /* yellow
*/
+ [QEMU_COLOR_WHITE] = QEMU_PIXMAN_COLOR_GRAY,
},
{ /* bright */
- [QEMU_COLOR_BLACK] = QEMU_RGB(0x00, 0x00, 0x00), /* black */
- [QEMU_COLOR_BLUE] = QEMU_RGB(0x00, 0x00, 0xff), /* blue */
- [QEMU_COLOR_GREEN] = QEMU_RGB(0x00, 0xff, 0x00), /* green */
- [QEMU_COLOR_CYAN] = QEMU_RGB(0x00, 0xff, 0xff), /* cyan */
- [QEMU_COLOR_RED] = QEMU_RGB(0xff, 0x00, 0x00), /* red */
- [QEMU_COLOR_MAGENTA] = QEMU_RGB(0xff, 0x00, 0xff), /* magenta */
- [QEMU_COLOR_YELLOW] = QEMU_RGB(0xff, 0xff, 0x00), /* yellow */
- [QEMU_COLOR_WHITE] = QEMU_RGB(0xff, 0xff, 0xff), /* white */
+ [QEMU_COLOR_BLACK] = QEMU_PIXMAN_COLOR_BLACK,
+ [QEMU_COLOR_BLUE] = QEMU_PIXMAN_COLOR(0x00, 0x00, 0xff), /* blue */
+ [QEMU_COLOR_GREEN] = QEMU_PIXMAN_COLOR(0x00, 0xff, 0x00), /* green
*/
+ [QEMU_COLOR_CYAN] = QEMU_PIXMAN_COLOR(0x00, 0xff, 0xff), /* cyan */
+ [QEMU_COLOR_RED] = QEMU_PIXMAN_COLOR(0xff, 0x00, 0x00), /* red */
+ [QEMU_COLOR_MAGENTA] = QEMU_PIXMAN_COLOR(0xff, 0x00, 0xff), /*
magenta */
+ [QEMU_COLOR_YELLOW] = QEMU_PIXMAN_COLOR(0xff, 0xff, 0x00), /* yellow
*/
+ [QEMU_COLOR_WHITE] = QEMU_PIXMAN_COLOR(0xff, 0xff, 0xff), /* white
*/
}
};
@@ -1520,8 +1517,8 @@ DisplaySurface *qemu_create_placeholder_surface(int w,
int h,
const char *msg)
{
DisplaySurface *surface = qemu_create_displaysurface(w, h);
- pixman_color_t bg = color_table_rgb[0][QEMU_COLOR_BLACK];
- pixman_color_t fg = color_table_rgb[0][QEMU_COLOR_WHITE];
+ pixman_color_t bg = QEMU_PIXMAN_COLOR_BLACK;
+ pixman_color_t fg = QEMU_PIXMAN_COLOR_GRAY;
pixman_image_t *glyph;
int len, x, y, i;
--
2.41.0
- [PATCH 27/67] ui/console: free more QemuConsole resources, (continued)
- [PATCH 27/67] ui/console: free more QemuConsole resources, marcandre . lureau, 2023/08/30
- [PATCH 28/67] ui/vc: move text fields to QemuTextConsole, marcandre . lureau, 2023/08/30
- [PATCH 29/67] ui/console: move graphic fields to QemuGraphicConsole, marcandre . lureau, 2023/08/30
- [PATCH 30/67] ui/vc: fold text_console_do_init() in vc_chr_open(), marcandre . lureau, 2023/08/30
- [PATCH 31/67] ui/vc: move some text console initialization to qom handlers, marcandre . lureau, 2023/08/30
- [PATCH 32/67] ui/console: simplify getting active_console size, marcandre . lureau, 2023/08/30
- [PATCH 33/67] ui/console: remove need for g_width/g_height, marcandre . lureau, 2023/08/30
- [PATCH 34/67] ui/vc: use common text console surface creation, marcandre . lureau, 2023/08/30
- [PATCH 35/67] ui/console: declare console types in console.h, marcandre . lureau, 2023/08/30
- [PATCH 38/67] ui/console: assert(surface) where appropriate, marcandre . lureau, 2023/08/30
- [PATCH 36/67] ui/console: use QEMU_PIXMAN_COLOR helpers,
marcandre . lureau <=
- [PATCH 39/67] ui/console: fold text_console_update_cursor_timer, marcandre . lureau, 2023/08/30
- [PATCH 40/67] ui/vc: skip text console resize when possible, marcandre . lureau, 2023/08/30
- [PATCH 37/67] ui/console: rename vga_ functions → qemu_console_, marcandre . lureau, 2023/08/30
- [PATCH 41/67] ui/console: minor stylistic changes, marcandre . lureau, 2023/08/30
- [PATCH 42/67] ui/vc: move text console invalidate in helper, marcandre . lureau, 2023/08/30